nRF5 SDK v11.0.0
Relocating the bootloader
This information applies to the nRF51 Series only.
This information applies to the following SoftDevices: S130, S132, S332

The start address of the bootloader is stored in the UICR.BOOTLOADERADDR register, which is located at address 0x10001014. In the DFU bootloader example, writing the UICR.BOOTLOADERADDR is linked into the HEX file, so that it is automatically written when programming the bootloader (see Programming the DFU bootloader).

Note that UICR.BOOTLOADERADDR can only be written if you use nrfjprog.exe as the tool for flash programming. Always erase the device before programming the bootloader, so that the value can be set correctly.

The following code in bootloader_util_arm.c writes the bootloader start address to UICR.BOOTLOADERADDR:

uint32_t m_uicr_bootloader_start_address __attribute__((at(NRF_UICR_BOOT_START_ADDRESS))) = BOOTLOADER_REGION_START;

BOOTLOADER_REGION_START must point to the correct location of the bootloader in the flash. In this example, this location is 0x0003C000.

You can change the start address of the bootloader if the size of your bootloader image exceeds the available memory. For example, changing the start address from 0x0003C000 to 0x00038000 increases the available bootloader size to 0x8000 (instead of 0x4000).

When selecting a new start address, keep in mind that all start addresses must be page aligned. The page size is 0x400 (1024) bytes. Also, start address and size of the memory for the bootloader must add up to 0x00040000 bytes (the end of the application area in the flash).

Complete the following steps to relocate the bootloader to a new start address:

  1. Erase the device.
  2. Program the SoftDevice.
  3. Change the value of BOOTLOADER_REGION_START in dfu_types.h.
  4. Compile the bootloader.
  5. In Keil, select Project > Options for Target 'xxx' and change the IROM1 start address and size:
    DFU bootloader start address setting in Keil
  6. Program the bootloader.

Documentation feedback | Developer Zone | Updated