Skip to content
Merged
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: 2 additions & 2 deletions src/utility/STM32_WPAN/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

## Source

[STMicroelectronics/STM32CubeWB Release v1.24.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.24.0)
- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.24.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode)
[STMicroelectronics/STM32CubeWB Release v1.25.0](https://github.com/STMicroelectronics/STM32CubeWB/releases/tag/v1.25.0)
- Application: [BLE_TransparentMode](https://github.com/STMicroelectronics/STM32CubeWB/tree/v1.25.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode)

5 changes: 3 additions & 2 deletions src/utility/STM32_WPAN/app_conf_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "hw_conf.h"
#include "hw_if.h"
#include "ble_bufsize.h"
#include "ble_std.h"
#endif

/******************************************************************************
Expand Down Expand Up @@ -176,7 +177,7 @@
* Maximum supported ATT_MTU size
* This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set
*/
#define CFG_BLE_MAX_ATT_MTU (156)
#define CFG_BLE_MAX_ATT_MTU (255)

/**
* Size of the storage area for Attribute values
Expand All @@ -201,7 +202,7 @@
* Number of allocated memory blocks
* This parameter is overwritten by the CPU2 with an hardcoded optimal value when the parameter CFG_BLE_OPTIONS has SHCI_C2_BLE_INIT_OPTIONS_LL_ONLY flag set
*/
#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK))
#define CFG_BLE_MBLOCK_COUNT (BLE_MBLOCKS_CALC(CFG_BLE_PREPARE_WRITE_LIST_SIZE, CFG_BLE_MAX_ATT_MTU, CFG_BLE_NUM_LINK))

/**
* Enable or disable the Extended Packet length feature. Valid values are 0 or 1.
Expand Down
75 changes: 53 additions & 22 deletions src/utility/STM32_WPAN/ble_bufsize.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*****************************************************************************
* @attention
*
* Copyright (c) 2018-2025 STMicroelectronics.
* Copyright (c) 2018-2026 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
Expand All @@ -30,9 +30,9 @@
#define BLE_DEFAULT_MAX_ATT_SIZE 512

/*
* BLE_PREP_WRITE_X_ATT: compute how many Prepare Write Request are needed to
* write a characteristic with size 'max_att' when the used ATT_MTU value is
* equal to BLE_DEFAULT_ATT_MTU (23).
* BLE_PREP_WRITE_X_ATT: compute how many memory blocks are needed to store
* Prepare Write Request packets when writing a characteristic with size
* 'max_att' and the used ATT_MTU value is equal to BLE_DEFAULT_ATT_MTU (23).
*/
#define BLE_PREP_WRITE_X_ATT(max_att) \
(DIVC(max_att, BLE_DEFAULT_ATT_MTU - 5) * 2)
Expand All @@ -44,8 +44,8 @@
BLE_PREP_WRITE_X_ATT(BLE_DEFAULT_MAX_ATT_SIZE)

/*
* BLE_MEM_BLOCK_X_MTU: compute how many memory blocks are needed to compose
* an ATT packet with ATT_MTU=mtu.
* BLE_MEM_BLOCK_X_... compute how many memory blocks are needed to compose
* ACL packets, based on the MTU (mtu) and the number of links (n_link)
*/
#define BLE_MEM_BLOCK_SIZE 32

Expand All @@ -56,31 +56,21 @@
#endif

#define BLE_MEM_BLOCK_X_TX(mtu) \
(DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 1)
(DIVC((mtu) + 4, BLE_MEM_BLOCK_SIZE) + 1)

#define BLE_MEM_BLOCK_X_RX(mtu, n_link) \
((DIVC((mtu) + 4U, BLE_MEM_BLOCK_SIZE) + 2U) * (n_link) + 1)

#define BLE_MEM_BLOCK_X_MTU(mtu, n_link) \
(BLE_MEM_BLOCK_X_TX(mtu) + BLE_MEM_BLOCK_X_PTX(n_link) + \
BLE_MEM_BLOCK_X_RX(mtu, n_link))

/*
* BLE_MBLOCKS_SECURE_CONNECTIONS: minimum number of blocks required for
* secure connections
*/
#define BLE_MBLOCKS_SECURE_CONNECTIONS 4
(((DIVC((mtu) + 4, BLE_MEM_BLOCK_SIZE) + 2) * (n_link)) + 1)

/*
* BLE_MBLOCKS_CALC: minimum number of buffers needed by the stack.
* This is the minimum racomanded value and depends on:
* This is the minimum recommended value and depends on:
* - pw: size of Prepare Write List
* - mtu: ATT_MTU size
* - mtu: maximum between ATT MTU, SMP MTU (65) and L2CAP COC MPS
* - n_link: maximum number of simultaneous connections
*/
#define BLE_MBLOCKS_CALC(pw, mtu, n_link) \
((pw) + MAX(BLE_MEM_BLOCK_X_MTU(mtu, n_link), \
BLE_MBLOCKS_SECURE_CONNECTIONS))
((pw) + BLE_MEM_BLOCK_X_TX(mtu) + BLE_MEM_BLOCK_X_PTX(n_link) + \
BLE_MEM_BLOCK_X_RX(mtu, n_link))

/*
* BLE_FIXED_BUFFER_SIZE_BYTES:
Expand Down Expand Up @@ -157,6 +147,47 @@
#define BLE_EXT_ADV_BUFFER_SIZE(set_nbr, data_len) \
(2512 + ((892 + (DIVC(data_len, 207) * 244)) * (set_nbr)))

/*
* BLE_DEFAULT_NUM_GATT_SERVICES: this macro returns the number of services
* created by the BLE stack after call to ACI_GATT_INIT and ACI_GAP_INIT.
*/
#define BLE_DEFAULT_NUM_GATT_SERVICES 2

/*
* BLE_DEFAULT_NUM_GATT_ATTRIBUTES: this macro returns the number of attributes
* created by the BLE stack after call to ACI_GATT_INIT and ACI_GAP_INIT.
*
* @param options: option flags used at BLE stack initialization
*
* @param privacy_en: 1 if privacy is used; otherwise 0
*/
#define BLE_DEFAULT_NUM_GATT_ATTRIBUTES(options, privacy_en) \
((((options) & BLE_OPTIONS_ENHANCED_ATT) ? \
(((options) & BLE_OPTIONS_NO_SVC_CHANGE_DESC) ? 4 : \
((options) & BLE_OPTIONS_GATT_CACHING) ? 9 : 7) : \
(((options) & BLE_OPTIONS_NO_SVC_CHANGE_DESC) ? 0 : \
((options) & BLE_OPTIONS_GATT_CACHING) ? 7 : 3)) + \
((privacy_en) ? 8 : 6))

/*
* BLE_DEFAULT_ATT_VALUE_ARRAY_SIZE : this macro returns the size of attribute
* values array used by the BLE stack after call to ACI_GATT_INIT and
* ACI_GAP_INIT.
*
* @param options: option flags used at BLE stack initialization
*
* @param n_link: Maximum number of simultaneous connections that the device
* supports. Valid values are from 1 to 8.
*
* @param dev_name_len: Length of the device name as passed to ACI_GAP_INIT
*/
#define BLE_DEFAULT_ATT_VALUE_ARRAY_SIZE(options, n_link, dev_name_len) \
((((options) & BLE_OPTIONS_NO_SVC_CHANGE_DESC) ? \
(((options) & BLE_OPTIONS_ENHANCED_ATT) ? (11 + (n_link)) : 0) : \
(((options) & BLE_OPTIONS_GATT_CACHING) ? (41 + ((n_link) * 3)) : \
((options) & BLE_OPTIONS_ENHANCED_ATT) ? (20 + ((n_link) * 3)) : \
(9 + ((n_link) * 2)))) + 31 + (dev_name_len))

/*
* BLE_TOTAL_BUFFER_SIZE_GATT: this macro returns the amount of memory,
* in bytes, needed for the storage of GATT database elements.
Expand Down
12 changes: 8 additions & 4 deletions src/utility/STM32_WPAN/shci.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ extern "C" {
FUS_STATE_ERROR_AUTH_TAG_CUST_NOTFOUND = 0x09,
FUS_STATE_ERROR_AUTH_KEY_LOCKED = 0x0A,
FUS_STATE_ERROR_FW_ROLLBACK_ERROR = 0x11,
FUS_STATE_ERROR_BUSY = 0x12,
FUS_STATE_ERROR_CKS_OPERATION_NOT_ALLOWED = 0x13,
FUS_STATE_ERROR_INVALID_OB = 0xF8,
FUS_STATE_ERROR_INVALID_ARGUMENT = 0xF9,
FUS_STATE_ERROR_USB_OBSOLETE = 0xFA,
FUS_STATE_ERROR_CRITICAL_FAILURE = 0xFB,
FUS_STATE_ERROR_FORBIDDEN = 0xFC,
FUS_STATE_ERROR_STATE_NOT_RUNNING = 0xFE,
FUS_STATE_ERROR_ERR_UNKNOWN = 0xFF,
} SHCI_FUS_GetState_ErrorCode_t;
Expand Down Expand Up @@ -909,7 +916,6 @@ extern "C" {
*/
#define SHCI_C2_CONFIG_CONFIG1_BIT0_BLE_NVM_DATA_TO_INTERNAL_FLASH (0<<0)
#define SHCI_C2_CONFIG_CONFIG1_BIT0_BLE_NVM_DATA_TO_SRAM (1<<0)
#define SHCI_C2_CONFIG_CONFIG1_BIT1_THREAD_NVM_DATA_TO_INTERNAL_FLASH (0<<1)
#define SHCI_C2_CONFIG_CONFIG1_BIT1_THREAD_NVM_DATA_TO_SRAM (1<<1)
#define SHCI_C2_CONFIG_CONFIG1_BIT2_SET_EUI64_FORMAT (1<<2)

Expand Down Expand Up @@ -1380,8 +1386,7 @@ typedef struct {
* uint8_t Config1 :
* - bit0 : 0 - BLE NVM Data data are flushed in internal secure flash
* 1 - BLE NVM Data are written in SRAM cache pointed by BleNvmRamAddress
* - bit1 : 0 - THREAD NVM Data data are flushed in internal secure flash
* 1 - THREAD NVM Data are written in SRAM cache pointed by ThreadNvmRamAddress
* - bit1 : Not used
* - bit2 : 0 - Thread EUI64 is set to new (and current) format
* 1 - Thread EUI64 is set to old format
* - bit3 to bit7 : Unused, shall be set to 0
Expand All @@ -1398,7 +1403,6 @@ typedef struct {
* The size of the buffer shall be BLE_NVM_SRAM_SIZE (number of 32bits)
* The buffer shall be allocated in SRAM2
* uint32_t ThreadNvmRamAddress :
* Only considered when Config1.bit1 = 1
* When set to 0, data are kept in internal SRAM on CPU2
* Otherwise, data are copied in the cache pointed by ThreadNvmRamAddress
* The size of the buffer shall be THREAD_NVM_SRAM_SIZE (number of 32bits)
Expand Down