diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a9a5d3f6..2e7ae4a08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,9 @@ elseif(OT_PLATFORM STREQUAL "external") elseif(OT_PLATFORM MATCHES "^nrf*") target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx/${OT_PLATFORM}) add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/nrf528xx") +elseif(OT_PLATFORM MATCHES "^efr*") + target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/efr32/${OT_PLATFORM}) + add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/efr32") else() target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}) add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}") diff --git a/etc/cmake/functions.cmake b/etc/cmake/functions.cmake index 7c5e62a68..f2ceff880 100755 --- a/etc/cmake/functions.cmake +++ b/etc/cmake/functions.cmake @@ -31,10 +31,12 @@ function(ot_get_platforms arg_platforms) list(APPEND result "NO" "posix" "external") set(platforms_dir "${PROJECT_SOURCE_DIR}/examples/platforms") file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*" - RELATIVE "${platforms_dir}/nrf528xx" "${platforms_dir}/nrf528xx/nrf*") + RELATIVE "${platforms_dir}/nrf528xx" "${platforms_dir}/nrf528xx/nrf*" + RELATIVE "${platforms_dir}/efr32" "${platforms_dir}/efr32/efr32*") foreach(platform IN LISTS platforms) if((IS_DIRECTORY "${platforms_dir}/${platform}") OR - (IS_DIRECTORY "${platforms_dir}/nrf528xx/${platform}")) + (IS_DIRECTORY "${platforms_dir}/nrf528xx/${platform}") OR + (IS_DIRECTORY "${platforms_dir}/efr32/${platform}")) list(APPEND result "${platform}") endif() endforeach() diff --git a/examples/Makefile-efr32mg1 b/examples/Makefile-efr32mg1 index 705afe3ba..0bb070362 100644 --- a/examples/Makefile-efr32mg1 +++ b/examples/Makefile-efr32mg1 @@ -79,7 +79,6 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_alt/include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/config EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc -EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc/configs EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_psa_driver/inc EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/CMSIS/Include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/Device/SiliconLabs/EFR32MG1P/Include diff --git a/examples/Makefile-efr32mg12 b/examples/Makefile-efr32mg12 index 16461a2e9..74fee9734 100644 --- a/examples/Makefile-efr32mg12 +++ b/examples/Makefile-efr32mg12 @@ -97,7 +97,6 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_alt/include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/config EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc -EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc/configs EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_psa_driver/inc EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/CMSIS/Include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/Device/SiliconLabs/EFR32MG12P/Include diff --git a/examples/Makefile-efr32mg13 b/examples/Makefile-efr32mg13 index 5cbcc93a4..59b9ec23c 100644 --- a/examples/Makefile-efr32mg13 +++ b/examples/Makefile-efr32mg13 @@ -83,7 +83,6 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_alt/include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/config EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc -EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc/configs EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_psa_driver/inc EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/CMSIS/Include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/Device/SiliconLabs/EFR32MG13P/Include diff --git a/examples/Makefile-efr32mg21 b/examples/Makefile-efr32mg21 index 80db2a686..d003e33ec 100644 --- a/examples/Makefile-efr32mg21 +++ b/examples/Makefile-efr32mg21 @@ -89,7 +89,6 @@ EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suit EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_alt/include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/config EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc -EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_mbedtls_support/inc/configs EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/util/third_party/crypto/sl_component/sl_psa_driver/inc EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/CMSIS/Include EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v3.1/platform/Device/SiliconLabs/EFR32MG21/Include diff --git a/examples/platforms/efr32/CMakeLists.txt b/examples/platforms/efr32/CMakeLists.txt new file mode 100644 index 000000000..00bee251e --- /dev/null +++ b/examples/platforms/efr32/CMakeLists.txt @@ -0,0 +1,143 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/utility.cmake) +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/includes.cmake) +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/imported_libs.cmake) + + +# ============================================================================== +# Common sources and includes +# ============================================================================== +set(EFR32_COMMON_SOURCES + src/alarm.c + src/diag.c + src/entropy.c + src/fem-control.c + src/flash.c + src/ieee802154mac.h + src/logging.c + src/mbedtls_config.h + src/memory.c + src/misc.c + src/openthread-core-efr32-config-check.h + src/openthread-core-efr32-config.h + src/platform-band.h + src/platform-efr32.h + src/radio.c + src/rail_config.h + src/startup-gcc.c + src/system.c + src/uart.c +) + +set(EFR32_INCLUDES + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR}/${EFR32_PLATFORM}/crypto + ${CMAKE_CURRENT_SOURCE_DIR}/${EFR32_PLATFORM}/${BOARD_LOWERCASE} + ${PROJECT_SOURCE_DIR}/third_party/silabs/rail_config + ${SILABS_GSDK_INCLUDES} + ${PROJECT_SOURCE_DIR}/examples/platforms + ${PROJECT_SOURCE_DIR}/src/core +) + +set(EFR32_CFLAGS + -Wno-sign-compare + -Wno-unused-parameter + -Wno-missing-field-initializers +) + +# ============================================================================== +# mbedtls +# ============================================================================== +if(NOT OT_EXTERNAL_MBEDTLS) + message(FATAL_ERROR "OT_EXTERNAL_MBEDTLS is not set. Please include the define when running cmake\n\t-DOT_EXTERNAL_MBEDTLS=silabs-mbedtls") +else() + list(APPEND OT_PLATFORM_DEFINES "MBEDTLS_CONFIG_FILE=\"mbedtls_config.h\"") +endif() +set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE) + +if(PLATFORM_LOWERCASE MATCHES "^efr32mg2\\d*") + list(APPEND OT_PUBLIC_INCLUDES + "${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/inc" + "${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src" + ) + set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE) +endif() + +# ============================================================================== +# General variables +# ============================================================================== + +# ============================================================================== +# Filter out CFLAGS +# ============================================================================== +set(ignored_flags + "-pedantic-errors" # Needed for RAIL lib + "-Wshadow" # Needed for RAIL lib +) + +foreach(flag IN LISTS ignored_flags) + string(REPLACE "${flag}" "" OT_CFLAGS "${OT_CFLAGS}") +endforeach() +list(APPEND EFR32_CFLAGS ${OT_CFLAGS}) +set(OT_CFLAGS ${OT_CFLAGS} PARENT_SCOPE) + +# Use default config file if one isn't specified +if(NOT OT_CONFIG) + set(OT_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/src/openthread-core-efr32-config.h") + set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE) +endif() + +list(APPEND OT_PLATFORM_DEFINES + "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"" + "OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-efr32-config-check.h\"" +) +set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE) + +# ============================================================================== +# Platform targets +# ============================================================================== +set(EFR32_COMMON_3RD_LIBS + jlinkrtt + ${OT_MBEDTLS} +) + +include(${PLATFORM_LOWERCASE}/${PLATFORM_LOWERCASE}.cmake) + +list(APPEND OT_PUBLIC_INCLUDES ${EFR32_INCLUDES}) +set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE) + +# ============================================================================== +# sleepy-demo +# ============================================================================== +option(EFR32_APP_SLEEPY_DEMO "enable sleepy-demo app" ON) + +if(EFR32_APP_SLEEPY_DEMO) + add_subdirectory(sleepy-demo) +endif() diff --git a/examples/platforms/efr32/arm-none-eabi.cmake b/examples/platforms/efr32/arm-none-eabi.cmake new file mode 100644 index 000000000..9f2e385f9 --- /dev/null +++ b/examples/platforms/efr32/arm-none-eabi.cmake @@ -0,0 +1,51 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) +set(CMAKE_ASM_COMPILER arm-none-eabi-as) +set(CMAKE_RANLIB arm-none-eabi-ranlib) + +execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb -fdata-sections -ffunction-sections") + +set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=c99") +set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs") + +set(CMAKE_C_FLAGS_DEBUG "-Og -g") +set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") +set(CMAKE_ASM_FLAGS_DEBUG "-g") + +set(CMAKE_C_FLAGS_RELEASE "-Os") +set(CMAKE_CXX_FLAGS_RELEASE "-Os") +set(CMAKE_ASM_FLAGS_RELEASE "") diff --git a/examples/platforms/efr32/efr32_platform_defs.am b/examples/platforms/efr32/efr32_platform_defs.am index 223a08b3b..f69d240c0 100644 --- a/examples/platforms/efr32/efr32_platform_defs.am +++ b/examples/platforms/efr32/efr32_platform_defs.am @@ -89,7 +89,6 @@ SILABS_GSDK_CPPFLAGS = -I$(SDK_SRC_DIR)/platform/emlib/inc \ -I$(SDK_SRC_DIR)/platform/halconfig/inc/hal-config \ -I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32 \ - -I$(SDK_SRC_DIR)/platform/radio/rail_lib/chip/efr32/rf/common/cortex \ -I$(SDK_SRC_DIR)/platform/radio/rail_lib/common \ -I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal \ -I$(SDK_SRC_DIR)/platform/radio/rail_lib/hal/efr32 \ diff --git a/examples/platforms/efr32/efr32mg1/Makefile.am b/examples/platforms/efr32/efr32mg1/Makefile.am index 873a8843c..fdf9e1eb5 100644 --- a/examples/platforms/efr32/efr32mg1/Makefile.am +++ b/examples/platforms/efr32/efr32mg1/Makefile.am @@ -33,7 +33,6 @@ lib_LIBRARIES = libopenthread-efr32mg1.a libopenthread_efr32mg1_a_CPPFLAGS = \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ - -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -Wno-sign-compare \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \ diff --git a/examples/platforms/efr32/efr32mg1/README.md b/examples/platforms/efr32/efr32mg1/README.md index 153ed0f5d..2473f2c1e 100644 --- a/examples/platforms/efr32/efr32mg1/README.md +++ b/examples/platforms/efr32/efr32mg1/README.md @@ -66,7 +66,35 @@ $ cd $ ./bootstrap ``` -For EFR32MG1™ Mighty Gecko Wireless Starter Kit: +For EFR32MG1™ Mighty Gecko Wireless Starter Kit, this can be done using both the CMake and autotools build systems + +**CMake (preferred)** + +```bash +$ ./script/cmake-build efr32mg1 -DBOARD=brd4151a +... +-- Configuring done +-- Generating done +-- Build files have been written to: /build/efr32mg1 ++ [[ -n ot-rcp ]] ++ ninja ot-rcp +[160/160] Linking CXX executable examples/apps/ncp/ot-rcp ++ cd +``` + +After a successful build, the `elf` files are found in `/build/efr32mg1/examples`. + +```bash +# For linux +$ find build/efr32mg1/examples -type f -executable +build/efr32mg1/examples/apps/ncp/ot-rcp + +# For BSD/Darwin/mac systems +$ find build/efr32mg1/examples -type f -perm +111 +build/efr32mg1/examples/apps/ncp/ot-rcp +``` + +**autotools (soon to be depracated)** ```bash $ make -f examples/Makefile-efr32mg1 BOARD=BRD4151A diff --git a/examples/platforms/efr32/efr32mg1/arm-none-eabi.cmake b/examples/platforms/efr32/efr32mg1/arm-none-eabi.cmake new file mode 100644 index 000000000..9f2e385f9 --- /dev/null +++ b/examples/platforms/efr32/efr32mg1/arm-none-eabi.cmake @@ -0,0 +1,51 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) +set(CMAKE_ASM_COMPILER arm-none-eabi-as) +set(CMAKE_RANLIB arm-none-eabi-ranlib) + +execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb -fdata-sections -ffunction-sections") + +set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=c99") +set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs") + +set(CMAKE_C_FLAGS_DEBUG "-Og -g") +set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") +set(CMAKE_ASM_FLAGS_DEBUG "-g") + +set(CMAKE_C_FLAGS_RELEASE "-Os") +set(CMAKE_CXX_FLAGS_RELEASE "-Os") +set(CMAKE_ASM_FLAGS_RELEASE "") diff --git a/examples/platforms/efr32/efr32mg1/efr32mg1.cmake b/examples/platforms/efr32/efr32mg1/efr32mg1.cmake new file mode 100644 index 000000000..39e5da530 --- /dev/null +++ b/examples/platforms/efr32/efr32mg1/efr32mg1.cmake @@ -0,0 +1,95 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# ============================================================================== +# Verify board is supported for platform +# ============================================================================== +if(BOARD_LOWERCASE STREQUAL "brd4151a") + set(MCU "EFR32MG1P232F256GM48") +else() + message(FATAL_ERROR " + BOARD=${BOARD} not supported. + + Please provide a value for BOARD variable e.g BOARD=brd4151a. + Currently supported: + - brd4151a + ") +endif() + +list(APPEND OT_PLATFORM_DEFINES "${MCU}") +set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE) + +# ============================================================================== +# Platform library +# ============================================================================== +set(OT_PLATFORM_LIB "openthread-efr32mg1") +set(OT_PLATFORM_LIB ${OT_PLATFORM_LIB} PARENT_SCOPE) + +set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/efr32mg1/efr32mg1.ld") + +add_library(openthread-efr32mg1 + ${EFR32_COMMON_SOURCES} + $ +) + +set_target_properties(openthread-efr32mg1 + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_link_libraries(openthread-efr32mg1 + PUBLIC + ${EFR32_COMMON_3RD_LIBS} + silabs-libnvm3_CM4_gcc + silabs-efr32mg1-sdk + -T${LD_FILE} + -Wl,--gc-sections + -Wl,-Map=$.map + PRIVATE + ot-config +) + +target_compile_definitions(openthread-efr32mg1 + PUBLIC + ${OT_PLATFORM_DEFINES} +) + +target_compile_options(openthread-efr32mg1 + PRIVATE + ${EFR32_CFLAGS} +) + +target_include_directories(openthread-efr32mg1 + PUBLIC + ${EFR32_INCLUDES} + PRIVATE + ${SILABS_EFR32MG1X_INCLUDES} + ${OT_PUBLIC_INCLUDES} +) + diff --git a/examples/platforms/efr32/efr32mg12/Makefile.am b/examples/platforms/efr32/efr32mg12/Makefile.am index 73cefb5a0..023523670 100644 --- a/examples/platforms/efr32/efr32mg12/Makefile.am +++ b/examples/platforms/efr32/efr32mg12/Makefile.am @@ -33,7 +33,6 @@ lib_LIBRARIES = libopenthread-efr32mg12.a libopenthread_efr32mg12_a_CPPFLAGS = \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ - -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -Wno-sign-compare \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \ diff --git a/examples/platforms/efr32/efr32mg12/README.md b/examples/platforms/efr32/efr32mg12/README.md index 7ee0592f1..713e0dcb2 100644 --- a/examples/platforms/efr32/efr32mg12/README.md +++ b/examples/platforms/efr32/efr32mg12/README.md @@ -71,7 +71,47 @@ $ cd $ ./bootstrap ``` -For EFR32MG12™ Mighty Gecko Wireless Starter Kit: +For EFR32MG12™ Mighty Gecko Wireless Starter Kit, this can be done using both the CMake and autotools build systems + +**CMake (preferred)** + +```bash +$ ./script/cmake-build efr32mg12 -DBOARD=brd4161a +... +-- Configuring done +-- Generating done +-- Build files have been written to: /build/efr32mg12 ++ [[ -n ot-rcp ot-cli-ftd ot-cli-mtd ot-ncp-ftd ot-ncp-mtd sleepy-demo-ftd sleepy-demo-mtd ]] ++ ninja ot-rcp ot-cli-ftd ot-cli-mtd ot-ncp-ftd ot-ncp-mtd sleepy-demo-ftd sleepy-demo-mtd +[572/572] Linking CXX executable examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/sleepy-demo-ftd ++ cd +``` + +After a successful build, the `elf` files are found in `/build/efr32mg12/examples`. + +```bash +# For linux +$ find build/efr32mg12/examples -type f -executable +build/efr32mg12/examples/apps/cli/ot-cli-mtd +build/efr32mg12/examples/apps/cli/ot-cli-ftd +build/efr32mg12/examples/apps/ncp/ot-ncp-ftd +build/efr32mg12/examples/apps/ncp/ot-ncp-mtd +build/efr32mg12/examples/apps/ncp/ot-rcp +build/efr32mg12/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/sleepy-demo-ftd +build/efr32mg12/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/sleepy-demo-mtd + +# For BSD/Darwin/mac systems +$ find build/efr32mg12/examples -type f -perm +111 +build/efr32mg12/examples/apps/cli/ot-cli-mtd +build/efr32mg12/examples/apps/cli/ot-cli-ftd +build/efr32mg12/examples/apps/ncp/ot-ncp-ftd +build/efr32mg12/examples/apps/ncp/ot-ncp-mtd +build/efr32mg12/examples/apps/ncp/ot-rcp +build/efr32mg12/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/sleepy-demo-ftd +build/efr32mg12/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/sleepy-demo-mtd +``` + +**autotools (soon to be depracated)** ```bash $ make -f examples/Makefile-efr32mg12 BOARD=BRD4161A diff --git a/examples/platforms/efr32/efr32mg12/arm-none-eabi.cmake b/examples/platforms/efr32/efr32mg12/arm-none-eabi.cmake new file mode 100644 index 000000000..9f2e385f9 --- /dev/null +++ b/examples/platforms/efr32/efr32mg12/arm-none-eabi.cmake @@ -0,0 +1,51 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) +set(CMAKE_ASM_COMPILER arm-none-eabi-as) +set(CMAKE_RANLIB arm-none-eabi-ranlib) + +execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb -fdata-sections -ffunction-sections") + +set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=c99") +set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs") + +set(CMAKE_C_FLAGS_DEBUG "-Og -g") +set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") +set(CMAKE_ASM_FLAGS_DEBUG "-g") + +set(CMAKE_C_FLAGS_RELEASE "-Os") +set(CMAKE_CXX_FLAGS_RELEASE "-Os") +set(CMAKE_ASM_FLAGS_RELEASE "") diff --git a/examples/platforms/efr32/efr32mg12/efr32mg12.cmake b/examples/platforms/efr32/efr32mg12/efr32mg12.cmake new file mode 100644 index 000000000..ad73e5f9a --- /dev/null +++ b/examples/platforms/efr32/efr32mg12/efr32mg12.cmake @@ -0,0 +1,104 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# ============================================================================== +# Verify board is supported for platform +# ============================================================================== +if(BOARD_LOWERCASE STREQUAL "brd4304a") + set(MCU "EFR32MG12P432F1024GM48") +elseif(BOARD_LOWERCASE STREQUAL "brd4161a") + set(MCU "EFR32MG12P432F1024GL125") +elseif(BOARD_LOWERCASE STREQUAL "brd4166a") + set(MCU "EFR32MG12P332F1024GL125") +elseif(BOARD_LOWERCASE STREQUAL "brd4170a") + set(MCU "EFR32MG12P433F1024GM68") +else() + message(FATAL_ERROR " + BOARD=${BOARD} not supported. + + Please provide a value for BOARD variable e.g BOARD=brd4161a. + Currently supported: + - brd4161a + - brd4166a + - brd4170a + - brd4304a + ") +endif() + +list(APPEND OT_PLATFORM_DEFINES "${MCU}") +set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE) + +# ============================================================================== +# Platform library +# ============================================================================== +set(OT_PLATFORM_LIB "openthread-efr32mg12") +set(OT_PLATFORM_LIB ${OT_PLATFORM_LIB} PARENT_SCOPE) + +set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/efr32mg12/efr32mg12.ld") + +add_library(openthread-efr32mg12 + ${EFR32_COMMON_SOURCES} + $ +) + +set_target_properties(openthread-efr32mg12 + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_link_libraries(openthread-efr32mg12 + PUBLIC + ${EFR32_COMMON_3RD_LIBS} + silabs-libnvm3_CM4_gcc + silabs-efr32mg12-sdk + -T${LD_FILE} + -Wl,--gc-sections + -Wl,-Map=$.map + PRIVATE + ot-config +) + +target_compile_definitions(openthread-efr32mg12 + PUBLIC + ${OT_PLATFORM_DEFINES} +) + +target_compile_options(openthread-efr32mg12 + PRIVATE + ${EFR32_CFLAGS} +) + +target_include_directories(openthread-efr32mg12 + PUBLIC + ${EFR32_INCLUDES} + PRIVATE + ${SILABS_EFR32MG1X_INCLUDES} + ${OT_PUBLIC_INCLUDES} +) + diff --git a/examples/platforms/efr32/efr32mg13/Makefile.am b/examples/platforms/efr32/efr32mg13/Makefile.am index b50f02913..cea711d27 100644 --- a/examples/platforms/efr32/efr32mg13/Makefile.am +++ b/examples/platforms/efr32/efr32mg13/Makefile.am @@ -33,7 +33,6 @@ lib_LIBRARIES = libopenthread-efr32mg13.a libopenthread_efr32mg13_a_CPPFLAGS = \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ - -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -Wno-sign-compare \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \ diff --git a/examples/platforms/efr32/efr32mg13/README.md b/examples/platforms/efr32/efr32mg13/README.md index 7a6cd080d..98a8c3c3d 100644 --- a/examples/platforms/efr32/efr32mg13/README.md +++ b/examples/platforms/efr32/efr32mg13/README.md @@ -70,7 +70,47 @@ $ cd $ ./bootstrap ``` -For EFR32MG13™ Mighty Gecko Wireless Starter Kit: +For EFR32MG13™ Mighty Gecko Wireless Starter Kit, this can be done using both the CMake and autotools build systems + +**CMake (preferred)** + +```bash +$ ./script/cmake-build efr32mg13 -DBOARD=brd4168a +... +-- Configuring done +-- Generating done +-- Build files have been written to: /build/efr32mg13 ++ [[ -n ot-rcp ot-cli-ftd ot-cli-mtd ot-ncp-ftd ot-ncp-mtd sleepy-demo-ftd sleepy-demo-mtd ]] ++ ninja ot-rcp ot-cli-ftd ot-cli-mtd ot-ncp-ftd ot-ncp-mtd sleepy-demo-ftd sleepy-demo-mtd +[573/573] Linking CXX executable examples/apps/ncp/ot-ncp-ftd ++ cd +``` + +After a successful build, the `elf` files are found in `/build/efr32mg13/examples`. + +```bash +# For linux +$ find build/efr32mg13/examples -type f -executable +build/efr32mg13/examples/apps/cli/ot-cli-mtd +build/efr32mg13/examples/apps/cli/ot-cli-ftd +build/efr32mg13/examples/apps/ncp/ot-ncp-ftd +build/efr32mg13/examples/apps/ncp/ot-ncp-mtd +build/efr32mg13/examples/apps/ncp/ot-rcp +build/efr32mg13/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/sleepy-demo-ftd +build/efr32mg13/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/sleepy-demo-mtd + +# For BSD/Darwin/mac systems +$ find build/efr32mg13/examples -type f -perm +111 +build/efr32mg13/examples/apps/cli/ot-cli-mtd +build/efr32mg13/examples/apps/cli/ot-cli-ftd +build/efr32mg13/examples/apps/ncp/ot-ncp-ftd +build/efr32mg13/examples/apps/ncp/ot-ncp-mtd +build/efr32mg13/examples/apps/ncp/ot-rcp +build/efr32mg13/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/sleepy-demo-ftd +build/efr32mg13/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/sleepy-demo-mtd +``` + +**autotools (soon to be depracated)** ```bash $ make -f examples/Makefile-efr32mg13 BOARD=BRD4168A diff --git a/examples/platforms/efr32/efr32mg13/arm-none-eabi.cmake b/examples/platforms/efr32/efr32mg13/arm-none-eabi.cmake new file mode 100644 index 000000000..9f2e385f9 --- /dev/null +++ b/examples/platforms/efr32/efr32mg13/arm-none-eabi.cmake @@ -0,0 +1,51 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) +set(CMAKE_ASM_COMPILER arm-none-eabi-as) +set(CMAKE_RANLIB arm-none-eabi-ranlib) + +execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -mthumb -fdata-sections -ffunction-sections") + +set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=c99") +set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs") + +set(CMAKE_C_FLAGS_DEBUG "-Og -g") +set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") +set(CMAKE_ASM_FLAGS_DEBUG "-g") + +set(CMAKE_C_FLAGS_RELEASE "-Os") +set(CMAKE_CXX_FLAGS_RELEASE "-Os") +set(CMAKE_ASM_FLAGS_RELEASE "") diff --git a/examples/platforms/efr32/efr32mg13/efr32mg13.cmake b/examples/platforms/efr32/efr32mg13/efr32mg13.cmake new file mode 100644 index 000000000..c94490173 --- /dev/null +++ b/examples/platforms/efr32/efr32mg13/efr32mg13.cmake @@ -0,0 +1,95 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# ============================================================================== +# Verify board is supported for platform +# ============================================================================== +if(BOARD_LOWERCASE STREQUAL "brd4168a") + set(MCU "EFR32MG13P732F512GM48") +else() + message(FATAL_ERROR " + BOARD=${BOARD} not supported. + + Please provide a value for BOARD variable e.g BOARD=brd4168a. + Currently supported: + - brd4168a + ") +endif() + +list(APPEND OT_PLATFORM_DEFINES "${MCU}") +set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE) + +# ============================================================================== +# Platform library +# ============================================================================== +set(OT_PLATFORM_LIB "openthread-efr32mg13") +set(OT_PLATFORM_LIB ${OT_PLATFORM_LIB} PARENT_SCOPE) + +set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/efr32mg13/efr32mg13.ld") + +add_library(openthread-efr32mg13 + ${EFR32_COMMON_SOURCES} + $ +) + +set_target_properties(openthread-efr32mg13 + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_link_libraries(openthread-efr32mg13 + PUBLIC + ${EFR32_COMMON_3RD_LIBS} + silabs-libnvm3_CM4_gcc + silabs-efr32mg13-sdk + -T${LD_FILE} + -Wl,--gc-sections + -Wl,-Map=$.map + PRIVATE + ot-config +) + +target_compile_definitions(openthread-efr32mg13 + PUBLIC + ${OT_PLATFORM_DEFINES} +) + +target_compile_options(openthread-efr32mg13 + PRIVATE + ${EFR32_CFLAGS} +) + +target_include_directories(openthread-efr32mg13 + PUBLIC + ${EFR32_INCLUDES} + PRIVATE + ${SILABS_EFR32MG1X_INCLUDES} + ${OT_PUBLIC_INCLUDES} +) + diff --git a/examples/platforms/efr32/efr32mg21/Makefile.am b/examples/platforms/efr32/efr32mg21/Makefile.am index 4697d3c2b..3ce9a376f 100644 --- a/examples/platforms/efr32/efr32mg21/Makefile.am +++ b/examples/platforms/efr32/efr32mg21/Makefile.am @@ -33,7 +33,6 @@ lib_LIBRARIES = libopenthread-efr32mg21.a libopenthread_efr32mg21_a_CPPFLAGS = \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ - -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -Wno-sign-compare \ -I$(top_srcdir)/examples/platforms \ -I$(top_srcdir)/examples/platforms/efr32/$(PLATFORM_LOWERCASE)/$(BOARD_LOWERCASE) \ diff --git a/examples/platforms/efr32/efr32mg21/README.md b/examples/platforms/efr32/efr32mg21/README.md index c2c64dcf8..610ca26cb 100644 --- a/examples/platforms/efr32/efr32mg21/README.md +++ b/examples/platforms/efr32/efr32mg21/README.md @@ -65,7 +65,47 @@ $ cd $ ./bootstrap ``` -For EFR32MG21™ Mighty Gecko Wireless Starter Kit: +For EFR32MG21™ Mighty Gecko Wireless Starter Kit, this can be done using both the CMake and autotools build systems + +**CMake (preferred)** + +```bash +$ ./script/cmake-build efr32mg21 -DBOARD=brd4180b +... +-- Configuring done +-- Generating done +-- Build files have been written to: /build/efr32mg21 ++ [[ -n ot-rcp ot-cli-ftd ot-cli-mtd ot-ncp-ftd ot-ncp-mtd sleepy-demo-ftd sleepy-demo-mtd ]] ++ ninja ot-rcp ot-cli-ftd ot-cli-mtd ot-ncp-ftd ot-ncp-mtd sleepy-demo-ftd sleepy-demo-mtd +[940/940] Linking CXX executable examples/apps/ncp/ot-ncp-ftd ++ cd +``` + +After a successful build, the `elf` files are found in `/build/efr32mg21/examples`. + +```bash +# For linux +$ find build/efr32mg21/examples -type f -executable +build/efr32mg21/examples/apps/cli/ot-cli-mtd +build/efr32mg21/examples/apps/cli/ot-cli-ftd +build/efr32mg21/examples/apps/ncp/ot-ncp-ftd +build/efr32mg21/examples/apps/ncp/ot-ncp-mtd +build/efr32mg21/examples/apps/ncp/ot-rcp +build/efr32mg21/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/sleepy-demo-ftd +build/efr32mg21/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/sleepy-demo-mtd + +# For BSD/Darwin/mac systems +$ find build/efr32mg21/examples -type f -perm +111 +build/efr32mg21/examples/apps/cli/ot-cli-mtd +build/efr32mg21/examples/apps/cli/ot-cli-ftd +build/efr32mg21/examples/apps/ncp/ot-ncp-ftd +build/efr32mg21/examples/apps/ncp/ot-ncp-mtd +build/efr32mg21/examples/apps/ncp/ot-rcp +build/efr32mg21/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/sleepy-demo-ftd +build/efr32mg21/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/sleepy-demo-mtd +``` + +**autotools (soon to be depracated)** ```bash $ make -f examples/Makefile-efr32mg21 BOARD=BRD4180A diff --git a/examples/platforms/efr32/efr32mg21/arm-none-eabi.cmake b/examples/platforms/efr32/efr32mg21/arm-none-eabi.cmake new file mode 100644 index 000000000..046031638 --- /dev/null +++ b/examples/platforms/efr32/efr32mg21/arm-none-eabi.cmake @@ -0,0 +1,51 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR ARM) + +set(CMAKE_C_COMPILER arm-none-eabi-gcc) +set(CMAKE_CXX_COMPILER arm-none-eabi-g++) +set(CMAKE_ASM_COMPILER arm-none-eabi-as) +set(CMAKE_RANLIB arm-none-eabi-ranlib) + +execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE COMPILER_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(COMMON_C_FLAGS "-mcpu=cortex-m33 -mthumb -fmessage-length=0 -ffunction-sections -fdata-sections -mfpu=fpv5-sp-d16 -mfloat-abi=hard") + +set(CMAKE_C_FLAGS_INIT "${COMMON_C_FLAGS} -std=c99") +set(CMAKE_CXX_FLAGS_INIT "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs") + +set(CMAKE_C_FLAGS_DEBUG "-Og -g") +set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") +set(CMAKE_ASM_FLAGS_DEBUG "-g") + +set(CMAKE_C_FLAGS_RELEASE "-Os") +set(CMAKE_CXX_FLAGS_RELEASE "-Os") +set(CMAKE_ASM_FLAGS_RELEASE "") diff --git a/examples/platforms/efr32/efr32mg21/efr32mg21.cmake b/examples/platforms/efr32/efr32mg21/efr32mg21.cmake new file mode 100644 index 000000000..eaaffdd49 --- /dev/null +++ b/examples/platforms/efr32/efr32mg21/efr32mg21.cmake @@ -0,0 +1,98 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# ============================================================================== +# Verify board is supported for platform +# ============================================================================== +if(BOARD_LOWERCASE STREQUAL "brd4180a") + set(MCU "EFR32MG21A020F1024IM32") +elseif(BOARD_LOWERCASE STREQUAL "brd4180b") + set(MCU "EFR32MG21A020F1024IM32") +else() + message(FATAL_ERROR " + BOARD=${BOARD} not supported. + + Please provide a value for BOARD variable e.g BOARD=brd4180a. + Currently supported: + - brd4180a + - brd4180b + ") +endif() + +list(APPEND OT_PLATFORM_DEFINES "${MCU}") +set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE) + +# ============================================================================== +# Platform library +# ============================================================================== +set(OT_PLATFORM_LIB "openthread-efr32mg21") +set(OT_PLATFORM_LIB ${OT_PLATFORM_LIB} PARENT_SCOPE) + +set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/efr32mg21/efr32mg21.ld") + +add_library(openthread-efr32mg21 + ${EFR32_COMMON_SOURCES} + $ +) + +set_target_properties(openthread-efr32mg21 + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +target_link_libraries(openthread-efr32mg21 + PUBLIC + ${EFR32_COMMON_3RD_LIBS} + silabs-libnvm3_CM33_gcc + silabs-efr32mg21-sdk + -T${LD_FILE} + -Wl,--gc-sections + -Wl,-Map=$.map + PRIVATE + ot-config +) + +target_compile_definitions(openthread-efr32mg21 + PUBLIC + ${OT_PLATFORM_DEFINES} +) + +target_compile_options(openthread-efr32mg21 + PRIVATE + ${EFR32_CFLAGS} +) + +target_include_directories(openthread-efr32mg21 + PUBLIC + ${EFR32_INCLUDES} + PRIVATE + ${SILABS_EFR32MG2X_INCLUDES} + ${OT_PUBLIC_INCLUDES} +) + diff --git a/examples/platforms/efr32/sleepy-demo/CMakeLists.txt b/examples/platforms/efr32/sleepy-demo/CMakeLists.txt new file mode 100644 index 000000000..b99a6b6b9 --- /dev/null +++ b/examples/platforms/efr32/sleepy-demo/CMakeLists.txt @@ -0,0 +1,35 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +if(OT_FTD) + add_subdirectory(sleepy-demo-ftd) +endif() + +if(OT_MTD) + add_subdirectory(sleepy-demo-mtd) +endif() diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/CMakeLists.txt b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/CMakeLists.txt new file mode 100644 index 000000000..521f2e6f2 --- /dev/null +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/CMakeLists.txt @@ -0,0 +1,52 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +add_executable(sleepy-demo-ftd + main.c +) + +target_include_directories(sleepy-demo-ftd PRIVATE ${COMMON_INCLUDES}) + +target_link_libraries(sleepy-demo-ftd PRIVATE + openthread-cli-ftd + ${OT_PLATFORM_LIB} + openthread-ftd + ${OT_PLATFORM_LIB} + ${OT_MBEDTLS} + ot-config +) + + +target_compile_options(sleepy-demo-ftd + PRIVATE + ${EFR32_CFLAGS} +) + +install(TARGETS sleepy-demo-ftd + DESTINATION bin) + diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am index 141968eae..eff74bf28 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-ftd/Makefile.am @@ -36,7 +36,6 @@ bin_PROGRAMS = $(NULL) CPPFLAGS_COMMON += \ - -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ -Wno-sign-compare \ -I$(top_srcdir)/examples/platforms \ diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/CMakeLists.txt b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/CMakeLists.txt new file mode 100644 index 000000000..8408e6f17 --- /dev/null +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/CMakeLists.txt @@ -0,0 +1,45 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +add_executable(sleepy-demo-mtd + main.c +) + +target_include_directories(sleepy-demo-mtd PRIVATE ${COMMON_INCLUDES}) + +target_link_libraries(sleepy-demo-mtd PRIVATE + openthread-cli-mtd + ${OT_PLATFORM_LIB} + openthread-mtd + ${OT_PLATFORM_LIB} + ${OT_MBEDTLS} + ot-config +) + +install(TARGETS sleepy-demo-mtd + DESTINATION bin) diff --git a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am index 6adedec40..64e9bb882 100644 --- a/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am +++ b/examples/platforms/efr32/sleepy-demo/sleepy-demo-mtd/Makefile.am @@ -36,7 +36,6 @@ bin_PROGRAMS = $(NULL) CPPFLAGS_COMMON += \ - -DNVIC_CONFIG=\"platform/base/hal/micro/cortexm3/efm32/nvic-config.h\" \ -DPLATFORM_HEADER=\"platform/base/hal/micro/cortexm3/compiler/gcc.h\" \ -Wno-sign-compare \ -I$(top_srcdir)/examples/platforms \ diff --git a/examples/platforms/efr32/src/alarm.c b/examples/platforms/efr32/src/alarm.c index 842823f8c..81a001539 100644 --- a/examples/platforms/efr32/src/alarm.c +++ b/examples/platforms/efr32/src/alarm.c @@ -156,7 +156,7 @@ uint32_t otPlatAlarmMicroGetNow(void) void otPlatAlarmMicroStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt) { // TODO microsecond support - return otPlatAlarmMilliStartAt(aInstance, aT0, aDt); + otPlatAlarmMilliStartAt(aInstance, aT0, aDt); } void otPlatAlarmMicroStop(otInstance *aInstance) diff --git a/examples/platforms/efr32/src/openthread-core-efr32-config.h b/examples/platforms/efr32/src/openthread-core-efr32-config.h index 49410853d..360821007 100644 --- a/examples/platforms/efr32/src/openthread-core-efr32-config.h +++ b/examples/platforms/efr32/src/openthread-core-efr32-config.h @@ -33,6 +33,9 @@ */ #include "board_config.h" + +// IMPORTANT: Do not remove this include. Apps will build without error, but +// they will not boot up properly #include "em_msc.h" #ifndef OPENTHREAD_CORE_EFR32_CONFIG_H_ diff --git a/script/cmake-build b/script/cmake-build index bd0f00bbe..4b5e7db2c 100755 --- a/script/cmake-build +++ b/script/cmake-build @@ -46,6 +46,17 @@ # # script/cmake-build ${platform} ${nrf_build_type} -D${option}=ON -D${option}=OFF # +# Need to add BOARD when compiling efr32: +# +# script/cmake-build ${platform} -DBOARD=${EFR32 board} +# +# Example: +# script/cmake-build efr32mg21 -DBOARD=brd4180b +# +# To enable dynamic multiprotocol support on efr32: +# +# script/cmake-build ${platform} -DBOARD=${EFR32 board} -DDMP=ON +# # Compile with the specified ninja build target: # # OT_CMAKE_NINJA_TARGET="ot-cli-ftd" script/cmake-build ${platform} @@ -68,7 +79,7 @@ set -euxo pipefail OT_CMAKE_NINJA_TARGET=${OT_CMAKE_NINJA_TARGET:-} readonly OT_SRCDIR="$(pwd)" -readonly OT_PLATFORMS=(cc1352 cc2538 cc2650 cc2652 kw41z nrf52811 nrf52833 nrf52840 gp712 qpg7015m qpg6095 qpg6100 samr21 simulation posix) +readonly OT_PLATFORMS=(cc1352 cc2538 cc2650 cc2652 efr32mg1 efr32mg12 efr32mg13 efr32mg21 kw41z nrf52811 nrf52833 nrf52840 gp712 qpg7015m qpg6095 qpg6100 samr21 simulation posix) readonly OT_NRF528XX_BUILD_TYPES=(UART_trans USB_trans_bl SPI_trans_NCP soft_crypto soft_crypto_threading) readonly OT_POSIX_SIM_COMMON_OPTIONS=( "-DOT_BORDER_AGENT=ON" @@ -131,6 +142,29 @@ readonly OT_nrf52833_OPTIONS=( readonly OT_nrf52840_OPTIONS=("${OT_nrf52833_OPTIONS[@]:0}") +readonly OT_efr32_OPTIONS=( + "-DOT_DIAGNOSTIC=ON" + "-DOT_EXTERNAL_HEAP=ON" + "-DOT_EXTERNAL_MBEDTLS=silabs-mbedtls" + "-DOT_BUILTIN_MBEDTLS_MANAGEMENT=OFF" +) + +readonly OT_efr32mg1_OPTIONS=( + "${OT_efr32_OPTIONS[@]:0}" +) + +readonly OT_efr32mg12_OPTIONS=( + "${OT_efr32_OPTIONS[@]:0}" +) + +readonly OT_efr32mg13_OPTIONS=( + "${OT_efr32_OPTIONS[@]:0}" +) + +readonly OT_efr32mg21_OPTIONS=( + "${OT_efr32_OPTIONS[@]:0}" +) + die() { echo " ** ERROR: Openthread CMake doesn't support platform \"$1\"" @@ -209,6 +243,31 @@ main() OT_CMAKE_NINJA_TARGET=("ot-cli-ftd" "ot-rcp") options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/${platform}/arm-linux-gnueabihf.cmake" "-DCMAKE_BUILD_TYPE=Release") ;; + efr32*) + options+=("-DCMAKE_TOOLCHAIN_FILE=examples/platforms/efr32/${platform}/arm-none-eabi.cmake") + + case "${platform}" in + efr32mg1) + OT_CMAKE_NINJA_TARGET=("ot-rcp") + options+=("${OT_efr32mg1_OPTIONS[@]}") + ;; + efr32mg12) + OT_CMAKE_NINJA_TARGET=("ot-rcp" "ot-cli-ftd" "ot-cli-mtd" "ot-ncp-ftd" "ot-ncp-mtd") + OT_CMAKE_NINJA_TARGET+=("sleepy-demo-ftd" "sleepy-demo-mtd") + options+=("${OT_efr32mg12_OPTIONS[@]}") + ;; + efr32mg13) + OT_CMAKE_NINJA_TARGET=("ot-rcp" "ot-cli-ftd" "ot-cli-mtd" "ot-ncp-ftd" "ot-ncp-mtd") + OT_CMAKE_NINJA_TARGET+=("sleepy-demo-ftd" "sleepy-demo-mtd") + options+=("${OT_efr32mg13_OPTIONS[@]}") + ;; + efr32mg21) + OT_CMAKE_NINJA_TARGET=("ot-rcp" "ot-cli-ftd" "ot-cli-mtd" "ot-ncp-ftd" "ot-ncp-mtd") + OT_CMAKE_NINJA_TARGET+=("sleepy-demo-ftd" "sleepy-demo-mtd") + options+=("${OT_efr32mg21_OPTIONS[@]}") + ;; + esac + ;; nrf52811) local_options+=("${OT_nrf52811_OPTIONS[@]}" "-DCMAKE_TOOLCHAIN_FILE=examples/platforms/nrf528xx/${platform}/arm-none-eabi.cmake" "-DCMAKE_BUILD_TYPE=Release") case "${nrf_build_type}" in diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 9e9120738..96ab34ab3 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -43,4 +43,7 @@ elseif(OT_PLATFORM STREQUAL "samr21") elseif(OT_PLATFORM MATCHES "^nrf*") add_subdirectory(jlink) add_subdirectory(NordicSemiconductor) +elseif(OT_PLATFORM MATCHES "^efr*") + add_subdirectory(jlink) + add_subdirectory(silabs) endif() diff --git a/third_party/jlink/CMakeLists.txt b/third_party/jlink/CMakeLists.txt index f3e22bd39..e2b1e7f90 100644 --- a/third_party/jlink/CMakeLists.txt +++ b/third_party/jlink/CMakeLists.txt @@ -31,31 +31,37 @@ add_library(jlinkrtt SEGGER_RTT_V640/RTT/SEGGER_RTT.c ) -if(OT_PLATFORM STREQUAL "nrf52811") - target_compile_options(jlinkrtt PRIVATE - -DNRF52811_XXAA - ) -elseif(OT_PLATFORM STREQUAL "nrf52833") - target_compile_options(jlinkrtt PRIVATE - -DNRF52833_XXAA - ) -else() - target_compile_options(jlinkrtt PRIVATE - -DNRF52840_XXAA - ) -endif() - -target_compile_options(jlinkrtt PRIVATE - -DSEGGER_RTT_CONFIG_H=\"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/segger_rtt/SEGGER_RTT_Conf.h\" - -DUSE_APP_CONFIG=1 -) - target_include_directories(jlinkrtt PRIVATE ${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/cmsis - ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config - ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/${OT_PLATFORM}/config - ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/dependencies - ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/app_error - ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/mdk ) + +if(OT_PLATFORM MATCHES "^nrf*") + + if(OT_PLATFORM STREQUAL "nrf52811") + target_compile_options(jlinkrtt PRIVATE + -DNRF52811_XXAA + ) + elseif(OT_PLATFORM STREQUAL "nrf52833") + target_compile_options(jlinkrtt PRIVATE + -DNRF52833_XXAA + ) + else() + target_compile_options(jlinkrtt PRIVATE + -DNRF52840_XXAA + ) + endif() + + target_compile_options(jlinkrtt PRIVATE + -DSEGGER_RTT_CONFIG_H=\"${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/segger_rtt/SEGGER_RTT_Conf.h\" + -DUSE_APP_CONFIG=1 + ) + + target_include_directories(jlinkrtt PRIVATE + ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/cmsis + ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config + ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/config/${OT_PLATFORM}/config + ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/dependencies + ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/libraries/app_error + ${PROJECT_SOURCE_DIR}/third_party/NordicSemiconductor/nrfx/mdk + ) +endif() diff --git a/third_party/silabs/CMakeLists.txt b/third_party/silabs/CMakeLists.txt new file mode 100644 index 000000000..862c13f11 --- /dev/null +++ b/third_party/silabs/CMakeLists.txt @@ -0,0 +1,109 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/utility.cmake) +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/includes.cmake) + +# Append SILABS_GSDK_INCLUDES to OT_PUBLIC_INCLUDES +list(APPEND OT_PUBLIC_INCLUDES ${SILABS_GSDK_INCLUDES}) +set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE) + +set(COMMON_FLAGS + -Wno-unused-parameter + -Wno-missing-field-initializers +) + +set(SILABS_GSDK_COMMON_SOURCES + rail_config/rail_config.c + ${SILABS_GSDK_DIR}/hardware/kit/common/bsp/bsp_bcc.c + ${SILABS_GSDK_DIR}/hardware/kit/common/bsp/bsp_init.c + ${SILABS_GSDK_DIR}/hardware/kit/common/bsp/bsp_stk.c + ${SILABS_GSDK_DIR}/hardware/kit/common/bsp/bsp_stk_leds.c + ${SILABS_GSDK_DIR}/platform/emdrv/dmadrv/src/dmadrv.c + ${SILABS_GSDK_DIR}/platform/emdrv/gpiointerrupt/src/gpiointerrupt.c + ${SILABS_GSDK_DIR}/platform/emdrv/nvm3/src/nvm3_default_common_linker.c + ${SILABS_GSDK_DIR}/platform/emdrv/nvm3/src/nvm3_hal_flash.c + ${SILABS_GSDK_DIR}/platform/emdrv/nvm3/src/nvm3_lock.c + ${SILABS_GSDK_DIR}/platform/emdrv/uartdrv/src/uartdrv.c + ${SILABS_GSDK_DIR}/platform/emdrv/ustimer/src/ustimer.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_cmu.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_core.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_emu.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_gpio.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_ldma.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_msc.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_rmu.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_rtcc.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_system.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_timer.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_usart.c + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/hal/efr32/hal_efr.c + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/hal/hal_common.c + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/pa-conversions/pa_conversions_efr32.c + ${SILABS_GSDK_DIR}/platform/service/mpu/src/sl_mpu.c + ${SILABS_GSDK_DIR}/platform/service/device_init/src/sl_device_init_nvic.c + ${SILABS_GSDK_DIR}/platform/service/sleeptimer/src/sl_sleeptimer.c + ${SILABS_GSDK_DIR}/platform/service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_alt/source/sl_entropy.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_alt/source/sl_mbedtls.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/mbedtls_sha.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_psa_driver_init.c +) + +# ============================================================================== +# Build RAIL lib name +# ============================================================================== +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/imported_libs.cmake) + +# replace 'mg' with 'xg' +string(REPLACE "mg" "xg" librail_platform_name ${OT_PLATFORM}) + +if(DMP) + set(rail_dmp_string "multiprotocol_") +else() + set(rail_dmp_string "") +endif() + +set(silabs-librail "silabs-librail_${rail_dmp_string}${librail_platform_name}_gcc_release") + +# ============================================================================== +# Platform GSDK lib +# ============================================================================== +set(platform_sdk_cmake "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${OT_PLATFORM}.cmake") +if(NOT EXISTS ${platform_sdk_cmake}) + message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}") +endif() +include(${platform_sdk_cmake}) + +# ============================================================================== +# mbedtls +# ============================================================================== +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/mbedtls.cmake) + +list(APPEND OT_PLATFORM_DEFINES "MBEDTLS_CONFIG_FILE=\"mbedtls_config.h\"") +set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE) diff --git a/third_party/silabs/Makefile.am b/third_party/silabs/Makefile.am index ae8eb643e..3608e2c77 100644 --- a/third_party/silabs/Makefile.am +++ b/third_party/silabs/Makefile.am @@ -91,7 +91,6 @@ SILABS_MBEDTLS_CPPFLAGS -I$(SDK_SRC_DIR)/util/third_party/crypto/sl_component/sl_alt/include \ -I$(SDK_SRC_DIR)/util/third_party/crypto/sl_component/sl_mbedtls_support/config \ -I$(SDK_SRC_DIR)/util/third_party/crypto/sl_component/sl_mbedtls_support/inc \ - -I$(SDK_SRC_DIR)/util/third_party/crypto/sl_component/sl_mbedtls_support/inc/configs \ -I$(SDK_SRC_DIR)/util/third_party/crypto/sl_component/sl_psa_driver/inc \ -I$(SDK_SRC_DIR)/util/silicon_labs/silabs_core/memory_manager \ -I$(SDK_SRC_DIR)/platform/CMSIS/Include \ diff --git a/third_party/silabs/cmake/efr32mg1.cmake b/third_party/silabs/cmake/efr32mg1.cmake new file mode 100644 index 000000000..68d0a0119 --- /dev/null +++ b/third_party/silabs/cmake/efr32mg1.cmake @@ -0,0 +1,57 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/efr32mg1x.cmake) + +add_library(silabs-efr32mg1-sdk) + +target_compile_definitions(silabs-efr32mg1-sdk + PRIVATE + ${COMMON_FLAG} +) + +target_include_directories(silabs-efr32mg1-sdk + PUBLIC + ${SILABS_COMMON_INCLUDES} + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG1P/Include + ${SILABS_EFR32MG1X_INCLUDES} +) + +target_sources(silabs-efr32mg1-sdk + PRIVATE + ${SILABS_GSDK_COMMON_SOURCES} + ${SILABS_EFR32MG1_SOURCES} +) + +target_link_libraries(silabs-efr32mg1-sdk + PUBLIC + silabs-mbedtls + PRIVATE + ${silabs-librail} + ot-config +) diff --git a/third_party/silabs/cmake/efr32mg12.cmake b/third_party/silabs/cmake/efr32mg12.cmake new file mode 100644 index 000000000..27675f038 --- /dev/null +++ b/third_party/silabs/cmake/efr32mg12.cmake @@ -0,0 +1,56 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/efr32mg1x.cmake) + +add_library(silabs-efr32mg12-sdk) + +target_compile_definitions(silabs-efr32mg12-sdk + PRIVATE + ${COMMON_FLAG} +) + +target_include_directories(silabs-efr32mg12-sdk + PUBLIC + ${SILABS_COMMON_INCLUDES} + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG12P/Include + ${SILABS_EFR32MG1X_INCLUDES} +) + +target_sources(silabs-efr32mg12-sdk + PRIVATE + ${SILABS_GSDK_COMMON_SOURCES} + ${SILABS_EFR32MG12_SOURCES} +) + +target_link_libraries(silabs-efr32mg12-sdk + PUBLIC + silabs-mbedtls + PRIVATE + ${silabs-librail} + ot-config) diff --git a/third_party/silabs/cmake/efr32mg13.cmake b/third_party/silabs/cmake/efr32mg13.cmake new file mode 100644 index 000000000..06ef0e5fb --- /dev/null +++ b/third_party/silabs/cmake/efr32mg13.cmake @@ -0,0 +1,56 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/efr32mg1x.cmake) + +add_library(silabs-efr32mg13-sdk) + +target_compile_definitions(silabs-efr32mg13-sdk + PRIVATE + ${COMMON_FLAG} +) + +target_include_directories(silabs-efr32mg13-sdk + PUBLIC + ${SILABS_COMMON_INCLUDES} + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG13P/Include + ${SILABS_EFR32MG1X_INCLUDES} +) + +target_sources(silabs-efr32mg13-sdk + PRIVATE + ${SILABS_GSDK_COMMON_SOURCES} + ${SILABS_EFR32MG13_SOURCES} +) + +target_link_libraries(silabs-efr32mg13-sdk + PUBLIC + silabs-mbedtls + PRIVATE + ${silabs-librail} + ot-config) diff --git a/third_party/silabs/cmake/efr32mg1x.cmake b/third_party/silabs/cmake/efr32mg1x.cmake new file mode 100644 index 000000000..1bba23a8f --- /dev/null +++ b/third_party/silabs/cmake/efr32mg1x.cmake @@ -0,0 +1,67 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# ============================================================================== +# Series-level _SOURCES +# ============================================================================== +set(SILABS_EFR32MG1X_SOURCES + ${SILABS_GSDK_DIR}/platform/emlib/src/em_adc.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_crypto.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_leuart.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/crypto_aes.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/crypto_ecp.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/crypto_management.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_crypto_transparent_driver_aead.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_crypto_transparent_driver_cipher.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_crypto_transparent_driver_hash.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_crypto_transparent_driver_mac.c +) + + +# ============================================================================== +# Platform-level _SOURCES +# ============================================================================== +set(SILABS_EFR32MG1_SOURCES + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG1P/Source/system_efr32mg1p.c + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG1P/Source/GCC/startup_efr32mg1p.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_alt/source/sl_entropy_adc.c + ${SILABS_EFR32MG1X_SOURCES} +) + +set(SILABS_EFR32MG12_SOURCES + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG12P/Source/system_efr32mg12p.c + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG12P/Source/GCC/startup_efr32mg12p.c + ${SILABS_EFR32MG1X_SOURCES} +) + +set(SILABS_EFR32MG13_SOURCES + ${SILABS_GSDK_DIR}/hardware/kit/common/drivers/mx25flash_spi.c + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG13P/Source/system_efr32mg13p.c + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG13P/Source/GCC/startup_efr32mg13p.c + ${SILABS_EFR32MG1X_SOURCES} +) diff --git a/third_party/silabs/cmake/efr32mg21.cmake b/third_party/silabs/cmake/efr32mg21.cmake new file mode 100644 index 000000000..8795e1109 --- /dev/null +++ b/third_party/silabs/cmake/efr32mg21.cmake @@ -0,0 +1,57 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/efr32mg2x.cmake) + +add_library(silabs-efr32mg21-sdk) + +target_compile_definitions(silabs-efr32mg21-sdk + PRIVATE + ${COMMON_FLAG} +) + +target_include_directories(silabs-efr32mg21-sdk + PUBLIC + ${SILABS_COMMON_INCLUDES} + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG21/Include + ${SILABS_EFR32MG2X_INCLUDES} +) + +target_sources(silabs-efr32mg21-sdk + PUBLIC + ${SILABS_EFR32MG21_SOURCES} + PRIVATE + ${SILABS_GSDK_COMMON_SOURCES} +) + +target_link_libraries(silabs-efr32mg21-sdk + PUBLIC + silabs-mbedtls + PRIVATE + ${silabs-librail} + ot-config) diff --git a/third_party/silabs/cmake/efr32mg2x.cmake b/third_party/silabs/cmake/efr32mg2x.cmake new file mode 100644 index 000000000..445311433 --- /dev/null +++ b/third_party/silabs/cmake/efr32mg2x.cmake @@ -0,0 +1,79 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# ============================================================================== +# Series-level _SOURCES +# ============================================================================== +set(SILABS_EFR32MG2X_SOURCES + ${SILABS_GSDK_DIR}/platform/emlib/src/em_burtc.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_prs.c + ${SILABS_GSDK_DIR}/platform/emlib/src/em_se.c + ${SILABS_GSDK_DIR}/platform/service/sleeptimer/src/sl_sleeptimer_hal_burtc.c + ${SILABS_GSDK_DIR}/platform/service/sleeptimer/src/sl_sleeptimer_hal_prortc.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_attestation.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_cipher.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_entropy.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_hash.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_key_derivation.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_key_handling.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_signature.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_util.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_alt/source/sl_se_management.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/mbedtls_cmac.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/mbedtls_ecdsa_ecdh.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_aes.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_ccm.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_jpake.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_aead.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_builtin_keys.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_cipher.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_key_derivation.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_key_management.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_mac.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_signature.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_driver_aead.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_driver_cipher.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_driver_mac.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_key_derivation.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_aead.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_cipher.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_hash.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_mac.c + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_key_derivation.c +) + + +# ============================================================================== +# Platform-level _SOURCES +# ============================================================================== +set(SILABS_EFR32MG21_SOURCES + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG21/Source/system_efr32mg21.c + ${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG21/Source/GCC/startup_efr32mg21.c + ${SILABS_EFR32MG2X_SOURCES} +) diff --git a/third_party/silabs/cmake/imported_libs.cmake b/third_party/silabs/cmake/imported_libs.cmake new file mode 100644 index 000000000..c09d79fb4 --- /dev/null +++ b/third_party/silabs/cmake/imported_libs.cmake @@ -0,0 +1,74 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# ============================================================================== +# RAIL libs +# ============================================================================== +set(librail_release_dir "${SILABS_GSDK_DIR}/platform/radio/rail_lib/autogen/librail_release") +file(GLOB rail_libs ${librail_release_dir}/*.a) + +foreach(lib_file ${rail_libs}) + + # Parse lib name, stripping .a extension + get_filename_component(lib_name ${lib_file} NAME_WLE) + set(imported_lib_name "silabs-${lib_name}") + + # Add as an IMPORTED lib + add_library(${imported_lib_name} STATIC IMPORTED) + set_target_properties(${imported_lib_name} + PROPERTIES + IMPORTED_LOCATION "${lib_file}" + IMPORTED_LINK_INTERFACE_LIBRARIES silabs-${PLATFORM_LOWERCASE}-sdk + ) + +endforeach() + + +# ============================================================================== +# NVM3 libs +# ============================================================================== +set(libnvm3_release_dir "${SILABS_GSDK_DIR}/platform/emdrv/nvm3/lib") +file(GLOB nvm3_libs ${libnvm3_release_dir}/*.a) + +foreach(lib_file ${nvm3_libs}) + + # Parse lib name, stripping .a extension + get_filename_component(lib_name ${lib_file} NAME_WLE) + set(imported_lib_name "silabs-${lib_name}") + + # Add as an IMPORTED lib + add_library(${imported_lib_name} STATIC IMPORTED) + set_target_properties(${imported_lib_name} + PROPERTIES + IMPORTED_LOCATION "${lib_file}" + IMPORTED_LINK_INTERFACE_LIBRARIES silabs-${PLATFORM_LOWERCASE}-sdk + ) + +endforeach() + + diff --git a/third_party/silabs/cmake/includes.cmake b/third_party/silabs/cmake/includes.cmake new file mode 100644 index 000000000..23bdd6f13 --- /dev/null +++ b/third_party/silabs/cmake/includes.cmake @@ -0,0 +1,103 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +set(SILABS_GSDK_INCLUDES + ${SILABS_GSDK_DIR} + ${SILABS_GSDK_DIR}/hardware/kit/${PLATFORM_UPPERCASE}_${BOARD_UPPERCASE}/config + ${SILABS_GSDK_DIR}/hardware/kit/common/bsp + ${SILABS_GSDK_DIR}/hardware/kit/common/drivers + ${SILABS_GSDK_DIR}/platform/base/hal/micro/cortexm3/efm32 + ${SILABS_GSDK_DIR}/platform/base/hal/micro/cortexm3/efm32/config + ${SILABS_GSDK_DIR}/platform/base/hal/plugin/antenna/ + ${SILABS_GSDK_DIR}/platform/CMSIS/Include + ${SILABS_GSDK_DIR}/platform/common/inc + ${SILABS_GSDK_DIR}/platform/emdrv/common/inc + ${SILABS_GSDK_DIR}/platform/emdrv/dmadrv/config + ${SILABS_GSDK_DIR}/platform/emdrv/dmadrv/inc + ${SILABS_GSDK_DIR}/platform/emdrv/gpiointerrupt/inc + ${SILABS_GSDK_DIR}/platform/emdrv/nvm3/config + ${SILABS_GSDK_DIR}/platform/emdrv/nvm3/inc + ${SILABS_GSDK_DIR}/platform/emdrv/uartdrv/config + ${SILABS_GSDK_DIR}/platform/emdrv/uartdrv/inc + ${SILABS_GSDK_DIR}/platform/emdrv/ustimer/inc + ${SILABS_GSDK_DIR}/platform/emlib/inc + ${SILABS_GSDK_DIR}/platform/halconfig/inc/hal-config + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/chip/efr32 + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/common + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/hal + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/hal/efr32 + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/pa-conversions + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/protocol/ieee802154 + ${SILABS_GSDK_DIR}/platform/service/device_init/inc + ${SILABS_GSDK_DIR}/platform/service/mpu/inc + ${SILABS_GSDK_DIR}/platform/service/sleeptimer/config + ${SILABS_GSDK_DIR}/platform/service/sleeptimer/inc + ${SILABS_GSDK_DIR}/util/plugin/plugin-common/fem-control +) + +file(GLOB gsdk_board_config_dir "${SILABS_GSDK_DIR}/hardware/board/config/*${BOARD_LOWERCASE}*") +list(APPEND SILABS_GSDK_INCLUDES ${gsdk_board_config_dir}) + +if(PLATFORM_LOWERCASE STREQUAL "efr32mg1") + set(gsdk_platform_device_silicon_labs_include_dir "${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG1P/Include") +elseif(PLATFORM_LOWERCASE STREQUAL "efr32mg12") + set(gsdk_platform_device_silicon_labs_include_dir "${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG12P/Include") +elseif(PLATFORM_LOWERCASE STREQUAL "efr32mg13") + set(gsdk_platform_device_silicon_labs_include_dir "${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG13P/Include") +elseif(PLATFORM_LOWERCASE STREQUAL "efr32mg21") + set(gsdk_platform_device_silicon_labs_include_dir "${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG21/Include") +endif() +list(APPEND SILABS_GSDK_INCLUDES ${gsdk_platform_device_silicon_labs_include_dir}) + +set(SILABS_COMMON_INCLUDES + ${PROJECT_SOURCE_DIR}/examples/platforms + ${PROJECT_SOURCE_DIR}/examples/platforms/efr32/src + ${PROJECT_SOURCE_DIR}/examples/platforms/efr32/${PLATFORM_LOWERCASE}/crypto + ${PROJECT_SOURCE_DIR}/examples/platforms/efr32/${PLATFORM_LOWERCASE}/${BOARD_LOWERCASE} + ${PROJECT_SOURCE_DIR}/third_party/silabs/rail_config + ${SILABS_GSDK_INCLUDES} + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/src/core +) + +# ============================================================================== +# Series-level CPPFLAGS +# ============================================================================== +set(SILABS_EFR32MG1X_INCLUDES + ${SILABS_GSDK_DIR}/platform/emdrv/nvm3/config/s1 + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/chip/efr32/efr32xg1x + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg1x/config +) +set(SILABS_EFR32MG2X_INCLUDES + ${SILABS_GSDK_DIR}/platform/emdrv/nvm3/config/s2 + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/chip/efr32/efr32xg2x + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg21/config + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/inc + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src +) diff --git a/third_party/silabs/cmake/mbedtls.cmake b/third_party/silabs/cmake/mbedtls.cmake new file mode 100644 index 000000000..9ad716df8 --- /dev/null +++ b/third_party/silabs/cmake/mbedtls.cmake @@ -0,0 +1,117 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +include(${PROJECT_SOURCE_DIR}/third_party/silabs/cmake/utility.cmake) + +add_library(silabs-mbedtls) + +set_target_properties(silabs-mbedtls + PROPERTIES + C_STANDARD 99 + CXX_STANDARD 11 +) + +set(SILABS_MBEDTLS_DIR "${SILABS_GSDK_DIR}/util/third_party/crypto/mbedtls") + +target_compile_definitions(silabs-mbedtls + PRIVATE + ${OT_PLATFORM_DEFINES} +) + +target_include_directories(silabs-mbedtls + PUBLIC + ${SILABS_MBEDTLS_DIR}/include + ${SILABS_MBEDTLS_DIR}/include/mbedtls + ${SILABS_MBEDTLS_DIR}/library + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_alt/include + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/config + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_mbedtls_support/inc + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/inc + ${PROJECT_SOURCE_DIR}/examples/platforms/efr32/${PLATFORM_LOWERCASE}/crypto + ${SILABS_GSDK_DIR}/util/silicon_labs/silabs_core/memory_manager + PRIVATE + ${SILABS_GSDK_DIR}/platform/CMSIS/Include + ${SILABS_GSDK_DIR}/platform/common/inc/ + ${SILABS_GSDK_DIR}/platform/emlib/inc + ${SILABS_GSDK_DIR}/platform/radio/rail_lib/common + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/inc + ${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/se_manager/src + ${gsdk_platform_device_silicon_labs_include_dir} + ${PROJECT_SOURCE_DIR}/examples/platforms/efr32/src +) + +set(SILABS_MBEDTLS_SOURCES + ${SILABS_MBEDTLS_DIR}/library/aes.c + ${SILABS_MBEDTLS_DIR}/library/asn1parse.c + ${SILABS_MBEDTLS_DIR}/library/asn1write.c + ${SILABS_MBEDTLS_DIR}/library/base64.c + ${SILABS_MBEDTLS_DIR}/library/bignum.c + ${SILABS_MBEDTLS_DIR}/library/ccm.c + ${SILABS_MBEDTLS_DIR}/library/cipher_wrap.c + ${SILABS_MBEDTLS_DIR}/library/cipher.c + ${SILABS_MBEDTLS_DIR}/library/cmac.c + ${SILABS_MBEDTLS_DIR}/library/ctr_drbg.c + ${SILABS_MBEDTLS_DIR}/library/des.c + ${SILABS_MBEDTLS_DIR}/library/ecdh.c + ${SILABS_MBEDTLS_DIR}/library/ecdsa.c + ${SILABS_MBEDTLS_DIR}/library/ecjpake.c + ${SILABS_MBEDTLS_DIR}/library/ecp_curves.c + ${SILABS_MBEDTLS_DIR}/library/ecp.c + ${SILABS_MBEDTLS_DIR}/library/entropy.c + ${SILABS_MBEDTLS_DIR}/library/error.c + ${SILABS_MBEDTLS_DIR}/library/md.c + ${SILABS_MBEDTLS_DIR}/library/oid.c + ${SILABS_MBEDTLS_DIR}/library/pem.c + ${SILABS_MBEDTLS_DIR}/library/pk_wrap.c + ${SILABS_MBEDTLS_DIR}/library/pk.c + ${SILABS_MBEDTLS_DIR}/library/pkparse.c + ${SILABS_MBEDTLS_DIR}/library/platform_util.c + ${SILABS_MBEDTLS_DIR}/library/platform.c + ${SILABS_MBEDTLS_DIR}/library/rsa_internal.c + ${SILABS_MBEDTLS_DIR}/library/rsa.c + ${SILABS_MBEDTLS_DIR}/library/sha256.c + ${SILABS_MBEDTLS_DIR}/library/ssl_cache.c + ${SILABS_MBEDTLS_DIR}/library/ssl_ciphersuites.c + ${SILABS_MBEDTLS_DIR}/library/ssl_cli.c + ${SILABS_MBEDTLS_DIR}/library/ssl_cookie.c + ${SILABS_MBEDTLS_DIR}/library/ssl_msg.c + ${SILABS_MBEDTLS_DIR}/library/ssl_srv.c + ${SILABS_MBEDTLS_DIR}/library/ssl_ticket.c + ${SILABS_MBEDTLS_DIR}/library/ssl_tls.c + ${SILABS_MBEDTLS_DIR}/library/threading.c + ${SILABS_MBEDTLS_DIR}/library/x509_create.c + ${SILABS_MBEDTLS_DIR}/library/x509_crl.c + ${SILABS_MBEDTLS_DIR}/library/x509_crt.c + ${SILABS_MBEDTLS_DIR}/library/x509_csr.c + ${SILABS_MBEDTLS_DIR}/library/x509.c + ${SILABS_MBEDTLS_DIR}/library/x509write_crt.c + ${SILABS_MBEDTLS_DIR}/library/x509write_csr.c + ${SILABS_GSDK_DIR}/util/silicon_labs/silabs_core/memory_manager/sl_malloc.c +) + +target_sources(silabs-mbedtls PRIVATE ${SILABS_MBEDTLS_SOURCES}) diff --git a/third_party/silabs/cmake/utility.cmake b/third_party/silabs/cmake/utility.cmake new file mode 100644 index 000000000..b212cf779 --- /dev/null +++ b/third_party/silabs/cmake/utility.cmake @@ -0,0 +1,44 @@ +# +# Copyright (c) 2021, The OpenThread Authors. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the copyright holder nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# Alias OT_PLATFORM as EFR32_PLATFORM +set(EFR32_PLATFORM ${OT_PLATFORM}) + +string(TOLOWER "${EFR32_PLATFORM}" PLATFORM_LOWERCASE) +string(TOUPPER "${EFR32_PLATFORM}" PLATFORM_UPPERCASE) + +string(TOLOWER "${BOARD}" BOARD_LOWERCASE) +string(TOUPPER "${BOARD}" BOARD_UPPERCASE) + +set(SILABS_GSDK_VERSION 3.1) +set(SILABS_GSDK_DIR ${PROJECT_SOURCE_DIR}/third_party/silabs/gecko_sdk_suite/v${SILABS_GSDK_VERSION}) + +# Check if GSDK exists +if(NOT EXISTS "${SILABS_GSDK_DIR}") + message(FATAL_ERROR "Cannot find: ${SILABS_GSDK_DIR}\nCheck that Silicon Labs GSDK ${SILABS_GSDK_VERSION} was installed properly") +endif()