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

Zephyr application reading it's own code partition

Hey guys,

I have a small concern and decided to ask here, as i was not able to found answer neither in zephyr or nrf sdk docs (not even sure which one apply to my question).
Is zephyr application able to read it's own code from slot0? (i.e. by using Zephyr flash_read())

This way I would be able to copy code of currently run from slot0 app to slot1, and then for mcuboot to swap and boot this cloned application right?
I know there is better DFU procedure but I'm just trying to understand if such manual copy is possible.

It looks possible, but isn't there any mechanism blocking such readout from currently run slot? 
How does APPROTECT apply to my question?

Thanks! :)

Parents
  • Hi,

    Is zephyr application able to read it's own code from slot0? (i.e. by using Zephyr flash_read())

    flash_read() is used to read the data from the flash. You should be able to read the content of the flash from your own application.


    This way I would be able to copy code of currently run from slot0 app to slot1, and then for mcuboot to swap and boot this cloned application right?

    When you have copied the content from primary to the secondary slot, then MCUboot would see the same content in both slots. The bootloader supports both swap-based and overwrite-based image upgrades, as explained in bootloader documentation.

    It looks possible, but isn't there any mechanism blocking such readout from currently run slot? 
    How does APPROTECT apply to my question?

    Access port protection (APPROTECT) is a register that is used to prevent read and write access to all CPU registers and memory-mapped addresses. APPROTECT needs to be enabled on the device in order to prevent reading certain memory addresses and it is not related to accessing the flash area from the application.

    Best regards,
    Dejan

Reply
  • Hi,

    Is zephyr application able to read it's own code from slot0? (i.e. by using Zephyr flash_read())

    flash_read() is used to read the data from the flash. You should be able to read the content of the flash from your own application.


    This way I would be able to copy code of currently run from slot0 app to slot1, and then for mcuboot to swap and boot this cloned application right?

    When you have copied the content from primary to the secondary slot, then MCUboot would see the same content in both slots. The bootloader supports both swap-based and overwrite-based image upgrades, as explained in bootloader documentation.

    It looks possible, but isn't there any mechanism blocking such readout from currently run slot? 
    How does APPROTECT apply to my question?

    Access port protection (APPROTECT) is a register that is used to prevent read and write access to all CPU registers and memory-mapped addresses. APPROTECT needs to be enabled on the device in order to prevent reading certain memory addresses and it is not related to accessing the flash area from the application.

    Best regards,
    Dejan

Children
Related