Skip to content

Sysbuild-configured project using west flash --recover will wrongly recover (and reset) the MCU each time it flashes an image #50421

@nordicjm

Description

@nordicjm

Describe the bug
Issue noticed whilst testing #49552
It seems that with a sysbuild project, with multiple images e.g. sample application and mcuboot, using west flash --recover will wrongly have the west flash runner recover the module for every instance it is used, which results in a non-working board. It also resets the board after each programming cycle, which can cause issues if e.g. readback protection is enabled or if an application needs something else to start, in which case the following programming cycles will fail.
Output:

west flash --recover
WARNING: can't find the zephyr repository
 - no --zephyr-base given
 - ZEPHYR_BASE is unset
 - west config contains no zephyr.base setting
 - no manifest project has name or path "zephyr"

 If this isn't a Zephyr workspace, you can   silence this warning with something like this:
   west config zephyr.base not-using-zephyr
-- west flash: rebuilding
[0/9] Performing build step for 'test_mcuboot'
ninja: no work to do.
[1/9] Performing build step for 'swapped_app'
ninja: no work to do.
[3/9] Performing build step for 'mcuboot'
ninja: no work to do.
[9/9] Completed 'mcuboot'
-- west flash: using runner nrfjprog
-- runners.nrfjprog: mass erase requested
Using board 483128317
-- runners.nrfjprog: Recovering and erasing flash memory for both the network and application cores.
Recovering device. This operation might take 30s.
Writing image to disable ap protect.
Erasing user code and UICR flash areas.
Recovering device. This operation might take 30s.
Writing image to disable ap protect.
Erasing user code and UICR flash areas.
-- runners.nrfjprog: Flashing file: /tmp/bb/zephyr/twister-out/bl5340_dvk_cpuapp/tests/boot/test_mcuboot/boot.mcuboot/mcuboot/zephyr/z
ephyr.hex
Parsing image file.
Verifying programming.
Verified OK.
Applying pin reset.
-- runners.nrfjprog: Board with serial number 483128317 flashed successfully.
-- west flash: using runner nrfjprog
Using board 483128317
-- runners.nrfjprog: Recovering and erasing flash memory for both the network and application cores.
Recovering device. This operation might take 30s.
Writing image to disable ap protect.
Erasing user code and UICR flash areas.
Recovering device. This operation might take 30s.
Writing image to disable ap protect.
Erasing user code and UICR flash areas.
-- runners.nrfjprog: Flashing file: /tmp/bb/zephyr/twister-out/bl5340_dvk_cpuapp/tests/boot/test_mcuboot/boot.mcuboot/swapped_app/zeph
yr/zephyr.signed.hex
Parsing image file.
Verifying programming.
Verified OK.
Applying pin reset.
-- runners.nrfjprog: Board with serial number 483128317 flashed successfully.
-- west flash: using runner nrfjprog
Using board 483128317
-- runners.nrfjprog: Recovering and erasing flash memory for both the network and application cores.
Recovering device. This operation might take 30s.
Writing image to disable ap protect.
Erasing user code and UICR flash areas.
Recovering device. This operation might take 30s.
Writing image to disable ap protect.
Erasing user code and UICR flash areas.
-- runners.nrfjprog: Flashing file: /tmp/bb/zephyr/twister-out/bl5340_dvk_cpuapp/tests/boot/test_mcuboot/boot.mcuboot/test_mcuboot/zep
hyr/zephyr.signed.hex
Parsing image file.
Verifying programming.
Verified OK.
Applying pin reset.
-- runners.nrfjprog: Board with serial number 483128317 flashed successfully.

To Reproduce
Build PR sample application for an nrf5340-based board and manually run west flash --recover in the build directory

Expected behavior
One recovery - at the start of the programming process.
One reset - after all images have been programmed.

Impact
Showstopper

Environment (please complete the following information):

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementChanges/Updates/Additions to existing featuresNeeds reviewThis PR needs attention from Zephyr's maintainers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions