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

Memory allocation macros in Segger Embedded Studio to program a Soft Device, Application and Bootloader all at once

I am looking for some guidance as to the memory regions to reserve for the Bootloader hex if I pull it in via Segger Embedded Studio. I have the memory allocations for the Application down pat and there is no problem linking in the SoftDevice. However how do I specify where the Bootloader goes (at the top of the memory allocation) using the section placement macros in Linker Options?

[UPDATE 10 JUNE - Brought up from the dead as it would be good if an answer could be found to this]

Thanks a lot - RJH

  • You need to use nrfjprog to program the bootloader, so I guess it will not work anyhow.

    To get the bootloader to start the application after flashing without using DFU you need to set address BOOTLOADER_SETTINGS_ADDRESS to 0x01, see this FAQ (question E).

  • Hi Ole, the reason I asked is that Mike said it was possible. I had an exchange with him yesterday where he said ask in the forum and he would respond.

  • Ok, then I will withdraw my statement and wait for Michael to answer.

  • Short Answer: You don't need to specify where the Bootloader goes (see the 'Loading .hex files' section below). Basically a .hex file specifies where the data should go. You have already configured the Section Placement Macro/Memory Map for the SoftDevice and don't need to do anything else here.

    Loading the .hex files:

    The .hex file specifies both the actual program data to be written to flash, along with the address of where that data should be written (i.e. write 0xDEADBEEF to address 0x1C000, 0xB16B00B5 to address 0x1C004, etc...) So when we load these .hex files to the board we are sure there will be no overlapping.

    Doing this all in Embedded Studio:

    We want to specify both the SoftDevice and Bootloader as 'Additional Load Files' in 'Project Properties -> Debugger -> Loader Options.' So specify the paths to each of the .hex files there. (To flash the Application when a Bootloader is present you also need to write a flag in FLASH. I recommend also specifying this bootloader_settings_nrf52.hex as an additional file to loader. It is a .hex file that writes that flag for you). bootloader_settings_nrf51.hex

    Now when you compile your application and load it to your board, Embedded Studio will flash the SD, BL and write the flag for you! And if there are any collisions between the .hex file you will get an error.

  • Note: A common misconception is that you need to flash the bootloader using nrfjprog. This is only the case when using Keil with nRF51. The Keil Flash algorithms can't properly write the UICR on nRF51 and this is why the problem occurs.

    If you are developing on nRF52, or you aren't using Keil, you can use your IDE to program the Bootloader no problem! (to be clear: You can program the bootloader from the Keil IDE when using nRF52 device).

Related