This project is all about accuratly driving brushless motors, for cheap. The aim is to make it possible to use inexpensive brushless motors in high performance robotics projects. Like this:
This repository contains the firmware that runs on the board. The other related repositories are:
- ODriveHardware: Circuit board design. Also, the pinout from the microcontroller to the board is documented here.
- ODrive: Configuration and analysis scripts that runs on a PC.
There is also ODriveFPGA, which contains the FPGA logic and software that runs on the FPGA based ODrive. This is not currently in development, but may be resumed at some later date.
- Compiling and downloading firmware
- Generating startup code
- Setting up Eclipse development environment
Get a programmer that supports SWD (Serial Wire Debugging) and is ST-link v2 compatible. You can get them really cheap on eBay or many other places.
To compile the program, you first need to install the prerequisite tools:
gcc-arm-none-eabi
: GCC compilation toolchain for ARM microcontrollers.- Installing on Ubuntu:
sudo apt-get install gcc-arm-none-eabi
- Installing on Windows (Cygwin): TODO
- Installing on Ubuntu:
OpenOCD
: Open On-Chip Debugging tools. This is what we use to flash the code onto the microcontroller.- Installing on Ubuntu:
sudo apt-get install openocd
- Installing on Windows (Cygwin): TODO
- Installing on Ubuntu:
Run make
in the root of this repository.
Connect SWD
, SWC
, and GND
on connector J2 to the programmer.
You need to power the board by only ONE of the following: VCC(3.3v), 5V, or the main power connection (the DC bus). The USB port (J1) does not power the board.
Run make flash
in the root of this repository.
(TODO Currently not implemented yet.)
Note: You do not need to run this step to program the board. This is only required if you wish to update the auto generated code.
This project uses the STM32CubeMX tool to generate startup code and to ease the configuration of the peripherals. We also use a tool to generate the Makefile. The steps to do this are as follows.
stm32cubeMX
: Tool from STM to automatically generate setup routines and configure libraries, etc.- Available here
- Run stm32cubeMX and load the
stm32cubemx/Odrive.ioc
project file. - Press
Project -> Generate code
- You may need to let it download some drivers and such.
There is an excellent project called CubeMX2Makefile, originally from baoshi. This project is included as a submodule.
- Initialise and clone the submodules:
git submodule init; git submodule update
- Generate makefile:
CubeMX2Makefile/CubeMX2Makefile.py .
- Install Eclipse IDE for C/C++ Developers
- Install the OpenOCD Eclipse plugin
- File -> Import -> C/C++ -> Existing Code as Makefile Project
- Browse for existing code location, find the OdriveFirmware root.
- In the Toolchain options, select
Cross GCC
- Hit Finish
- Build the project (press ctrl-B)
- File -> Import -> Run/Debug -> Launch Configurations -> Next
- Highlight (don't tick) the OdriveFirmare folder in the left column
- Tick OdriveFirmware.launch in the right column
- Hit Finish
- Make sure the programmer is connected to the board as per Flashing the firmware.
- Press the down-arrow of the debug symbol in the toolbar, and hit Debug Configurations
- You can also hit Run -> Debug Configurations
- Highlight the debug configuration you imported, called OdriveFirmware.
- Hit Debug
- The program should start halted on the first instruction in
Main
- Set beakpoints, step, hit Resume, etc.
- Make some cool features! ;D