Determine boot slot/offset from application for custom DFU

I am working on enabling MCUboot with direct XIP with revert in NCS v2.5.1.  Right now, I have things pretty well working - I can build an initial confirmed image and boot it (slot 0), then build "update" images and load them using my existing custom DFU application to slot 1. (Documentation on this is here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/device_guides/working_with_nrf/nrf52/developing.html#build-configuration-additions-for-mcuboot-in-the-direct-xip-mode)

I have tested improperly signed images and corrupt images and valid images and in each case it boots to the expected slot.

Now I need to update my custom DFU application to understand which slot I am currently booting from so that I can write into the other slot. So far in my searching I have not found the API to do so.  MCU boot knows this, since it reports to me that it is booting Image 0 from the {primary,secondary} slot.

Once I know which slot I am booting from, I believe I can simply continue using the flash_img_init() API (flash_img_init_id() actually) with the appropriate area_id and I should be golden.

Am I missing something? Are there any changes I would need to make beyond just calling flash_img_init_id()? How can I determine which slot I have booted to from my application?

Parents Reply Children
No Data
Related