mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-24 01:23:52 +08:00
Merge branch 'Wetmelon-feature/cortex-debug' into devel
This commit is contained in:
Vendored
+11
-14
@@ -5,19 +5,16 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"type": "gdb",
|
||||
"request": "attach",
|
||||
"name": "Debug Firmware",
|
||||
"target": "localhost:3333",
|
||||
"gdbpath": "arm-none-eabi-gdb",
|
||||
"remote": true,
|
||||
"executable": "./build/ODriveFirmware.elf",
|
||||
"cwd": "${workspaceRoot}",
|
||||
"printCalls": false,
|
||||
//"preLaunchTask": "openocd", // This isn't working quite right.
|
||||
"autorun": [
|
||||
"monitor reset halt"
|
||||
]
|
||||
}
|
||||
// For the Cortex-Debug extension
|
||||
"type": "openocd-gdb",
|
||||
"request": "launch",
|
||||
"name": "Debug ODrive",
|
||||
"executable": "${workspaceRoot}/build/ODriveFirmware.elf",
|
||||
"configFiles": [
|
||||
"interface/stlink-v2.cfg",
|
||||
"target/stm32f4x_stlink.cfg",
|
||||
],
|
||||
"cwd": "${workspaceRoot}"
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -1,3 +1,12 @@
|
||||
## UNRELEASED
|
||||
|
||||
### Added
|
||||
* Getting started instructions for VSCode
|
||||
|
||||
### Changed
|
||||
* Recommended method to debug firmware from VSCode now uses Cortex-Debug extension instead of native-debug.
|
||||
* Refactor IDE instructions into separate files
|
||||
|
||||
## [0.3] - 2017-12-18
|
||||
### Added
|
||||
* **New binary communication protocol**
|
||||
|
||||
+17
-52
@@ -12,9 +12,10 @@ The project is under active development, so make sure to check the [Changelog](C
|
||||
|
||||
- [Configuring parameters](#configuring-parameters)
|
||||
- [Compiling and downloading firmware](#compiling-and-downloading-firmware)
|
||||
- [Setting up an IDE](#setting-up-an-ide)
|
||||
- [Continuing without an IDE](#no-ide-instructions)
|
||||
- [Communicating over USB or UART](#communicating-over-usb-or-uart)
|
||||
- [Generating startup code](#generating-startup-code)
|
||||
- [Setting up Eclipse development environment](#setting-up-eclipse-development-environment)
|
||||
- [Notes for Contributors](#notes-for-contributors)
|
||||
|
||||
<!-- /MarkdownTOC -->
|
||||
@@ -94,8 +95,8 @@ An upcoming feature will enable automatic tuning. Until then, here is a rough tu
|
||||
By default both motors are enabled, and the default control mode is position control.
|
||||
If you want a different mode, you can change `.control_mode`. To disable a motor, set `.enable_control` and `.do_calibration` to false.
|
||||
|
||||
<br><br>
|
||||
## 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](http://www.ebay.co.uk/itm/ST-Link-V2-Emulator-Downloader-Programming-Mini-Unit-STM8-STM32-with-20CM-Line-/391173940927?hash=item5b13c8a6bf:g:3g8AAOSw~OdVf-Tu) or many other places.
|
||||
|
||||
@@ -122,6 +123,15 @@ Install the following:
|
||||
* [Make for Windows](http://gnuwin32.sourceforge.net/packages/make.htm). Make is used to script the compilation process. Download and run the complete package setup program. Add the path of the binaries to your PATH environment variable. For me this was at `C:\Program Files (x86)\GnuWin32\bin`. For details on how to set your path envirment in windows see [these instructions.](https://www.java.com/en/download/help/path.xml)
|
||||
* OpenOCD. Follow the instructions at [GNU ARM Eclipse - How to install the OpenOCD binaries](http://gnuarmeclipse.github.io/openocd/install/), including the part about ST-LINK/V2 drivers. Add the path of the binaries to your PATH environment variable. For me this was at `C:\Program Files\GNU ARM Eclipse\OpenOCD\0.10.0-201704182147-dev\bin`.
|
||||
|
||||
<br><br>
|
||||
## Setting up an IDE
|
||||
ODrive is a Makefile project. It does not require an IDE, but the open-source IDE VSCode is recommended. It is also possible to use Eclipse. If you'd like to go that route, please see the respective configuration document:
|
||||
|
||||
* [Configuring VSCode](configuring-vscode.md)
|
||||
* [Configuring Eclipse](configuring-eclipse.md)
|
||||
|
||||
<br><br>
|
||||
## No IDE Instructions
|
||||
After installing all of the above, open a Git Bash shell. Continue at section [Building the firmware](#building-the-firmware).
|
||||
|
||||
### Building the firmware
|
||||
@@ -138,19 +148,9 @@ After installing all of the above, open a Git Bash shell. Continue at section [B
|
||||
If the flashing worked, you can start sending commands. If you want to do that now, you can go to [Communicating over USB or UART](#communicating-over-usb-or-uart).
|
||||
|
||||
### Debugging the firmware
|
||||
The following options are known to work and supported:
|
||||
* Command line GDB. Run `make gdb`. This will reset and halt at program start. Now you can set breakpoints and run the program. If you know how to use gdb, you are good to go.
|
||||
* Eclipse, see [Setting up Eclipse development environment](#setting-up-eclipse-development-environment).
|
||||
* Visual Studio Code. The solution we have is not the most elegant, and if you know a better way, please do help us.
|
||||
* Make sure you have the Firmware folder as your active folder
|
||||
* Flash the board with the newest code (starting debug session doesn't do this)
|
||||
* Tasks -> Run Task -> openocd
|
||||
* Debug -> Start Debugging
|
||||
* The processor will reset and halt.
|
||||
* Set your breakpoints. Note: you can only set breakpoints when the processor is halted, if you set them during run mode, they won't get applied.
|
||||
* Run
|
||||
* When you are done, you must kill the openocd task before you are able to flash the board again: Tasks -> Terminate task -> openocd.
|
||||
* Run `make gdb`. This will reset and halt at program start. Now you can set breakpoints and run the program. If you know how to use gdb, you are good to go.
|
||||
|
||||
<br><br>
|
||||
## Communicating over USB or UART
|
||||
Warning: If testing USB or UART communication for the first time it is recommend that your motors are free to spin continuously and are not connected to a drivetrain with limited travel.
|
||||
### From Linux/Windows/macOS
|
||||
@@ -188,9 +188,9 @@ pip install pyusb pyserial
|
||||
[See ODrive Arduino Library](https://github.com/madcowswe/ODriveArduino)
|
||||
|
||||
### Other platforms
|
||||
See the [protocol specification](https://github.com/madcowswe/ODrive/blob/devel/Firmware/protocol.md) or the [legacy protocol specification](https://github.com/madcowswe/ODrive/blob/devel/Firmware/legacy-protocol.md).
|
||||
|
||||
See the [protocol specification](protocol.md) or the [legacy protocol specification](legacy-protocol.md).
|
||||
|
||||
<br><br>
|
||||
## 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.
|
||||
|
||||
@@ -206,42 +206,7 @@ You will likely want the pinout for this process. It is available [here](https:/
|
||||
* Press `Project -> Generate code`
|
||||
* You may need to let it download some drivers and such.
|
||||
|
||||
## Setting up Eclipse development environment
|
||||
|
||||
### Install
|
||||
* Install [Eclipse IDE for C/C++ Developers](http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/neon3)
|
||||
* Install the [OpenOCD Eclipse plugin](http://gnuarmeclipse.github.io/plugins/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)
|
||||
|
||||

|
||||
|
||||
### 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!
|
||||
* Make sure the programmer is connected to the board as per [Flashing the firmware](#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. If you do not see the imported launch configuration rename your project to `ODriveFirmware` or edit the launch configuration to match your project name by unfiltering unavailable projects:
|
||||
|
||||

|
||||
|
||||
* Hit Debug
|
||||
* Eclipse should flash the board for you and the program should start halted on the first instruction in `Main`
|
||||
* Set beakpoints, step, hit Resume, etc.
|
||||
* Make some cool features! ;D
|
||||
|
||||
<br><br>
|
||||
## Notes for Contributors
|
||||
In general the project uses the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html), except that the default indendtation is 4 spaces, and that the 80 character limit is not very strictly enforced, merely encouraged.
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# Setting up Eclipse development environment
|
||||
|
||||
## Install
|
||||
* Install [Eclipse IDE for C/C++ Developers](http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/neon3)
|
||||
* Install the [OpenOCD Eclipse plugin](http://gnuarmeclipse.github.io/plugins/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)
|
||||
|
||||

|
||||
|
||||
## 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!
|
||||
* Make sure the programmer is connected to the board as per [Flashing the firmware](#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. If you do not see the imported launch configuration rename your project to `ODriveFirmware` or edit the launch configuration to match your project name by unfiltering unavailable projects:
|
||||
|
||||

|
||||
|
||||
* Hit Debug
|
||||
* Eclipse should flash the board for you and the program should start halted on the first instruction in `Main`
|
||||
* Set beakpoints, step, hit Resume, etc.
|
||||
* Make some cool features! ;D
|
||||
@@ -0,0 +1,54 @@
|
||||
# Configuring VSCode
|
||||
|
||||
VSCode is the recommended IDE for working with the ODrive codebase. It is a light-weight text editor with Git integration and GDB debugging functionality.
|
||||
|
||||
Before doing the VSCode setup, make sure you've installed all of your [prerequisites](README.md#installing-prerequisites)
|
||||
|
||||
## Setup Procedure
|
||||
1. Clone the ODrive repository
|
||||
1. [Download VSCode](https://code.visualstudio.com/download)
|
||||
1. Open VSCode
|
||||
1. Install extensions. This can be done directly from VSCode (Ctrl+Shift+X)
|
||||
* Required extensions:
|
||||
* C/C++
|
||||
* Recommended Extensions:
|
||||
* Cortex-Debug
|
||||
* vscode-icons
|
||||
* Code Outline
|
||||
* Include Autocomplete
|
||||
* Path Autocomplete
|
||||
* Auto Comment Blocks
|
||||
1. Restart VSCode
|
||||
1. Open the VSCode Workspace file, which is located in the root of the ODrive repository. It is called `VSCodeWorkspace.code-workspace`. The first time you open it, VSCode will install some dependencies. If it fails, you may need to [change your proxy settings](https://code.visualstudio.com/docs/getstarted/settings).
|
||||
|
||||
You should now be ready to compile and test the ODrive project.
|
||||
|
||||
## Building the Firmware
|
||||
* Tasks -> Run Build Task
|
||||
|
||||
A terminal window will open with your native shell. VSCode is configured to run the command `make -j4` in this terminal.
|
||||
|
||||
## Flashing the Firmware
|
||||
* Tasks -> Run Task -> flash
|
||||
|
||||
A terminal window will open with your native shell. VSCode is configured to run the command `make flash` in this terminal.
|
||||
|
||||
If the flashing worked, you can start sending commands. If you want to do that now, you can go to [Communicating over USB or UART](README.md#communicating-over-usb-or-uart).
|
||||
|
||||
## Debugging
|
||||
An extension called Cortex-Debug has recently been released which is designed specifically for debugging ARM Cortex projects. You can read more on Cortex-Debug here: https://github.com/Marus/cortex-debug
|
||||
|
||||
Note: If developing on Windows, you should have `arm-none-eabi-gdb` and `openOCD` on your PATH.
|
||||
|
||||
* Make sure you have the Firmware folder as your active folder
|
||||
* Flash the board with the newest code (starting debug session doesn't do this)
|
||||
* Debug -> Start Debugging (or press F5)
|
||||
* The processor will reset and halt.
|
||||
* Set your breakpoints. Note: you can only set breakpoints when the processor is halted, if you set them during run mode, they won't get applied.
|
||||
* Run (F5)
|
||||
* Stepping over/in/out, restarting, and changing breakpoints can be done by first pressing the "pause" (F6) button at the top the screen.
|
||||
* When done debugging, simply stop (Shift+F5) the debugger. It will kill your openOCD process too.
|
||||
|
||||
## Cleaning the Build
|
||||
This sometimes needs to be done if you change branches.
|
||||
* Open a terminal (View -> Integrated Terminal) and enter `make clean`
|
||||
Reference in New Issue
Block a user