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

Porting S130 bootloader to NRF51822

Hello,

I'm pretty much new to NRF development and I'm having lots of questions trying to get a custom board to work with the provided BLE bootloader example in SDK 11.

I'm using GCC and most of the answers in this forum are using Keil I think. I see that I need to change the IROM and IRAM settings to match the ones for nrf51822_xxaa, but I have no idea where to do that. If somebody could point me out the basics I would be extremely grateful!

  • QFAA has 16k less RAM than the QFAC, so normally you need to change the RAM size setting in the linker and reduce it by 0x4000

    However I don't know what value IRAM is in your linker file.

  • This is what I see in the linker file (some comments removed):

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x3C000, LENGTH = 0x3C00
    
      /** RAM Region for bootloader. This setting is suitable when used with s110, s120, s130, s310. */
      RAM (rwx) :  ORIGIN = 0x20002C00, LENGTH = 0x5380
    
      /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
       *  from application to bootloader when using buttonluss DFU OTA. 
       */
      NOINIT (rwx) :  ORIGIN = 0x20007F80, LENGTH = 0x80
      BOOTLOADER_SETTINGS (rw) : ORIGIN = 0x0003FC00, LENGTH = 0x0400
      UICR_BOOTLOADER (r) : ORIGIN = 0x10001014, LENGTH = 0x04
    }
    
  • As Roger said, you need to adjust the linker settings to limit RAM usage to the 16K boundary. The linker file (*.ld) is located in the bootloader directory and can be changed as follows:

    /** RAM Region for bootloader. This setting is suitable when used with s110, s120, s130, s310. */
    RAM (rwx) :  ORIGIN = 0x20002C00, LENGTH = 0x1380
    
    /** Location of non initialized RAM. Non initialized RAM is used for exchanging bond information
    *  from application to bootloader when using buttonluss DFU OTA. 
    */
    NOINIT (rwx) :  ORIGIN = 0x20003F80, LENGTH = 0x80
    
  • Ok, thanks. I did that but I still cannot download the .bin to the board. It just gets stuck there... Any idea what could be happening?

  • Please try to call 'nrfjprog --readregs' while the bootloader is running and post the output in order to confirm that the hardfault exception hasn't been triggered.

    Also, does your board have a LF crystal like the dev boards? If not you will need to change the clock source to the internal RC in the stack init routine.

Related