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

Switching between apps with dual bank

Hi,

let's say I program flash with SD, Booloader and merged App1&Ap2 images. I need to switch application (only once, after some self tests) using some command from application.

What would be the best way to do it?

Preferably the App2 image is copied over App1, but if not - that's also acceptable. In both cases DFU must be working after switch.

thanks

  • Hi Oskar, in which order would the applications run? Will the device start Application 1, then do some testing and then switch to Application 2? Could you describe your use-case and why it is necessary to have two applications?

  • Bjoern,

    I wouldn't like to go into details here, but in general we need different sets of features during production, which are not needed in final software. But we don't want to do programming twice - it takes time. Since there is a bootloader it should be pretty obvious to switch applications.

    I already know that this is not really supported operation and I'd need to add some libs from bootloader to do it, but any hint would be helpful.

  • I have made an example for the nRF51 DK, where Application 1(blinky) turns on led 1 and 2, waits for 5 seconds and then branches to Application 2(blinky_2), which turns on led 3 and 4.

    Application 1 starts at 0x18000 and ends at 0x19000 and Application 2 starts at 0x19000 and ends at 0x40000.

    The two Keil projects are attached. Please note that this is for SDK v9.0, but it should be easy to migrate it to SDK v11. Unpack the zips to SDK-folder/examples/peripheral.

    Attachments:

    blinky.zip

    blinky_2.zip

  • Bjoern, I must say I can only trust that it works. We have a full blown app with SD and secure bootloader, preserved data app etc. Doing it this way (assembler?!) would be highly inconvienient if the rest of the code relays strictly on SDK(+HK) functionalities. Is there really no way to merge two apps and use bootloader settings to start with one and switch from to another? I can imagine mixing of direct flash access and booloader API, but assembler in the way you suggest just won't work in longer perspective. Thanks anyway.

  • @oskar-mezyk: The function written in assembly, bootloader_util_reset(), is the same function that is used to branch from the bootloader to the application in our production-ready bootloader(both legacy and Secure).This is as far as I know the only way to safely branch to another application/bootloader at runtime.

Related