Skip to content

ICRS/ODriveFirmware

Repository files navigation

ODriveFirmware

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: Servo motor control demo

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.

Table of contents

Compiling and downloading firmware

Getting a programmer

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.

Installing prerequisites

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
  • 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

Building the firmware

Run make in the root of this repository.

Flashing the firmware

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.)

Generating startup code

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.

Installing prerequisites

  • stm32cubeMX: Tool from STM to automatically generate setup routines and configure libraries, etc.

Generate code

  • 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.

Generate makefile

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 .

Setting up Eclipse development environment

Install

Import project

  • 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)

Toolchain options

Load the launch configuration

  • 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

Launch Configurations

Launch!

  • 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

About

Fork of official ODriveFirmware with Serial USB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages