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

How to jump from Bootloader to Application (nrf51822)

Currently, I am trying to develop nrf51822 (MDBT40) using Nordic SDK v12 (S130). The programmer I used is DAPLink from RedBear.

I am wondering how to make program to jump from bootloader to application code.

This is what I have don:

  • Flash bootloader_secure example as my bootloader program:

    • Go to bootloader_secure/pca10028/armgcc/ and type "make clean; make";

    • Copy the generated .hex file in _build directory;

    • Merge the provided s130_nrf51_2.0.1_softdevice.hex with .hex file using:

      ./mergehex -m s130_nrf51_2.0.1_softdevice.hex nrf51422_xxac.hex -o bootloaderout.hex

    • Drag bootloaderout.hex file into virtual file system created by DAPLink for flashing bootloader;

  • Flash Beacon Example as Application Firmware:

    • Similar to previous steps, get .hex file by making the program;

    • Merge the provided s130_nrf51_2.0.1_softdevice.hex with .hex file using:

      ./mergehex -m s130_nrf51_2.0.1_softdevice.hex nrf51422_xxac.hex -o appout.hex

    • Drag appout.hex file into virtual file system created by DAPLink for flashing application code;

From what I observed, my nrf51822 only execute the beacon app, with the secure DFU bootloader being ignore. However, from what I think, the nrf51822 should execute bootloader code, after which the application code will be executed. This can be explained by following statement in main.c from bootloader:

nrf_bootloader_app_start(MAIN_APPLICATION_START_ADDR); // the MAIN_APPLICATION_START_ADDR looks like the increment of SoftDevice

Can anyone suggest me where the mistake I may make. Thanks!

Parents
  • You need to generate a bootloader settings page, please see Appendix 1 in this blog post.

  • Thanks Bjørn, as your reference, after double checking the hardware specification an datasheet, the nrf51822 chip I used has 32kB RAM 256KB Flash (RedBear Nano V1.5).

    I used the default bootloader linker scripts in Nordic V12 SDK:

    MEMORY
    {
        FLASH (rx) : ORIGIN = 0x3AC00, LENGTH = 0x5000
        RAM (rwx) :  ORIGIN = 0x20002C00, LENGTH = 0x5380
        NOINIT (rwx) :  ORIGIN = 0x20007F80, LENGTH = 0x80
        BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0003FC00, LENGTH = 0x0400
        UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
    }
    

    And here are the linker scripts I used for application code:

    MEMORY
    {
        FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
        RAM (rwx) :  ORIGIN = 0x20002080, LENGTH = 0x1800
    }
    

    Could you please help me confirming whether the parameters are correct? And thank you for helping me out these days!

Reply
  • Thanks Bjørn, as your reference, after double checking the hardware specification an datasheet, the nrf51822 chip I used has 32kB RAM 256KB Flash (RedBear Nano V1.5).

    I used the default bootloader linker scripts in Nordic V12 SDK:

    MEMORY
    {
        FLASH (rx) : ORIGIN = 0x3AC00, LENGTH = 0x5000
        RAM (rwx) :  ORIGIN = 0x20002C00, LENGTH = 0x5380
        NOINIT (rwx) :  ORIGIN = 0x20007F80, LENGTH = 0x80
        BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0003FC00, LENGTH = 0x0400
        UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
    }
    

    And here are the linker scripts I used for application code:

    MEMORY
    {
        FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
        RAM (rwx) :  ORIGIN = 0x20002080, LENGTH = 0x1800
    }
    

    Could you please help me confirming whether the parameters are correct? And thank you for helping me out these days!

Children
No Data
Related