This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF51822: adjust Bootloader space

Hello, guys.

We are using nRF51822 SoC together with nRF5 v12.3.0 SDK.

According to the nRF51822 memory layout, we have 127KB of space reserved for the Application code and 20KB of space reserved for the Bootloader:

Now, we slightly customized the existing Bootloader code mainly by adding a periodical timer that will feed the Watchdog peripheral (SDKs below v15 do not support automatic watchdog feeding from the Bootloader - link). As a consequence, the size of our Bootloader code is now ~22KB.

Is it safe that we increase the Bootloader area for ~2KB and take this space from the Application area (so that now we have 127-2 = 125KB for the Application code)?

If affirmative, is the line 14 in secure_dfu_gcc_nrf51.ld linker file (located at $(SDK_ROOT)/examples/dfu/bootloader_secure) the only place where we need to adjust the Bootloader size. For example, to change the default:

FLASH (rx) : ORIGIN = 0x3AC00, LENGTH = 0x5000

with

FLASH (rx) : ORIGIN = 0x3A400, LENGTH = 0x5800

Thanks in advance for your time and efforts.

Sincerely,

Bojan.

Parents
  • Hi,

    Is it safe that we increase the Bootloader area for ~2KB and take this space from the Application area (so that now we have 127-2 = 125KB for the Application code)?

    Yes, as long as the rest space is enough for your application. 

    The modification looks fine. Can it work without issue?

    Regards,
    Amanda

  • Hello, .

    Thanks for the reply. It seems it is working fine.

    One more question... I don't initialize the Watchdog timer within the Bootloader, I just feed it periodically with

    nrf_drv_wdt_channel_feed(0);

    This is basically writing a 0x6E524635UL magic number into NRF_WDT->RR[0] register. Do you see any issue with that in the case our main Application does not use (initialize) Watchdog timer?

    Regards,

    Bojan.

  • Hi, 

    nrf_drv_wdt_channel_feed is used to feed the invidual watchdog channel.

    Could you try to initialize the Watchdog timer with nrf_drv_wdt_init?

    -Amanda

  • I can try to initialize watchdog from Bootloader but what will happen in the case it is already initialized from the main Application?

    It can be that WDT channel 0 will be used in the main application and WDT channel 1 in the Bootloader. If I feed channel 1 instead of channel 0 from the Bootloader, that might restart the CPU. What do you think?

  • Hi, 

    The bootloader handles this scenario(starting from SDK v15/v16). It will check if the WDT is already running or not, and feed all channels that are enabled. But if you are using an older SDK version, you need to backport this feature yourself. You can take a look at nrf_bootloader_wdt.c from the newest SDK version to see how you should do this. 

    -Amanda

Reply
  • Hi, 

    The bootloader handles this scenario(starting from SDK v15/v16). It will check if the WDT is already running or not, and feed all channels that are enabled. But if you are using an older SDK version, you need to backport this feature yourself. You can take a look at nrf_bootloader_wdt.c from the newest SDK version to see how you should do this. 

    -Amanda

Children
No Data
Related