Program runs but does not get flashed


I have bought two ODrives, a PM motor and an encoder, and tried using them. I am using the firmware environment on a Mac; it has compiled cleanly, then I have tried to flash it. After flashing, the motor spins for a short while, then I get a serial connection /dev/tty.usbmodem141141 and can run over it. It shows stuff, but it will not move when I try “my_odrive.motor0.pos_setpoint = 10000”.

But worse, everything vanishes on power cycle; ODrive boots up with the power LED flashing, no serial port opens, nothing works.

Does it mean that the CPU is damaged? How can I tell if the flash memory is alive or dead?

Here is what I get upon flashing:

sudo 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
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.251459
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: 0x0800a2f4 msp: 0x20020000
auto erase enabled
Info : device id = 0x10076413
Info : flash size = 1024kbytes
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x20000046 msp: 0x20020000
Warn : no flash bank found for address 10000000
wrote 131072 bytes from file build/ODriveFirmware.elf in 5.433234s (23.559 KiB/s)
adapter speed: 2000 kHz


This is really bad, it means something is drawing too much current on the 5V or 3.3V rails.
Do you think sending the my_odrive.motor0.pos_setpoint = 10000 caused the issue, probably not right? Do you think you could have pysically shorted some pins with a dangling piece of metal, a loose wire/STLink?


Thanks for the advice and sorry for misleading you.
The board is not dead, I can re-flash it and it starts to communicate, the problem is that it loses the program on power cycle, and I have to do it again.
Is it possible that the flash memory is damaged? Or maybe my settings are wrong for this board and I am trying to write to the flash at a wrong address?
Any help will be greatly appreciated, I really want to use this board since it looks so cool!


You can read the first 0x10000 bytes of flash by running

openocd -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c flash\ read_bank\ 0\ extracted_image.bin\ 0\ 0x10000 -c exit
hexdump -C extracted_image.bin      # to view the data in hex format

For reference you can dump the firmware binary in raw hex using objdump (the output will differ slightly from the hexdump, it will show as 32-bit values):

arm-none-eabi-objdump -s build/ODriveFirmware.elf

The warning “Warn : no flash bank found for address 10000000” is nothing to worry about, I get that too. That address points to the CCMRAM so probably some linker settings can be tweaked to make the warning go away.