On Thu, Apr 20, 2023 at 02:14:24PM -0000, Kristof Mulier wrote: > (Paul Fertser) Have you tried using stlink-dap.cfg instead? > > Yes, we tried that today as well. No effect.
Can you please add -d3 log with stlink-dap attempt? Another idea is to try using "reset halt; flash write_image erase ..." instead to see if it might be higher frequency or something else in the reset-init handler that makes the difference. Another thing to try would be using an external swd adapter. --- ** [tickets:#392] Regression in OpenOCD 0.11.0 and 0.12.0** **Status:** new **Milestone:** 0.11.0 **Created:** Mon Apr 17, 2023 11:47 AM UTC by Kristof Mulier **Last Updated:** Thu Apr 20, 2023 02:14 PM UTC **Owner:** nobody We discovered a regression in `OpenOCD 0.11.0` and `0.12.0`. Some `.elf` files can be flashed with `OpenOCD 0.10.0` while versions `0.11.0` and `0.12.0` are unable to flash the same `.elf` file. Below I'll explain everything you need to know, to reproduce the problem. --- # 1. System and OpenOCD builds I'm working on a Windows 11 laptop. The OpenOCDs I'm using are all downloaded from Liviu Ionescu's xPack project: https://github.com/xpack-dev-tools/openocd-xpack/releases When I refer to `OpenOCD 0.10.0`, `0.11.0` and `0.12.0`, I actualy mean this: - **`OpenOCD 0.10.0`** Downloaded as: `xpack-openocd-0.10.0-15-win32-x64.zip` The `--version` output is: ``` xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev (2020-10-13-17:29) ``` - **`OpenOCD 0.11.0`** Downloaded as: `xpack-openocd-0.11.0-5-win32-x64.zip` The `--version` output is: ``` xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2022-09-01-17:58) ``` - **`OpenOCD 0.12.0`** Downloaded as: `xpack-openocd-0.12.0-1-win32-x64.zip` The `--version` output is: ``` xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04) ``` --- # 2. Demonstration of the problem The target board is a `NUCLEO-F303K8`, which has a `STM32F303K8` chip onboard:  We have prepared two projects for this demonstration: - **`f303-working`**: This project works with all the OpenOCD versions - up to and including `OpenOCD 0.12.0` - **`f303-failing`**: This project works with `OpenOCD 0.10.0`, but not with `OpenOCD 0.11.0` and `0.12.0`. Both projects are <a href="https://embeetle.com">Embeetle projects</a>. However, I'll explain here how to flash the project's binaries without Embeetle involved. - **f303-working** For the **f303-working** project, just download the `.elf` file from this source: https://new.embeetle/downloads/misc/openocd_problem/f303-working.elf Next, you need the `openocd_probe.cfg` and `openocd_chip.cfg` files. They're very simple: > ```sh > # openocd_probe.cfg > source [find interface/stlink.cfg] > transport select hla_swd > ``` > ```sh > # openocd_chip.cfg > source [find target/stm32f3x.cfg] > reset_config srst_only > ``` Put the `f303-working.elf`, `openocd_probe.cfg` and `openocd_chip.cfg` files all in the same folder. Then issue the following command: ```sh $ openocd -f openocd_probe.cfg -f openocd_chip.cfg -c "program {f303-working.elf} verify reset; shutdown;" ``` As you will notice, this `f303-working.elf` firmware can be flashed with both `OpenOCD 0.10.0`, `0.11.0` and `0.12.0`. The output is: > ```sh > xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:04) > Licensed under GNU GPL v2 > For bug reports, read > http://openocd.org/doc/doxygen/bugs.html > hla_swd > 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 1000 kHz > Info : STLINK V2J25M14 (API v2) VID:PID 0483:374B > Info : Target voltage: 3.249572 > Info : [stm32f3x.cpu] Cortex-M4 r0p1 processor detected > Info : [stm32f3x.cpu] target has 6 breakpoints, 4 watchpoints > Info : starting gdb server for stm32f3x.cpu on 3333 > Info : Listening on port 3333 for gdb connections > [stm32f3x.cpu] halted due to breakpoint, current mode: Thread > xPSR: 0x61000000 pc: 0x2000003a msp: 0xfffffffc > Info : Unable to match requested speed 1000 kHz, using 950 kHz > Info : Unable to match requested speed 1000 kHz, using 950 kHz > [stm32f3x.cpu] halted due to debug-request, current mode: Thread > xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc > Info : Unable to match requested speed 8000 kHz, using 4000 kHz > Info : Unable to match requested speed 8000 kHz, using 4000 kHz > ** Programming Started ** > Info : device id = 0x10016438 > Info : flash size = 64 KiB > Warn : Adding extra erase range, 0x080014a0 .. 0x080017ff > ** Programming Finished ** > ** Verify Started ** > ** Verified OK ** > ** Resetting Target ** > Info : Unable to match requested speed 1000 kHz, using 950 kHz > Info : Unable to match requested speed 1000 kHz, using 950 kHz > shutdown command invoked > ``` <br> - **f303-failing** For the **f303-failing** project, just replace the `f303-working.elf` file with the `f303-failing.elf` file from this source: https://new.embeetle/downloads/misc/openocd_problem/f303-failing.elf Everthing else remains the same. With `OpenOCD 0.10.0`, the output is also the same (flashing works). But with `OpenOCD 0.11.0` and `0.12.0`, you'll get the following output: > ```sh > xPack OpenOCD x86_64 Open On-Chip Debugger 0.11.0+dev (2022-09-01-17:58) > Licensed under GNU GPL v2 > For bug reports, read > http://openocd.org/doc/doxygen/bugs.html > hla_swd > 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 1000 kHz > Info : STLINK V2J25M14 (API v2) VID:PID 0483:374B > Info : Target voltage: 3.249572 > Info : [stm32f3x.cpu] Cortex-M4 r0p1 processor detected > Info : [stm32f3x.cpu] target has 6 breakpoints, 4 watchpoints > Info : starting gdb server for stm32f3x.cpu on 3333 > Info : Listening on port 3333 for gdb connections > Info : Unable to match requested speed 1000 kHz, using 950 kHz > Info : Unable to match requested speed 1000 kHz, using 950 kHz > target halted due to debug-request, current mode: Thread > xPSR: 0x01000000 pc: 0x08001384 msp: 0x20003000 > Info : Unable to match requested speed 8000 kHz, using 4000 kHz > Info : Unable to match requested speed 8000 kHz, using 4000 kHz > ** Programming Started ** > Info : device id = 0x10016438 > Info : flash size = 64 KiB > Warn : Adding extra erase range, 0x08003198 .. 0x080037ff > Error: error writing to flash at address 0x08000000 at offset 0x00000000 > embedded:startup.tcl:1435: Error: ** Programming Failed ** > in procedure 'program' > in procedure 'program_error' called at file "embedded:startup.tcl", line 1500 > at file "embedded:startup.tcl", line 1435 > ``` --- # 3. Resources You can download the entire Embeetle projects here: - https://new.embeetle/downloads/misc/openocd_problem/f303-working.7z - https://new.embeetle/downloads/misc/openocd_problem/f303-failing.7z Aside from the `.elf` file, you can also find the `.bin`, `.hex` and `.map` files here: - https://new.embeetle/downloads/misc/openocd_problem/f303-working.elf - https://new.embeetle/downloads/misc/openocd_problem/f303-working.bin - https://new.embeetle/downloads/misc/openocd_problem/f303-working.hex - https://new.embeetle/downloads/misc/openocd_problem/f303-working.map - https://new.embeetle/downloads/misc/openocd_problem/f303-failing.elf - https://new.embeetle/downloads/misc/openocd_problem/f303-failing.bin - https://new.embeetle/downloads/misc/openocd_problem/f303-failing.hex - https://new.embeetle/downloads/misc/openocd_problem/f303-failing.map I've run `OpenOCD 0.12.0` on both projects with the `-d` flag to obtain debug output: - https://new.embeetle/downloads/misc/openocd_problem/f303-working-openocd-debug-output.txt - https://new.embeetle/downloads/misc/openocd_problem/f303-failing-openocd-debug-output.txt --- Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is subscribed to https://sourceforge.net/p/openocd/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list.