-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bug
Description
Describe the bug
To Reproduce
Steps to reproduce the behavior:
- Program bootloader and first slot to borad stm32l151
- Program the second slot
- Reboot,but bootloader can not find second slot
Expected behavior
- Copy the second slot to first slot.
- Upgrade normally
Impact
Can't upgrade by bootloader
Logs and console output
I: Starting bootloader
I: Swap type: none
I: Bootloader chainload address offset: 0xa000
I: Jumping to the first image slot
Environment (please complete the following information):
- OS: Ubuntu18.04
- Toolchain: Zephyr SDK
- Zephyr version: v2.6
Additional context
I debugged mcuboot code.
In function bootutil_buffer_is_erased on file bootutil_public.c
bool bootutil_buffer_is_erased(const struct flash_area *area,
const void *buffer, size_t len)
{
size_t i;
uint8_t *u8b;
uint8_t erased_val;
if (buffer == NULL || len == 0) {
return false;
}
erased_val = flash_area_erased_val(area);
for (i = 0, u8b = (uint8_t *)buffer; i < len; i++) {
if (u8b[i] != erased_val) {
return false;
}
}
return true;
}
The 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.c
static const struct flash_parameters flash_stm32_parameters = {
.write_block_size = FLASH_STM32_WRITE_BLOCK_SIZE,
/* Some SoCs (L0/L1) use an EEPROM under the hood. Distinguish
* between them based on the presence of the PECR register. */
#if defined(FLASH_PECR_ERASE)
.erase_value = 0x0,
#else
.erase_value = 0xff,
#endif
};
If 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?
Metadata
Metadata
Assignees
Labels
bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bug