This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

example ble_app_hrs_freertos crashing with MAX_MTU_SIZE=247 and DATA_LENGTH=251

SDK 15.2.0

nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_hrs_freertos\pca10040\s132\ses\ble_app_hrs_freertos_pca10040_s132.emProject

When changing NRF_SDH_BLE_GAP_DATA_LENGTH 251 and NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247 in the local sdk_config.h
the example crashes with "hard fault" when trying to connect with nRf connect from a android device.

Compiled with SEGGER Embedded Studio 4.12, running on PCA10040

// <h> BLE Stack configuration - Stack configuration parameters

// <i> The SoftDevice handler will configure the stack with these parameters when calling @ref nrf_sdh_ble_default_cfg_set.
// <i> Other libraries might depend on these values; keep them up-to-date even if you are not explicitely calling @ref nrf_sdh_ble_default_cfg_set.
//==========================================================
// <o> NRF_SDH_BLE_GAP_DATA_LENGTH   <27-251> 


// <i> Requested BLE GAP data length to be negotiated.

#ifndef NRF_SDH_BLE_GAP_DATA_LENGTH
#define NRF_SDH_BLE_GAP_DATA_LENGTH 251
#endif

// <o> NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. 
#ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT
#define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 1
#endif

// <o> NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. 
#ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT
#define NRF_SDH_BLE_CENTRAL_LINK_COUNT 0
#endif

// <o> NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. 
// <i> Maximum number of total concurrent connections using the default configuration.

#ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT
#define NRF_SDH_BLE_TOTAL_LINK_COUNT 1
#endif

// <o> NRF_SDH_BLE_GAP_EVENT_LENGTH - GAP event length. 
// <i> The time set aside for this connection on every connection interval in 1.25 ms units.

#ifndef NRF_SDH_BLE_GAP_EVENT_LENGTH
#define NRF_SDH_BLE_GAP_EVENT_LENGTH 320
#endif

// <o> NRF_SDH_BLE_GATT_MAX_MTU_SIZE - Static maximum MTU size. 
#ifndef NRF_SDH_BLE_GATT_MAX_MTU_SIZE
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247
#endif

// <o> NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE - Attribute Table size in bytes. The size must be a multiple of 4. 
#ifndef NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE
#define NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE 1408
#endif

Parents
  • I think with such a large MTU and data length extension the application stack/heap sizes needed to be increased in FreeRTOSConfig.h file. Can you please give it a try.

  • The ble_app_hrs_freertos example with MAX_MTU_SIZE=247 and DATA_LENGTH=251 already crashes when connecting to the device through "nRF connect".

    There were no yet any transfers with big payload.

    And increasing the stack size of idleTask and SoftDeviceTask does NOT fix the problem:

    // #define configMINIMAL_STACK_SIZE ( 60 )
    // #define configTOTAL_HEAP_SIZE ( 4096 )
    #define configMINIMAL_STACK_SIZE ( 512 )
    #define configTOTAL_HEAP_SIZE ( 8192 )

    // #define NRF_BLE_FREERTOS_SDH_TASK_STACK 256
    #define NRF_BLE_FREERTOS_SDH_TASK_STACK 512

    And I get never the payload handed over on the stack. There are only pointers to the data in the events. 

    The size of the event buffer is adapted in nrf_sdh_ble.h on line 66 depeinding on MAX_MTU_SIZE:

    /** @brief Size of the buffer for a BLE event. */
    #define NRF_SDH_BLE_EVT_BUF_SIZE BLE_EVT_LEN_MAX(NRF_SDH_BLE_GATT_MAX_MTU_SIZE

Reply
  • The ble_app_hrs_freertos example with MAX_MTU_SIZE=247 and DATA_LENGTH=251 already crashes when connecting to the device through "nRF connect".

    There were no yet any transfers with big payload.

    And increasing the stack size of idleTask and SoftDeviceTask does NOT fix the problem:

    // #define configMINIMAL_STACK_SIZE ( 60 )
    // #define configTOTAL_HEAP_SIZE ( 4096 )
    #define configMINIMAL_STACK_SIZE ( 512 )
    #define configTOTAL_HEAP_SIZE ( 8192 )

    // #define NRF_BLE_FREERTOS_SDH_TASK_STACK 256
    #define NRF_BLE_FREERTOS_SDH_TASK_STACK 512

    And I get never the payload handed over on the stack. There are only pointers to the data in the events. 

    The size of the event buffer is adapted in nrf_sdh_ble.h on line 66 depeinding on MAX_MTU_SIZE:

    /** @brief Size of the buffer for a BLE event. */
    #define NRF_SDH_BLE_EVT_BUF_SIZE BLE_EVT_LEN_MAX(NRF_SDH_BLE_GATT_MAX_MTU_SIZE

Children
No Data
Related