Skip to content

Commit

Permalink
[chibios] Update chibios and add Pixhawk 6X autopilot
Browse files Browse the repository at this point in the history
  • Loading branch information
fvantienen committed Apr 19, 2024
1 parent 893a65f commit 9ddcd69
Show file tree
Hide file tree
Showing 45 changed files with 3,237 additions and 121 deletions.
360 changes: 360 additions & 0 deletions conf/airframes/examples/pixhawk_6x.xml

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions conf/boards/pixhawk_6x.makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Hey Emacs, this is a -*- makefile -*-
#
# cube_orange.makefile
#
# This is for the main MCU (STM32F767) on the PX4 board
# See https://pixhawk.org/modules/pixhawk for details
#

BOARD=px4fmu
BOARD_VERSION=v6x
BOARD_DIR=$(BOARD)/chibios/$(BOARD_VERSION)
BOARD_CFG=\"arch/chibios/common_board.h\"

ARCH=chibios
$(TARGET).ARCHDIR = $(ARCH)

RTOS=chibios
MCU=cortex-m7

# FPU on F7
USE_FPU=hard
USE_FPU_OPT= -mfpu=fpv5-d16

#USE_LTO=yes

$(TARGET).CFLAGS += -DPPRZLINK_ENABLE_FD

##############################################################################
# Architecture or project specific options
#
# Define project name here (target)
PROJECT = $(TARGET)

# Project specific files and paths (see Makefile.chibios for details)
CHIBIOS_BOARD_PLATFORM = STM32H7xx/platform.mk
CHIBIOS_LINKER_DIR = $(PAPARAZZI_SRC)/sw/airborne/arch/chibios/
CHIBIOS_BOARD_LINKER = STM32H743xI.ld
CHIBIOS_BOARD_STARTUP = startup_stm32h7xx.mk

##############################################################################
# Compiler settings
#

# default flash mode is the PX4 bootloader
# possibilities: DFU, SWD, PX4 bootloader
FLASH_MODE ?= PX4_BOOTLOADER
PX4_TARGET = "ap"
PX4_PROTOTYPE ?= "${PAPARAZZI_HOME}/sw/tools/px4/px4fmu_v6x.prototype"
PX4_BL_PORT ?= "/dev/serial/by-id/*-BL_*,/dev/serial/by-id/*_BL_*"

#
# default LED configuration
#
SDLOG_LED ?= none
RADIO_CONTROL_LED ?= none
BARO_LED ?= none
AHRS_ALIGNER_LED ?= none
GPS_LED ?= none
SYS_TIME_LED ?= 4

#
# default UART configuration (modem, gps, spektrum)
# The TELEM2 port
SBUS_PORT ?= UART6
RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT ?= UART6

# The TELEM1 port (UART5 is TELEM2, UART2 is TELEM3)
MODEM_PORT ?= UART7
MODEM_BAUD ?= B57600

# The GPS1 port (UART1 is GPS2)
GPS_PORT ?= UART8
GPS_BAUD ?= B460800

# InterMCU port connected to the IO processor
#INTERMCU_PORT ?= UART6
#INTERMCU_BAUD ?= B1500000

#
# default actuator configuration
#
# you can use different actuators by adding a configure option to your firmware section
# e.g. <configure name="ACTUATORS" value="actuators_ppm/>
# and by setting the correct "driver" attribute in servo section
# e.g. <servo driver="Ppm">
#
ACTUATORS ?= actuators_pwm

13 changes: 12 additions & 1 deletion conf/conf_tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/rotorcraft_basic_geofence.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/gps_ubx_ucenter.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/preflight_checks.xml modules/scheduling_indi_simple.xml modules/stabilization_indi_simple.xml"
settings_modules="modules/air_data.xml modules/airspeed_uavcan.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/gps_ubx_ucenter.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/preflight_checks.xml modules/scheduling_indi_simple.xml modules/stabilization_indi_simple.xml"
gui_color="blue"
/>
<aircraft
Expand Down Expand Up @@ -109,4 +109,15 @@
settings_modules="modules/air_data.xml modules/electrical.xml modules/gps.xml modules/guidance_pid_rotorcraft.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/ins_ekf2.xml modules/nav_rotorcraft.xml modules/stabilization_int_quat.xml"
gui_color="red"
/>
<aircraft
name="Pixhawk6X"
ac_id="5"
airframe="airframes/examples/pixhawk_6x.xml"
radio="radios/crossfire_sbus.xml"
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/rotorcraft_basic_geofence.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/preflight_checks.xml modules/scheduling_indi_simple.xml modules/stabilization_indi_simple.xml"
gui_color="blue"
/>
</conf>
20 changes: 16 additions & 4 deletions conf/modules/baro_board.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,39 @@ LIA_BARO ?= BARO_MS5611_SPI

# PX4FMU
else ifeq ($(BOARD),$(filter $(BOARD),px4fmu))
include $(CFG_SHARED)/spi_master.makefile
BARO_BOARD_SRCS += peripherals/ms5611.c
BARO_BOARD_SRCS += peripherals/ms5611_spi.c
BARO_BOARD_SRCS += boards/baro_board_ms5611_spi.c
ifeq ($(BOARD_VERSION), 1.7)
# PX4FMU 1.7
include $(CFG_SHARED)/spi_master.makefile
BARO_BOARD_SRCS += peripherals/ms5611.c
BARO_BOARD_SRCS += peripherals/ms5611_spi.c
BARO_BOARD_SRCS += boards/baro_board_ms5611_spi.c
BARO_BOARD_CFLAGS += -DUSE_SPI1 -DUSE_SPI_SLAVE3
BARO_BOARD_CFLAGS += -DBB_MS5611_SPI_DEV=spi1
BARO_BOARD_CFLAGS += -DBB_MS5611_SLAVE_IDX=SPI_SLAVE3
else ifeq ($(BOARD_VERSION), 2.4)
# PX4FMU 2.4 a.k.a. PIXHAWK
include $(CFG_SHARED)/spi_master.makefile
BARO_BOARD_SRCS += peripherals/ms5611.c
BARO_BOARD_SRCS += peripherals/ms5611_spi.c
BARO_BOARD_SRCS += boards/baro_board_ms5611_spi.c
BARO_BOARD_CFLAGS += -DUSE_SPI1 -DUSE_SPI_SLAVE3
BARO_BOARD_CFLAGS += -DBB_MS5611_SPI_DEV=spi1
BARO_BOARD_CFLAGS += -DBB_MS5611_SLAVE_IDX=SPI_SLAVE3
else ifeq ($(BOARD_VERSION), 4.0)
# PX4FMU 4.0 a.k.a. PX4_PIXRACER
include $(CFG_SHARED)/spi_master.makefile
BARO_BOARD_SRCS += peripherals/ms5611.c
BARO_BOARD_SRCS += peripherals/ms5611_spi.c
BARO_BOARD_SRCS += boards/baro_board_ms5611_spi.c
BARO_BOARD_CFLAGS += -DUSE_SPI2 -DUSE_SPI_SLAVE3
BARO_BOARD_CFLAGS += -DBB_MS5611_SPI_DEV=spi2
BARO_BOARD_CFLAGS += -DBB_MS5611_SLAVE_IDX=SPI_SLAVE3
else ifeq ($(BOARD_VERSION), 5.0)
# PX4FMU 5.0
include $(CFG_SHARED)/spi_master.makefile
BARO_BOARD_SRCS += peripherals/ms5611.c
BARO_BOARD_SRCS += peripherals/ms5611_spi.c
BARO_BOARD_SRCS += boards/baro_board_ms5611_spi.c
BARO_BOARD_CFLAGS += -DUSE_SPI4 -DUSE_SPI_SLAVE4
BARO_BOARD_CFLAGS += -DBB_MS5611_SPI_DEV=spi4
BARO_BOARD_CFLAGS += -DBB_MS5611_SLAVE_IDX=SPI_SLAVE4
Expand Down
25 changes: 25 additions & 0 deletions conf/modules/boards/pixhawk_6x.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE module SYSTEM "../module.dtd">

<module name="pixhawk_v6x" dir="boards">
<doc>
<description>
Specific configuration for Pixhawk V6X with ChibiOS
</description>
</doc>
<dep>
<depends>spi_master,baro_bmp3</depends>
</dep>
<makefile target="!sim|nps|fbw">
<define name="USE_RTC_BACKUP" value="TRUE"/>
<configure name="SDLOG_USE_RTC" value="FALSE"/>
<configure name="SDLOG_SDIO" value="SDCD2"/>

<!-- On FMU board -->
<!--configure name="BMP3_I2C_DEV" value="i2c2"/>
<define name="BMP3_SLAVE_ADDR" value="BMP3_I2C_ADDR"/-->

<!-- On IMU board -->
<configure name="BMP3_I2C_DEV" value="i2c4"/>
<define name="BMP3_SLAVE_ADDR" value="BMP3_I2C_ADDR_ALT"/>
</makefile>
</module>
2 changes: 1 addition & 1 deletion conf/modules/imu_cube.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</description>
</doc>
<dep>
<depends>spi_master,imu_common,intermcu_iomcu,imu_heater</depends>
<depends>spi_master,i2c,imu_common,intermcu_iomcu,imu_heater</depends>
<provides>imu</provides>
</dep>
<header>
Expand Down
76 changes: 76 additions & 0 deletions conf/modules/imu_pixhawk6x.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="imu_pixhawk6x" dir="imu" task="sensors">
<doc>
<description>
IMU driver for the sensors inside the Pixhawk 6X autopilots
- IMU1: ICM42670
- IMU2: ???
- IMU3: ???
</description>
</doc>
<dep>
<depends>spi_master,i2c,imu_common,imu_heater</depends>
<provides>imu</provides>
</dep>
<header>
<file name="imu_pixhawk6x.h"/>
</header>
<init fun="imu_pixhawk6x_init()"/>
<periodic fun="imu_pixhawk6x_periodic()"/>
<event fun="imu_pixhawk6x_event()"/>
<makefile target="!sim|nps|fbw">
<!-- Files -->
<file name="invensense2.c" dir="peripherals"/>
<file name="invensense3.c" dir="peripherals"/>
<file name="imu_pixhawk6x.c"/>

<!-- IMU1: ICM42670 -->
<configure name="PIXHAWK6X_IMU1_SPI_DEV" default="spi1" case="lower|upper"/>
<configure name="PIXHAWK6X_IMU1_SPI_SLAVE_IDX" default="SPI_SLAVE1"/>
<define name="PIXHAWK6X_IMU1_SPI_DEV" value="$(PIXHAWK6X_IMU1_SPI_DEV_LOWER)"/>
<define name="USE_$(PIXHAWK6X_IMU1_SPI_DEV_UPPER)"/>
<define name="PIXHAWK6X_IMU1_SPI_SLAVE_IDX" value="$(PIXHAWK6X_IMU1_SPI_SLAVE_IDX)"/>
<define name="USE_$(PIXHAWK6X_IMU1_SPI_SLAVE_IDX)"/>

<!-- IMU2: ICM42688-->
<configure name="PIXHAWK6X_IMU2_SPI_DEV" default="spi2" case="lower|upper"/>
<configure name="PIXHAWK6X_IMU2_SPI_SLAVE_IDX" default="SPI_SLAVE2"/>
<define name="PIXHAWK6X_IMU2_SPI_DEV" value="$(PIXHAWK6X_IMU2_SPI_DEV_LOWER)"/>
<define name="USE_$(PIXHAWK6X_IMU2_SPI_DEV_UPPER)"/>
<define name="PIXHAWK6X_IMU2_SPI_SLAVE_IDX" value="$(PIXHAWK6X_IMU2_SPI_SLAVE_IDX)"/>
<define name="USE_$(PIXHAWK6X_IMU2_SPI_SLAVE_IDX)"/>

<!-- IMU3: BMI088 / ICM20649 -->
<configure name="PIXHAWK6X_IMU3_SPI_DEV" default="spi3" case="lower|upper"/>
<configure name="PIXHAWK6X_IMU3_SPI_SLAVE_IDX" default="SPI_SLAVE3"/>
<define name="PIXHAWK6X_IMU3_SPI_DEV" value="$(PIXHAWK6X_IMU3_SPI_DEV_LOWER)"/>
<define name="USE_$(PIXHAWK6X_IMU3_SPI_DEV_UPPER)"/>
<define name="PIXHAWK6X_IMU3_SPI_SLAVE_IDX" value="$(PIXHAWK6X_IMU3_SPI_SLAVE_IDX)"/>
<define name="USE_$(PIXHAWK6X_IMU3_SPI_SLAVE_IDX)"/>

<!-- Configure the heater (ICM42688) -->
<define name="IMU_HEATER_GYRO_ID" value="IMU_PIXHAWK2_ID"/>
<define name="IMU_HEATER_TARGET_TEMP" value="45.0"/>
<define name="IMU_HEATER_P_GAIN" value="50.0"/>
<define name="IMU_HEATER_I_GAIN" value="0.07"/>

<test>
<define name="SPI_MASTER"/>
<define name="PIXHAWK6X_IMU1_SPI_DEV" value="spi1"/>
<define name="PIXHAWK6X_IMU1_SPI_SLAVE_IDX" value="1"/>
<define name="PIXHAWK6X_IMU2_SPI_DEV" value="spi2"/>
<define name="PIXHAWK6X_IMU2_SPI_SLAVE_IDX" value="2"/>
<define name="PIXHAWK6X_IMU3_SPI_DEV" value="spi3"/>
<define name="PIXHAWK6X_IMU3_SPI_SLAVE_IDX" value="3"/>
<define name="USE_SPI1"/>
<define name="USE_SPI2"/>
<define name="USE_SPI3"/>
<define name="USE_SPI_SLAVE1"/>
<define name="USE_SPI_SLAVE2"/>
<define name="USE_SPI_SLAVE3"/>
<define name="PERIODIC_FREQUENCY" value="512"/>
<define name="IMU_PIXHAWK6X_PERIODIC_FREQ" value="512"/>
</test>
</makefile>
</module>
12 changes: 12 additions & 0 deletions conf/modules/logger_sd_chibios.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
Files are written on a FAT file system using the FatFS library and can be accessed
by using the autopilot as a mass storage (plug USB while the board is running).
</description>
<configure name="SDLOG_SDIO" value="SDCDx" description="The SDC device which the SD card is connected to. Default: SDCD1"/>
<configure name="SDLOG_LED" value="none|num" description="LED number or 'none' to disable. Default: none"/>
<define name="SDLOG_START_DELAY" value="30" unit="s" description="Set the delay in seconds before starting the logger. This delay can be used to get plug USB cable and get data without starting a new log. Default: 30s"/>
<define name="SDLOG_AUTO_FLUSH_PERIOD" value="10" unit="s" description="Data flush period. Shorter period may decrease performances. Default: 10s"/>
Expand All @@ -31,8 +32,17 @@
<init fun="sdlog_chibios_init()"/>
<datalink message="INFO_MSG_UP" fun="logger_log_msg_up(buf)"/>
<makefile target="ap">
<!-- LED -->
<configure name="SDLOG_LED" default="none"/>
<define name="SDLOG_LED" value="$(SDLOG_LED)" cond="ifneq ($(SDLOG_LED),none)"/>

<!-- SDMMC device -->
<configure name="SDLOG_SDIO" default="SDCD1" case="upper"/>
<define name="SDLOG_SDIO" value="$(SDLOG_SDIO_UPPER)"/>
<define name="FATFS_HAL_DEVICE" value="$(SDLOG_SDIO_UPPER)"/>
<define name="USE_$(SDLOG_SDIO_UPPER)"/>

<!-- Files -->
<file name="sdlog_chibios.c"/>
<file name="sdlog_chibios/sdLog.c"/>
<file name="sdlog_chibios/msg_queue.c"/>
Expand All @@ -41,6 +51,8 @@
<file name="sdlog_chibios/usb_msd.c"/>
<file name="sdlog_chibios/usbStorage.c"/>
<file_arch name="sdio_arch.c" dir="mcu_periph"/>

<!-- Configuration -->
<configure name="SDLOG_USE_RTC" default="TRUE"/>
<configure name="USE_FATFS" value="TRUE"/>
<define name="HAL_USE_RTC" value="TRUE" cond="ifeq (,$(findstring $(SDLOG_USE_RTC),0 FALSE))"/>
Expand Down
33 changes: 0 additions & 33 deletions conf/userconf/tudelft/conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -593,37 +593,4 @@
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
<aircraft
name="RotatingWingV3F"
ac_id="10"
airframe="airframes/tudelft/rot_wing_v3f.xml"
radio="radios/crossfire_sbus.xml"
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/tudelft/rotating_wing_EHVB.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
<aircraft
name="RotatingWingV3G"
ac_id="11"
airframe="airframes/tudelft/rot_wing_v3g.xml"
radio="radios/crossfire_sbus.xml"
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/tudelft/rotating_wing_EHVB.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
<aircraft
name="RotatingWingV3H"
ac_id="33"
airframe="airframes/tudelft/rot_wing_v3h.xml"
radio="radios/crossfire_sbus.xml"
telemetry="telemetry/highspeed_rotorcraft.xml"
flight_plan="flight_plans/tudelft/rotating_wing_EHVB.xml"
settings="settings/rotorcraft_basic.xml"
settings_modules="modules/air_data.xml modules/airspeed_ms45xx_i2c.xml modules/airspeed_uavcan.xml modules/approach_moving_target.xml modules/ekf_aw.xml modules/electrical.xml modules/gps.xml modules/gps_ublox.xml modules/guidance_indi_hybrid.xml modules/guidance_rotorcraft.xml modules/imu_common.xml modules/imu_heater.xml modules/ins_ekf2.xml modules/logger_sd_chibios.xml modules/nav_hybrid.xml modules/nav_rotorcraft.xml modules/pfc_actuators.xml modules/preflight_checks.xml modules/rot_wing_automation.xml modules/rotwing_state.xml modules/stabilization_indi.xml modules/sys_id_auto_doublets.xml modules/sys_id_doublet.xml modules/target_pos.xml"
gui_color="red"
/>
</conf>

0 comments on commit 9ddcd69

Please sign in to comment.