-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MCUBoot swap using scratch bricks after power cut on STM32H5xx using external flash NOR for update storage #2217
Comments
Assuming your part contains ECC on the flash memory which results in a fault if you read from memory which was partially written and is corrupt |
Hi, and thank you for your prompt response. Based on the datasheet, the external flash memory I’m using (AT45DB321E) doesn't appear to have an ECC mechanism. Could you further clarify the concept you described? |
your internal flash does |
The internal uC flash has ECC protection as you correctly said. |
try reading all flash pages in a loop and seeing what happens, I would guess you will hit the same fault on one of them, that page would be the partially written one during move/swap |
@MBorto On an H7 MCU, this might have been an ECC-related issue as @nordicjm said, unfortunately on the H5, according to RM0481 §7.9.10, an NMI is generated on ECC error, not a bus fault as for the H7:
When you say:
Do you mean you were able to confirm that after these lines mcuboot/boot/bootutil/src/loader.c Lines 1737 to 1740 in 7330df7
Also, FYI I recently fixed two bugs with the swap-scratch that apply to your configuration:
I doubt they are related to the issue you described, but I guess you will need those two fixes anyway. If the issue is easily reproducible, you might want give a try with at least bbd0ee1 just to be sure. The latter MR won't have any effect unless you have a very large image in one of the slots. |
Thank @taltenbach for the feedback!! When you said that NMI is generated after ECC issue is correct. I can confirm that is after the line 1740. To copy_size is assigned the value 0xFFFFFFFF. The BusFault is generated after, when the swap_run function is called, precisely when calling the method boot_im_sector_size(...) of the first if condition: How I can integrate in easy way your fixes into Zephyr enviroement?
I've tried the following way, but it gives me compile error:
|
@MBorto Thanks for those details, I tried to reproduce your issue in the simulator and in fact with your configuration and without applying at least the first fix I mentioned, I was not even able to do a simple upgrade unless using very small images (< 90 KiB). But I might have done something wrong. Are you able to do an upgrade if you're not resetting the device in the middle of the upgrade? And in case you reset the device, does the issue occurs consistently or is it reproducible only if you reset at a very precise time?
I will create tomorrow a branch with my fixes based on the MCUboot version used by Zephyr 3.6.0 :) |
Thank you @taltenbach for your availability !! |
I am developing a firmware update system for a project that includes an STM32H5xx microcontroller running Zephyr and an external NOR flash memory connected via the SPI interface.
The internal flash of the microcontroller is 2MB, divided into 128 sectors, each 8KB in size. The external NOR flash has a capacity of 4MB, divided into 8192 pages of 512 bytes each.
Given the differences between the two memory structures, I have used the swap mechanism using the scratch partition.
An area of non-init SRAM is used for sharing measured boot data between bootloader and mainapp.
Here is the current DTS configuration:
Downloading the firmware image to the external flash works fine.
However, when a power cut occurs during the image swap, MCUBoot encounters a BusFault on the next reboot. This seems to be due to an invalid value (0xFFFFFFFF) in the swap_size field, causing the BusFault in the swap_run(...) function in the swap_scratch.c file.
Here are the MCUBoot configuration variables I’m using with Zephyr sysbuild:
Has anyone encountered this behavior before?
Can someone provide support with this issue?
Thank you in advance for your assistance.
The text was updated successfully, but these errors were encountered: