west flash --recover on nRF54L15 erases mcuboot after flashing

Hi Nordic Support!

I'm working on a custom board using the nRF54L15. I'm utilizing both mcuboot and the flpr core, so in total I have three domains to flash. This works fine when I run west flash. All three images get flashed. But sometimes I need to run west flash --recover (performing a DFU seems to lock the RRAM). In these cases I get the following log in my shell:

(ncs) user@computer% west flash --recover                           
-- west flash: rebuilding
[0/11] Performing build step for 'app'
ninja: no work to do.
[1/11] Performing build step for 'flpr'
ninja: no work to do.
[4/11] Performing build step for 'mcuboot'
ninja: no work to do.
[10/10] Completed 'mcuboot'
WARNING: Specifying runner options for multiple domains is experimental.
If problems are experienced, please specify a single domain using '--domain <domain>'
-- west flash: using runner nrfutil
-- runners.nrfutil: reset after flashing requested
There are multiple boards connected.
1. 000821009665
2. 000960098736
3. 001057757641
Please select one with desired serial number (1-3): 3
-- runners.nrfutil: Recovering and erasing all flash memory.
-- runners.nrfutil: Flashing file: <project-dir>/build/mcuboot/zephyr/zephyr.hex
-- runners.nrfutil: Recover
-- runners.nrfutil: Programming image
-- runners.nrfutil: Verifying image
-- runners.nrfutil: Reset
-- runners.nrfutil: Board(s) with serial number(s) 1057757641 flashed successfully.
-- west flash: using runner nrfutil
-- runners.nrfutil: reset after flashing requested
-- runners.nrfutil: Recovering and erasing all flash memory.
-- runners.nrfutil: Flashing file: <project-dir>/build/flpr/zephyr/zephyr.hex
-- runners.nrfutil: Recover
-- runners.nrfutil: Programming image
-- runners.nrfutil: Verifying image
-- runners.nrfutil: Reset
-- runners.nrfutil: Board(s) with serial number(s) 1057757641 flashed successfully.
-- west flash: using runner nrfutil
-- runners.nrfutil: reset after flashing requested
-- runners.nrfutil: Recovering and erasing all flash memory.
-- runners.nrfutil: Flashing file: <project-dir>/build/app/zephyr/zephyr.signed.hex
-- runners.nrfutil: Recover
-- runners.nrfutil: Programming image
-- runners.nrfutil: Verifying image
-- runners.nrfutil: Reset
-- runners.nrfutil: Board(s) with serial number(s) 1057757641 flashed successfully.

When the mcuboot image is done flashing, the device immediately starts running, and mcuboot prints E: unable to find bootable image. This is understandable, since the cpuapp image hasn't been flashed yet (although it would be nice if the device only booted after it was completely flashed).

After this, the device does nothing. Resetting with nrfutil does nothing, reset button does nothing etc. I think this is due to west flash --recover performing the --recover routine for each domain/image. So after being flashed, the mcuboot image is erased when cpuapp is flashed, which is again erased when cpuflpr is flashed. You can see this happening in the log.

The best workaround I have right now is to run west flash --recover && west flash, or alternatively nrfutil device recover && west flash (but then I have to write the debugger serial number). I think I didn't use to have problems with running west flash --recover. The issue started showing up when I began working on different revisions of my custom board.

Is there any way to tell west flash to only recover once?

Best Regards,
Fridtjof

  • The issue stemmed from adding board revisions to my custom board. This meant that instead of building for plank/nrf54l15/cpuapp I was building for [email protected]/nrf54l15/cpuapp, which does not match the entries in my board.yml which specify what "runners" should only be run once.

    To solve this I added some regex to the runner board names, appending the board name with @?.*. (For those not familiar with regex, this means an optional @ followed by zero or more of any character.)

    I changed this section of my board.yml:

    runners:
      run_once:
        '--recover':
          - runners:
              - nrfjprog
              - nrfutil
            run: first
            groups:
              - boards:
                  - plank/nrf54l15/cpuapp
                  - plank/nrf54l15/cpuflpr
        '--erase':
          - runners:
              - nrfjprog
              - jlink
              - nrfutil
            run: first
            groups:
              - boards:
                  - plank/nrf54l15/cpuapp
                  - plank/nrf54l15/cpuflpr
        '--reset':
          - runners:
              - nrfjprog
              - jlink
              - nrfutil
            run: last
            groups:
              - boards:
                  - plank/nrf54l15/cpuapp
                  - plank/nrf54l15/cpuflpr
    

    To this:

    runners:
      run_once:
        '--recover':
          - runners:
              - nrfjprog
              - nrfutil
            run: first
            groups:
              - boards:
                  - plank@?.*/nrf54l15/cpuapp
                  - plank@?.*/nrf54l15/cpuflpr
        '--erase':
          - runners:
              - nrfjprog
              - jlink
              - nrfutil
            run: first
            groups:
              - boards:
                  - plank@?.*/nrf54l15/cpuapp
                  - plank@?.*/nrf54l15/cpuflpr
        '--reset':
          - runners:
              - nrfjprog
              - jlink
              - nrfutil
            run: last
            groups:
              - boards:
                  - plank@?.*/nrf54l15/cpuapp
                  - plank@?.*/nrf54l15/cpuflpr

    Now west flash understands that it should run recover/erase only once at the start and reset once at the end.

Related