nRF5340 non-simultaneous netcore updates with external QSPI

Development Environment: VS Code on Windows 10, SDK: 2.0.0, HW: nRF5340 Development Kit

I am trying to perform just a network core update on the nRF5340 DK based off of the smp_svr sample where the secondary slot for incoming updates is on an external QSPI. Using the Device Manager app, I can perform application core updates without issue, but when doing a network core update, MCUBoot seems to interpret the incoming image as an application core update no matter what. Which causes a second boot cycle as it swaps the images back.

I have an overlay both top level and the child images containing:

And the following config files:
prj.conf:


child_image/mcuboot.conf:


Am I missing something here? I do notice when I debug to MCUBoot's loader.c line 982, where the vector table of the image is grabbed, the loaded data seems to be from the internal flash rather than the external memory. I have gone through the thread here nRF5340 Netcore firmware update using external flash - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com) but my behavior isn't lining up and discussion is all on pre 2.0.0 SDKs. I tried UPGRADE_ONLY but it seems to do the same thing but not be able to revert back and so end up in a boot loop. As said in the title I have no need for simultaneous updates, I am just trying to perform core updates one at a time from the external QSPI.

Attached at the bottom is my minimal reproduction based off of smp_svr. Would greatly appreciate any assistance or pointers on this.

Regards,

D Miller

smp_svr_ext_qspi.zip

Parents
  • Check out this ticket  Busfault when MCUboot reads Network core secondary image header in external flash 

    Try applying this patch https://github.com/nrfconnect/sdk-mcuboot/pull/197/commits/b628d6e238bb15eae06a9582fb19b00ea4990e13 and see if you're able to update the netcore using external flash.

    Best regards,

    Simon 

  • I have applied the changes in that commit in the pull request and then tried the removal of the code block also suggested, both to no avail, the system still attempts all updates like they are for the application core.

    I see the intention is to use nrf53_hooks.c to trigger a net core update but those hooks are only called in UPGRADE_ONLY configurations and I wish to retain app core reversion. It seems like the code block that was suggested to be removed in the other ticket is supposed to handle the "one core at a time" netcore updates but the flash simulator in RAM just isn't getting set up to pull the data from the external flash like it is in hooks.

    So, I applied the patch like before which correctly runs the header check, but instead of removing the further down lines as the other thread suggested, I turned them into something closer to what is done in nrf53_hooks.c:

    I also added the needed includes at the top:

    No other changes to the SDK or project. With this, I can now perform net and app core updates one at a time from a single secondary slot on the external qspi in a way that still allows for reversion of the application core.

    I don't feel like I'm doing everything correctly here, especially with the use of the flash simulator, but I can do my update scheme. I've uploaded my loader.c, otherwise it is v2.0.0 SDK.

    loader.c

  • Did you remember to enable CONFIG_BOOT_IMAGE_ACCESS_HOOKS?

    Then add CONFIG_BOOT_IMAGE_ACCESS_HOOKS_FILE to your prj.conf file and set it to your custom hook file. That is better than trying to modify loader.c. By default the hook file modules/mcuboot/hooks/nrf53_hooks.c is used: https://github.com/nrfconnect/sdk-nrf/blob/v2.0.0/modules/mcuboot/boot/zephyr/Kconfig#L95.

    Best regards,

    Simon

  • (moved my reply up here)

    Hello,

    Yes, I did try with and without CONFIG_BOOT_IMAGE_ACCESS_HOOKS. This required I do the whole CONFIG_UPDATEABLE_IMAGE_NUMBER=2 and CONFIG_BOOT_UPGRADE_ONLY=y to get running (the depends for the KConfig on that flag seem to confirm) as there is code in the hooks that assume >1 slots on the secondary and the partitions only seem to be correctly generated with that configuration. But we are not wanting upgrade only updates.

    The net core updates in nrf53_hooks.c are hooked to `boot_copy_region_post_hook` and `boot_serial_uploaded_hook`. The first is called in loader.c `boot_copy_image` which is only used in  `MCUBOOT_OVERWRITE_ONLY` configurations. And the latter is used for serial recovery.

    In the github patch conversation ([nrf noup] loader: Fix reading reset addr to support ext flash by chrta · Pull Request #197 · nrfconnect/sdk-mcuboot · GitHub), there seems to be some discussion relating to this specifically where hooks do not cover the functionality we are seeking.

  • D Miller said:
    Yes, I did try with and without CONFIG_BOOT_IMAGE_ACCESS_HOOKS. This required I do the whole CONFIG_UPDATEABLE_IMAGE_NUMBER=2 and CONFIG_BOOT_UPGRADE_ONLY=y to get running (the depends for the KConfig on that flag seem to confirm) as there is code in the hooks that assume >1 slots on the secondary and the partitions only seem to be correctly generated with that configuration. But we are not wanting upgrade only updates.

    I was able to enable CONFIG_BOOT_IMAGE_ACCESS_HOOKS, I simply set CONFIG_BOOT_IMAGE_ACCESS_HOOKS=y inside smp_svr\child_image\mcuboot.conf (should be set in mcuboot sample, not main application). However, I did get some errors, but that is not related to the Kconfigs, but the nrf53_hooks.c file. The nrf53_hooks.c file tries to access the primary_1 partition, which is not present in your case since you're not doing multi-image updates. I then modified nrf\modules\mcuboot\hooks\nrf53_hooks.c like shown below and was able to build the sample:

    Then I could see that CONFIG_BOOT_IMAGE_ACCESS_HOOKS was set to y and that CONFIG_BOOT_IMAGE_ACCESS_HOOKS_FILE was equal to "nrf/modules/mcuboot/hooks/nrf53_hooks.c" in smp_svr\build\mcuboot\zephyr\.config.

    Be aware that the above file is not meant to work, I made it just so the code would compile, and it can be a starting point for creating your own custom hook file.

    Of course the proper way would be to add your own file to nrf/modules/mcuboot/hooks/ and set CONFIG_BOOT_IMAGE_ACCESS_HOOKS_FILE (in smp_svr\child_image\mcuboot.conf) accordingly.

    D Miller said:
    there seems to be some discussion relating to this specifically where hooks do not cover the functionality we are seeking.

    Yes, that is true. The nrf53_hooks.c file is tailored towards multi-image, so it needs to be modified to your need, non simultaneous netcore/appcore updates.

    I did try to play around and add the changes you made to loader.c into the hooks file, but wasn't able to make it work (the hooks stuff are new to me and I don't have complete control of how it works). I will see if I can get it to work the next days. If you succeed if would be nice if you could share the solution, as I'm sure many other customer will benefit from it as well.

    Best regards,

    Simon

  • Hello Miller,

    What is the current state on this? Were you able to implement the changes to a hook file? Unfortunately, I haven't gotten time myself to do it yet. I will be gone for the next two weeks, and my colleague Sigurd will watch the case in the meanwhile (he will be gone until 2 of Aug.). 

    Best regards,

    Simon

  • Hello,

    The tips to get the hooks file started were useful. I am needing to do a little more testing to confirm but I might have a hooks file way to perform this update scheme. Have done a net core update.

    Will know more by the end of the week but I am no longer stuck.

    Thanks,

    Derrick

Reply
  • Hello,

    The tips to get the hooks file started were useful. I am needing to do a little more testing to confirm but I might have a hooks file way to perform this update scheme. Have done a net core update.

    Will know more by the end of the week but I am no longer stuck.

    Thanks,

    Derrick

Children
No Data