mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-25 11:06:48 +08:00
Merge pull request #128 from madcowswe/sam_build_config
Configurable Build
This commit is contained in:
+5
-5
@@ -23,14 +23,14 @@ install:
|
||||
- export GCC_URL=https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2
|
||||
- if [ ! -e $GCC_DIR/bin/arm-none-eabi-gcc ]; then wget $GCC_URL -O $GCC_ARCHIVE; tar xfj $GCC_ARCHIVE -C $HOME/dl; fi
|
||||
- export PATH=$PATH:$GCC_DIR/bin
|
||||
- export TUP_DIR=$HOME/dl/tup_0.7.2.12+ga582fee_amd64
|
||||
- export TUP_ARCHIVE=$HOME/dl/tup_0.7.2.12+ga582fee_amd64.deb
|
||||
- export TUP_URL=http://ppa.launchpad.net/anatol/tup/ubuntu/pool/main/t/tup/tup_0.7.2.12+ga582fee_amd64.deb
|
||||
- export TUP_DIR=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64
|
||||
- export TUP_ARCHIVE=$HOME/dl/tup_0.7.5-0~16.04.york0_amd64.deb
|
||||
- export TUP_URL=http://ppa.launchpad.net/jonathonf/tup/ubuntu/pool/main/t/tup/tup_0.7.5-0~16.04.york0_amd64.deb
|
||||
- if [ ! -e $TUP_DIR/bin/tup ]; then wget $TUP_URL -O $TUP_ARCHIVE; dpkg-deb -R $TUP_ARCHIVE $TUP_DIR; fi
|
||||
- export PATH=$PATH:$TUP_DIR/usr/bin
|
||||
|
||||
script:
|
||||
- cd Firmware
|
||||
- mkdir -p build
|
||||
- mkdir -p Firmware/build
|
||||
- echo "CONFIG_BOARD_VERSION=v3.4-24V" > tup.config # TODO: build more configuration combinations
|
||||
- tup generate ./build.sh
|
||||
- bash -xe ./build.sh
|
||||
|
||||
@@ -52,10 +52,6 @@
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
#define HW_VERSION_MAJOR 3
|
||||
#define HW_VERSION_MINOR 4
|
||||
// #define HW_VERSION_HIGH_VOLTAGE true
|
||||
|
||||
#if HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR == 1 \
|
||||
|| HW_VERSION_MAJOR == 3 && HW_VERSION_MINOR == 2
|
||||
#include "prev_board_ver/main_V3_2.h"
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
# Unreleased Features
|
||||
Please add a note of your changes below this heading if you make a Pull Request.
|
||||
|
||||
### Added
|
||||
* **Storing of configuration parameters to Non Volatile Memory**
|
||||
|
||||
### Changed
|
||||
* The build is now configured using the `tup.config` file instead of editing source files. Make sure you set your board version correctly. See [here](README.md#configuring-the-build) for details.
|
||||
|
||||
# Releases
|
||||
|
||||
## [0.3.5] - 2018-03-04
|
||||
|
||||
@@ -38,6 +38,13 @@ extern USBD_HandleTypeDef hUsbDeviceFS;
|
||||
|
||||
/* Private constant data -----------------------------------------------------*/
|
||||
// TODO: make command to switch gpio_mode during run-time
|
||||
|
||||
typedef enum {
|
||||
GPIO_MODE_NONE,
|
||||
GPIO_MODE_UART,
|
||||
GPIO_MODE_STEP_DIR,
|
||||
} GpioMode_t;
|
||||
|
||||
#if defined(USE_GPIO_MODE_STEP_DIR)
|
||||
static const GpioMode_t gpio_mode = GPIO_MODE_STEP_DIR; //GPIO 1,2 is M0 Step,Dir
|
||||
#elif !defined(UART_PROTOCOL_NONE)
|
||||
|
||||
@@ -10,27 +10,6 @@
|
||||
#include <limits>
|
||||
#include "crc.hpp"
|
||||
|
||||
// Select which protocol to run on USB (see README for more details)
|
||||
#define USB_PROTOCOL_NATIVE
|
||||
// #define USB_PROTOCOL_NATIVE_STREAM_BASED
|
||||
// #define USB_PROTOCOL_LEGACY
|
||||
// #define USB_PROTOCOL_NONE
|
||||
|
||||
// Select which protocol to run on UART (see README for more details)
|
||||
// #define UART_PROTOCOL_NATIVE
|
||||
// #define UART_PROTOCOL_LEGACY
|
||||
#define UART_PROTOCOL_NONE
|
||||
|
||||
// Use GPIO 1/2 for step/dir input instead of UART
|
||||
// #define USE_GPIO_MODE_STEP_DIR
|
||||
|
||||
|
||||
typedef enum {
|
||||
GPIO_MODE_NONE,
|
||||
GPIO_MODE_UART,
|
||||
GPIO_MODE_STEP_DIR,
|
||||
} GpioMode_t;
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
+13
-31
@@ -27,41 +27,23 @@ The project is under active development, so make sure to check the [Changelog](C
|
||||
To correctly operate the ODrive, you need to supply some parameters. Some are mandatory, and if supplied incorrectly will cause the drive to malfunction.
|
||||
In this section we will set the compile-time parameters, later we will also set the [run time parameters](#configuring-parameters).
|
||||
|
||||
The first thing to set is your board hardware version, located at the top of [Inc/main.h](Inc/main.h). If, for example, you are using the hardware: ODrive v3.2, then you should set it like this:
|
||||
```C
|
||||
#define HW_VERSION_MAJOR 3
|
||||
#define HW_VERSION_MINOR 2
|
||||
```
|
||||
If you are using the 48V version of ODrive, you should also uncomment this line
|
||||
```C
|
||||
#define HW_VERSION_HIGH_VOLTAGE true
|
||||
```
|
||||
To customize the compile time parameters, copy or rename the file `tup.config.default` to `tup.config` and edit the parameters in that file:
|
||||
|
||||
### Communication configuration
|
||||
If want to use the example python scripts and connect the ODrive via USB, the defaults are fine for you and you can skip this step.
|
||||
__CONFIG_BOARD_VERSION__: The board version you're using. Can be `v3.1`, `v3.2`, `v3.3`, `v3.4-24V` or `v3.4-48V`. Check for a label on the upper side of the ODrive to find out which version you have.
|
||||
|
||||
You can select what interface you want to run on USB and GPIO pins. See [Communicating over USB or UART](#communicating-over-usb-or-uart) for more information.
|
||||
The following options are available in [MotorControl/commands.h](MotorControl/commands.h):
|
||||
__CONFIG_USB_PROTOCOL__: Defines which protocol the ODrive should use on the USB interface.
|
||||
* `native`: The native ODrive protocol. Use this if you want to use the python tools in this repo.
|
||||
* `native-stream`: Like the native ODrive protocol, but the ODrive will treat the USB connection exactly as if it was a UART connection. __Use this if you're on macOS__. This is necessary because macOS doesn't grant our python tools sufficient low-level access to treat the device as the USB device that it is.
|
||||
* `ascii`: The ASCII protocol. This allows sending simple commands like position setpoints directly from the terminal to the ODrive without the use of intermediate utilities.
|
||||
* `none`: Disable USB. The device will still show up when plugged in but it will ignore any commands.
|
||||
|
||||
__USB__:
|
||||
- `USB_PROTOCOL_NATIVE`: Use the native protocol (recommended for new applications).
|
||||
The python library only understands the native protocol, so this is the way to go
|
||||
if you use that.
|
||||
- `USB_PROTOCOL_NATIVE_STREAM_BASED`: Use the native stream based protocol.
|
||||
On most platforms the device shows up as a serial port when connected over USB.
|
||||
So instead of using the python tool's direct USB access, you can use this option and then pretend you connected the device over serial.
|
||||
__On some platforms (specifically macOS), this is required__ because the kernel doesn't allow direct USB access.
|
||||
- `USB_PROTOCOL_LEGACY`: Use the human-readable legacy protocol
|
||||
Select this option if you already have an existing application. This option will be removed in the future.
|
||||
- `USB_PROTOCOL_NONE`: Ignore USB communication
|
||||
__CONFIG_UART_PROTOCOL__: Defines which protocol the ODrive should use on the UART interface (GPIO1 and GPIO2). Note that UART is only supported on ODrive v3.3 and higher.
|
||||
* `native`: The native ODrive protocol. Use this if you're connecting the ODrive to a PC using UART and want to use the python tools to control and setup the ODrive.
|
||||
* `ascii`: The ASCII protocol. Use this option if you control the ODrive with an Arduino. The ODrive Arduino library is not yet updated to the native protocol.
|
||||
* `none`: Disable UART.
|
||||
|
||||
__CONFIG_STEP_DIR__: Set to `y` to use the GPIO1 and GPIO2 for step/direction input. Set to `n` otherwise. To use this, `CONFIG_UART_PROTOCOL` must be `none` because UART uses the same pins.
|
||||
|
||||
__GPIO 1,2 pins__:
|
||||
Note that UART is only supported on ODrive v3.3 and higher.
|
||||
- `UART_PROTOCOL_NATIVE`: Use the native protocol (see notes above).
|
||||
- `UART_PROTOCOL_LEGACY`: Use the human-readable legacy protocol
|
||||
Use this option if you control the ODrive with an Arduino. The ODrive Arduino library is not yet updated to the native protocol.
|
||||
- `UART_PROTOCOL_NONE`: Ignore UART communication
|
||||
- `USE_GPIO_MODE_STEP_DIR`: Step/direction control mode (use in conjunction with `UART_PROTOCOL_NONE`)
|
||||
|
||||
<br><br>
|
||||
## Compiling and downloading firmware
|
||||
|
||||
+62
-1
@@ -1,7 +1,67 @@
|
||||
|
||||
tup.include('build.lua')
|
||||
|
||||
boarddir = 'Board/v3.3'
|
||||
-- Switch between board versions
|
||||
boardversion = tup.getconfig("BOARD_VERSION")
|
||||
if boardversion == "v3.1" then
|
||||
boarddir = 'Board/v3.3' -- currently all platform code is in the same v3.3 directory
|
||||
FLAGS += "-DHW_VERSION_MAJOR=3 -DHW_VERSION_MINOR=1"
|
||||
FLAGS += "-DHW_VERSION_HIGH_VOLTAGE=false"
|
||||
elseif boardversion == "v3.2" then
|
||||
boarddir = 'Board/v3.3'
|
||||
FLAGS += "-DHW_VERSION_MAJOR=3 -DHW_VERSION_MINOR=2"
|
||||
FLAGS += "-DHW_VERSION_HIGH_VOLTAGE=false"
|
||||
elseif boardversion == "v3.3" then
|
||||
boarddir = 'Board/v3.3'
|
||||
FLAGS += "-DHW_VERSION_MAJOR=3 -DHW_VERSION_MINOR=3"
|
||||
FLAGS += "-DHW_VERSION_HIGH_VOLTAGE=false"
|
||||
elseif boardversion == "v3.4-24V" then
|
||||
boarddir = 'Board/v3.3'
|
||||
FLAGS += "-DHW_VERSION_MAJOR=3 -DHW_VERSION_MINOR=4"
|
||||
FLAGS += "-DHW_VERSION_HIGH_VOLTAGE=false"
|
||||
elseif boardversion == "v3.4-48V" then
|
||||
boarddir = 'Board/v3.3'
|
||||
FLAGS += "-DHW_VERSION_MAJOR=3 -DHW_VERSION_MINOR=4"
|
||||
FLAGS += "-DHW_VERSION_HIGH_VOLTAGE=true"
|
||||
elseif boardversion == "" then
|
||||
error("board version not specified - take a look at tup.config.default")
|
||||
else
|
||||
error("unknown board version "..boardversion)
|
||||
end
|
||||
buildsuffix = boardversion
|
||||
|
||||
-- USB I/O settings
|
||||
if tup.getconfig("USB_PROTOCOL") == "native" or tup.getconfig("USB_PROTOCOL") == "" then
|
||||
FLAGS += "-DUSB_PROTOCOL_NATIVE"
|
||||
elseif tup.getconfig("USB_PROTOCOL") == "native-stream" then
|
||||
FLAGS += "-DUSB_PROTOCOL_NATIVE_STREAM_BASED"
|
||||
elseif tup.getconfig("USB_PROTOCOL") == "ascii" then
|
||||
FLAGS += "-DUSB_PROTOCOL_LEGACY"
|
||||
elseif tup.getconfig("USB_PROTOCOL") == "none" then
|
||||
FLAGS += "-DUSB_PROTOCOL_NONE"
|
||||
else
|
||||
error("unknown USB protocol")
|
||||
end
|
||||
|
||||
-- UART I/O settings
|
||||
if tup.getconfig("UART_PROTOCOL") == "native" then
|
||||
FLAGS += "-DUART_PROTOCOL_NATIVE"
|
||||
elseif tup.getconfig("UART_PROTOCOL") == "ascii" or tup.getconfig("UART_PROTOCOL") == "" then
|
||||
FLAGS += "-DUART_PROTOCOL_LEGACY"
|
||||
elseif tup.getconfig("UART_PROTOCOL") == "none" then
|
||||
FLAGS += "-DUART_PROTOCOL_NONE"
|
||||
else
|
||||
error("unknown UART protocol "..tup.getconfig("UART_PROTOCOL"))
|
||||
end
|
||||
|
||||
-- GPIO settings
|
||||
if tup.getconfig("STEP_DIR") == "y" then
|
||||
if tup.getconfig("UART_PROTOCOL") == "none" then
|
||||
FLAGS += "-DUSE_GPIO_MODE_STEP_DIR"
|
||||
else
|
||||
error("Step/dir mode conflicts with UART. Set CONFIG_UART_PROTOCOL to none.")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- C-specific flags
|
||||
@@ -16,6 +76,7 @@ FLAGS += '-mfpu=fpv4-sp-d16'
|
||||
FLAGS += '-mfloat-abi=hard'
|
||||
FLAGS += { '-Wall', '-fdata-sections', '-ffunction-sections'}
|
||||
|
||||
-- debug build
|
||||
FLAGS += '-g -gdwarf-2'
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Copy this file to tup.config and adapt it to your needs
|
||||
CONFIG_DEBUG=y
|
||||
#CONFIG_BOARD_VERSION=v3.3 # make sure this fits your board
|
||||
CONFIG_USB_PROTOCOL=native
|
||||
CONFIG_UART_PROTOCOL=ascii
|
||||
CONFIG_STEP_DIR=n
|
||||
Reference in New Issue
Block a user