Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.
147 changes: 85 additions & 62 deletions lib/stm32wba/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,107 +1,130 @@
# Copyright (c) 2024 STMicroelectronics
# Copyright (c) 2025 STMicroelectronics
#
# SPDX-License-Identifier: Apache-2.0

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)
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(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)


if(CONFIG_FLASH)
zephyr_sources(Common/WPAN/Modules/Flash/flash_manager.c)
zephyr_sources(Common/WPAN/Modules/Flash/flash_driver.c)
zephyr_sources(Common/WPAN/Modules/stm_list.c)
zephyr_sources(Common/WPAN/Modules/Flash/rf_timing_synchro.c)
endif()

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_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)
OR (CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER OR CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER OR CONFIG_BT_CTLR_SYNC_PERIODIC)
OR CONFIG_BT_ISO_UNICAST
OR CONFIG_BT_ISO_BROADCASTER
OR CONFIG_BT_ISO_SYNC_RECEIVER
OR CONFIG_BT_TRANSMIT_POWER_CONTROL
OR CONFIG_BT_SUBRATING
OR CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT
OR CONFIG_BT_EXT_ADV_CODING_SELECTION)
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()
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)
OR (CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER OR CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER OR CONFIG_BT_CTLR_SYNC_PERIODIC)
OR CONFIG_BT_ISO_UNICAST
OR CONFIG_BT_ISO_BROADCASTER
OR CONFIG_BT_ISO_SYNC_RECEIVER
OR CONFIG_BT_TRANSMIT_POWER_CONTROL
OR CONFIG_BT_SUBRATING
OR CONFIG_BT_CTLR_ADV_PERIODIC_ADI_SUPPORT
OR CONFIG_BT_EXT_ADV_CODING_SELECTION)
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_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/ble/stack)
set(STM32WBA_BLE_LIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/STM32_WPAN/ble/stack)

add_library(stm32wba_ble_lib STATIC IMPORTED GLOBAL)
add_library(stm32wba_ble_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_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
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()
# 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})
# Using the selected version of ble lib
set_target_properties(stm32wba_ble_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${STM32WBA_BLE_LIB_INCLUDE_DIR})

target_link_libraries(app PUBLIC stm32wba_ble_lib)
target_link_libraries(app PUBLIC stm32wba_ble_lib)
endif()

# Selecting the proper version of link layer lib
# 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")
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()
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")
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_Zephyr.a lib selected")
set(LL_LIB "WBA6_LinkLayer_Thread_lib_Zephyr.a")
else()
message(STATUS "WBA6_LinkLayer15_4_Zephyr.a lib selected")
set(LL_LIB "WBA6_LinkLayer15_4_Zephyr.a")
endif()
endif()
endif()

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)
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()

add_subdirectory(STM32_WPAN)

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