Hi everyone,
I'm having a problem when flashing a new firmware to an STM32L051 on a Raspberry Pi 4. While reading from flash as well as writing small chunks of data to flash works very well, I cannot write a complete firmware image to flash.
In particular,
./st-flash --connect-under-reset --freq=8M write ~/firmware-accel_V5_Release.bin 0x08000000
results in the following (shortened) output:
2021-12-06T11:09:54 INFO common.c: Flash page at addr: 0x0800b080 erased
2021-12-06T11:09:54 INFO common.c: Flash page at addr: 0x0800b100 erased
2021-12-06T11:09:54 INFO common.c: Finished erasing 355 pages of 128 (0x80) bytes
2021-12-06T11:09:54 INFO common.c: Starting Flash write for L0
2021-12-06T11:09:54 INFO common.c: Starting Half page flash write for STM32L core id
2021-12-06T11:09:54 INFO flash_loader.c: Successfully loaded flash loader in sram
2021-12-06T11:09:54 INFO flash_loader.c: Clear DFSR
2021-12-06T11:09:54 ERROR flash_loader.c: Write error
2021-12-06T11:09:54 WARN flash_loader.c: Loader state: R2 0x40 R15 0xFFFFFFFE
2021-12-06T11:09:54 WARN flash_loader.c: MCU state: DHCSR 0x3000B DFSR 0x8 CFSR 0x0 HFSR 0x0
2021-12-06T11:09:54 WARN common.c: l1_stlink_flash_loader_run(0x8000000) failed! == -1
2021-12-06T11:09:54 WARN common.c:
write_half_pages failed == -1
As writing small chunks of data is working, I have disabled writing half pages by removing the following lines in src/common.c:3346:
if (len > pagesize) {
if (stm32l1_write_half_pages(sl, addr, base, len, pagesize) == -1) {
// this may happen on a blank device!
WLOG("\nwrite_half_pages failed == -1\n");
} else {
off = (size_t)(len / pagesize) * pagesize;
}
}
With this fix, writing the firmware to flash is working:
2021-12-06T11:07:54 INFO common.c: Flash page at addr: 0x0800b080 erased
2021-12-06T11:07:54 INFO common.c: Flash page at addr: 0x0800b100 erased
2021-12-06T11:07:54 INFO common.c: Finished erasing 355 pages of 128 (0x80) bytes
2021-12-06T11:07:54 INFO common.c: Starting Flash write for L0
353/354 pages written
2021-12-06T11:08:35 INFO common.c: Starting verification of write complete
2021-12-06T11:08:36 INFO common.c: Flash written and verified! jolly good!
Obviously, not using half-page writing is very slow, but this is fine with me for the moment. Does anyone see any other downside of this workaround? Does it significantly reduce the number of available write cycles of the flash?
My setup:
Best,
Matt
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4