About failure when writing nucleo-F446RE using Openocd.

Hi,

Writing nucleo-F446RE using Openocd repeats success and failure.

The following is the log at that time.

How can I get rid of this error?

#—first time—

openocd -f openocd.cfg -c "flash_elf build/xxx.elf"
Open On-Chip Debugger 0.11.0
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
Info : clock speed 2000 kHz
Info : STLINK V2J39M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.261335
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f4x.cpu on 3333
Info : Listening on port 3333 for gdb connections
flash_elf
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0xfffffffe msp: 0xfffeffe0
Info : device id = 0x10006421
Info : flash size = 512 kbytes
flash write_image (build/xxx.elf) complete
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz

#—second time—

openocd -f openocd.cfg -c "flash_elf build/xxx.elf"
Open On-Chip Debugger 0.11.0
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
Info : clock speed 2000 kHz
Info : STLINK V2J39M27 (API v2) VID:PID 0483:374B
Info : Target voltage: 3.256576
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f4x.cpu on 3333
Info : Listening on port 3333 for gdb connections
flash_elf
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x08000642 msp: 0x2001ffe0
Info : device id = 0x10006421
Info : flash size = 512 kbytes
Error: timeout waiting for algorithm, a target reset is recommended
Error: error executing stm32x flash write algorithm
Error: flash write failed = 0x00000040
Error: error writing to flash at address 0x08000000 at offset 0x00000000
auto erase enabled

— third time —

Same as the first time

Repeat below.

#—openpcd.cfg—

telnet_port 4444
gdb_port 3333

source [find board/st_nucleo_f4.cfg]

init

proc flash_elf {elf_file} {
    reset
    halt
    flash write_image erase $elf_file
    verify_image $elf_file
    echo "flash write_image ($elf_file) complete"
    reset
	  exit
    halt
}

By the way, if I modify “adapter speed 2000” in “stm32f4x.cfg” to “adapter speed 1800”, the message “Info: Unable to match requested speed 2000 kHz, using 1800 kHz” disappears, but the problem still occurs. …

Thanks.

I haven’t seen this before; try cross-posting here as well https://forum.arduino.cc/c/hardware/portenta/91 and maybe someone knows what’s going on