zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.71k stars 6.54k forks source link

mcuboot: Application fails to access QSPI flash after image swap #37501

Closed hjuul closed 2 years ago

hjuul commented 3 years ago

My Zephyr application uses QSPI flash. I'm using MCUboot to boot the application.

On normal boot my application can access the QSPI flash as expected.

But on the first boot after an image swap the QSPI driver fails when reading serial flash discovery parameters:

[00:00:05.001,000] <err> flash_stm32_qspi: 2: Failed to send QSPI instruction
[00:00:05.001,000] <inf> flash_stm32_qspi: ra cmd: 0x5a
[00:00:05.001,000] <err> flash_stm32_qspi: SFDP read failed: -5

MCUboot is configured to use internal flash only (slot0, slot1 and swap partitions are all in internal flash). But MCUboot has QSPI support because it finds the &quadspi entry in my dts file.

A few interesting observations:

Environment

Additional context It fails both for BOOT_SWAP_TYPE_TEST and BOOT_SWAP_TYPE_REVERT.

If I remove lines 542-667 here and attempt a firmware update the images won't be swapped, but my application will start with a functioning QSPI flash. This isolates the problem to these lines and their subroutines, and the bug is likely to be found in one of the #ifdef MCUBOOT_ENC_IMAGES blocks there. But that's as far as I got.

github-actions[bot] commented 2 years ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.