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

Bootloader DFU Register and Flash Changes

I have been having issues with bootloader launching my application on a custom nRF52832 based hardware device.

The bootloader itself seems to be successfully completing the DFU process but the app fails to start after the download. Various other versions of modified example projects get successfully launched after dfu download with the same bootloader. However, the final application that has all features enabled fails to launch and resets back into the bootloader.

I have been looking at the various dfu and bootloader settings/changes that could have a bearing on how the bootloader-to-app transition happens. The following is what I see as the relevant changes:

  1. UICR register modifications:

After Erase All, programming the SoftDevice changes 0x10001000 to 0x0001C000

-- this is the correct start address of my application Code 0 section.

After programming the bootloader, 0x10001014 to 0x00075000, and 0x10001018 to 0x0007E000

-- booloader is located at 0x75000 and the boot-settings block is at 0x7E000.
  1. 0x7F000 page modifications:

    After successful, DFU of an application using the bootloader,

nrfjprog -s 203201034 --memrd 0x0007f000 --w 32 --n 0x30

0x0007F000: 00000001 000000FF 0001C9CC 00000000

0x0007F010: 00000000 00000000 00000000 FFFFFFFF

The value, 0x1C9CC at address 0x7F008 is the correct size of the application.

My question is, "Are these all the changes to UICR and flash areas that happens during the bootloader DFU process, other than the actual flashing of the application code?"

-- Also, I do not use bonding for DFU
-- I use the zip package generated by nrfutil for the DFU download.

Thanking for any input on this.

Milton

Parents
  • Hi Milton,

    The UICR register at 0x10001014 holds the bootloader start address and is only written to when the bootloader is flashed to the nRF5x device. The bootloader start address will not be altered after this initial write.

    The UICR register at 0x10001000 holds the start address of the application vector table which is also the end of the Softdevice region. Only written to when the SoftDevice is initially flashed to the nRF5x device.

    The MBR params page at 0x7E000 is used by the Master Boot Record(MBR) to store state information and will be altered when the bootloader issues commands to the MBR.

    The bootloader settings page at 0x7F000 and will change during the DFU update to contain data about the received firmware image and the status of the firmware banks. The data isstored in the bootloader_settings_t struct

    typedef enum
    {
        BANK_VALID_APP   = 0x01,
        BANK_VALID_SD    = 0xA5,
        BANK_VALID_BOOT  = 0xAA,
        BANK_ERASED      = 0xFE,
        BANK_INVALID_APP = 0xFF,
    } bootloader_bank_code_t;
    
    typedef struct
    {
        bootloader_bank_code_t bank_0;          /**< Variable to store if bank 0 contains a valid application. */
        uint16_t               bank_0_crc;      /**< If bank is valid, this field will contain a valid CRC of the total image. */
        bootloader_bank_code_t bank_1;          /**< Variable to store if bank 1 has been erased/prepared for new image. Bank 1 is only used in Banked Update scenario. */
        uint32_t               bank_0_size;     /**< Size of active image in bank0 if present, otherwise 0. */
        uint32_t               sd_image_size;   /**< Size of SoftDevice image in bank0 if bank_0 code is BANK_VALID_SD. */
        uint32_t               bl_image_size;   /**< Size of Bootloader image in bank0 if bank_0 code is BANK_VALID_SD. */
        uint32_t               app_image_size;  /**< Size of Application image in bank0 if bank_0 code is BANK_VALID_SD. */
        uint32_t               sd_image_start;  /**< Location in flash where SoftDevice image is stored for SoftDevice update. */
    } bootloader_settings_t;
    

    A successful DFU of the application will result in the bank_0 field of the bootloader_settings_t struct being set to BANK_VALID_APP = 0x01 and the bank_0_size field is set to the size of the application.

    Best regards Bjørn

  • Hi Bjørn,

    Thank you for the detailed explanation. It definitely helps to clarify things and to have all the information in one place.

    Regards,

    Milton

Reply Children
No Data
Related