Closed LQchengdu closed 2 years ago
Can you provide the exact reference of the chip you're using ?
FYI, this was discussed here and here. And thanks to https://github.com/zephyrproject-rtos/zephyr/pull/25947, there should be a way to sort this out. We just need to understand the exact chip memory techno/mapping.
Can you provide the exact reference of the chip you're using ?
stm32l151cba
@LQchengdu According to RM manual, as implemented erase value is 0x00, even on the flash (program memory). cf RM0038.pdf (Unfortunately, there is no explicitly information about this)
**3.4.2 Erasing memory**
[...]
*Program memory page erase*
This operation is used to erase a page in program memory (64 words). To do so:
[...]
• Write 0x0000 0000 to the first word of the program page to erase
[...]
I've been able to verify this on a nucleo_l152re
, using STM32CubeProgrammer: Perform a full chip erase, then read flash memory, erased bytes are 0x00. In Zephyr, same behavior could be observed using samples/drivers/flash_shell
.
If you confirm that the changing erase_value
from 0x00 to 0xFF, then I'd suspect that this confusion is coming from another component of the chain.
In call to bootutil_buffer_is_erased, can you check where buffer
is coming from ?
@erwango After I testing, the erased value is indeed 0,This issue should be caused by other reasons.
@erwango
When using imgtool.py in mcuboot, I did not use the option --erased-val
to set the erased value, and its default value is 0xff, which is wrong for the L0/L1 series.
-R, --erased-val [0|0xff] The value that is read back from erased
flash.
thank you very much for your help.
When using imgtool.py in mcuboot, I did not use the option --erased-val to set the erased value, and its default value is 0xff, which is wrong for the L0/L1 series.
Ok, great I wasn't aware of this option, but this explains the issue you were seeing. Thanks for the heads up. I'm closing this issue for now, don't hesitate to re open or open a new one if needed.
Describe the bug
To Reproduce Steps to reproduce the behavior:
Expected behavior
Impact Can't upgrade by bootloader
Logs and console output
Environment (please complete the following information):
Additional context I debugged mcuboot code. In function
bootutil_buffer_is_erased
on file bootutil_public.cThe value returned by flash_area_erased_val is 0 but actually is 0xff. then I step in
flash_area_erased_val
on file flash_stm32.cIf defined FLASH_PECR_ERASE macro, the erase_value will always zero. That is correct for EEROM, not for FLASH. EEROM and FLASH exist at the same time on stm32l151. I comment the zero value, then the problem solved. So I wonder there is another smart way to fix it?