Betaflight飞控之4.5版本配置文件调整
1. 源由
自BF4.0开始引入抽象硬件配置文件概念后,存在较长一段target原始目标板配置与抽象硬件配置文件的混合存在期。
2022年AT32芯片被移植到BF代码后,抽象硬件配置文件又经历了一次更新迭代(同时该方法对ROM的需求将会减少使用量)。
经过确认,接下来的BF4.5版本将会使用迭代更新的抽象硬件配置文件方式对硬件进行描述。
- support AT32 unified-targets #1158
- How to Create a Flight Controller Configuration File for Betaflight 4.5
2. 对比
本次将针对AOCODARC H7Dual进行对比分析,给出差异化解释。
2.1 制造商定义
- BF4.0抽象统一配置文件
board_name AOCODARCH7DUAL
manufacturer_id SJET
- BF4.5抽象统一配置文件
#define BOARD_NAME AOCODARCH7DUAL
#define MANUFACTURER_ID SJET
2.2 资源定义
2.2.1 CPU选型
- BF4.0抽象统一配置文件
# Betaflight / STM32H743 (SH74) 4.3.0 Feb 1 2022 / 20:15:46 (3267f0417) MSP API: 1.44
- BF4.5抽象统一配置文件
#define FC_TARGET_MCU STM32H743
2.2.2 引脚定义
- BF4.0抽象统一配置文件
resource BEEPER 1 A15
resource MOTOR 1 B00
resource MOTOR 2 B01
resource MOTOR 3 A00
resource MOTOR 4 A01
resource MOTOR 5 A02
resource MOTOR 6 A03
resource MOTOR 7 D12
resource MOTOR 8 D13
resource SERVO 1 E05
resource SERVO 2 E06
resource PPM 1 A10
resource LED_STRIP 1 A08
resource SERIAL_TX 1 A09
resource SERIAL_TX 2 D05
resource SERIAL_TX 3 D08
resource SERIAL_TX 4 B09
resource SERIAL_TX 6 C06
resource SERIAL_TX 7 E08
resource SERIAL_TX 8 E01
resource SERIAL_RX 1 A10
resource SERIAL_RX 2 D06
resource SERIAL_RX 3 D09
resource SERIAL_RX 4 B08
resource SERIAL_RX 6 C07
resource SERIAL_RX 7 E07
resource SERIAL_RX 8 E00
resource I2C_SCL 1 B06
resource I2C_SCL 2 B10
resource I2C_SDA 1 B07
resource I2C_SDA 2 B11
resource LED 1 E03
resource LED 2 E04
resource SPI_SCK 1 A05
resource SPI_SCK 2 B13
resource SPI_SCK 3 B03
resource SPI_SCK 4 E12
resource SPI_MISO 1 A06
resource SPI_MISO 2 B14
resource SPI_MISO 3 B04
resource SPI_MISO 4 E13
resource SPI_MOSI 1 D07
resource SPI_MOSI 2 B15
resource SPI_MOSI 3 B05
resource SPI_MOSI 4 E14
resource ESCSERIAL 1 C07
resource ADC_BATT 1 C00
resource ADC_RSSI 1 C05
resource ADC_CURR 1 C01
resource ADC_EXT 1 C04
resource PINIO 1 D10
resource PINIO 2 D11
resource FLASH_CS 1 D03
resource OSD_CS 1 B12
resource GYRO_EXTI 1 B02
resource GYRO_EXTI 2 E15
resource GYRO_CS 1 C15
resource GYRO_CS 2 E11
resource USB_DETECT 1 E02
- BF4.5抽象统一配置文件
#define BEEPER_PIN PA15
#define MOTOR1_PIN PB0
#define MOTOR2_PIN PB1
#define MOTOR3_PIN PA0
#define MOTOR4_PIN PA1
#define MOTOR5_PIN PA2
#define MOTOR6_PIN PA3
#define MOTOR7_PIN PD12
#define MOTOR8_PIN PD13
#define SERVO1_PIN PE5
#define SERVO2_PIN PE6
#define RX_PPM_PIN PA10
#define LED_STRIP_PIN PA8
#define UART1_TX_PIN PA9
#define UART2_TX_PIN PD5
#define UART3_TX_PIN PD8
#define UART4_TX_PIN PB9
#define UART6_TX_PIN PC6
#define UART7_TX_PIN PE8
#define UART8_TX_PIN PE1
#define UART1_RX_PIN PA10
#define UART2_RX_PIN PD6
#define UART3_RX_PIN PD9
#define UART4_RX_PIN PB8
#define UART6_RX_PIN PC7
#define UART7_RX_PIN PE7
#define UART8_RX_PIN PE0
#define I2C1_SCL_PIN PB6
#define I2C2_SCL_PIN PB10
#define I2C1_SDA_PIN PB7
#define I2C2_SDA_PIN PB11
#define LED0_PIN PE3
#define LED1_PIN PE4
#define SPI1_SCK_PIN PA5
#define SPI2_SCK_PIN PB13
#define SPI3_SCK_PIN PB3
#define SPI4_SCK_PIN PE12
#define SPI1_SDI_PIN PA6
#define SPI2_SDI_PIN PB14
#define SPI3_SDI_PIN PB4
#define SPI4_SDI_PIN PE13
#define SPI1_SDO_PIN PD7
#define SPI2_SDO_PIN PB15
#define SPI3_SDO_PIN PB5
#define SPI4_SDO_PIN PE14
#define ESCSERIAL_PIN PC7
#define ADC_VBAT_PIN PC0
#define ADC_RSSI_PIN PC5
#define ADC_CURR_PIN PC1
#define ADC_EXTERNAL1_PIN PC4
#define PINIO1_PIN PD10
#define PINIO2_PIN PD11
#define FLASH_CS_PIN PD3
#define MAX7456_SPI_CS_PIN PB12
#define GYRO_1_EXTI_PIN PB2
#define GYRO_2_EXTI_PIN PE15
#define GYRO_1_CS_PIN PC15
#define GYRO_2_CS_PIN PE11
#define USB_DETECT_PIN PE2
2.2.3 IMU芯片
- BF4.0抽象统一配置文件
#define USE_ACCGYRO_BMI270
set gyro_1_bustype = SPI
set gyro_1_spibus = 1
set gyro_1_sensor_align = CW90
set gyro_1_align_yaw = 900
set gyro_2_spibus = 4
set gyro_2_sensor_align = CW180
set gyro_2_align_yaw = 1800
- BF4.5抽象统一配置文件
#define USE_GYRO
#define USE_ACC
#define USE_ACC_SPI_MPU6000
#define USE_GYRO_SPI_MPU6000
#define USE_ACCGYRO_BMI270
#define USE_ACC_SPI_ICM42688P
#define USE_GYRO_SPI_ICM42688P
#define USE_SPI_GYRO
#define GYRO_1_SPI_INSTANCE SPI1
#define GYRO_1_ALIGN CW90_DEG
#define GYRO_1_ALIGN_YAW 900
#define GYRO_2_SPI_INSTANCE SPI4
#define GYRO_2_ALIGN CW180_DEG
#define GYRO_2_ALIGN_YAW 1800
注:配置上增加了对MPU6000/ICM42688P的支持。
2.2.4 气压计芯片
- BF4.0抽象统一配置文件
#define USE_BARO_DPS310
- BF4.5抽象统一配置文件
#define USE_BARO
#define USE_BARO_BMP280
#define USE_BARO_MS5611
#define USE_BARO_DPS310
注:配置上增加了对BMP280/MS5611的支持。
2.2.5 存储芯片
- BF4.0抽象统一配置文件
#define USE_FLASH_W25N01G
set flash_spi_bus = 3
- BF4.5抽象统一配置文件
#define USE_FLASH
#define USE_FLASH_W25N01G
#define FLASH_SPI_INSTANCE SPI3
2.2.6 OSD芯片
- BF4.0抽象统一配置文件
#define USE_MAX7456
set max7456_spi_bus = 2
- BF4.5抽象统一配置文件
#define USE_MAX7456
#define MAX7456_SPI_INSTANCE SPI2
2.2.7 ADC DMA
- BF4.0抽象统一配置文件
dma ADC 1 8
# ADC 1: DMA2 Stream 0 Request 9
dma ADC 3 9
# ADC 3: DMA2 Stream 1 Request 115
- BF4.5抽象统一配置文件
#define ADC1_DMA_OPT 8
#define ADC3_DMA_OPT 9
#define TIMUP1_DMA_OPT 0
#define TIMUP3_DMA_OPT 2
#define TIMUP4_DMA_OPT 1
#define TIMUP5_DMA_OPT 0
2.2.8 Timer pin
- BF4.0抽象统一配置文件
# timer
timer A10 AF1
# pin A10: TIM1 CH3 (AF1)
timer B00 AF2
# pin B00: TIM3 CH3 (AF2)
timer B01 AF2
# pin B01: TIM3 CH4 (AF2)
timer A00 AF2
# pin A00: TIM5 CH1 (AF2)
timer A01 AF2
# pin A01: TIM5 CH2 (AF2)
timer A02 AF2
# pin A02: TIM5 CH3 (AF2)
timer A03 AF2
# pin A03: TIM5 CH4 (AF2)
timer D12 AF2
# pin D12: TIM4 CH1 (AF2)
timer D13 AF2
# pin D13: TIM4 CH2 (AF2)
timer D14 AF2
# pin D14: TIM4 CH3 (AF2)
timer D15 AF2
# pin D15: TIM4 CH4 (AF2)
timer E05 AF4
# pin E05: TIM15 CH1 (AF4)
timer E06 AF4
# pin E06: TIM15 CH2 (AF4)
timer A08 AF1
# pin A08: TIM1 CH1 (AF1)
- BF4.5抽象统一配置文件
#define TIMER_PIN_MAPPING \
TIMER_PIN_MAP( 0, PA10, 1, 0) \
TIMER_PIN_MAP( 1, PB0 , 2, 0) \
TIMER_PIN_MAP( 2, PB1 , 2, 1) \
TIMER_PIN_MAP( 3, PA0 , 2, 2) \
TIMER_PIN_MAP( 4, PA1 , 2, 3) \
TIMER_PIN_MAP( 5, PA2 , 2, 4) \
TIMER_PIN_MAP( 6, PA3 , 2, 5) \
TIMER_PIN_MAP( 7, PD12, 1, 6) \
TIMER_PIN_MAP( 8, PD13, 1, 7) \
TIMER_PIN_MAP( 9, PD14, 1, 12) \
TIMER_PIN_MAP(10, PD15, 1, -1) \
TIMER_PIN_MAP(11, PE5 , 1, 0) \
TIMER_PIN_MAP(12, PE6 , 1, -1) \
TIMER_PIN_MAP(13, PA8 , 1, 14)
2.3 配置定义
2.3.1 GYRO
- BF4.0抽象统一配置文件
set gyro_to_use = BOTH
- BF4.5抽象统一配置文件
#define DEFAULT_GYRO_TO_USE GYRO_CONFIG_USE_GYRO_BOTH
2.3.2 mag
- BF4.0抽象统一配置文件
set mag_bustype = I2C
set mag_i2c_device = 1
- BF4.5抽象统一配置文件
#define MAG_I2C_INSTANCE (I2CDEV_1)
2.3.3 baro
- BF4.0抽象统一配置文件
set baro_bustype = I2C
set baro_i2c_device = 2
- BF4.5抽象统一配置文件
#define BARO_I2C_INSTANCE (I2CDEV_2)
2.3.4 blackbox
- BF4.0抽象统一配置文件
set blackbox_device = SPIFLASH
- BF4.5抽象统一配置文件
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_FLASH
2.3.5 ADC
- BF4.0抽象统一配置文件
set current_meter = ADC
set battery_meter = ADC
set ibata_scale = 500
- BF4.5抽象统一配置文件
#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC
#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
#define DEFAULT_CURRENT_METER_SCALE 500
2.3.6 beep
- BF4.0抽象统一配置文件
set beeper_inversion = ON
set beeper_od = OFF
- BF4.5抽象统一配置文件
#define BEEPER_INVERTED
2.3.7 pinio
- BF4.0抽象统一配置文件
set pinio_config = 129,1,1,1
set pinio_box = 39,40,255,255
- BF4.5抽象统一配置文件
#define PINIO1_BOX 40
#define PINIO2_BOX 41
2.4 无对应定义
BF4.0抽象统一配置文件中未找到对应项:
# dma
dma TIMUP 1 0
# TIMUP 1: DMA1 Stream 0 Request 15
dma TIMUP 3 2
# TIMUP 3: DMA1 Stream 2 Request 27
dma TIMUP 4 1
# TIMUP 4: DMA1 Stream 1 Request 32
dma TIMUP 5 0
# TIMUP 5: DMA1 Stream 0 Request 59
dma pin A10 0
# pin A10: DMA1 Stream 0 Request 13
dma pin B00 0
# pin B00: DMA1 Stream 0 Request 25
dma pin B01 1
# pin B01: DMA1 Stream 1 Request 26
dma pin A00 2
# pin A00: DMA1 Stream 2 Request 55
dma pin A01 3
# pin A01: DMA1 Stream 3 Request 56
dma pin A02 4
# pin A02: DMA1 Stream 4 Request 57
dma pin A03 5
# pin A03: DMA1 Stream 5 Request 58
dma pin D12 6
# pin D12: DMA1 Stream 6 Request 29
dma pin D13 7
# pin D13: DMA1 Stream 7 Request 30
dma pin D14 12
# pin D14: DMA2 Stream 4 Request 31
dma pin E05 0
# pin E05: DMA1 Stream 0 Request 105
dma pin A08 14
# pin A08: DMA2 Stream 6 Request 11
# feature
feature RX_SERIAL
feature TELEMETRY
feature OSD
# serial
serial 0 64 115200 57600 0 115200
3. 预定义
目前,官方文档尚在整理过程中,详见:How to Create a Flight Controller Configuration File for Betaflight 4.5
注:以下内容,后续会尽量随着官方文档的补充,进行增减。实时情况,可以参考代码,或者上面官方指南。
3.1 Serial Configuration
Value | Function define |
---|---|
1 | MSP_UART |
2 | GPS_UART |
64 | SERIALRX_UART |
32 | SBUS_TELEMETRY_UART |
1024 | ESC_SENSOR_UART |
2048 | VTX_SMARTAUDIO_UART |
8192 | VTX_TRAMP_UART |
131072 | VTX_MSP_UART |
131073 | MSP_DISPLAYPORT_UART |
比如:
#define SERIALRX_UART SERIAL_PORT_USART1
#define VTX_SMARTAUDIO_UART SERIAL_PORT_USART3
#define GPS_UART SERIAL_PORT_USART4
3.2 Serial Receiver Provider
比如:
#define SERIALRX_PROVIDER CRSF
4. 参考资料
【1】BetaFlight开源代码框架简介
【2】BetaFlight统一硬件资源简单配置修改
【3】BetaFlight统一硬件配置文件研读之resource命令
【4】BetaFlight统一硬件配置文件研读之timer命令
【6】BetaFlight统一硬件配置文件研读之serial命令
【7】BetaFlight统一硬件配置文件研读之set命令
【8】BetaFlight统一硬件配置文件研读之feature命令
【9】BetaFlight统一硬件配置文件研读之dma命令
【10】BetaFlight统一硬件AOCODARC H7DUAL配置文件讨论
【11】BetaFlight飞控AOCODARC-F7MINI固件编译