Firmware Update Problems

I am currently working on an Autonomous Vehicle project for my senior design class. I have already successfully upgrade the firmware on one of my ODrive v3.6 (56V) boards from v0.4.12 to v0.5.1 but I am having trouble with the second board.

For the first board, I already went through the odrivetool installation and driver setup using Zadig and everything was working perfectly. I was able to update the firmware successfully by using the odrivetool dfu command (via USB) and was then able to successfully set the parameters and get my first two motors spinning.

When I was satisfied with the first board, I then went to update the firmware on the second board for the other two motors. I followed the same procedure but during the update, it went through the normal routine and got to 6/6, but then gave an error with something like (0 2 0 0) or the such. I do not have the actual error at this time as my laptop died while I was in the process of troubleshooting.

Right now my board is in a weird state and I am not sure what is going on. When the board DIP switch is in RUN mode, my laptop will not recognize that there is even a USB device attached. When I open the Zadig tool, there is no CDC Interface (Interface 0) or Native Interface (Interface 2) available. When the board DIP switch is in DFU mode, my laptop will recognize that there is a USB device attached, and Zadig shows the STM32 Bootloader device.

Based on this behavior I was lead to believe that the firmware was corrupted and that I would need to restore the firmware via the ST-Link method. However, this method has been giving me nothing but trouble.

On my Ubuntu device, I installed OpenOCD and downloaded the ODrive v3.6 56V .elf file from github. I connected my ST-Link (the one that came with the boards) with GND to GND, SWC to SWC, and SWD to SWD. I made sure my wires were good with a continuity test prior to connecting them to the ST Link or the ODrive. With the DIP switch set to RUN and the firmware saved to my desktop, I tried running the sudo command

openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase ODriveFirmware_v3.4-24V.elf” -c “reset run” -c exit

and received an error saying that there was no device found.

I flipped the DIP switch to DFU and ran the same code and got an error saying the ST-Link was not in the correct state and that the communication failed.

I measured 50VDC across the input terminals so I know its not an under/over voltage issue.

I had to leave the campus because security kicked me out to close for the night, but I thought I would seek help with what I could remember and I can give more info tomorrow morning if required to solve this issue.

If anyone has any suggestions, I would greatly appreciate it.

You’ve got the wrong firmware for that device, for one. You need to make sure you use 3.6-56V instead of the 3.4-24V.

But that STLink flash should work. Try 'er again (in RUN mode)

Sorry, I think I misspoke.

The firmware I am using is 3.6-56V, the above command was just a copy and paste from the odrivetool guide and I forgot to edit it in my post. When I did try the ST-Link method, I used the above command but I swapped the 3.4 firmware for the 3.6 firmware before hitting enter.

I still have the errors from the above command in both RUN and DFU modes on my ubuntu machine at school and I am about to head over there in a few minutes.

Edit: Below is the command/response I get when the DIP switch is in RUN mode.

nvidia@nvidia-desktop:~$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase ODriveFirmware_v3.6-56V.elf” -c “reset run” -c exit
[sudo] password for nvidia:
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 '.
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.246592
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 300ms
adapter speed: 2000 kHz
Error: mem2array: Read @ 0xe0042004, w=4, cnt=1, failed
/usr/bin/…/share/openocd/scripts/mem_helper.tcl:6: Error:
in procedure ‘reset’
in procedure ‘ocd_bouncer’
in procedure ‘ocd_process_reset’
in procedure ‘ocd_process_reset_inner’ called at file “embedded:startup.tcl”, line 248
in procedure ‘stm32f4x.cpu’ called at file “embedded:startup.tcl”, line 299
in procedure ‘ocd_bouncer’
in procedure ‘mmw’
in procedure ‘mrw’ called at file “/usr/bin/…/share/openocd/scripts/mem_helper.tcl”, line 25
at file “/usr/bin/…/share/openocd/scripts/mem_helper.tcl”, line 6

Info : Previous state query failed, trying to reconnect
Error: jtag status contains invalid mode value - communication failure
TARGET: stm32f4x.cpu - Not halted
in procedure ‘reset’
in procedure ‘ocd_bouncer’

That doesn’t sound very promising.

Can you maybe try the make unlock command?
openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c 'reset halt' -c 'stm32f2x unlock 0'

Also, I’ve had weird problems with some versions of OpenOCD in the past. I’m on 0.10.0+dev (2020-10-13-17)

nvidia@nvidia-desktop:~$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “stm32f2x unlock 0”
[sudo] password for nvidia:
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 '.
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.243886
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
adapter speed: 2000 kHz
Error: jtag status contains invalid mode value - communication failure
TARGET: stm32f4x.cpu - Not halted
in procedure ‘reset’
in procedure ‘ocd_bouncer’

Oh you’re on a Jetson… we’ve had all sorts of trouble with those.

Yeah I’ve also had a lot of USB issues with my Jetson TX2.
In the end, I bought a PCI USB card for it. Works much better than whatever onboard host controller it has.

I was able to grab a university laptop with Ubuntu installed and tried the process again.

I first tried flashing the firmware and was getting the following two errors. The first error occurs the first time I try the command, and every time I try the command after that before power cycling everything I get the second error.

wiu@Computer:~ cd ~/Desktop wiu@Computer:~/Desktop sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase ODriveFirmware_v3.6-56V.elf” -c “reset run” -c exit
[sudo] password for wiu:
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 '.
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.255666
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
adapter speed: 2000 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
Error: jtag status contains invalid mode value - communication failure
Error: error waiting for target flash write algorithm
Error: error writing to flash at address 0x08000000 at offset 0x00000000

wiu@Computer:~/Desktop$ sudo openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c “reset halt” -c “flash write_image erase ODriveFirmware_v3.6-56V.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 '.
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.247714
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
adapter speed: 2000 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
Error: failed erasing sectors 0 to 5

I then tried the unlock command, which made some progress, but seems to be stuck in an infinate loop where the communication times out every 3-4 minutes. I sat there letting it run for about 15-20minutes with no luck.

wiu@Computer:~$ 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 '.
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.249768
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
adapter speed: 2000 kHz
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
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.
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Polling target stm32f4x.cpu failed, trying to reexamine
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Polling target stm32f4x.cpu failed, trying to reexamine
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Polling target stm32f4x.cpu failed, trying to reexamine
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
Error: jtag status contains invalid mode value - communication failure
Polling target stm32f4x.cpu failed, trying to reexamine
Examination failed, GDB will be halted. Polling again in 100ms
Info : Previous state query failed, trying to reconnect
Polling target stm32f4x.cpu failed, trying to reexamine
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints

I could be wrong as I am new to this openocd software, but I think we can confirm the TX2 was the issue we were encountering previously, but now we are still having issues with flashing the firmware. I do not want to rule out saving this board, but with the end of the semester coming up shortly, do you think it would be in our best interest to purchase a new board that already has the 5.1 firmware due to time constraints?

Again, thanks for all of the help.

Edit: I do want to note that I did try the firmware update again after trying the unlock command multiple times with the same result.

As per my other reply, I think we can confirm the issue is with the TX2 USB as our team was also having issues with our StereoLabs ZED2 Camera on both our TX2 and Nano. Right now we are limited on time and I myself am not working on that portion of our project, what information can you provide to us about alternate USB cards for the TX2 and Nano and what it would require to integrate?

Thank you for the information you have provided and any info you can get to us.

Hey @Phnx did you ever figure out what the issue was with this?

1 Like