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

How compile and flash SDK 7.1 DFU Bootloader, S110 V7 or S130 using gcc on linux or mac os x ?

Hi All,

anyone was been successful in compiling and flashing SDK 7.1 Bootloader/DFU using arm-gcc on *nix machine ?

If every single hex file needs to be flashed apart, how are the right mem addresses to be used with jlinkexe loadbin command ? (bootloader, softdevice and app addresses) ?

Happy new year!

-c

  • Hi, the load address is the same as the flash start address you'll find in the linker script for your applications. The softdevice should always be loaded to address zero.

    The application start address varies depending on the softdevice used. With the s110 v6-7.x.x the application start address is 0x16000. You can refer to the migration documents located in the softdevice download, or the softdevice specification available at the nRF51 product page for the other softdevices.

    The bootloader in our SDK's starts at 0x3C000, but you may have to reduce this one a bit in order for it to fit in flash. Compiling with the -O3 option in GCC gives a slightly bigger binary compared to the Keil compiler. See this thread on how you can allocate more flash space in needed.

    Note that UICR->BOOTLOADERADDR defines the start address of the bootloader, and it needs to be set, otherwise the bootloader will assert. On windows this is automatically written to by nrfjprog. J-link does on the other hand require some additional steps in order to write to the UICR register:

    J-Link>w4 0x4001E504 0x1                 //NVMC->CONFIG.WEN 
    J-Link>w4 0x10001014 0x0003C000          //UICR->BOOTLOAERADDR
    

    Writing to the UICR register is described in more detail in chapter 6 in nRF51 RM

    Also, this blog post by Erik describes how you can automate the flashing via the makefile.

  • Using GCC you should compile using the -Os flag if you want it to optimise for size and not speed(-03 optimises for speed at the detriment of size)

Related