Firmware update bricked Drive

While trying to update firmware using st-link, got the following error.

$make flash

openocd -f interface/stlink-v2.cfg  -f target/stm32f4x.cfg -c init \
	-c 'reset halt' \
	-c 'flash write_image erase build/ODriveFirmware.elf' \
	-c 'reset run' \
	-c exit
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
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 v36 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.183290
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0800b9ec msp: 0x20020000
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
Error: error writing to flash at address 0x08000000 at offset 0x00000000

Makefile:17: recipe for target 'flash' failed
make: *** [flash] Error 1

Replacing the stm32 chip had resolved the issue in the past for me.

I have tried the suggestion from Firmware Update Problems - #8 by Phnx, but it didn’t work out.

Is there a reliable way to update the drive? Is St-link v2 or loose connections the issue?
Any help is much appreciated.

(PS: I have 2 bricked odrives)

Result from unlocking attempt:

Firmware$ openocd -f interface/stlink-v2.cfg  -f target/stm32f4x.cfg -c init -c 'reset halt' -c "stm32f2x unlock 0"
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
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 v36 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.185910
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0800b9ec msp: 0x20020000
Info : device id = 0x10076413
Info : flash size = 1024kbytes
stm32f2x unlocked.
INFO: a reset or power cycle is required for the new settings to take effect.

^C

Firmware$ make flash
openocd -f interface/stlink-v2.cfg  -f target/stm32f4x.cfg -c init \
	-c 'reset halt' \
	-c 'flash write_image erase build/ODriveFirmware.elf' \
	-c 'reset run' \
	-c exit
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
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 v36 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.176517
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
adapter speed: 1800 kHz
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0800b9ec msp: 0x20020000
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
Error: error writing to flash at address 0x08000000 at offset 0x00000000

Makefile:17: recipe for target 'flash' failed
make: *** [flash] Error 1
1 Like

What STlink are you using?

STlink V2, https://www.mouser.in/ProductDetail/Adafruit/2548?qs=sGAEpiMZZMuqBwn8WqcFUsGY9cgyOYqF3y0%2F%2Fp2qXvx8ufHaU0ckeQ%3D%3D. Got it from a local reseller.

Resolved the issue using stlinkv2 and stlink utility from windows.

For the fix, the board was powered by programer’s 3.3v, this might have resolved ground loops (which might be the reason in the first place). No external power was used.

Had to disable read and write protection (don’t know how those bytes got turned on). Read protection level has to be set to 0.

The hex file from build folder is required for programming.

Hope this helps.