Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

ble softdevice enable fail with bootloader

I'm developing BLE code using the s140 + Nordic 52833 with nrf5 SDK. My flash contains the hex files for s140, the bootloader, and the app. I've encountered a strange issue: When I only flash s140 + the app, the softd evice stack initializes successfully, and the program runs perfectly. However, when I flash s140 + the bootloader + the app, the app jumps in correctly (s140 -> boot -> app), but the soft device stack initialization fails. The specific error is shown in the image below.

I've compared the code in the flash and confirmed that the only difference is the bootloader being flashed; the rest of the addresses have identical code. Why does this happen? Could it be that the additional jump to the bootloader causes the SVC exception to be lost? How can I resolve this issue?

Here are a few points of suspicion:
1.The bootloader I'm using is based on s113 with modifications. However, it shouldn’t involve any protocol stack‑related calls; it only performs a jump.here are some defined in project file:

c_preprocessor_definitions="BLE_STACK_SUPPORT_REQD;BOARD_PCA10100;CONFIG_GPIO_AS_PINRESET;FLOAT_ABI_HARD;INITIALIZE_USER_SECTIONS;NO_VTOR_CONFIG;NRF52833_XXAA;NRF_DFU_SETTINGS_VERSION=2;NRF_DFU_SVCI_ENABLED;NRF_SD_BLE_API_VERSION=7;S113;SOFTDEVICE_PRESENT;SVC_INTERFACE_CALL_AS_NORMAL_FUNCTION;uECC_ENABLE_VLI_API=0;uECC_OPTIMIZATION_LEVEL=3;uECC_SQUARE_FUNC=0;uECC_SUPPORT_COMPRESSED_POINT=0;uECC_VLI_NATIVE_LITTLE_ENDIAN=1;"

2.The jump‑related code in my bootloader is as follows:
nrf_bootloader_app_start(IMAGE_START_ADDR);

void nrf_bootloader_app_start(uint32_t addr)
{
    NRF_LOG_DEBUG("Running nrf_bootloader_app_start with address: 0x%08x", addr);
    uint32_t err_code;

    // Disable and clear interrupts
    // Notice that this disables only 'external' interrupts (positive IRQn).
    NRF_LOG_DEBUG("Disabling interrupts. NVIC->ICER[0]: 0x%x", NVIC->ICER[0]);

    NVIC->ICER[0]=0xFFFFFFFF;
    NVIC->ICPR[0]=0xFFFFFFFF;
#if defined(__NRF_NVIC_ISER_COUNT) && __NRF_NVIC_ISER_COUNT == 2
    NVIC->ICER[1]=0xFFFFFFFF;
    NVIC->ICPR[1]=0xFFFFFFFF;
#endif

    err_code = nrf_dfu_mbr_irq_forward_address_set(addr);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR("Failed running nrf_dfu_mbr_irq_forward_address_set()");
    }

    NRF_LOG_FLUSH();
    nrf_bootloader_app_start_final(addr);
}


void nrf_bootloader_app_start_final(uint32_t vector_table_addr)
{
    ret_code_t ret_val;

    // Size of the flash area to protect.
    uint32_t area_size;

    area_size = BOOTLOADER_SIZE + NRF_MBR_PARAMS_PAGE_SIZE;
    if (!NRF_BL_DFU_ALLOW_UPDATE_FROM_APP && !NRF_BL_DFU_ENTER_METHOD_BUTTONLESS && !NRF_DFU_TRANSPORT_BLE)
    {
        area_size += BOOTLOADER_SETTINGS_PAGE_SIZE;
    }

    ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, area_size);

    if (ret_val != NRF_SUCCESS)
    {
        NRF_LOG_ERROR("Could not protect bootloader and settings pages, 0x%x.", ret_val);
    }
    APP_ERROR_CHECK(ret_val);

    //ret_val = nrf_bootloader_flash_protect(0,
    //                nrf_dfu_bank0_start_addr() + ALIGN_TO_PAGE(s_dfu_settings.bank_0.image_size));

    if (ret_val != NRF_SUCCESS)
    {
        NRF_LOG_ERROR("Could not protect SoftDevice and application, 0x%x.", ret_val);
    }
    APP_ERROR_CHECK(ret_val);

    // Run application
    app_start(vector_table_addr);
}

Parents Reply Children
No Data
Related