From: Zixian Z. <syc...@gm...> - 2025-07-21 10:13:05
|
Hi Paul: On Fri, Jul 18, 2025 at 05:24:11PM +0000, Paul Rothhammer-Ruiz wrote: > Hello OpenOCD developers, > > I am using OpenOCD version 0.12.0 on a windows machine (openOCD is running on MSYS2). I have successfully used openOCD for years. Recently when using an STM32F334 (64KB flash size), I am occasionally getting errors when flashing. The error message is: "Error: error writing to flash at address 0x08000000 at offset 0x00000000." This error seems to be binary file dependent. Flashing will immediately work again on openOCD if I switch over to flashing a "known good" binary file. In fact, I can often get a problematic binary file to flash successfully if I delete random lines of code in the file. > I would think the issue is the size of the binary file, however, I am able to successfully flash the "bad" binary file using the STM32CubeProgrammer. I confirmed this by doing a simple LED blink program; it would not flash with OpenOCD but LEDs did blink once I tried with STM32CubeProgrammer. When using the size utility (arm-none-eabi-size) I get text=12652, data=120, bss=1696, dec=14468. I should have plenty of space left on the STM32F334. I am using default the default linker script generated by the STM32CubeProgrammer. > When I enable a verbose output on OpenOCD, I see the following error message: > "Error: 596 2811 core.c:96 flash_driver_write(): error writing to flash at address 0x08000000 at offset 0x00000000 > Debug: 597 2815 command.c:545 run_command(): Command 'flash write_image' failed with error code -4" > Please advise how I can best troubleshoot this issue. I rely on OpenOCD for flashing and debugging. > Thank you in advance! > > Regards, > Paul I have similar issue before when I was using the STM32H755ZI-Q with dual cores. The most possible reason I can guess is "You LOCKED your flash accidentally". If I remembered correctly, flash memory on STM32 might trap into a "broken state" when you did something "bad". According to STM32H755ZI-Q user guide, STM32CubeProgrammer can help to erase the broken flash sector. I have try it and after that I find a similar feature in OpenOCD, you can use "-c help" option and search keyword "flash" on your board. For your reference, I used the similar commands like following one: openocd -f interface/stlink.cfg -f target/stm32h7x_dual_bank.cfg -c init -c "flash erase_sector 0 0 last" I not a develop of OpenOCD, Sorry if I was misleading. Best regards, Zixian |