Bootloader with Custom DFU

We have an existing DFU to deliver the pending firmware in flash.  I need to develop a custom bootloader that copies the pending firmware and activates it.  I am close but getting stuck. 

Issue:

- When app_activate() is called, it just skips over it.  Even when I add __root to it.  The function exists in the .map file, but I can't enter it in debugger.

Specs:

- nRF52840, SDK15.0.0, SD140, using IAR compiler

My memory layout is

  

My Steps to processing the hex files

1) To fake a pending firmware update, I offset the main application to place it in Bank-1:

- srec_cat.exe app.hex -Intel -offset 0x5F000 -o appOffset.hex -Intel

2) To create the bootloader settings, I use the nrfutil:

- `nrfutil.exe” settings generate --family NRF52840 --application appOffset.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex

3) I use the NRF programmer to merge and program the MBR/SoftDevices, Pending FW, Bootloader, and Bootloader Settings

Debugging

I'm trying to reuse as much of the example bootloader.  

When debugging, I have to manually write to the s_dfu_settings.  I assume this would typically be set by the DFU.

- When I created the bootloader settings, I used an offset copy of the app.  So here, I copied the info from Bank 0 to Bank 1 to tell the firmware that there is a pending update to handle.

This works in getting me to app_activate(), the function that copies the pending firmware to the target address (0x26000).  However, in the debugger, it just skips over this function.  I checked the map file and the function is linked.  What am I doing wrong?

I am manually setting s_dfu_settings.  Can I write to this in the application?  Is there a preferred way to do this?

Parents
  •  Thank you for your help! Is there a way to create bootloader settings for bank1 using the NRF Utilities?  Our application requires a custom transport layer and I would like to create firmware offset for bank1 along with bootloader settings for bank1.  I understand this is usually handled in the DFU transport layer.

  • As the nRF5 SDK bootloader only supports booting applications in slot 0 which start right after the SoftDevice (or MBR if no SoftDevice is used), there is also no support in the accompanying tools like nrfutil for other configurations. That said, the you can clone pc-nrfutil and modify it to your needs for your custom bootloader / DFU solution.

Reply
  • As the nRF5 SDK bootloader only supports booting applications in slot 0 which start right after the SoftDevice (or MBR if no SoftDevice is used), there is also no support in the accompanying tools like nrfutil for other configurations. That said, the you can clone pc-nrfutil and modify it to your needs for your custom bootloader / DFU solution.

Children
  •  What are your thoughts on IAR compiling binary files that are not page aligned? Should I be concerned?  Is there a way to force it to be page aligned?

  • I am no IAR expert, but as long as you specify the start of a page as the application start address (see under 7. Change start addresses for the IAR here), then that should work (?).

    Regarding if you should be concerned I cannot recall ever dealing with an application that was not page aligned, but at the same time, I cannot immediately think of a reason why it should cause problems when using a bootloader (the address  should be word aligned, though).