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

How does the nrfjprog know the addresses of area to program?

I'm curious. I believe I can set it up in the keil "options->target" tab.

I get it that as long as I don't cause the softdevice and my program to "overlap", it is fine, but I clearly cannot guarantee there wouldn't be a huge "gap" between the ending address of the softdevice and the starting address of my program. But so far I haven't had any issue with this. Why?

Don't I have to worry about where my program should be downloaded to? Or the downloader tool is much more intelligent than I thought?

  • The firmware you supply to nrfjprog (no matter if it is application, SoftDevice, bootloader or something else) is in Intel HEX format. This file contains the address along with the data. This means that the addresses are decide when you build the hex file, and not by nrfjprog.

    If you change the start address of your application in Keil, you will see that the hex file changes accordingly (note that just moving your application to a random address will make it fail, as it of course has to be in the expected location, but you can do it to see how the hex file works.

    If you analyze the hex file in a editor you should note that in addition to the address field of every line (byte second and third byte) there is often a shorter line with record type (byte four) Extended Linear Address. This specify the upper 16 bits of the 32-bit absolute address for all subsequent data records. For example, this is always needed for the application hex file when the SoftDevice is used, as the address will be higher than 16 bit.

Related