Skip to content

Commit

Permalink
Merge pull request #2681 from particle-iot/feature/add-msom-platform
Browse files Browse the repository at this point in the history
[rtl872x] Add MSoM platform support
  • Loading branch information
scott-brust authored Aug 14, 2023
2 parents 6bc7ef3 + b3b6850 commit b7b1b93
Show file tree
Hide file tree
Showing 85 changed files with 1,288 additions and 209 deletions.
4 changes: 2 additions & 2 deletions .buildpackrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export BUILDPACK_VARIATION=manifest
export RELEASE_PLATFORMS=( )

# Platforms for which this firmware is considered experimental
export PRERELEASE_PLATFORMS=( argon boron bsom b5som tracker esomx p2 trackerm )
export PRERELEASE_PLATFORMS=( argon boron bsom b5som tracker esomx p2 trackerm msom)
# Note: a single platform should be only in release or prerelease list. If
# added to both it will be considered a prerelease

# Platforms which require modules to be prebuilt
export MODULAR_PLATFORMS=( argon boron bsom b5som tracker esomx p2 trackerm )
export MODULAR_PLATFORMS=( argon boron bsom b5som tracker esomx p2 trackerm msom)

4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ orbs:

aliases:
- &tasks ["compile:all clean:all", "compile:user clean:user", "compile:debug clean:debug"]
- &platforms ["argon", "boron", "esomx", "bsom", "b5som", "tracker", "p2", "trackerm"]
- &platforms ["argon", "boron", "esomx", "bsom", "b5som", "tracker", "p2", "trackerm", "msom"]

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
Expand Down Expand Up @@ -475,7 +475,7 @@ workflows:
- particle-ci-private
matrix:
parameters:
platform: ["argon", "boron", "esomx", "bsom", "b5som", "tracker", "p2", "trackerm", "unit-test newhal gcc"]
platform: ["argon", "boron", "esomx", "bsom", "b5som", "tracker", "p2", "trackerm", "msom", "unit-test newhal gcc"]
- combine-binaries:
requires:
- build-and-test
Expand Down
2 changes: 1 addition & 1 deletion .workbench/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": "1.0.0",
"toolchains": [
{
"platforms": [12, 13, 15, 23, 25, 26, 28, 32],
"platforms": [12, 13, 15, 23, 25, 26, 28, 32, 35],
"firmware": "deviceOS@source",
"compilers": "gcc-arm@10.2.1",
"tools": "buildtools@1.1.1",
Expand Down
2 changes: 2 additions & 0 deletions bootloader/src/msom/include.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INCLUDE_DIRS += $(BOOTLOADER_MODULE_PATH)/src/$(PLATFORM_NAME)
include $(BOOTLOADER_MODULE_PATH)/src/rtl872x/include.mk
2 changes: 2 additions & 0 deletions bootloader/src/msom/sources.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BOOTLOADER_SRC_PATH = $(BOOTLOADER_MODULE_PATH)/src/${PLATFORM_NAME}
include $(BOOTLOADER_MODULE_PATH)/src/rtl872x/sources.mk
3 changes: 2 additions & 1 deletion build/create_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Platform(IntEnum):
TRACKER = 26
TRACKERM = 28
P2 = 32
MSOM = 35

class StructSerializable(struct.Struct):
def __init__(self, fmt):
Expand Down Expand Up @@ -244,7 +245,7 @@ def parse_dependency(dep):
GEN3_RADIO_STACK_DEPENDENCY = ModuleDependency(ModuleFunction.BOOTLOADER, 501)
GEN3_RADIO_STACK_DEPENDENCY2 = ModuleDependency(ModuleFunction.SYSTEM_PART, 1321, 1)

RTL_PLATFORMS = [Platform.P2, Platform.TRACKERM]
RTL_PLATFORMS = [Platform.P2, Platform.TRACKERM, Platform.MSOM]
RTL_MBR_OFFSET = 0x08000000
RTL_KM0_PART1_OFFSET = 0x08014000

Expand Down
3 changes: 2 additions & 1 deletion build/make_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function valid_platform()
# Validate platform (result of expression returned to caller)
[ "$platform" = "all" ] || [ "$platform" = "argon" ] || [ "$platform" = "asom" ] || \
[ "$platform" = "boron" ] || [ "$platform" = "bsom" ] || [ "$platform" = "b5som" ] || \
[ "$platform" = "esomx" ] || [ "$platform" = "tracker" ] || [ "$platform" = "p2" ] || [ "$platform" = "trackerm" ]
[ "$platform" = "esomx" ] || [ "$platform" = "tracker" ] || [ "$platform" = "p2" ] || [ "$platform" = "trackerm" ] || [ "$platform" = "msom" ]
}

if !(valid_platform $PLATFORM); then
Expand All @@ -156,6 +156,7 @@ if [ $PLATFORM = "all" ]; then
release_platform "esomx"
release_platform "p2"
release_platform "trackerm"
release_platform "msom"
else
release_platform "$PLATFORM"
fi
Expand Down
30 changes: 30 additions & 0 deletions build/platform-id.mk
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ ifeq ("$(PLATFORM)","p2")
PLATFORM_ID=32
endif

ifeq ("$(PLATFORM)","msom")
PLATFORM_ID=35
endif

ifeq ("$(PLATFORM)","newhal")
PLATFORM_ID=60000
endif
Expand Down Expand Up @@ -270,6 +274,32 @@ MODULE_SUFFIX_PRODUCT_DATA_OFFSET_FROM_END=42
BOOTLOADER_USE_LTO=n
endif

ifeq ("$(PLATFORM_ID)","35")
PLATFORM=msom
PLATFORM_NAME=msom
PLATFORM_GEN=3
PLATFORM_MCU=rtl872x
PLATFORM_NET=rtl872x
PLATFORM_WIZNET=W5500
PRODUCT_DESC=Production M SoM
USBD_VID_PARTICLE=0x2B04
USBD_PID_DFU=0xD023
USBD_PID_CDC=0xC023
DEFAULT_PRODUCT_ID=$(PLATFORM_ID)
PLATFORM_DYNALIB_MODULES=msom
PLATFORM_PREBOOTLOADER=1
ifneq ("$(PLATFORM_MCU_CORE)","")
ARM_CPU=cortex-$(PLATFORM_MCU_CORE)
MCU_DEVICE=rtl872x_$(PLATFORM_MCU_CORE)
else
ARM_CPU=cortex-m33
MCU_DEVICE=rtl872x
endif
PLATFORM_THREADING=1
MODULE_SUFFIX_PRODUCT_DATA_OFFSET_FROM_END=42
BOOTLOADER_USE_LTO=n
endif

ifeq ("$(PLATFORM_ID)","60000")
PLATFORM=newhal
# needed for conditional compilation of some MCU specific files
Expand Down
3 changes: 2 additions & 1 deletion build/release-publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ function valid_platform()
# Validate platform (result of expression returned to caller)
[ "$platform" = "argon" ] || [ "$platform" = "asom" ] || [ "$platform" = "boron" ] || \
[ "$platform" = "bsom" ] || [ "$platform" = "b5som" ] || [ "$platform" = "tracker" ] || \
[ "$platform" = "esomx" ] || [ "$platform" = "p2" ] || [ "$platform" = "trackerm" ]
[ "$platform" = "esomx" ] || [ "$platform" = "p2" ] || [ "$platform" = "trackerm" ] || \
[ "$platform" = "msom" ]
}

# Identify the absolute directory
Expand Down
6 changes: 5 additions & 1 deletion build/release-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ function valid_platform ()
# Validate platform (result of expression returned to caller)
[ "$platform" = "argon" ] || [ "$platform" = "asom" ] || [ "$platform" = "boron" ] || \
[ "$platform" = "bsom" ] || [ "$platform" = "b5som" ] || [ "$platform" = "tracker" ] || \
[ "$platform" = "esomx" ] || [ "$platform" = "p2" ] || [ "$platform" = "trackerm" ]
[ "$platform" = "esomx" ] || [ "$platform" = "p2" ] || [ "$platform" = "trackerm" ] || \
[ "$platform" = "msom" ]
}

# Handle invalid arguments
Expand Down Expand Up @@ -159,6 +160,9 @@ case "$PLATFORM" in
"p2")
PLATFORM_ID="32"
;;
"msom")
PLATFORM_ID="35"
;;
*)
echo "ERROR: No rules to release platform: \"$PLATFORM\"!"
exit 9
Expand Down
10 changes: 9 additions & 1 deletion build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ elif [ ! -z $PLATFORM ]; then
PLATFORM_ID="32"
GEN3=true
;;
"msom")
PLATFORM_ID="35"
GEN3=true
;;
*)
echo "ERROR: No rules to release platform: \"$PLATFORM\"!"
exit 6
Expand Down Expand Up @@ -289,6 +293,10 @@ else
PLATFORM="p2"
GEN3=true
;;
35)
PLATFORM="msom"
GEN3=true
;;
*)
echo "ERROR: No rules to release platform id: $PLATFORM_ID!"
exit 7
Expand Down Expand Up @@ -329,7 +337,7 @@ rm -rf $ABSOLUTE_TARGET_DIRECTORY/
#########################

# GEN3
if [ $PLATFORM_ID -eq 12 ] || [ $PLATFORM_ID -eq 13 ] || [ $PLATFORM_ID -eq 15 ] || [ $PLATFORM_ID -eq 22 ] || [ $PLATFORM_ID -eq 23 ] || [ $PLATFORM_ID -eq 25 ] || [ $PLATFORM_ID -eq 26 ] || [ $PLATFORM_ID -eq 28 ] || [ $PLATFORM_ID -eq 32 ]; then
if [ $PLATFORM_ID -eq 12 ] || [ $PLATFORM_ID -eq 13 ] || [ $PLATFORM_ID -eq 15 ] || [ $PLATFORM_ID -eq 22 ] || [ $PLATFORM_ID -eq 23 ] || [ $PLATFORM_ID -eq 25 ] || [ $PLATFORM_ID -eq 26 ] || [ $PLATFORM_ID -eq 28 ] || [ $PLATFORM_ID -eq 32 ] || [ $PLATFORM_ID -eq 35 ]; then
# Configure
if [ $DEBUG = true ]; then
cd ../main
Expand Down
2 changes: 1 addition & 1 deletion ci/cf_generate_message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ EOF
)

fields=""
for p in P2; do
for p in MSoM; do
if echo -e "${failures}" | grep -q "PLATFORM=\"${p,,}\""; then
msg=":scrum_closed: $p\\n"
else
Expand Down
8 changes: 4 additions & 4 deletions ci/enumerate_build_matrix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ MAKE=runmake
# define build matrix dimensions
# "" means execute execute the $MAKE command without that var specified
DEBUG_BUILD=( y n )
PLATFORM=( argon boron asom bsom b5som esomx p2 trackerm )
PLATFORM=( argon boron asom bsom b5som esomx p2 trackerm msom )
# All modules are now built by release scripts instead, skip
# Only building applications and tests here
# PLATFORM_BOOTLOADER=( argon boron asom bsom b5som tracker esomx p2 )
# PLATFORM_PREBOOTLOADER=( p2 trackerm )
# PLATFORM_PREBOOTLOADER=( p2 trackerm msom )
PLATFORM_BOOTLOADER=()
PLATFORM_PREBOOTLOADER=()
APP=( "" product_id_and_version )
TEST=( wiring/api )

MODULAR_PLATFORM=( argon boron asom bsom b5som tracker esomx p2 trackerm )
MODULAR_PLATFORM=( argon boron asom bsom b5som tracker esomx p2 trackerm msom )

filterPlatform PLATFORM
filterPlatform MODULAR_PLATFORM
Expand Down Expand Up @@ -159,7 +159,7 @@ do
do
# Gen 3 overflows with modular DEBUG_BUILD=y, so skip those
if [[ "$db" = "y" ]]; then
if [[ "$p" = "argon" ]] || [[ "$p" = "boron" ]] || [[ "$p" = "asom" ]] || [[ "$p" = "bsom" ]] || [[ "$p" = "b5som" ]] || [[ "$p" = "tracker" ]] || [[ "$p" = "esomx" ]] || [[ "$p" = "p2" ]] || [[ "$p" = "trackerm" ]]; then
if [[ "$p" = "argon" ]] || [[ "$p" = "boron" ]] || [[ "$p" = "asom" ]] || [[ "$p" = "bsom" ]] || [[ "$p" = "b5som" ]] || [[ "$p" = "tracker" ]] || [[ "$p" = "esomx" ]] || [[ "$p" = "p2" ]] || [[ "$p" = "trackerm" ]] || [[ "$p" = "msom" ]]; then
continue
fi
fi
Expand Down
4 changes: 3 additions & 1 deletion dynalib/inc/dynalib.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
******************************************************************************
*/

#include "platforms.h"

//
// The dynalib macros produce either a a dynamic lib export table (jump table)
// or a set of import stubs.
Expand Down Expand Up @@ -125,7 +127,7 @@ constexpr T2* dynalib_checked_cast(T2 *p) {
#define __S(x) #x
#define __SX(x) __S(x)

#if PLATFORM_ID == 32 || PLATFORM_ID == 28
#if PLATFORM_ID == PLATFORM_P2 || PLATFORM_ID == PLATFORM_TRACKERM || PLATFORM_ID == PLATFORM_MSOM
#define DYNALIB_FN_IMPORT(index, tablename, name, counter) \
DYNALIB_STATIC_ASSERT(index == counter, "Index of the dynamically exported function has changed"); \
const char check_name_## tablename ## _ ## name[0]={}; /* this will fail if the name is already defined */ \
Expand Down
1 change: 1 addition & 0 deletions dynalib/inc/include.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
TARGET_DYNALIB_PATH=$(DYNALIB_MODULE_PATH)

INCLUDE_DIRS += $(TARGET_DYNALIB_PATH)/inc
INCLUDE_DIRS += $(PROJECT_ROOT)/hal/shared
1 change: 1 addition & 0 deletions dynalib/makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

MODULE=dynalib
DYNALIB_MODULE_PATH=.
PROJECT_ROOT ?= ..

# Target this makefile is building.
TARGET_TYPE = a
Expand Down
6 changes: 6 additions & 0 deletions hal/inc/hal_dynalib_wlan_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ DYNALIB_FN(14, hal_wlan, wlan_set_error_count, void(uint32_t))
DYNALIB_FN(15, hal_wlan, wlan_fetch_ipconfig, int(WLanConfig*))
DYNALIB_FN(16, hal_wlan, wlan_setup, void(void))

#if PLATFORM_ID == PLATFORM_MSOM
DYNALIB_FN_PLACEHOLDER(17, hal_wlan)
DYNALIB_FN_PLACEHOLDER(18, hal_wlan)
DYNALIB_FN_PLACEHOLDER(19, hal_wlan)
#else
DYNALIB_FN(17, hal_wlan, HAL_NET_SetNetWatchDog, uint32_t(uint32_t))
DYNALIB_FN(18, hal_wlan, inet_gethostbyname, int(const char*, uint16_t, HAL_IPAddress*, network_interface_t, void*))
DYNALIB_FN(19, hal_wlan, inet_ping, int(const HAL_IPAddress*, network_interface_t, uint8_t, void*))
#endif
DYNALIB_FN(20, hal_wlan, wlan_select_antenna, int(WLanSelectAntenna_TypeDef))
DYNALIB_FN(21, hal_wlan, wlan_set_ipaddress, void(const HAL_IPAddress*, const HAL_IPAddress*, const HAL_IPAddress*, const HAL_IPAddress*, const HAL_IPAddress*, void*))
DYNALIB_FN(22, hal_wlan, wlan_set_ipaddress_source, void(IPAddressSource, bool, void*))
Expand Down
1 change: 0 additions & 1 deletion hal/inc/inet_hal_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ int inet_gethostbyname(const char* hostname, uint16_t hostnameLen, HAL_IPAddress
int inet_ping(const HAL_IPAddress* address, network_interface_t nif, uint8_t nTries,
void* reserved);


#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 5 additions & 5 deletions hal/inc/usart_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ typedef struct hal_usart_ring_buffer_t {
} hal_usart_ring_buffer_t;

typedef enum hal_usart_interface_t {
HAL_USART_SERIAL1 = 0, //maps to USART_TX_RX
HAL_USART_SERIAL2 = 1,
HAL_USART_SERIAL3 = 2,
HAL_USART_SERIAL4 = 3,
HAL_USART_SERIAL5 = 4,
HAL_USART_SERIAL1 = 0, // maps to Serial1
HAL_USART_SERIAL2 = 1, // may map to NCP or Serial2, see HAL_PLATFORM_CELLULAR_SERIAL / HAL_PLATFORM_WIFI_SERIAL
HAL_USART_SERIAL3 = 2, // may map to NCP or Serial3, see HAL_PLATFORM_CELLULAR_SERIAL / HAL_PLATFORM_WIFI_SERIAL
HAL_USART_SERIAL4 = 3, // may map to NCP or Serial4, see HAL_PLATFORM_CELLULAR_SERIAL / HAL_PLATFORM_WIFI_SERIAL
HAL_USART_SERIAL5 = 4, // may map to NCP or Serial5, see HAL_PLATFORM_CELLULAR_SERIAL / HAL_PLATFORM_WIFI_SERIAL
} hal_usart_interface_t;

typedef enum hal_usart_state_t {
Expand Down
2 changes: 1 addition & 1 deletion hal/network/ncp_client/esp32/esp32_ncp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ int Esp32NcpClient::init(const NcpClientConfig& conf) {

#if !HAL_PLATFORM_WIFI_NCP_SDIO
// Initialize serial stream
std::unique_ptr<SerialStream> serial(new(std::nothrow) SerialStream(HAL_USART_SERIAL2, ESP32_NCP_DEFAULT_SERIAL_BAUDRATE,
std::unique_ptr<SerialStream> serial(new(std::nothrow) SerialStream(HAL_PLATFORM_WIFI_SERIAL, ESP32_NCP_DEFAULT_SERIAL_BAUDRATE,
SERIAL_8N1 | SERIAL_FLOW_CONTROL_RTS_CTS));
#else
std::unique_ptr<Esp32SdioStream> serial(new(std::nothrow) Esp32SdioStream(HAL_SPI_INTERFACE2, ESP32_NCP_DEFAULT_SDIO_SPEED, WIFI_CS, WIFI_INT));
Expand Down
Loading

0 comments on commit b7b1b93

Please sign in to comment.