Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an eero version of the openthread-efr32-[soc/rcp] CMake libs #533

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ target_compile_options(ot-config INTERFACE
# Generated platform projects
# ==============================================================================
set(slc_generated_projects
${PROJECT_SOURCE_DIR}/build/${BOARD_LOWERCASE}/slc/soc/platform
${PROJECT_SOURCE_DIR}/build/${BOARD_LOWERCASE}/slc/soc/mbedtls
${PROJECT_SOURCE_DIR}/build/${BOARD_LOWERCASE}/slc/rcp/platform
${PROJECT_SOURCE_DIR}/build/${BOARD_LOWERCASE}/slc/rcp/mbedtls
${PROJECT_SOURCE_DIR}/src/platform_libs/openthread-efr32-soc-eero
${PROJECT_SOURCE_DIR}/src/platform_libs/openthread-efr32-rcp-eero
)

foreach(slc_project IN LISTS slc_generated_projects)
Expand Down
60 changes: 30 additions & 30 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ build()
# ==============================================================================================================
# Generate openthread-efr32-soc and openthread-efr32-soc-sdk libs
# ==============================================================================================================
current_project_export_dir="${slc_generated_projects_dir}/soc/platform"

run_slc -v 1 generate \
--sdk="${sdk_dir}" \
--clear-cache \
--project-file="${repo_dir}/src/platform_projects/openthread-efr32-soc.slcp" \
--output-type=makefile \
--no-copy \
--export-templates="${repo_dir}"/third_party/silabs/slc/exporter_templates/platform_library \
--export-destination="${current_project_export_dir}" \
--with "${board}"

# TODO: Remove this when slc supports generic jinja template generation
mv "${current_project_export_dir}/openthread-efr32-soc.Makefile" "${current_project_export_dir}/CMakeLists.txt"
mv "${current_project_export_dir}/openthread-efr32-soc.project.mak" "${current_project_export_dir}/openthread-efr32-soc-sdk.cmake"
# current_project_export_dir="${slc_generated_projects_dir}/soc/platform"

# run_slc -v 1 generate \
# --sdk="${sdk_dir}" \
# --clear-cache \
# --project-file="${repo_dir}/src/platform_projects/openthread-efr32-soc.slcp" \
# --output-type=makefile \
# --no-copy \
# --export-templates="${repo_dir}"/third_party/silabs/slc/exporter_templates/platform_library \
# --export-destination="${current_project_export_dir}" \
# --with "${board}"

# # TODO: Remove this when slc supports generic jinja template generation
# mv "${current_project_export_dir}/openthread-efr32-soc.Makefile" "${current_project_export_dir}/CMakeLists.txt"
# mv "${current_project_export_dir}/openthread-efr32-soc.project.mak" "${current_project_export_dir}/openthread-efr32-soc-sdk.cmake"

# ==============================================================================================================
# Generate openthread-efr32-soc-mbedtls lib
Expand All @@ -117,21 +117,21 @@ build()
# ==============================================================================================================
# Generate openthread-efr32-rcp and openthread-efr32-rcp-sdk libs
# ==============================================================================================================
current_project_export_dir="${slc_generated_projects_dir}/rcp/platform"

run_slc -v 1 generate \
--sdk="${sdk_dir}" \
--clear-cache \
--project-file="${repo_dir}/src/platform_projects/openthread-efr32-rcp.slcp" \
--output-type=makefile \
--no-copy \
--export-templates="${repo_dir}"/third_party/silabs/slc/exporter_templates/platform_library \
--export-destination="${current_project_export_dir}" \
--with "${board}"

# TODO: Remove this when slc supports generic jinja template generation
mv "${current_project_export_dir}/openthread-efr32-rcp.Makefile" "${current_project_export_dir}/CMakeLists.txt"
mv "${current_project_export_dir}/openthread-efr32-rcp.project.mak" "${current_project_export_dir}/openthread-efr32-rcp-sdk.cmake"
# current_project_export_dir="${slc_generated_projects_dir}/rcp/platform"

# run_slc -v 1 generate \
# --sdk="${sdk_dir}" \
# --clear-cache \
# --project-file="${repo_dir}/src/platform_projects/openthread-efr32-rcp.slcp" \
# --output-type=makefile \
# --no-copy \
# --export-templates="${repo_dir}"/third_party/silabs/slc/exporter_templates/platform_library \
# --export-destination="${current_project_export_dir}" \
# --with "${board}"

# # TODO: Remove this when slc supports generic jinja template generation
# mv "${current_project_export_dir}/openthread-efr32-rcp.Makefile" "${current_project_export_dir}/CMakeLists.txt"
# mv "${current_project_export_dir}/openthread-efr32-rcp.project.mak" "${current_project_export_dir}/openthread-efr32-rcp-sdk.cmake"

# ==============================================================================================================
# Generate openthread-efr32-rcp-mbedtls lib
Expand Down
2 changes: 1 addition & 1 deletion script/make-pretty
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ set -euo pipefail

OT_BUILD_JOBS=$(getconf _NPROCESSORS_ONLN)
readonly OT_BUILD_JOBS
readonly OT_EXCLUDE_DIRS=(openthread third_party)
readonly OT_EXCLUDE_DIRS=(openthread third_party src/platform_libs)

readonly OT_CLANG_SOURCES=('*.c' '*.cc' '*.cpp' '*.h' '*.hpp')
readonly OT_MARKDOWN_SOURCES=('*.md')
Expand Down
255 changes: 255 additions & 0 deletions src/platform_libs/openthread-efr32-rcp-eero/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
####################################################################
# Automatically-generated file. Do not edit! #
# CMake Version 1 #
####################################################################
#
# Copyright (c) 2022, 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(openthread-efr32-rcp-sdk.cmake)

# ==============================================================================
# Platform library
# ==============================================================================
add_library(openthread-efr32-rcp
$<TARGET_OBJECTS:openthread-platform-utils>
)

# Interface lib for sharing efr32 config to relevant targets
add_library(openthread-efr32-rcp-config INTERFACE)

# Define RCP specific libraries
set(OT_PLATFORM_LIB_RCP openthread-efr32-rcp)
set(OT_MBEDTLS_RCP silabs-mbedtls-rcp)

set_target_properties(openthread-efr32-rcp
PROPERTIES
C_STANDARD 99
CXX_STANDARD 11
)

# ==============================================================================
# Includes
# ==============================================================================
target_include_directories(ot-config INTERFACE
${SILABS_GSDK_DIR}/platform/Device/SiliconLabs/EFR32MG12P/Include
${SILABS_GSDK_DIR}/platform/common/inc
${SILABS_GSDK_DIR}/hardware/board/inc
${SILABS_GSDK_DIR}/platform/CMSIS/Core/Include
${SILABS_GSDK_DIR}/hardware/driver/configuration_over_swo/inc
${SILABS_GSDK_DIR}/platform/driver/debug/inc
${SILABS_GSDK_DIR}/platform/service/device_init/inc
${SILABS_GSDK_DIR}/platform/emdrv/dmadrv/inc
${SILABS_GSDK_DIR}/platform/emdrv/common/inc
${SILABS_GSDK_DIR}/platform/emlib/inc
${SILABS_GSDK_DIR}/platform/emdrv/gpiointerrupt/inc
${SILABS_GSDK_DIR}/util/third_party/crypto/mbedtls/include
${SILABS_GSDK_DIR}/util/third_party/crypto/mbedtls/library
${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}/platform/service/mpu/inc
${SILABS_GSDK_DIR}/hardware/driver/mx25_flash_shutdown/inc/sl_mx25_flash_shutdown_usart
${SILABS_GSDK_DIR}/platform/emdrv/nvm3/inc
${PROJECT_SOURCE_DIR}/openthread/examples/platforms
${PROJECT_SOURCE_DIR}/openthread/examples/platforms/utils
${PROJECT_SOURCE_DIR}/src/src
${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/inc
${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_psa_driver/inc/public
${SILABS_GSDK_DIR}/platform/radio/rail_lib/common
${SILABS_GSDK_DIR}/platform/radio/rail_lib/protocol/ble
${SILABS_GSDK_DIR}/platform/radio/rail_lib/protocol/ieee802154
${SILABS_GSDK_DIR}/platform/radio/rail_lib/protocol/zwave
${SILABS_GSDK_DIR}/platform/radio/rail_lib/chip/efr32/efr32xg1x
${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/pa-conversions
${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg1x
${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/rail_util_pti
${SILABS_GSDK_DIR}/platform/radio/rail_lib/plugin/rail_util_rssi
${SILABS_GSDK_DIR}/util/third_party/segger/systemview/SEGGER
${SILABS_GSDK_DIR}/util/silicon_labs/silabs_core/memory_manager
${SILABS_GSDK_DIR}/platform/common/toolchain/inc
${SILABS_GSDK_DIR}/platform/service/system/inc
${SILABS_GSDK_DIR}/platform/service/sleeptimer/inc
${SILABS_GSDK_DIR}/util/third_party/crypto/sl_component/sl_protocol_crypto/src
${SILABS_GSDK_DIR}/platform/emdrv/uartdrv/inc
${SILABS_GSDK_DIR}/platform/service/udelay/inc
)

target_include_directories(openthread-efr32-rcp-config INTERFACE
autogen
config
)

target_link_libraries(openthread-radio PUBLIC openthread-efr32-rcp-config)

target_include_directories(openthread-efr32-rcp PRIVATE
${OT_PUBLIC_INCLUDES}
)

# ==============================================================================
# Sources
# ==============================================================================
target_sources(openthread-efr32-rcp PRIVATE
${PROJECT_SOURCE_DIR}/src/src/alarm.c
${PROJECT_SOURCE_DIR}/src/src/board_config.h
${PROJECT_SOURCE_DIR}/src/src/crypto.c
${PROJECT_SOURCE_DIR}/src/src/diag.c
${PROJECT_SOURCE_DIR}/src/src/entropy.c
${PROJECT_SOURCE_DIR}/src/src/flash.c
${PROJECT_SOURCE_DIR}/src/src/ieee802154-packet-utils.cpp
${PROJECT_SOURCE_DIR}/src/src/ieee802154-packet-utils.hpp
${PROJECT_SOURCE_DIR}/src/src/ieee802154mac.h
${PROJECT_SOURCE_DIR}/src/src/logging.c
${PROJECT_SOURCE_DIR}/src/src/memory.c
${PROJECT_SOURCE_DIR}/src/src/misc.c
${PROJECT_SOURCE_DIR}/src/src/openthread-core-efr32-config-check.h
${PROJECT_SOURCE_DIR}/src/src/openthread-core-efr32-config.h
${PROJECT_SOURCE_DIR}/src/src/platform-band.h
${PROJECT_SOURCE_DIR}/src/src/platform-efr32.h
${PROJECT_SOURCE_DIR}/src/src/radio.c
${PROJECT_SOURCE_DIR}/src/src/rail_config.h
${PROJECT_SOURCE_DIR}/src/src/security_manager.c
${PROJECT_SOURCE_DIR}/src/src/security_manager.h
${PROJECT_SOURCE_DIR}/src/src/sl_openthread.h
${PROJECT_SOURCE_DIR}/src/src/sl_packet_utils.h
${PROJECT_SOURCE_DIR}/src/src/startup-gcc.c
${PROJECT_SOURCE_DIR}/src/src/system.c
${PROJECT_SOURCE_DIR}/src/src/uartdrv_uart.c
)

# ==============================================================================
# Compile definitions
# ==============================================================================
target_compile_definitions(ot-config INTERFACE
EFR32MG12P432F1024GL125=1
SL_BOARD_NAME="BRD4161A"
SL_BOARD_REV="A03"
SL_COMPONENT_CATALOG_PRESENT=1
MBEDTLS_CONFIG_FILE=<mbedtls_config.h>
OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=0
OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE="openthread-core-efr32-config-check.h"
OPENTHREAD_PROJECT_CORE_CONFIG_FILE="openthread-core-efr32-config.h"
BUFFER_SIZE_DOWN=0
BUFFER_SIZE_UP=768
MBEDTLS_PSA_CRYPTO_CONFIG_FILE=<psa_crypto_config.h>
SL_RAIL_LIB_MULTIPROTOCOL_SUPPORT=0
SL_RAIL_UTIL_PA_CONFIG_HEADER=<sl_rail_util_pa_config.h>
RTT_USE_ASM=0
SEGGER_RTT_SECTION="SEGGER_RTT"
)

target_compile_definitions(openthread-efr32-rcp-config INTERFACE
MBEDTLS_PSA_CRYPTO_CLIENT=1
)

target_compile_definitions(openthread-efr32-rcp PUBLIC
OPENTHREAD_COPROCESSOR=1
OPENTHREAD_RADIO=1
)

target_compile_definitions(openthread-efr32-rcp-sdk PRIVATE
OPENTHREAD_COPROCESSOR=1
OPENTHREAD_RADIO=1
)

target_compile_options(openthread-efr32-rcp PRIVATE
# GNU C flags
$<$<COMPILE_LANG_AND_ID:C,GNU>:
"SHELL:-mcpu=cortex-m4"
"SHELL:-mthumb"
"SHELL:-mfpu=fpv4-sp-d16"
"SHELL:-mfloat-abi=softfp"
"SHELL:-std=c99"
"SHELL:-Wall"
"SHELL:-Wextra"
"SHELL:-Os"
"SHELL:-fdata-sections"
"SHELL:-ffunction-sections"
"SHELL:-fomit-frame-pointer"
"SHELL:-imacros sl_gcc_preinclude.h"
"SHELL:-imacros sl_gcc_preinclude.h"
"SHELL:--specs=nano.specs"
"SHELL:-g"
>
)

# ==============================================================================
# Linking
# ==============================================================================
set(LD_FILE "${CMAKE_CURRENT_SOURCE_DIR}/autogen/linkerfile.ld")
set(openthread-efr32-rcp-sdk_location $<TARGET_FILE:openthread-efr32-rcp-sdk>)

target_link_libraries(openthread-efr32-rcp
PUBLIC
-lstdc++
-lgcc
-lc
-lm
-lnosys
openthread-efr32-rcp-config

PRIVATE
-T${LD_FILE}
-Wl,--gc-sections

# The --whole-archive flags are necessary to resolve all symbols from the GSDK
-Wl,--whole-archive ${openthread-efr32-rcp-sdk_location} -Wl,--no-whole-archive
ot-config
)

target_link_options(openthread-efr32-rcp PRIVATE
-mcpu=cortex-m4
-mthumb
-mfpu=fpv4-sp-d16
-mfloat-abi=softfp
-Wl,--gc-sections
)

# ==============================================================================
# Static libraries from GSDK
# ==============================================================================
set(GSDK_LIBS
"${SILABS_GSDK_DIR}/platform/emdrv/nvm3/lib/libnvm3_CM4_gcc.a"
"${SILABS_GSDK_DIR}/protocol/openthread/libs/libsl_openthread_efr32mg1x_gcc.a"
"${SILABS_GSDK_DIR}/platform/radio/rail_lib/autogen/librail_release/librail_efr32xg12_gcc_release.a"
)

# Import GSDK static libs and set a dependency on the GSDK library
# This will ensure proper linking order
foreach(lib_file ${GSDK_LIBS})
# Parse lib name, stripping .a extension
get_filename_component(lib_name ${lib_file} NAME_WE)
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 openthread-efr32-rcp-sdk
)
target_link_libraries(openthread-efr32-rcp PUBLIC ${imported_lib_name})
endforeach()
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#CRC Codes for initially generated config files -- do not modify!
SEGGER_RTT_Conf.h=-674599354
dmadrv_config.h=-894158991
emlib_core_debug_config.h=171843933
mbedtls_config.h=-1710232477
nvm3_default_config.h=1109545002
psa_crypto_config.h=-715200899
sl_board_control_config.h=-858618493
sl_debug_swo_config.h=848473986
sl_device_init_dcdc_config.h=-1223674373
sl_device_init_emu_config.h=1414330218
sl_device_init_hfxo_config.h=349146444
sl_device_init_lfxo_config.h=239925891
sl_memory_config.h=-995392215
sl_mx25_flash_shutdown_usart_config.h=330822538
sl_rail_util_pa_config.h=1112608945
sl_rail_util_pti_config.h=1157262329
sl_rail_util_rssi_config.h=-1255858871
sl_sleeptimer_config.h=-1074849105
sl_uartdrv_usart_vcom_config.h=108701171
uartdrv_config.h=-1381003705
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file is autogenerated by Silicon Labs SLC.
// The contents of this file will be replaced in their entirety upon regeneration.
//
// Source template file: RTE_Components.h.jinja


#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H

/* standard device header from emlib */
#define CMSIS_device_header "em_device.h"

/* components are auto-generated here */


#endif /* RTE_COMPONENTS_H */

/* This file is autogenerated by Silicon Labs SLC. */
/* The contents of this file will be replaced in their entirety upon regeneration. */
/* */
/* Source template file: RTE_Components.h.jinja */