Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

if(CONFIG_HAS_STM32LIB)
add_subdirectory_ifdef(CONFIG_BT_STM32_IPM stm32wb)
add_subdirectory_ifdef(CONFIG_BT_STM32WBA stm32wba)
if(CONFIG_BT_STM32WBA OR CONFIG_IEEE802154_STM32WBA)
add_subdirectory(stm32wba)
endif()
add_subdirectory_ifdef(CONFIG_BT_STM32WB0 stm32wb0)
endif()
2 changes: 1 addition & 1 deletion lib/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Available libraries:
* stm32wb0:
STM32WB0 BLE controller interfacing library.
* stm32wba:
STM32WBA BLE controller interfacing library.
STM32WBA BLE and 802.15.4 controller interfacing libraries.
159 changes: 85 additions & 74 deletions lib/stm32wba/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
# Copyright (c) 2024 STMicroelectronics
# Copyright (c) 2025 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0

zephyr_compile_definitions( -DBLE )

zephyr_include_directories(BLE_TransparentMode/Core/Inc)
zephyr_include_directories(BLE_TransparentMode/STM32_WPAN/Target)
zephyr_include_directories(BLE_TransparentMode/System/Config/Debug_GPIO)
zephyr_include_directories(BLE_TransparentMode/System/Config/Log)
zephyr_include_directories(Common/WPAN/Interfaces)
zephyr_include_directories(Common/WPAN/Modules)
zephyr_include_directories(Common/WPAN/Modules/Flash)
zephyr_include_directories(Common/WPAN/Modules/RTDebug)
zephyr_include_directories(Common/WPAN/Modules/Log)
zephyr_include_directories(STM32_WPAN)
zephyr_include_directories(STM32_WPAN/ble/stack/include)
zephyr_include_directories(STM32_WPAN/ble/stack/include/auto)
zephyr_include_directories(STM32_WPAN/link_layer/ll_cmd_lib/config/ble_full)
zephyr_include_directories(STM32_WPAN/link_layer/ll_cmd_lib/inc)
zephyr_include_directories(STM32_WPAN/link_layer/ll_cmd_lib/inc/_40nm_reg_files)
zephyr_include_directories(STM32_WPAN/link_layer/ll_sys/inc)
if(CONFIG_IEEE802154_STM32WBA)
zephyr_include_directories(Common/WPAN/Modules/BasicAES)
endif()
zephyr_include_directories(Utilities/misc)
zephyr_include_directories(Utilities/tim_serv)
zephyr_include_directories(Utilities/trace/adv_trace)
zephyr_include_directories(STM32_WPAN)

zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/bpka.c)
zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/linklayer_plat.c)
zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/ll_sys_if.c)
zephyr_sources(BLE_TransparentMode/STM32_WPAN/Target/power_table.c)
zephyr_sources(Common/WPAN/Modules/Log/log_module.c)
zephyr_sources(Common/WPAN/Interfaces/hw_pka.c)
zephyr_sources(Common/WPAN/Interfaces/hw_pka_p256.c)
zephyr_sources(Common/WPAN/Modules/RTDebug/RTDebug.c)
zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_cs.c)
zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_dp_slp.c)
zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_intf.c)
zephyr_sources(STM32_WPAN/link_layer/ll_sys/src/ll_sys_startup.c)

if(CONFIG_FLASH)
zephyr_sources(Common/WPAN/Modules/Flash/flash_manager.c)
Expand All @@ -44,7 +26,17 @@ if(CONFIG_FLASH)
zephyr_sources(Common/WPAN/Modules/Flash/rf_timing_synchro.c)
endif()

if (CONFIG_BT_EXT_ADV
if(CONFIG_IEEE802154_STM32WBA)
zephyr_sources(Common/WPAN/Modules/BasicAES/baes_ccm.c)
zephyr_sources(Common/WPAN/Modules/BasicAES/baes_cmac.c)
zephyr_sources(Common/WPAN/Modules/BasicAES/baes_ecb.c)
endif()

set(STM32WBA_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/stm32wba/lib)

# select the type of BLE library
if(CONFIG_BT_STM32WBA)
if(CONFIG_BT_EXT_ADV
OR (CONFIG_BT_PER_ADV OR CONFIG_BT_PER_ADV_SYNC)
OR CONFIG_BT_SCA_UPDATE
OR (CONFIG_BT_DF_CTE_RX_AOA OR CONFIG_BT_CTLR_DF_ANT_SWITCH_RX OR CONFIG_BT_CTLR_DF_ANT_SWITCH_TX OR CONFIG_BT_DF_CTE_TX_AOD)
Expand All @@ -56,65 +48,84 @@ if (CONFIG_BT_EXT_ADV
OR CONFIG_BT_SUBRATING
OR CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT
OR CONFIG_BT_EXT_ADV_CODING_SELECTION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, the 10 lines above should be indented by 1 more space char.

message(STATUS "link layer FULL lib selected")
set(BLE_LIB_TYPE "BLE_LIB_FULL")
else()
message(STATUS "link layer BASIC lib selected")
set(BLE_LIB_TYPE "BLE_LIB_BASIC")
endif()
message(STATUS "link layer FULL lib selected")
set(BLE_LIB_TYPE "BLE_LIB_FULL")
else()
message(STATUS "link layer BASIC lib selected")
set(BLE_LIB_TYPE "BLE_LIB_BASIC")
endif()


set(STM32WBA_BLE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../zephyr/blobs/stm32wba/lib)
set(STM32WBA_BLE_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/ble/stack)
set(STM32WBA_LL_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/link_layer/ll_cmd_lib)

add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL)
add_library(stm32wba_ll_lib STATIC IMPORTED GLOBAL)

add_dependencies(
stm32wba_ble_lib
stm32wba_ll_lib
)
if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC")
set_target_properties(
stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/stm32wba_ble_stack_llobasic.a
)
elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL")
set_target_properties(
stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/stm32wba_ble_stack_llo.a
set(STM32WBA_BLE_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/ble/stack)

add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL)

add_dependencies(
stm32wba_ble_lib
stm32wba_ll_lib
)
endif()
if(BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC")
set_target_properties(
stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_LIB_DIR}/stm32wba_ble_stack_llobasic.a
)
elseif(BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL")
set_target_properties(
stm32wba_ble_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_LIB_DIR}/stm32wba_ble_stack_llo.a
)
endif()

# Setting the right Cube define according to the Zephyr configuration
if(NOT CONFIG_BT_STM32WBA_USE_TEMP_BASED_CALIB)
zephyr_compile_definitions( -DUSE_TEMPERATURE_BASED_RADIO_CALIBRATION=0 )
endif()

# Using the selected version of ble lib
set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_LIB_INCLUDE_DIR})

# Setting the right Cube define according to the Zephyr configuration
if(NOT CONFIG_BT_STM32WBA_USE_TEMP_BASED_CALIB)
zephyr_compile_definitions( -DUSE_TEMPERATURE_BASED_RADIO_CALIBRATION=0 )
target_link_libraries(app PUBLIC stm32wba_ble_lib)
endif()

# Selecting the proper version of link layer lib according the soc
# Checking all the soc variants and not simply relying on board name
message(STATUS "STATUS - Selecting the proper version of link layer lib")
# Selecting the proper version of link layer lib
if(CONFIG_BT_STM32WBA)
# Checking all the soc variants and not simply relying on board name
if(CONFIG_SOC_STM32WBA65XX)
message(STATUS "STM32WBA6 link layer lib selected")
if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC")
set(LL_LIB "WBA6_LinkLayer_BLE_Basic_lib.a")
elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL")
set(LL_LIB "WBA6_LinkLayer_BLE_Full_lib.a")
endif()
endif()

if(CONFIG_SOC_STM32WBA65XX)
message(STATUS "STM32WBA6 link layer lib selected")
if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC")
set(LL_LIB "WBA6_LinkLayer_BLE_Basic_lib.a")
elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL")
set(LL_LIB "WBA6_LinkLayer_BLE_Full_lib.a")
if(CONFIG_SOC_STM32WBA55XX OR SOC_STM32WBA52XX)
message(STATUS "STM32WBA5 link layer lib selected")
if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC")
set(LL_LIB "LinkLayer_BLE_Basic_lib.a")
elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL")
set(LL_LIB "LinkLayer_BLE_Full_lib.a")
endif()
endif()
elseif(CONFIG_IEEE802154_STM32WBA)
if(CONFIG_SOC_STM32WBA65XX)
if(CONFIG_OPENTHREAD)
message(STATUS "WBA6_LinkLayer_Thread_lib.a lib selected")
set(LL_LIB "WBA6_LinkLayer_Thread_lib.a")
else()
message(STATUS "WBA6_LinkLayer15_4.a lib selected")
set(LL_LIB "WBA6_LinkLayer15_4.a")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation:

Suggested change
set(LL_LIB "WBA6_LinkLayer15_4.a")
set(LL_LIB "WBA6_LinkLayer15_4.a")

endif()
endif()
endif()

if(CONFIG_SOC_STM32WBA55XX OR SOC_STM32WBA52XX)
message(STATUS "STM32WBA5 link layer lib selected")
if (BLE_LIB_TYPE STREQUAL "BLE_LIB_BASIC")
set(LL_LIB "LinkLayer_BLE_Basic_lib.a")
elseif (BLE_LIB_TYPE STREQUAL "BLE_LIB_FULL")
set(LL_LIB "LinkLayer_BLE_Full_lib.a")
endif()
if(CONFIG_BT_STM32WBA OR CONFIG_IEEE802154_STM32WBA)
add_library(stm32wba_ll_lib STATIC IMPORTED GLOBAL)
set(STM32WBA_LL_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/link_layer/ll_cmd_lib)
set_target_properties(stm32wba_ll_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_LIB_DIR}/${LL_LIB})
set_target_properties(stm32wba_ll_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_LL_LIB_INCLUDE_DIR})
target_link_libraries(app PUBLIC stm32wba_ll_lib)
endif()

# Using the selected version of link layer lib
set_target_properties(stm32wba_ll_lib PROPERTIES IMPORTED_LOCATION ${STM32WBA_BLE_LIB_DIR}/${LL_LIB})
set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_LIB_INCLUDE_DIR})
set_target_properties(stm32wba_ll_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_LL_LIB_INCLUDE_DIR})
add_subdirectory(STM32_WPAN)

target_link_libraries(app PUBLIC stm32wba_ble_lib)
target_link_libraries(app PUBLIC stm32wba_ll_lib)
add_subdirectory_ifdef(CONFIG_BT_STM32WBA ble)
add_subdirectory_ifdef(CONFIG_IEEE802154_STM32WBA IEEE802154)
73 changes: 73 additions & 0 deletions lib/stm32wba/Common/WPAN/Modules/BasicAES/baes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
******************************************************************************
* @file baes.h
* @author MCD Application Team
* @brief This file contains the interface of the basic AES software module.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/

#ifndef BAES_H__
#define BAES_H__

#include <stdint.h>

/* Basic AES module dedicated to BLE stack with the following features:
* - AES ECB encryption
* - AES CMAC computation
*
* Configuration: the file "app_common.h" is included in this module.
* It must define:
* - CFG_BAES_SW equals to 1 for software implementation
* - CFG_BAES_SW equals to 0 for use of hardware accelerator
*
* Notes:
* - only 128-bit key is supported
* - re-entrance is not supported
*/

/* General interface */

extern void BAES_Reset( void );

/* AES ECB interface */

extern void BAES_EcbCrypt( const uint8_t* key,
const uint8_t* input,
uint8_t* output,
int enc );

/* AES CMAC interface */

extern void BAES_CmacSetKey( const uint8_t* key );

extern void BAES_CmacSetVector( const uint8_t * pIV );

extern void BAES_CmacCompute( const uint8_t* input,
uint32_t size,
uint8_t* output );

/* AES CCM interface */

extern int BAES_CcmCrypt( uint8_t mode,
const uint8_t* key,
uint8_t iv_length,
const uint8_t* iv,
uint16_t add_length,
const uint8_t* add,
uint16_t input_length,
const uint8_t* input,
uint8_t tag_length,
uint8_t* tag,
uint8_t* output );

#endif /* BAES_H__ */
Loading