Change Bootloader start address

I need to do a DFU via BLE but I do not have enough memory.
For the past few months I have been working on a custom bootloader that would use an external memory to do the DFU.
The problem is that the new bootloader is bigger than the previous one and requires me to change the allocated memory.

Current Memory Layout New Memory Layout
Bootloader Settings Page 0x3F000 to 0x40000 0x3F000 to 0x40000
MBR Params Page 0x3E000 to 0x3F000 0x3E000 to 0x3F000
Bootloader 0x38000 to 0x3E000 0x37000 to 0x3E000

I only have two options:

  • Allocate only 0x500 for the settings page and params page so that they will fit between 0x3F000 and 0x40000.
  • Move the bootloader start address

I know this is not recommended but I have no choice in this case.
I cant change the hardware, I already have tens of thousands of devices with the clients that can only be updated through BLE DFU.

As it was mentioned in another public ticket, for SoftDevice versions beyond 6.1, the bootloader start address is stored in the MBR.
I need to know how can I modify this address correctly.

For now i have disabled the memory flash protection of the MBR, in main.c, so that I can modify the value.
Then in nrf_bootloader_fw_activation.c, i modify that value right before the MBR is called to replace the bootloader by calling this function:

  • nrf_nvmc_write_word(MBR_BOOTLOADER_ADDR, (uint32_t) 0x37000);

However, if I read the value stored in MBR_BOOTLOADER_ADDR, it is not necessarily the value I have written.
How can I change this value?

If this is actually impossible, can I reduce the allocated size for the params and settings pages? they only need  800 bytes each but they allocate 4096 each.

Parents
  • Neither of your two options will work. You cannot set bits with the write_word function, you can only reset them to zero. Now look at your hex values in windows calculator binary mode - you have to both set and reset bits.

    The pages also must be as big as one erase page because that is what you can erase at a time for the flash memory.

    Your only option is to mess with compiler and bootloader settings in order to fit the new on in the space for the old.

    Resetting this bootloader setting in MBR or UICR is a manufacturer only thing - you can only do that reliably via SWD connection.

  • I think you are right.

    That explains why when I want to write 0x37000, the value i get is 30000. Because 0x37000 & 0x38000 = 0x30000.
    Bits are indeed set to 0 and no bits are set to 1.

Reply Children
No Data
Related