zephyr: openocd: Can't flash on various STM32 boards
Describe the bug Since SDK0.15.0, a flashing issue using openocd appears in specific conditions on various STM32 boards.
Impacted boards identified so far (likely more to come):
- disco_l475_iot1
- nucleo_f429zi
- stm32f3_disco
- stm32f429i_disc1
Note: Potentially applies to non STM32 boards, due to the nature of the issue.
Issues could be seen when trying to flash just after the board is plugged-in. Following flashing attempts work seamlessly (reason it was not seen on test bench)
Workarounds Several workarounds are possible:
- Run the flash command twice
- Press reset button at the beginning of flash sequence
- Use other runners (stm32cubeprorgammer, pyocd)
To Reproduce Steps to reproduce the behavior: Build and try to flash any of these boards using Zephyr SDK 0.15.0
Expected behavior Flashing using openocd works seamlessly, every time.
Impact Annoyance, widely spread. Could disturb new users.
Environment (please complete the following information):
- OS: (e.g. Linux, MacOS, Windows): Linux
- Toolchain (e.g Zephyr SDK, …): Zephyr SDK 0.15.0
- Commit SHA or Version used: v3.2-rc1
Additional context
Open On-Chip Debugger 0.11.0+dev-00724-g42b6471c1 (2022-08-17-18:23)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : clock speed 500 kHz
Info : STLINK V2J35M26 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.225790
Warn : target stm32l4x.cpu examination failed
Info : starting gdb server for stm32l4x.cpu on 3333
Info : Listening on port 3333 for gdb connections
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32l4x.cpu hla_target little stm32l4x.cpu unknown
Info : Unable to match requested speed 500 kHz, using 480 kHz
Info : Unable to match requested speed 500 kHz, using 480 kHz
TARGET: stm32l4x.cpu - Not halted
FATAL ERROR: command exited with status 1: <redacted>/sdk/zephyr-sdk-0.15.0/sysroots/x86_64-pokysdk-linux/usr/bin/openocd -s <redacted>/zephyrproject/zephyr/boards/arm/disco_l475_iot1/support -s <redacted>/sdk/zephyr-sdk-0.15.0/sysroots/x86_64-pokysdk-linux/usr/share/openocd/scripts -f <redacted>/zephyrproject/zephyr/boards/arm/disco_l475_iot1/support/openocd.cfg '-c init' '-c targets' -c 'reset halt' -c 'flash write_image erase build/disco_l475_iot1/zephyr/zephyr.hex' -c 'reset halt' -c 'verify_image build/disco_l475_iot1/zephyr/zephyr.hex' -c 'reset run' -c shutdown
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (21 by maintainers)
Commits related to this issue
- Revert "target: reset target examined flag if target::examine() fails" This reverts commit 98d9f1168cbdc59e4c2c0b1f01b225a4df9ad98a because it causes flashing issues with some Zephyr targets (notably... — committed to zephyrproject-rtos/openocd by stephanosio 2 years ago
- Revert "target: reset target examined flag if target::examine() fails" This reverts commit 98d9f1168cbdc59e4c2c0b1f01b225a4df9ad98a because it causes flashing issues with some Zephyr targets (notably... — committed to zephyrproject-rtos/openocd by stephanosio 2 years ago
- boards: nucleo_f103rb: Fix openocd configuration With latest version of openocd delivered in Zephyr SDK 0.15.0, a new configuration is required to flash and debug this board: "reset_config connect_as... — committed to erwango/zephyr by erwango 2 years ago
- boards: nucleo_f103rb: Fix openocd configuration With latest version of openocd delivered in Zephyr SDK 0.15.0, a new configuration is required to flash and debug this board: "reset_config connect_as... — committed to zephyrproject-rtos/zephyr by erwango 2 years ago
- Revert "target: reset target examined flag if target::examine() fails" This reverts commit 98d9f1168cbdc59e4c2c0b1f01b225a4df9ad98a because it causes flashing issues with some Zephyr targets (notably... — committed to katyo/openocd by stephanosio 2 years ago
- Revert "target: reset target examined flag if target::examine() fails" This reverts commit 98d9f1168cbdc59e4c2c0b1f01b225a4df9ad98a because it causes flashing issues with some Zephyr targets (notably... — committed to katyo/openocd by stephanosio 2 years ago
This should be now fixed with the latest SDK.
You’re right! And that might be the easiest one in most cases. Updating the description.
Yes. If I hold down reset, run west flash, then release reset after openocd is running, it works.
I will look into reverting https://github.com/zephyrproject-rtos/openocd/commit/98d9f1168cbdc59e4c2c0b1f01b225a4df9ad98a in the upcoming Zephyr SDK 0.15.1, unless a proper fix comes before that.