Hi guys
I am working on a NRF52832 device. My SDK is 15.2. I am on S132.
To initialiser the Softdevice, I use the following function :
/**@brief Function for initializing the BLE stack.
*
* @details Initializes the SoftDevice and the BLE event interrupt.
*/
void ble_stack_init(void)
{
extern uint8_t __data_start__;
ret_code_t err_code;
err_code = nrf_sdh_enable_request();
APP_ERROR_CHECK(err_code);
// Configure the BLE stack using the default settings.
// Fetch the start address of the application RAM.
uint32_t app_ram_base = 0;
err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &app_ram_base);
APP_ERROR_CHECK(err_code);
// Enable BLE stack.
err_code = nrf_sdh_ble_enable(&app_ram_base);
// Check if we do memory allocation correctly.
if (err_code == NRF_SUCCESS)
{
// Verify that value provided in linked script (LD file) matches the SD calculations.
if (app_ram_base == (uint32_t) &__data_start__)
{
//NRF_LOG_INFO("Soft Device enabled, __data_start__ is set correctly.");
printf("Soft Device enabled, __data_start__ is set correctly.\n");
}
else
{
//NRF_LOG_INFO("Soft Device enabled, __data_start__ is set incorrectly (should be = 0x%08X instead of 0x%08X).", app_ram_base, (uint32_t) &__data_start__);
printf("Soft Device enabled, __data_start__ is set incorrectly (should be = 0x%08X instead of 0x%08X).\n", app_ram_base, (uint32_t) &__data_start__);
#if (!SECURITY_MODE)
APP_ERROR_CHECK(NRF_ERROR_FORBIDDEN); //AKR for test
#endif
}
}
else if (err_code == NRF_ERROR_NO_MEM)
{
// Not enough memory for the Soft Device (value provided is too low).
//NRF_LOG_INFO("Soft Device failed to enabled, __data_start__ is set incorrectly (should be = 0x%08X instead of 0x%08X).", app_ram_base, (uint32_t) &__data_start__);
}
APP_ERROR_CHECK(err_code);
// Register a handler for BLE events.
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}
You can see that we added a condition, after nrf_sdh_ble_enable() function, in the case where the err_code == NRF_SUCCESS
Here we check if the the value provided in linked script, __data_start__, is the same as the value returned by the nrf_sdh_ble_enable() function, app_ram_base, so the SD calculations.
When i don't use the Security Layer, so the Peer manager, the error code from nrf_sdh_ble_enable() is NRF_SUCCESS, and __data_start__ and app_ram_base are the same.
When i implement the Peer manager and all the modules needed, error code from nrf_sdh_ble_enable() is NRF_SUCCESS, but __data_start__ and app_ram_base are not the same.
I have commented in this case the following APP_ERROR_CHECK(NRF_ERROR_FORBIDDEN), and we have done many tests and all seems to work anyway, but it worries me.
Do you know why in this case __data_start__ and app_ram_base are different ? What are the consequences ?
Is there a way to correct that ?
I should mention that I tried to correct this problem by changing the RAM size with RAM_START and RAM_SIZE, but It didn't change anything.
Thanks !
