Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Need help with custom DFU bootloader; Transferring back to main app

Hi all,

I'm working on a custom Bootloader for my nrf52840-based board. The bootloader needs to support DFU from external SPI Flash. So far, my bootloader can read from the external SPI Flash and copies the firmware into the internal Flash. But then when the bootloader calls nrf_bootloader_app_start(), the main application does not start, and it appears that the SOC isn't doing anything.

I've attached my Bootloader project here too. It's based on the 15.0 NRF5 SDK. If you extract the ZIP file into the Examples folder, the project should build.

Here's the output from the Bootloader that I see (some debug output above has been removed):

<info> main: Starting app...
<debug> app: Running nrf_bootloader_app_start with address: 0x00001000
<debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0
<debug> app: running irq table set
<debug> app: After running irq table set

There are a few questions I have, as I'm trying to figure out what's going wrong:

  1. Do I have a valid firmware image in internal Flash?
    1. I believe my main application does successfully write a valid image to SPI, and I've confirmed the SPI image gets copied exactly to the internal Flash. I'm copying the image to address 0x26000, as my application uses the S140 SoftDevice too.
    2. Additionally, I've also built simple blinky applications and flashed those apps onto the board with nrfjprog. When I'm testing without a Bootloader, the blinky app will run correctly. Then I flash in the Bootloader, and the blinky app does not run. I can see my bootloader logs, so I know the bootloader ran, but something goes wrong transferring control back to the main app/softdevice. In this case, I modify the Bootloader to *not* overwrite the firmware image, as the Blinky app is good.
  2. Is my Bootloader correct?
    1. Now here's where I'm not sure. I know I need to be mindful of where I'm writing the Bootloader (to address 0xF8000), and where I'm writing the firmware image (to address 0x26000), but beyond that I'm not sure what else to check. From what I can tell, the Bootloader is trying to pass control back to 0x1000, which should be the start of the SoftDevice. I'm guessing something about my flash_placement.xml or sdk_config.h or other #defines is incorrect.
  3. Is my MBR/SoftDevice correct?
    1. Again, I'm not sure, but I'm also not sure what to check for. When I run an app without the Bootloader, apps that require the SoftDevice, they work. So that points me back to (2) above.

I'm not sure what additional information would be helpful to provide, so just let me know anything that I've missed and I'll gladly provide that info.

I'm thinking I haven't configured some Vector Interrupt Table correctly, or enabled/disabled/configured the SoftDevice properly, or I'm not updating the UICR right, but I'm not sure what to check anymore. Step-debugging the Bootloader all the way through into jump_to_addr() in app_start() in nrf_bootlader_app_start_final.c hasn't given me more insight.

Thank you in advance!

Here's a small list of resources I've read through and used while trying to write this bootloader:

spi_flash_dfu_bootloader.zip

Related