Reflashing using stlink

Hi !
I’m using odrive 3.6-56V and ubuntu 20.04 OS.
recently I had problem with usb connectivity, when I open odrivetool I get “please connect to your odrive”, so I considered to reflash the firmware.

So i tried to reflash the firmware using stlink/v2 , but i got this error

I tried also this to unlock the stm32x, but still not working

when I execute lsusb the stlink is visible , and it’s light on, also the odrive power light is on.
Does anyone know how to solve it?

@madcowswe Can you help me?

STM32F4 sometimes behaves in such way when there’s not enought power on +3.3v line. Do you power it from ST-Link? Is your ST-Link genuine or clone?

it’s connected like this , power supply to the odrive and I’m connecting stlink with odrive via (swd,ground,swc) pins and connecting stlink with pc via usb port.

St-link is genuine.

If your ST-Link is genuine, it will also require TVCC connection to measure STM32’s VCC and adjust it’s logic levels.
Here’s genuine ST-Link.

sorry for the misleading, I thought something else.
I have one that looks exactly like this

I had similar issues with such clone. It had “APM32F103CBT6” chip inside, crappy clone of STM32F103CBT6.
Or, maybe, it’s something wrong with Linux drivers. Try with Windows ST-Link Utility.

where can I find this method?
I downloaded the ST-Link utility and I get this message when I try to connect to the target
“Can not read memory! Disable Read Out Protection and retry”

when i try to connect the target ST-Link utility says

Can not read memory!
Disable Read Out Protection and retry.

and when I try to change preotection from option bytes (from level 1 to level 0 ) , I get

Could not set Options byte! Please reset the target and retry

Is there something else I should do?

Use odrivetool unlock then try the STM32 again. If that doesn’t work, you can use the unlock command with STLink. My recommendation is to clone the repo, then type make unlock, which uses openocd to send these flags behind the scenes (after the init):

-c 'reset halt' -c 'stm32f2x unlock 0'

Sorry I am new to this .
Do you mean I should just write “drivetool unlock” in the terminal ? Or something else?

I did the ''drivetool unlock ‘’ , not sure if you ment like this
but this the result that i got. the odrive is switched to DFU mode

I tried also to clone the rep and navigated to firmware folder and used ‘‘make unlock’’ command, but I got this.
Screenshot from 2022-02-04 11-39-02

Hmm, you might have to use the DFU/RUN switch. Put it in DFU, power cycle the board, and see if you get an “STM32BOOTLOADER” device to show up, then try odrivetool dfu again :slight_smile:

I already tried that , it doesn’t show up neither in run nor DFU mode.
when I clone the repo and before I execute ‘‘make unlock’’ should I change anything in the files ? or just clone and execute ?

Just clone and execute, but it seems it doesn’t know where to find python on your computer. You may need to follow the “Firmware Developer Guide” to get the pre-requisites.

Same thing, I followed the ‘‘Firmware developer guide’’ and got the prerequisites.
when I try to flash it using ‘‘odrivetool dfu’’ I got

it cant find the ODrive , note the it switched to dfu mode.

then I tried with using ST-LINK , and I got this

and I tried to unlock it but got the same result. any suggestion ?

Looks like everything is working up to the point that the STM is write protected.

Did you do make unlock or only odrivetool unlock? The former should fix it (uses the STLink)

now I connected the ST_LINK and navigated into Firmware folder and did make unlock, this is the result

it hanged at INFO: a reset or power cycle .....
I powered off then on and executed the make flash , I got the same result that says it is protected

Hmm. That looks correct. I’m not sure what’s going on. Very strange.