Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Build and Run with SEGGER Embedded Studio (SES) v6.20a on nRF5 SDK 17.1.0 and S140 7.2.0 on nRF52840

Hi DevZone,

I have recently updated:

  • nRF5 SDK to 17.1.0 from 15.3.0
  • S140 to 7.2.0 from 6.1.1
  • SES to v6.20a from 4.16

The SoftDevice now fails to initialize when using the "Build and Run" option with SES.

The code initializes without issue if I:

  • Use Programmer v2.3.3 from nRF Connect for Desktop v3.10.0
  • If I Power Cycle the hardware after each flash of the .hex files
  • If I "Build and Debug" with SES

Is this a known issue, and could it potentially be a timing issue?

Code that fails:

void ble_stack_init(void)
{
    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 ram_start = 0;
    err_code = nrf_sdh_ble_default_cfg_set(BLE_CONN_CFG_TAG, &ram_start);
    APP_ERROR_CHECK(err_code);

    // Enable BLE stack.
    err_code = nrf_sdh_ble_enable(&ram_start);
    APP_ERROR_CHECK(err_code);

//    // NO OBSERVERS AT THIS POINT 
//    // Register a handler for BLE events.
//    NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}

Specifically the call to nrf_sdh_enable_request() returns with error code NRF_ERROR_INVALID_STATE (0x00000008).

This should mean that the SoftDevice is already initialized when reading the documentation. However, preceding the nrf_sdh_enable_request() call with a nrf_sdh_is_enabled()

tells me that it is not.

Comparing with example projects:

I have compared to the example projects given in SDK 17.1.0, and the initialization code for the BLE stack seems unchanged between versions 17.1.0 and 15.3.0. 

Also, I have tried building and running the peripheral example from SDK 17.1.0 "usbd_ble_uart_freertos" both on our hardware and an nRF52840-DK, which fails with the same error code.

So, even with code directly from the SDK and on multiple hardware the issue is the same.

Thanks in advance.

Br. Casper

Parents
  • Hello,

    I didn't understand exactly what you did with your log, but if you look at the implementation of nrf_sdh_ble_enable(), it should look something like this:

    ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start)
    {
        // Start of RAM, obtained from linker symbol.
        uint32_t const app_ram_start_link = *p_app_ram_start;
    
        ret_code_t ret_code = sd_ble_enable(p_app_ram_start);
        if (*p_app_ram_start > app_ram_start_link)
        {
            NRF_LOG_WARNING("Insufficient RAM allocated for the SoftDevice.");
    
            NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.",
                            app_ram_start_link, *p_app_ram_start);
            NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.",
                            ram_end_address_get() - (*p_app_ram_start));
        }
        else
        {
            NRF_LOG_DEBUG("RAM starts at 0x%x", app_ram_start_link);
            if (*p_app_ram_start != app_ram_start_link)
            {
                NRF_LOG_DEBUG("RAM start location can be adjusted to 0x%x.", *p_app_ram_start);
    
                NRF_LOG_DEBUG("RAM size for application can be adjusted to 0x%x.",
                              ram_end_address_get() - (*p_app_ram_start));
            }
        }
    
        if (ret_code == NRF_SUCCESS)
        {
            m_stack_is_enabled = true;
        }
        else
        {
            NRF_LOG_ERROR("sd_ble_enable() returned %s.", nrf_strerror_get(ret_code));
        }
    
        return ret_code;
    }

    Are any of the lines containing NRF_LOG_WARNING hit? And if so, what are the parameters that it is trying to print?

    Best regards,

    Edvin

Reply
  • Hello,

    I didn't understand exactly what you did with your log, but if you look at the implementation of nrf_sdh_ble_enable(), it should look something like this:

    ret_code_t nrf_sdh_ble_enable(uint32_t * const p_app_ram_start)
    {
        // Start of RAM, obtained from linker symbol.
        uint32_t const app_ram_start_link = *p_app_ram_start;
    
        ret_code_t ret_code = sd_ble_enable(p_app_ram_start);
        if (*p_app_ram_start > app_ram_start_link)
        {
            NRF_LOG_WARNING("Insufficient RAM allocated for the SoftDevice.");
    
            NRF_LOG_WARNING("Change the RAM start location from 0x%x to 0x%x.",
                            app_ram_start_link, *p_app_ram_start);
            NRF_LOG_WARNING("Maximum RAM size for application is 0x%x.",
                            ram_end_address_get() - (*p_app_ram_start));
        }
        else
        {
            NRF_LOG_DEBUG("RAM starts at 0x%x", app_ram_start_link);
            if (*p_app_ram_start != app_ram_start_link)
            {
                NRF_LOG_DEBUG("RAM start location can be adjusted to 0x%x.", *p_app_ram_start);
    
                NRF_LOG_DEBUG("RAM size for application can be adjusted to 0x%x.",
                              ram_end_address_get() - (*p_app_ram_start));
            }
        }
    
        if (ret_code == NRF_SUCCESS)
        {
            m_stack_is_enabled = true;
        }
        else
        {
            NRF_LOG_ERROR("sd_ble_enable() returned %s.", nrf_strerror_get(ret_code));
        }
    
        return ret_code;
    }

    Are any of the lines containing NRF_LOG_WARNING hit? And if so, what are the parameters that it is trying to print?

    Best regards,

    Edvin

Children
No Data
Related