BetaFlight flight control AOCODAF435V2MPU6500 firmware compilation

BetaFlight flight control AOCODAF435V2MPU6500 firmware compilation

  • 1. Origin
  • 2. Prepare
    • 2.1 Board
    • 2.2 Code
    • 2.3 Tools
  • 3. Configuration modification
  • 4. Compile
    • 4.1 Get the code
    • 4.2 Get configuration
    • 4.3 Compile firmware
    • 4.4 DFU burning
    • 4.5 Version Check
  • 5. Summary
  • 6. Track issues
  • 7. Appendix

1. Origin

I just got an Aocoda F405V2 (MPU6500) + AT32F435 flight control board (replacing the main control chip).

  • Aocoda-RC F405V2 FC(STM32F405RGT6 v.s. AT32F435RGT7) IO Definitions
  • STM32F405RGT6 v.s. AT32F435RGT7 Comparison for Flight Controller

Prepare to try out the latest betaflight code from github, which should be 4.5.

2. Preparation

2.1 Board

The atbetaflight firmware v4.3.2 has been burned by default, and the hardware IMU/Baro/MAX7456 has been found.

2.2 Code

For this code version, see git log -n 1 below for details.

betaflight latest code

commit eee0cb54677aaf4daae28fd7068460abbffa53c8 (HEAD -> master, origin/master, origin/HEAD)
Author: Steve Evans <[email protected]>
Date: Sat Oct 21 23:40:46 2023 + 0100

    Fix buffer overflow in JETIEXBUS character reception (#13130)

    * Fix buffer overflow in jetiexbus character reception

    * Update src/main/rx/jetiexbus.c

    Co-authored-by: Mark Haslinghuis <[email protected]>

    ----------

    Co-authored-by: Mark Haslinghuis <[email protected]>

config latest configuration

commit 6fa050144d5e6bccf0f50ac67d014491ddb10a71 (HEAD -> master, origin/master, origin/HEAD)
Author: Steve Evans <[email protected]>
Date: Thu Oct 19 19:17:18 2023 + 0100

    Add ICM42688P to SKYSTARSF405 (#193)

2.3 Tools

Betaflight Configurator needs to be upgraded to version 10.10 or later.

Note: Previous versions cannot recognize AT32 chips.

Root cause: Artery AT32F435/7 DFU and VCP support #3259


Note: First, make sure that the AT32 DFU driver correctly identifies the hardware. The picture above is version 10.9, DFU recognizes the chip, but the configuration tool fails to enumerate.

3. Configuration modification

In view of the fact that the entire board is simply replaced. Based on some previous experience, based on the modification of AOCODAF405V2MPU6500, the new target AOCODAF435V2MPU6500 was added.

  • Betaflight flight control version 4.5 configuration file adjustment
  • BetaFlight Unified Hardware AOCODARC H7DUAL Profile Discussion
  • Simple configuration modification of BetaFlight unified hardware resources

Note: The following configuration is only the current version, make sure the firmware compiles normally. There may be some IO function abnormalities, which need to be confirmed by subsequent test flights and debugging.

/*
 * This file is part of Betaflight.
 *
 * Betaflight is free software. You can redistribute this software
 * and/or modify this software under the terms of the GNU General
 * Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later
 * version.
 *
 * Betaflight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this software.
 *
 * If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#define FC_TARGET_MCU AT32F435G

#define BOARD_NAME AOCODAF435V2MPU6500
#define MANUFACTURER_ID SJET

#define USE_GYRO
#define USE_GYRO_SPI_MPU6500
#defineUSE_ACC
#define USE_ACC_SPI_MPU6500
#define USE_BARO_BMP280
#define USE_BARO_DPS310
#define USE_FLASH
#define USE_FLASH_W25Q128FV
#define USE_MAX7456

#define BEEPER_PIN PB8
#define MOTOR1_PIN PC6
#define MOTOR2_PIN PC7
#define MOTOR3_PIN PC8
#define MOTOR4_PIN PC9
#define MOTOR5_PIN PA15
#define MOTOR6_PIN PA8
#define MOTOR7_PIN PB10
#define MOTOR8_PIN PB11
#define RX_PPM_PIN PA3
#define LED_STRIP_PIN PB1
#define UART1_TX_PIN PA9
#define UART2_TX_PIN PA2
#define UART3_TX_PIN PC10
#define UART4_TX_PIN PA0
#define UART5_TX_PIN PC12
#define UART1_RX_PIN PA10
#define UART2_RX_PIN PA3
#define UART3_RX_PIN PC11
#define UART4_RX_PIN PA1
#define UART5_RX_PIN PD2
#define I2C1_SCL_PIN PB6
#define I2C1_SDA_PIN PB7
#define LED0_PIN PC13
#define SPI1_SCK_PIN PA5
#define SPI2_SCK_PIN PB13
#define SPI3_SCK_PIN PB3
#define SPI1_SDI_PIN PA6
#define SPI2_SDI_PIN PB14
#define SPI3_SDI_PIN PB4
#define SPI1_SDO_PIN PA7
#define SPI2_SDO_PIN PB15
#define SPI3_SDO_PIN PB5
#define ESCSERIAL_PIN PC11
#define ADC_VBAT_PIN PC2
#define ADC_RSSI_PIN PC3
#define ADC_CURR_PIN PC1
#define FLASH_CS_PIN PC0
#define MAX7456_SPI_CS_PIN PA13
#define GYRO_1_EXTI_PIN PC4
#define GYRO_1_CS_PIN PA4
#define USB_DETECT_PIN PB12

#define TIMER_PIN_MAPPING \
    TIMER_PIN_MAP( 0, RX_PPM_PIN , 2, 0) \
    TIMER_PIN_MAP( 1, MOTOR1_PIN , 2, 1) \
    TIMER_PIN_MAP( 2, MOTOR2_PIN , 2, 1) \
    TIMER_PIN_MAP( 3, MOTOR3_PIN , 2, 1) \
    TIMER_PIN_MAP( 4, MOTOR4_PIN , 2, 0) \
    TIMER_PIN_MAP( 5, MOTOR5_PIN , 1, 0) \
    TIMER_PIN_MAP( 6, MOTOR6_PIN , 1, 1) \
    TIMER_PIN_MAP( 7, MOTOR7_PIN , 1, 0) \
    TIMER_PIN_MAP( 8, MOTOR8_PIN , 1, 0) \
    TIMER_PIN_MAP( 9, LED_STRIP_PIN , 2, 0)


#define ADC_INSTANCE ADC3
#define ADC3_DMA_OPT 1

#define MAG_I2C_INSTANCE (I2CDEV_1)
#define USE_BARO
#define BARO_I2C_INSTANCE (I2CDEV_1)
#define DEFAULT_BLACKBOX_DEVICE BLACKBOX_DEVICE_FLASH
#define DEFAULT_DSHOT_BURST DSHOT_DMAR_OFF
#define DEFAULT_DSHOT_BITBANG DSHOT_BITBANG_OFF
#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC
#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC
#define DEFAULT_CURRENT_METER_SCALE 500
#define BEEPER_INVERTED
#define SYSTEM_HSE_MHZ 8
#define MAX7456_SPI_INSTANCE SPI2
#define FLASH_SPI_INSTANCE SPI3
#define USE_SPI_GYRO
#define GYRO_1_SPI_INSTANCE SPI1

4. Compile

4.1 Get code

$ git clone [email protected]:betaflight/betaflight.git
$ cd betaflight

4.2 Get configuration

$ cd src/
$ git clone [email protected]:betaflight/config.git
$ cd ..

4.3 Compiling firmware

$ make AOCODAF435V2MPU6500
$ ls obj
betaflight_4.5.0_AT32F435G_AOCODAF435V2MPU6500.hex

Note: Please refer to iNav flight control AOCODARC-F7MINI firmware compilation

4.4 DFU burning

Press and hold the Reset button, power on the flight controller via USB, and enter DFU mode.

4.5 version check

5. Summary

  1. betaflight firmware version, flight control configuration ==》Basically normal
  2. Gyro/Acc/Baro and sensor data ==》Basically normal
  3. Gyro calibration, Pitch/Roll/Yaw ==》Basically normal
  4. [Solved] OSD MAX7456 chip SPI not found ==》Abnormal //atbetaflight is normal
  5. [Solved] Chip internal temperature: Vref=0. 0V, Core temp=-281degC ==》Abnormal //atbetaflight is normal
  6. [To be verified] Suspected problem: The motor page prompts that 4 motor configurations are required ==》Exception //To be confirmed TIMER_PIN_MAP


6. Tracking issues

【1】 AT32F435 internal reference voltage issue “Vref=0. 0V” #13133
【2】 AT32F435 OSD_CS resouce allocate issue #13134
【3】How was the fourth parameter determined in TIMER_PIN_MAP? #13135
【4】 VCP hangs on AT32 while getting dma list of valid resource #13138

7. Appendix

betaflight 4.5 basically works normally:

  • betaflight(AocodaRC)
  • AOCODAF435V2MPU6500/config.h
# status
MCU AT32F435 Clock=288MHz, Vref=3.29V, Core temp=63degC
Stack size: 2048, Stack address: 0x2002fff0
Configuration: CONFIGURED, size: 4057, max available: 16384
Devices detected: SPI:1, I2C:1
Gyros detected: gyro 1 locked dma
GYRO=MPU6500, ACC=MPU6500, BARO=DPS310
OSD: MAX7456 (30 x 13)
System Uptime: 7 seconds, Current Time: 2023-10-24T06:02:28.061 + 00:00
CPU:20%, cycle time: 124, GYRO rate: 8064, RX rate: 15, System rate: 9
Voltage: 0 * 0.01V (0S battery - NOT PRESENT)
I2C Errors: 0
FLASH: JEDEC ID=0x00ef4018 16M
GPS: NOT ENABLED
Arming disable flags: RXLOSS ANGLE CLI MSP

# version
# Betaflight / AT32F435G (A435) 4.5.0 Oct 24 2023 / 13:58:02 (4f17fe0aa) MSP API: 1.46
# config rev: 6ab06df
# board: manufacturer_id: SJET, board_name: AOCODAF435V2MPU6500