Skip to content

Commit

Permalink
add can-zero board
Browse files Browse the repository at this point in the history
  • Loading branch information
karu2003 committed Nov 26, 2023
1 parent 6dcaf94 commit 2e38f7b
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test_linux_sbc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ jobs:
bebop,
erlebrain2,
pxfmini,
pxf
pxf,
canzero,
]
toolchain: [
armhf,
Expand Down
13 changes: 13 additions & 0 deletions Tools/ardupilotwaf/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,19 @@ def configure_env(self, cfg, env):
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_LINUX_OBAL_V1',
)

class canzero(linux):
toolchain = 'arm-linux-gnueabihf'

def __init__(self):
self.with_can = True

def configure_env(self, cfg, env):
super(canzero, self).configure_env(cfg, env)

env.DEFINES.update(
CONFIG_HAL_BOARD_SUBTYPE = 'HAL_BOARD_SUBTYPE_LINUX_CANZERO',
)

class SITL_static(sitl):
def configure_env(self, cfg, env):
super(SITL_static, self).configure_env(cfg, env)
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/board_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def __init__(self):
Board("bbbmini"),
Board("blue"),
Board("pxfmini"),
Board("canzero"),
Board("SITL_x86_64_linux_gnu"),
Board("SITL_arm_linux_gnueabihf"),
]
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/firmware_version_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class BoardSubType(enum.Enum):
LINUX_NAVIGATOR = 1023
LINUX_VNAV = 1024
LINUX_OBAL = 1025
LINUX_CANZERO = 1026
CHIBIOS_SKYVIPER_F412 = 5000
CHIBIOS_FMUV3 = 5001
CHIBIOS_FMUV4 = 5002
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_HAL/AP_HAL_Boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#define HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR 1023
#define HAL_BOARD_SUBTYPE_LINUX_VNAV 1024
#define HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 1025
#define HAL_BOARD_SUBTYPE_LINUX_CANZERO 1026

/* HAL CHIBIOS sub-types, starting at 5000
Expand Down
17 changes: 16 additions & 1 deletion libraries/AP_HAL/board/linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,22 @@
#define HAL_BARO_PROBE_LIST PROBE_BARO_SPI(MS56XX, "ms5611")
#define HAL_MAG_PROBE_LIST PROBE_MAG_SPI(LIS3MDL, lis3mdl, false, ROTATION_ROLL_180_YAW_90)
#define HAL_OPTFLOW_PX4FLOW_I2C_BUS 0

#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
#define HAL_INS_PROBE_LIST PROBE_IMU_SPI(Invensense, "mpu9250", ROTATION_NONE)
#define HAL_BARO_PROBE_LIST PROBE_BARO_SPI(MS56XX, "ms5611")
#define HAL_MAG_PROBE_LIST PROBE_MAG_IMU(AK8963, mpu9250, 0, ROTATION_NONE)
#define HAL_PROBE_EXTERNAL_I2C_COMPASSES
#define HAL_NUM_CAN_IFACES 1
#define HAL_CAN_DRIVER_DEFAULT 1
#define HAL_GPIO_A_LED_PIN 22
#define HAL_GPIO_B_LED_PIN 27
#define HAL_GPIO_C_LED_PIN 6
#define HAL_GPIO_LED_ON 0
#define HAL_GPIO_LED_OFF 1
#define HAL_BOARD_LOG_DIRECTORY "/home/pi/ardupilot/logs"
#define HAL_BOARD_TERRAIN_DIRECTORY "/home/pi/ardupilot/terrain"
#define HAL_BOARD_STORAGE_DIRECTORY "/home/pi/ardupilot"
#define HAL_DEFAULT_INS_FAST_SAMPLE 0
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1

//#define HAL_BARO_ALLOW_INIT_NO_BARO
Expand Down
4 changes: 3 additions & 1 deletion libraries/AP_HAL_Linux/GPIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class DigitalSource : public AP_HAL::DigitalSource {
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO

#include "GPIO_RPI.h"
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
#include "GPIO_Navigator.h"
Expand Down
3 changes: 2 additions & 1 deletion libraries/AP_HAL_Linux/GPIO_RPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO

#include <assert.h>
#include <errno.h>
Expand Down
14 changes: 10 additions & 4 deletions libraries/AP_HAL_Linux/HAL_Linux_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ using namespace Linux;
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
static UtilRPI utilInstance;
#else
static Util utilInstance;
Expand Down Expand Up @@ -90,7 +91,8 @@ static UARTDriver uartBDriver(false);
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR|| \
((CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1) && (OBAL_ALLOW_ADC ==1))
((CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1) && (OBAL_ALLOW_ADC ==1)) || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
static AnalogIn_ADS1115 analogIn;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD || \
Expand Down Expand Up @@ -123,7 +125,8 @@ static GPIO_BBB gpioDriver;
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
static GPIO_RPI gpioDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR
static GPIO_Navigator gpioDriver;
Expand Down Expand Up @@ -154,7 +157,8 @@ static RCInput_Multi rcinDriver{2, new RCInput_AioPRU, new RCInput_RCProtocol(NU
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
static RCInput_RPI rcinDriver;
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ZYNQ || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OCPOC_ZYNQ
Expand Down Expand Up @@ -219,6 +223,8 @@ static RCOutput_Sysfs rcoutDriver(0, 0, 15);
static RCOutput_Sysfs rcoutDriver(0, 0, 8);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
static RCOutput_PCA9685 rcoutDriver(i2c_mgr_instance.get_device(1, PCA9685_PRIMARY_ADDRESS), 0, 0, RPI_GPIO_<17>());
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
static RCOutput_Sysfs rcoutDriver(0, 0, 2);
#else
static Empty::RCOutput rcoutDriver;
#endif
Expand Down
3 changes: 2 additions & 1 deletion libraries/AP_HAL_Linux/RCInput_RPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
Expand Down
7 changes: 6 additions & 1 deletion libraries/AP_HAL_Linux/SPIDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ SPIDesc SPIDeviceManager::_device[] = {
#endif
};
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
SPIDesc SPIDeviceManager::_device[] = {
SPIDesc("mpu9250", 0, 1, SPI_MODE_0, 8, SPI_CS_KERNEL, 1*MHZ, 11*MHZ),
SPIDesc("ms5611", 0, 0, SPI_MODE_0, 8, SPI_CS_KERNEL, 1*KHZ, 10*MHZ),
};
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
SPIDesc SPIDeviceManager::_device[] = {
SPIDesc("mpu9250", 0, 1, SPI_MODE_0, 8, SPI_CS_KERNEL, 1*MHZ, 11*MHZ),
SPIDesc("ms5611", 0, 0, SPI_MODE_0, 8, SPI_CS_KERNEL, 10*MHZ, 10*MHZ),
};
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI
SPIDesc SPIDeviceManager::_device[] = {
SPIDesc("mpu9250", 2, 0, SPI_MODE_3, 8, SPI_CS_KERNEL, 1*MHZ, 11*MHZ),
Expand Down
3 changes: 2 additions & 1 deletion libraries/AP_HAL_Linux/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ extern const AP_HAL::HAL& hal;
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
#define APM_LINUX_RCIN_RATE 500
#define APM_LINUX_IO_RATE 50
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
Expand Down
3 changes: 2 additions & 1 deletion libraries/AP_HAL_Linux/Util_RPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DARK || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIGATOR || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO

#include <errno.h>
#include <stdarg.h>
Expand Down
6 changes: 4 additions & 2 deletions libraries/AP_Notify/AP_Notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ AP_Notify *AP_Notify::_singleton;
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BH || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_OBAL_V1 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
#define DEFAULT_NTF_LED_TYPES (Notify_LED_Board)

#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ
Expand Down Expand Up @@ -436,7 +437,8 @@ void AP_Notify::add_backends(void)
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBRAIN2 || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_RST_ZYNQ || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE || \
CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_CANZERO
// No noise makers, keep this though to ensure that the final else is safe

#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI || \
Expand Down

0 comments on commit 2e38f7b

Please sign in to comment.