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

Nrf52832 ble_app_uart DFU No bootloader found(NRF_ERROR_NO_MEM) | SDK 15.3.0 | Soft device S132 6.1.1

I am trying to integrate buttonless DFU with FDS in ble_app_uart example from sdk 15.3.0. Merge hex was done properly which includes bootloader_settings.hex+bootloader.hex+softdevice.hex+application.hex and programmed using JLink prior to that i erased the chip using nrfjprog -f nrf52 -e command successfully. Then i resetted the board, application started and reaches ble_dfu_buttonless_async_svci_init() which gives NRF_ERROR_NO_MEM error. I went into debug mode and found uint32_t bootloader address was 0xFFFFFFFF. I checked UICR register value using JLink command -> mem8 0x10001014 4 which results 0xFFFFFFFF. The bootloader i programmed was debug version and i got the below prints.

PRINT_START

00> <info> app: Inside main
00>
00> <debug> app: In nrf_bootloader_init
00>
00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
00>
00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
00>
00> <debug> nrf_dfu_settings: Using settings page.
00>
00> <debug> nrf_dfu_settings: Copying forbidden parts from backup page.
00>
00> <info> nrf_dfu_settings: Old settings page detected. Upgrading info.
00>
00> <debug> nrf_dfu_settings: Writing settings...
00>
00> <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
00>
00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 0
00>
00> <debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 0
00>
00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, src=0x20009188, len=896 bytes), queue usage: 1
00>
00> <debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
00>
00> <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
00>
00> <debug> nrf_dfu_settings: Writing settings...
00>
00> <debug> nrf_dfu_settings: Erasing old settings at: 0x0007E000
00>
00> <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007E000, len=1 pages), queue usage: 1
00>
00> <debug> nrf_dfu_flash: Flash erase success: addr=0x0007E000, pending 0
00>
00> <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007E000, src=0x20009508, len=896 bytes), queue usage: 1
00>
00> <debug> nrf_dfu_flash: Flash write success: addr=0x0007E000, pending 0
00>
00> <debug> app: Enter nrf_bootloader_fw_activate
00>
00> <info> app: No firmware to activate.
00>
00> <debug> nrf_dfu_validation: CRC check of app failed. Return 1
00>
00> <debug> app: App is valid
00>
00> <info> nrf_dfu_settings: Backing up settings page to address 0x7E000.
00>
00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
00>
00> <debug> app: Running nrf_bootloader_app_start with address: 0x00001000
00>
00> <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0
00>
00> <info> app: Setting vector table to bootloader: 0x00072000
00>
00> <info> app: Setting vector table to main app: 0x00026000
00>

<debug> No bootloader found


00> <error> app: Fatal error
00>

PRINT_ENDS

The application Linker script has 

FLASH_PH_START=0x0

FLASH_PH_SIZE=0x80000

RAM_PH_START=0x20000000

RAM_PH_SIZE=0x10000

FLASH_START=0x26000

FLASH_SIZE=0x53000

RAM_START= 0x200030E0

RAM_SIZE=0xCF20

I don't know why UICR has 0xFFFFFFFF value and i know that because this my application stucks in Fatal error. Why UICR is not programmed properly?

I am attaching nrf52832_xxaa_s132.map(from pca10040_ble_debug\armgcc\build), bootloader_settings.hex, bootloader.hex, application.hex and sd_app_boot.hex for reference.  74862.nrf52832_xxaa_s132.map6567.bootloader_settings.hex1667.nrf52832_xxaa_s132.hex8524.sd_app_boot.hex0513.ble_app_uart_pca10040_s132.hex

Parents
  • Actually this issue is happening because i am using segger and it erases the bootloader if going into debug mode. The issue actually comes when buttonless_service initialization happens. Hence i want to modify the NRF_POWER->GPREGRET = BOOTLOADER_DFU_START and restarted the device so i can able to see Dfu_Targ in nrf_connect app. But Now if i upload an app.zip file which i made using nrfutil along with private key i am getting signature failed error in bootloader while uploading app.zip. The bootloader has dfu_public_key.c and i modified the file by using private key. So what could be the issue?

  • Hi,

    Referring to the initial question first, I want to mention that  SDK 15.3 introduced a new location for the bootloader start address. It is no longer in the UICR (though some code still incorrectly refers to "uicr" or "UICR"), but instead it is in the end of the first page, the MBR params page. You can see that MBR_BOOTLOADER_ADDR is set to 0xFF8 in nrf_mbr.h, and this is what is used. So the bootloader start address does not need to be in the UICR.

    Yogeshwaran said:
    But Now if i upload an app.zip file which i made using nrfutil along with private key i am getting signature failed error in bootloader while uploading app.zip. The bootloader has dfu_public_key.c and i modified the file by using private key. So what could be the issue?

    Good question. Based on what you wrote it should work, but perhaps there has been a mixup? Can you double check that you build the bootloader with the correct public key and that this is the bootloader you uploaded to the device? And then verify that you signed the DFU image using the correct corresponding private key?

  • I am getting the below error if use 327680 for DATA_AREA_SIZE

    00> <debug> app: SD_PRESENT: true.
    00>
    00> <debug> app: Bank contents:
    00>
    00> <debug> app: Bank 0 code: 0x01: Size: 0xC420
    00>
    00> <debug> app: Bank 1 code: 0x00: Size: 0x0
    00>
    00> <error> app: Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x2000FF18

  • Do i need to adjust the application flash size in segger Linker script? and 0x2000FF18 denotes to which register location?

  • I used FDS_VIRTUAL_PAGES as 10 then it is working fine but i need more pages so what should i do. Atleast 30 pages.

  • NRF_DFU_APP_DATA_AREA_SIZE 204800 which is 50 pages of FDS and i enabled 

    NRF_DFU_FORCE_DUAL_BANK_APP_UPDATES by setting to 1 now the issue got resolved and DFU successfully updating application and running properly after update. If i change the NRF_DFU_APP_DATA_AREA_SIZE  to 80 pages then throwing error after update as '11' at fds_init() which denotes NO_PAGES. what is the reason? One more issue is if i call sd_nvic_SystemReset() gives Fatal error in loop(). This function will get called after device receives cmd from ble_client(nRF_Connect app) so can you tell how to reset the device properly to go into DFU.
  • Hi,

    Yogeshwaran said:
    NRF_DFU_FORCE_DUAL_BANK_APP_UPDATES by setting to 1 now the issue got resolved and DFU successfully updating application and running properly after update.

    That makes sense. With forced dual bank updates you need more available space, so it makes sense that setting NRF_DFU_FORCE_DUAL_BANK_APP_UPDATES to 0 allows you to reserve more space for user data (FDS pages).

    Yogeshwaran said:
    NRF_DFU_APP_DATA_AREA_SIZE  to 80 pages then throwing error after update as '11' at fds_init() which denotes NO_PAGES. what is the reason?

    Do you have an overview of the memory layout of your device? You can refer to the figure at the end of this page and put in your sizes. You cannot use more pages for FDS than what is between the end of the application and the beginning of the bootloader. And even if that fits, it may be too much to allow you to do SoftDevice and  updates, as they must be dual bank bootloader.

    Yogeshwaran said:
    One more issue is if i call sd_nvic_SystemReset() gives Fatal error in loop(). This function will get called after device receives cmd from ble_client(nRF_Connect app) so can you tell how to reset the device properly to go into DFU.

    You should not get an error from sd_nvic_SystemReset(), it should just reset and never return.  If the SoftDevice is not enabled you should call NVIC_SystemReset(). Are you sure this is the problem?

Reply
  • Hi,

    Yogeshwaran said:
    NRF_DFU_FORCE_DUAL_BANK_APP_UPDATES by setting to 1 now the issue got resolved and DFU successfully updating application and running properly after update.

    That makes sense. With forced dual bank updates you need more available space, so it makes sense that setting NRF_DFU_FORCE_DUAL_BANK_APP_UPDATES to 0 allows you to reserve more space for user data (FDS pages).

    Yogeshwaran said:
    NRF_DFU_APP_DATA_AREA_SIZE  to 80 pages then throwing error after update as '11' at fds_init() which denotes NO_PAGES. what is the reason?

    Do you have an overview of the memory layout of your device? You can refer to the figure at the end of this page and put in your sizes. You cannot use more pages for FDS than what is between the end of the application and the beginning of the bootloader. And even if that fits, it may be too much to allow you to do SoftDevice and  updates, as they must be dual bank bootloader.

    Yogeshwaran said:
    One more issue is if i call sd_nvic_SystemReset() gives Fatal error in loop(). This function will get called after device receives cmd from ble_client(nRF_Connect app) so can you tell how to reset the device properly to go into DFU.

    You should not get an error from sd_nvic_SystemReset(), it should just reset and never return.  If the SoftDevice is not enabled you should call NVIC_SystemReset(). Are you sure this is the problem?

Children
  • I am using SoftDevice for advertising then it must be enabled i feel, but even i tried NVIC_SystemReset() still same Fatal error. The below is the code which i am using

    for(;;)

    {

    if(go_to_dfu)
    {
    NRF_LOG_INFO("Going to dfu ");
    uint32_t err_code;
    err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
    APP_ERROR_CHECK(err_code);
    sd_ble_gap_scan_stop();
    sd_ble_gap_adv_stop(NULL);
    while(connected);
    NRF_POWER->GPREGRET = BOOTLOADER_DFU_START;
    nrf_delay_ms(100);
    sd_nvic_SystemReset();
    }

    if(start_advertise)

    {

    //starting_advertising

    }

    }

  • How have you debugged to verify that you get an error after calling NVIC_SystemReset? The function does not return anything, and really should not fail. For reference, this is the implementation (<SDK>\components\toolchain\cmsis\include\core_cm4.h):

    /**
      \brief   System Reset
      \details Initiates a system reset request to reset the MCU.
     */
    __STATIC_INLINE void NVIC_SystemReset(void)
    {
      __DSB();                                                          /* Ensure all outstanding memory accesses included
                                                                           buffered write are completed before reset */
      SCB->AIRCR  = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos)    |
                               (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
                                SCB_AIRCR_SYSRESETREQ_Msk    );         /* Keep priority group unchanged */
      __DSB();                                                          /* Ensure completion of memory access */
    
      for (;;)                                                           /* wait until reset */
      {
        __NOP();
      }
    }

  • Yeah as you said it not getting Fatal error because of NVIC_SystemReset(). if i add NRF_POWER->GPREGRET = BOOTLOADER_DFU_START before NVIC_SystemReset() then it is happening but if add the NRF_POWER->GPREGRET = BOOTLOADER_DFU_START and restart the device by switch off and on then it goes to DFU mode as excepected and other functionalities are working fine.

  • Hi,

    Yogeshwaran said:
    Yeah as you said it not getting Fatal error because of NVIC_SystemReset().

    Sounds good. Then we can ignore NVIC_SystemReset() itself.

    Yogeshwaran said:
    if i add NRF_POWER->GPREGRET = BOOTLOADER_DFU_START before NVIC_SystemReset() then it is happening but if add the NRF_POWER->GPREGRET = BOOTLOADER_DFU_START and restart the device by switch off and on then it goes to DFU mode as excepected and other functionalities are working fine.

    By turning off and on here do you mean power-cycle? If so, then whatever was in the GPREGRET is lost as it is only retained while the device is powered. It is a bit odd that the device enters DFU mode though, as the BOOTLOADER_DFU_START flag is lost after the reset. It is also strange that you get the error when the flag is set. Some questions:

    • Do you only get this error when using a high number of FDS pages, or is that unrelated to the issue?
    • Have you made any modifications in the bootloader? If so, which?
    • Do you see anything useful if testing with the debug bootloader with RTT logging (example bootloader project ending with "_debug")?
  • I am sorry basically resetting the board drives the device into DFU mode not power off and on. So i found some useful things from https://devzone.nordicsemi.com/f/nordic-q-a/30856/invalid-memory-access-when-writing-to-nrf_power--gpregret and https://devzone.nordicsemi.com/f/nordic-q-a/37971/gpregret-clears-on-sd_nvic_systemreset using this the issue got resolved. Actually we should not directly set NRF_POWER->GPREGRET if Softdevice is present. The way we should set by only using below code 

    err_code = sd_power_gpregret_clr(0, 0xffffffff);
    APP_ERROR_CHECK(err_code);
    err_code = sd_power_gpregret_set(0,BOOTLOADER_DFU_START);
    APP_ERROR_CHECK(err_code);
    nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_DFU);

    I am right sir?

Related