Skip to content

Commit

Permalink
mpsl: Use kconfig to determine library path
Browse files Browse the repository at this point in the history
Instead of using SOC and ARCH configs to determine the library
paths, use mpsl-specific kconfigs. We will then be able to change
the paths independently of which value various upstream configs
have.

This also makes it simpler to use the same library for different socs,
or different libraries for the same cpu core variant.

Signed-off-by: Herman Berget <[email protected]>
  • Loading branch information
hermabe authored and cvinayak committed Apr 26, 2024
1 parent 2547dcc commit beed6b3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 50 deletions.
29 changes: 8 additions & 21 deletions mpsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,14 @@
#

if (CONFIG_MPSL_BUILD_TYPE_LIB)
add_subdirectory(fem)
set(MPSL_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CONFIG_MPSL_LIB_DIR}/${CONFIG_MPSL_LIB_FLOAT_ABI_DIR}")

add_subdirectory(fem)

if (CONFIG_SOC_SERIES_NRF54HX OR CONFIG_SOC_SERIES_NRF54LX)
nrfxlib_calculate_lib_path(MPSL_LIB_DIR SOC_MODE
BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
SOFT_FLOAT_FALLBACK
)
else ()
nrfxlib_calculate_lib_path(MPSL_LIB_DIR
BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
SOFT_FLOAT_FALLBACK
)
endif ()

if(NOT MPSL_LIB_DIR)
message(WARNING "This combination of SoC and floating point ABI is not supported by the MPSL lib.")
endif()

zephyr_include_directories(include)
zephyr_include_directories(include/protocol)
zephyr_link_libraries(${MPSL_LIB_DIR}/libmpsl.a)
if(NOT EXISTS "${MPSL_LIB_DIR}/libmpsl.a")
message(FATAL_ERROR "This combination of SoC and floating point ABI is not supported by the MPSL lib.")
endif()

zephyr_include_directories(include)
zephyr_include_directories(include/protocol)
zephyr_link_libraries(${MPSL_LIB_DIR}/libmpsl.a)
endif()
22 changes: 21 additions & 1 deletion mpsl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,24 @@ config MPSL_BUILD_TYPE_LIB

endchoice

endif
if MPSL_BUILD_TYPE_LIB
config MPSL_LIB_DIR
string
default "cortex-m4" if SOC_SERIES_NRF52X
default "cortex-m33+nodsp" if SOC_COMPATIBLE_NRF5340_CPUNET
default "nrf54h20_cpurad" if SOC_NRF54H20_CPURAD
default "nrf54l15_cpuapp" if SOC_SERIES_NRF54LX
default "bsim_nrfxx" if SOC_SERIES_BSIM_NRFXX
help
Hidden helper option to calculate the library path

config MPSL_LIB_FLOAT_ABI_DIR
string
default "hard-float" if FPU && FP_HARDABI
default "softfp-float" if FPU && FP_SOFTABI
default "soft-float"
help
Hidden helper option to calculate the library path

endif # MPSL_BUILD_TYPE_LIB
endif # MPSL
14 changes: 2 additions & 12 deletions mpsl/fem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@
#

function(mpsl_fem_append_lib fem_lib_name)
if (CONFIG_SOC_SERIES_NRF54HX OR CONFIG_SOC_SERIES_NRF54LX)
nrfxlib_calculate_lib_path(LIB_DIR SOC_MODE
BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${fem_lib_name}
SOFT_FLOAT_FALLBACK
)
else ()
nrfxlib_calculate_lib_path(LIB_DIR
BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${fem_lib_name}
SOFT_FLOAT_FALLBACK
)
endif()
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${fem_lib_name}/lib/${CONFIG_MPSL_LIB_DIR}/${CONFIG_MPSL_LIB_FLOAT_ABI_DIR}")

if(LIB_DIR)
zephyr_include_directories(${fem_lib_name}/include)
Expand All @@ -26,7 +16,7 @@ FILE(GLOB subdirlist RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE

# call mpsl_fem_append_lib for each subdirectory
FOREACH(subdir ${subdirlist})
IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subdir})
IF((IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}) AND NOT (${subdir} STREQUAL "include"))
mpsl_fem_append_lib(${subdir})
ENDIF()
ENDFOREACH()
Expand Down
23 changes: 7 additions & 16 deletions softdevice_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,7 @@ if (CONFIG_BT_LL_SOFTDEVICE_HEADERS_INCLUDE)
endif()

if(CONFIG_BT_LL_SOFTDEVICE AND CONFIG_BT_LL_SOFTDEVICE_BUILD_TYPE_LIB)
if (CONFIG_SOC_SERIES_NRF54HX OR CONFIG_SOC_SERIES_NRF54LX)
nrfxlib_calculate_lib_path(SOFTDEVICE_CONTROLLER_LIB_DIR SOC_MODE
BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
SOFT_FLOAT_FALLBACK
)
else()
nrfxlib_calculate_lib_path(SOFTDEVICE_CONTROLLER_LIB_DIR
BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
SOFT_FLOAT_FALLBACK
)
endif()

if(NOT SOFTDEVICE_CONTROLLER_LIB_DIR)
message(WARNING "This combination of SoC and floating point ABI is not"
"supported by the SoftDevice Controller lib.")
endif()
set(SOFTDEVICE_CONTROLLER_LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/${CONFIG_MPSL_LIB_DIR}/${CONFIG_MPSL_LIB_FLOAT_ABI_DIR}")

if(CONFIG_BT_LL_SOFTDEVICE_PERIPHERAL)
set(softdevice_controller_variant peripheral)
Expand All @@ -41,5 +26,11 @@ if(CONFIG_BT_LL_SOFTDEVICE AND CONFIG_BT_LL_SOFTDEVICE_BUILD_TYPE_LIB)

set(SOFTDEVICE_CONTROLLER_LIB
${SOFTDEVICE_CONTROLLER_LIB_DIR}/libsoftdevice_controller_${softdevice_controller_variant}.a)

if(NOT EXISTS ${SOFTDEVICE_CONTROLLER_LIB})
message(FATAL_ERROR "This combination of SoC and floating point ABI is not"
"supported by the SoftDevice Controller lib.")
endif()

zephyr_link_libraries(${SOFTDEVICE_CONTROLLER_LIB})
endif()

0 comments on commit beed6b3

Please sign in to comment.