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

Can't get DFU to work

I am developing an app for the 51822 with 16KB RAM, which is supposed to integrate the buttonless DFU.

I have attached the whole hex of the merged application+softdevice+bootloader, and also the linker script for my app.

Sadly, I have lost the linker script for the bootloader, but the address offsets can be seen in this extract from the nrf-intel-hex demo site:

Block starting at 0 (0x0), 1984 (0x7c0) bytes long   <- softdevice
Block starting at 4096 (0x1000), 106464 (0x19fe0) bytes long  <- softdevice
Block starting at 110592 (0x1b000), 27880 (0x6ce8) bytes long <- application
Block starting at 229376 (0x38000), 30240 (0x7620) bytes long  <- bootloader
Block starting at 268439572 (0x10001014), 4 (0x4) bytes long   <- bootloader address for the MBR

please correct me if any of my labeling is wrong.
The bootloader works and allows uploading my code (standalone hex in that case) via Bluetooth.
The issue occurs when the application starts (even when there is not bootloader in place at all):
APP:INFO:starting
SDH:DEBUG:sd_ble_enable: RAM start at 0x20001ff8
:INFO:------- nrf_dfu_flash_init-------
:INFO:running nrf_dfu_settings_init
:INFO:!!!!!!!!!!!!!!! Resetting bootloader settings !!!!!!!!!!!
:INFO:Erasing old settings at: 0x200021e8
:INFO:Erasing: 0x200021e8, num: 1
:ERROR:Erase failed: 6
:ERROR:Erasing from flash memory failed.
APP_ERROR:ERROR:Fatal
That's the RTT output of my application.
To me, the error seems to appear in the line
ret_val = fs_erase(&fs_dfu_config, p_dest, num_pages, (void*)callback);
in nrf_dfu_flash.c::nrf_dfu_flash_erase().
1. Is there anything with my memory layout?
2  How can I get the application to boot normaly?
3. Why is the code trying to delete something at address 0x200021e8? Is that some kind of mapping of the flash to the ram?
     0x200021e8 Clearly exceeds the boundaries of the flash itself, thus I am wondering wha it does not try to delete an address contained in the flash...
4. How does the size parameter in the linker script (0x1D9E0 and 0x2008) affect the resulting hex or flash layout?
    The sizes of the blocks in the hex do not seem to have any correlation to the sizes given in the linker script as far as I can cell.
  • Hi Daniel, 

    Did you do any modification to the bootloader ? 
    What showed in the log looks strange. The m_dfu_settings_buffer should be located in flash at location BOOTLOADER_SETTINGS_ADDRESS ( 0x0003FC00) but in your log it's located at 0x200021e8 which is RAM. 
    This setting is configurated in nrf_dfu_settings.c . Could you let me know which compiler do you use ? 

    Have you tried to test updating a very small example using unmodified bootloader from the SDK ? I have a step by step guide here

  • I am using the armgcc folder on the command line with "arm-none-eabi-gcc" as my compiler through "make build".

    Here is what I found out:

    nrf_dfu_settings.c states

    /** @brief  This variable reserves a codepage for bootloader specific settings,
     *          to ensure the compiler doesn't locate any code or variables at his location.
     */
    #if defined (__CC_ARM )
        uint8_t  m_dfu_settings_buffer[CODE_PAGE_SIZE] __attribute__((at(BOOTLOADER_SETTINGS_ADDRESS)))
                                                       __attribute__((used));
    
    #elif defined ( __GNUC__ )
    
        uint8_t m_dfu_settings_buffer[CODE_PAGE_SIZE] __attribute__ ((section(".bootloaderSettings")))
                                                      __attribute__((used));
    
    #elif defined ( __ICCARM__ )
    
        __no_init __root uint8_t m_dfu_settings_buffer[CODE_PAGE_SIZE] @ BOOTLOADER_SETTINGS_ADDRESS;
    
    #else
    
        #error Not a valid compiler/linker for m_dfu_settings placement.
    
    #endif

    During the compilation, "__GNUC__" seems to be set, which seems to involve 

    section(".bootloaderSettings"), which is not configured in my linker script.
    Is there any adjustment I need to make to my linker script?
  • Indeed it turned out that my linker script was incomplete.

    8156.freshener_nrf51.lddemonstrates how it works for me when compiling using armgcc and make.

Related