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

Problem with bootloader relocation

My goal is to replace the legacy bootloader present in nRF52832 with a new bootloader with the DFU process.

I am using nRF5 SDK v15.3.0, GCC ARM and S132.

I have done the following with the help of this.

To summarize,

  • The new bootloader was copied into bank-1.
  • Next, the UICR region is erased and the new address is written into 0x10001014 and also the other content which was present before erasing.
  • I had verified the new address being written to 0x10001014 (NRF_UICR->NRFFW[0]).

Now the problem is that, after calling the sd_mbr_cmd(..) with SD_MBR_COMMAND_COPY_BL command, the device resets and doesn't start the new bootloader.

A similar question was asked here, but doesn't seem to have a solution.

I am not sure if I am missing something.

Thanks in advance.

Update: I have also verified (with the help of JLink by reading bytes at the new location) that the new bootloader is being copied into the new location.

  • The address 0xFF8 shows FFFF.., every time, which means there is no address in the MBR region. In which case, it should use the address present in UICR region (0x10001014) but seems like it isn't doing so.

    Or by saying "MBR Setting Page", did you mean the one present in UICR.NRFFW[1] (just after the bootloader - higher address / MBR Param Storage)?

    Additionally, the following two check scenarios could be of help (supporting your hypothesis):

    - copied the same bootloader to a different address (0x60000) faraway from the current one (also modified the UICR address to this) and it still jumps to the same old address 0x71000.

    - over-wrote the existing bootloader just in place (i.e. at 0x71000) with the same code and I could verify that it works (staying at the older address).

    I am lighting up an LED in the main() of the bootloader to know that the bootloader is functioning.

    Update: when I read the content present at the address in UICR.NRFFW[1] (MBR Param Storage), it is cleared. Before writing the new bootloader, this address has some content.

    Also, could you tell me how to interpret the data present in MBR Parameter Storage?

  • Hello Hung,

    I've been struggling with this for a while, could you tell me how to set the address in the MBR settings page (I am assuming this to be a part of address *UICR.NRFFW[1])?

  • Hi Naveenj, 

    I would suggest to test with the stock bootloader, you can have a fresh copy of the SDK. 

    Which IDE you are using ? If you using KEIL, this line should be enabled in nrf_bootloader_info.c. 

    uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOTLOADER_START_ADDRESS)))
    = BOOTLOADER_START_ADDR;

    This line will configure the address NRF_UICR_BOOTLOADER_START_ADDRESS = MBR_BOOTLOADER_ADDR = 0xFF8 with the value of BOOTLOADER_START_ADDR 

    When you flash the bootloader hex file, the value whould be written at 0xFF8. 

    I assume you are using S132 v6.1.1 ? 

    If you still having trouble you can send us the hex files you have (bootloader + softdevice )

  • I am not using any dedicated IDEs and I am using GCC ARM compiler.

    This line is enabled in my case:

    volatile uint32_t m_uicr_bootloader_start_address __attribute__ ((section(".uicr_bootloader_start_address")))
    = BOOTLOADER_START_ADDR;
    Yes, I am using S132 v6.1.1.
    The bootloader is initially present at 0x71000, relocated to 0x70000. I am attaching the hex files that I took at every step.
    This is the final file after relocating the bootloader.
    This hex file, is taken just after the bootloader is received and before the bootloader is written to the new location.
    This is before the whole process is started.
    The linker file:
    Update: Just to clear some confusion, I am trying to relocate from the bootloader code. Flashing it fully with the new address works, but I want to do this from the bootloader code itself.
  • Hi, 

    Please send us your bootloader and softdevice hex file, the original one. Don't test with changing/switching the bootloader yet. Test with just the normal bootloader, we need to find where the MBR find the bootloader location. 

    I attached here bootloader that I built, you can see at the first 3 lines the address 0xFF8 is written 0x78000 

    I don't see that in your dump_after_copying_to_newloc.hex nor dump_before_dfu.hex

    Note that flash dump wouldn't show the UICR. 

    bootloader.hex

Related