Error: read version failed when trying to use OpenOCD 0.7.0 with STM32F407 Discovery Board As Programmer

General topics and discussions about the VESC and its development.
vaziri
Posts: 7
Joined: 18 Feb 2016, 17:59
Location: San Jose, CA

Error: read version failed when trying to use OpenOCD 0.7.0 with STM32F407 Discovery Board As Programmer

Postby vaziri » 24 Aug 2016, 07:33

I received the following error when trying to flash the firmware of my 4.12 board using an STM43F407 discovery board as the programmer.

Code: Select all

 vaziri@computer:~/BLDC/bldc-firmware$ make upload
#qstlink2 --cli --erase --write build/BLDC_4_ChibiOS.bin
#openocd -f interface/stlink-v2.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x_stlink.cfg -c "prog
ram build/BLDC_4_ChibiOS.elf verify reset" # Older openocd
openocd -f board/stm32f4discovery.cfg -c "reset_config trst_only combined" -c "program build/BLDC_4_Chi
biOS.elf verify reset exit" # For openocd 0.9
Open On-Chip Debugger 0.7.0 (2013-10-22-08:31)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.sourceforge.net/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
trst_only combined trst_push_pull
Info : This adapter doesn't support configurable speed
Error: read version failed
in procedure 'transport'
** OpenOCD init Failed **
shutdown command invoked


After reading through the Makefile it seemed to suggest that I should be using OpenOCD 0.9.0. I double checked that I had followed the dependency installation direction correctly, which I had. However those directions install version 0.7.0. I then manually downloaded and installed 0.9.0. It fixed the problem. See the successful output below

Code: Select all

vaziri@computer:~/BLDC/bldc-firmware$ make upload                                                     
#qstlink2 --cli --erase --write build/BLDC_4_ChibiOS.bin
#openocd -f interface/stlink-v2.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x_stlink.cfg -c "prog
ram build/BLDC_4_ChibiOS.elf verify reset" # Older openocd
openocd -f board/stm32f4discovery.cfg -c "reset_config trst_only combined" -c "program build/BLDC_4_Chi
biOS.elf verify reset exit" # For openocd 0.9
Open On-Chip Debugger 0.9.0 (2016-08-24-00:17)
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
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
trst_only combined trst_push_pull
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v14 API v2 SWIM v0 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.215213
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800c000 msp: 0x20000400
** Programming Started **
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
Info : Padding image section 0 with 48704 bytes
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000042 msp: 0x20000400
wrote 262144 bytes from file build/BLDC_4_ChibiOS.elf in 9.848132s (25.995 KiB/s)
** Programming Finished **
** Verify Started **
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000400
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000400
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000400
verified 144400 bytes in 1.325245s (106.407 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked


I am posting this to save others the time in finding the same problem. It should also be noted that instead of installing a new version of OpenOCD it might be possible to work around this by commenting and uncommenting some lines in the Makefile. In particular there is a line marked with "# Older openocd" which might work with 0.7.0. I did not try it.

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Error: read version failed when trying to use OpenOCD 0.7.0 with STM32F407 Discovery Board As Programmer

Postby lizardmech » 24 Aug 2016, 11:56

I have the same problem, I think it's related to a newer MCU revision. It's possible to flash the firmware using ST software but VESC cannot function as it can't read or write flash memory. I found something similar happened in the past and it was a register that determines if flash is write protected had changed breaking openOCD. I don't know how to fix it, I don't have enough programming knowledge. Let me see if this fixes it.

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Error: read version failed when trying to use OpenOCD 0.7.0 with STM32F407 Discovery Board As Programmer

Postby lizardmech » 24 Aug 2016, 12:17

Installed 0.9.0 same error as I have with other versions. Seems to fail at a different spot than yours did.

Code: Select all

#qstlink2 --cli --erase --write build/BLDC_4_ChibiOS.bin
openocd -f interface/stlink-v2.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x.cfg -c "program build/BLDC_4_ChibiOS.elf verify reset"
Open On-Chip Debugger 0.9.0 (2015-09-02-10:42)
Licensed under GNU GPL v2
For bug reports, read
   http://openocd.org/doc/doxygen/bugs.html
0x2000
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Error: open failed
in procedure 'program'
in procedure 'init' called at file "embedded:startup.tcl", line 473
in procedure 'ocd_bouncer'
** OpenOCD init failed **
shutdown command invoked

Makefile:272: recipe for target 'upload' failed
make: *** [upload] Error 1


lyphix
Posts: 1
Joined: 07 Sep 2016, 15:27
Location: shanghai

Re: Error: read version failed when trying to use OpenOCD 0.7.0 with STM32F407 Discovery Board As Programmer

Postby lyphix » 10 Sep 2016, 03:24

I install the openocd 0.9.0 and successful verified the BLDC_4_ChibiOS.bin
but I can't verify the bootloader. Actually it successful verified but can't Resetting Target.
The program stopped at resetting forever. hardwear:4.12 bootloader and chibios get on github.

Code: Select all

root@ubuntu:~/BLDC/bldc-bootloader# make upload
#qstlink2 --cli --erase --write build/BLDC_4_Bootloader.bin
openocd -f interface/stlink-v2.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x_stlink.cfg -c "program build/BLDC_4_Bootloader.elf verify reset"
Open On-Chip Debugger 0.9.0 (2016-08-24-20:27)
Licensed under GNU GPL v2
For bug reports, read
   http://openocd.org/doc/doxygen/bugs.html
0x2000
WARNING: target/stm32f4x_stlink.cfg is deprecated, please switch to target/stm32f4x.cfg
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.246123
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x0800c000 msp: 0x20000400
** Programming Started **
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
wrote 131072 bytes from file build/BLDC_4_Bootloader.elf in 7.534637s (16.988 KiB/s)
** Programming Finished **
** Verify Started **
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x20000400
verified 4256 bytes in 0.667099s (6.230 KiB/s)
** Verified OK **
** Resetting Target **
//STOP AT HERE FOREVER//

zhud
Posts: 2
Joined: 19 Nov 2017, 12:40
Location: US

Re: Error: read version failed when trying to use OpenOCD 0.7.0 with STM32F407 Discovery Board As Programmer

Postby zhud » 19 Nov 2017, 21:25

Did anyone every figure out the answer to this? I am having the same problem and it doesn't seem like there is a solution available

rew
Posts: 943
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Error: read version failed when trying to use OpenOCD 0.7.0 with STM32F407 Discovery Board As Programmer

Postby rew » 20 Nov 2017, 09:15

The discovery board is a reliable programmer. First try flashing the BLDC firmware into the CPU on the discovery board, then try removing the jumpers and making theconnection to the VESC. So this way you know for sure if it is software you're having trouble with or hardware.


Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests