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

How do I change the application/bootloader start address?

My ultimate issue is trying to get a bootloader working on custom hardware with an nRF52832. The bootloader is mostly the base UART DFU bootloader from the Nordic SDK, with a few customizations to work with our hardware. I've been able to get the bootloader up and running by using the following flash set up that I have for the application: FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000. However, when I try to change the start address (e.g. to FLASH (rx) : ORIGIN = 0x25000, LENGTH = 0x5b000), the bootloader no longer appears to run. Similarly, I can use Eclipse to step into the debug code of the bootloader when it starts at 0x26000, but not at 0x25000.

To try to eliminate as many variables as possible, I also tried changing the start address of one of the SDK examples and running it on an nRF52 dev kit. In the same way as the bootloader on custom hardware, building the ble_central/ble_app_blinky_c produces an hex file that will run successfully on the dev kit, while building it with the start address changed to 0x25000 produces a hex file that will not run successfully. Below is a diff of my complete changes to the blinky example.

In both the custom code/hardware and stock SDK/dev kit situations I'm using GCC as my compiler and SDK 15.2.0, with softdevice s132_nrf52_6.1.0_softdevice.hex. My programming procedure in each case is:

What am I missing about changing the starting address of either the application or the bootloader? What configuration needs to be done to get an application and bootloader running together?

Thanks.

Parents
  • Hi Kathleen,

     the S132 v6.1.0 SoftDevice requires 152 kB (0x26000 bytes) of program memory, starting from 0x0000 ( This is included the MBR, see Memory resource map and usage for the memory layout). So when you are setting the application or bootloader start address to 0x25000, you are effectively overwritting the SoftDevice. Hence setting any start address higher than 0x26000 should work fine for both the bootloader and the application. 

    Best regards
    Bjørn 

  • So that explains why 0x25000 won't work as a start address, but I also can't run the blinky example with the following configuration: FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x59000. Any idea what might be going on here?

  • So if I'm understanding you right, the blinky application isn't working at another address because it has to be located immediately after the softdevice (i.e. 0x26000.) But the bootloader should be able to be placed pretty much anywhere in flash where's it's not overwriting the softdevice as the its start location is saved in the UICR registers.

    When I switch over to using our custom bootloader, I'm seeing that when I set the flash configuration to FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000, the bootloader boots up and prints to the debug port successfully, but when I set the flash configuration to FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x59000I don't see any output on the debug port, leading me to believe the bootloader is never being run. As part of my programming procedure I'm running an eraseall, which should make sure the UICR registers get reprogrammed and I'm also making sure to reset the board after programming everything. What am I missing here?

  • Yes, you understanding is correct. 

    Are you able to debug the bootloader when you use the FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x59000 configuration?

    Best regards

    Bjørn

  • No, I am not able to debug with that configuration. I have been able to debug the bootloader with the FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0x5a000 configuration.

  • I think the issue is that the length value is to large as ORIGIN+LENGTH is 0x81000. The bootloader should stop at the start of the MBR Params page at 0x7E000, i.e. LENGTH = 0x78000 - ORIGIN = 0x57000.

    I tested the following setting with the bootlaoder in SDK v15.2.0 and I had no issues. 

     FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0x57000

  • I've noticed that my custom bootloader isn't setting the bootloader start address in the UICR registers. Is there anything specific in the project setup that signals nrfjprog that a given application is a bootloader and thus that the UICR registers should be set? I'm using the same ld file for my bootloader as for the example in the SDK, so maybe I'm missing something in the makefile?

Reply
  • I've noticed that my custom bootloader isn't setting the bootloader start address in the UICR registers. Is there anything specific in the project setup that signals nrfjprog that a given application is a bootloader and thus that the UICR registers should be set? I'm using the same ld file for my bootloader as for the example in the SDK, so maybe I'm missing something in the makefile?

Children
  • Hi Kathleen,
    as long as you have the following memory regions and sections set in your linker script

    specifically the uicr_bootloader_start_address section, then you should be fine. Could you search through your .map file and see if uicr_bootloader_start_address section is included in the generated binary?

  • I've got this line  under Memory Configuration:

    And this later on in the map file:

  • After looking into the allocation in the map file, it became apparent that the issue I was seeing was due to the bootloader sections not being allocated properly. While the sections in the linker script do need to be added, this is only part of what's needed.

    As opposed to the examples given in the SDK, my build configuration file (CMakeLists.txt using cmake and ninja to build) was designed in a minimalistic way, including only bootloader_main.c and one support file, with the Nordic files available as a separate library. The bootloader sections are utilized in components/libraries/bootloader/dfu/nrf_dfu_settings.c and components/libraries/bootloader/nrf_bootloader_info.c. As bootloader_main.c was not referencing these files explicitly, they were not being included in the build and were not being given space in the bootloader map. Adding these files to the bootloader target explictly caused them to be allocated and enabled the bootloader to boot.

    So the change I needed to make to the project was to go from this executable setup:

    To this one: