Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hwdef :Add betaflightf4 hwdef.dat #28656

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tools/AP_Bootloader/board_types.txt
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ AP_HW_2RAWH743 1173
AP_HW_X-MAV-AP-H743V2 1174
AP_HW_BETAFPV_F4_2-3S_20A 1175
AP_HW_MicoAir743AIOv1 1176

AP_HW_BetaflightF4 1177
AP_HW_FlywooF405HD_AIOv2 1180
AP_HW_FlywooH743Pro 1181

Expand Down
Binary file added Tools/bootloaders/BetaflightF4_bl.bin
Binary file not shown.
893 changes: 893 additions & 0 deletions Tools/bootloaders/BetaflightF4_bl.hex

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/BetaflightF4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# CrazyF405HD ELRS 1-2SAIO Flight Controller

The CrazyF405HD ELRS 1-2S AIO is a flight controller produced by [Happymodel](https://www.happymodel.cn/index.php/2023/05/26/crazyf405hd-elrs-1-2s-aio-fc-built-in-uart-elrs-receiver-and-12a-blheli_s-esc/.)

## Features

- MCU: STM32F405RGT6, 168MHz
- Gyro: BMI270 (SPI)
- 1Mb Onboard Flash
- BEC output: 5V, 2A@4V
- Barometer: BMP280
- OSD:
- 3 UARTS: (UART1, UART2 ,UART6)
- 5 PWM outputs (4 motor outputs used internally for integrated 4-in-1 ESC and 1 integrated LED)
- Integrated 4-in-1 BlueJay ESC
- Firmware target: BetaflightF4

## Pinout

![CrazyF405HD ELRS 1-2S AIO Board](CrazyF405HD_pinout.jpg "CrazyF405HD ELRS 1-2S AIO")

## UART Mapping

The UARTs are marked Rn and Tn in the above pinouts. The Rn pin is the
receive pin for UARTn. The Tn pin is the transmit pin for UARTn.
|Name|Pin|Function|
|:-|:-|:-|
|SERIAL0|COMPUTER|USB|
|SERIAL1|RX1/TX1|UART1 ( DMA-enabled)|
|SERIAL2|TX2/RX2|UART2 (ELRS, internal)
|SERIAL6|RX6|UART6 (DMA-disabled)|

## RC Input

RC input is configured on the on-board ELRS on UART2 or through (UART2_RX/UART2_TX) pins. It supports all serial RC protocols.

## OSD Support
The CrazyF405HDAIO is optimized for Digital HD FPV and does not require the analog OSD chip (MAX7456); OSD data is transmitted via MSP to the digital VTX.

## PWM Output

The Carzyf405HD AIO has 4 PWM outputs internally connected to its 4-in-1 ESC. The pads for motor output are M1 to M4 on the board. All 4 outputs support bi-directional DShot and DShot, as well as all PWM types. The default configuration is for DShot using the already installed BlueJay firmware.


## Battery Monitoring

The board has a builtin voltage sensor and a current sensor input tied to its 4 in 1 ESC current sensor. The voltage sensor can handle up to 2S
LiPo/Li-Hv batteries.

The correct battery setting parameters are:

- BATT_MONITOR 4
- BATT_VOLT_PIN 12
- BATT_VOLT_MULT 10.9
- BATT_CURR_PIN 13
- BATT_CURR_MULT 50

These are set by default in the firmware and shouldn't need to be adjusted

## Compass

The BETAFPV F405 AIO does not have a builtin compass.


## Loading Firmware

Initial firmware load can be done with DFU by plugging in USB with the
bootloader button pressed. Then you should load the "with_bl.hex"
firmware, using your favourite DFU loading tool.

Once the initial firmware is loaded you can update the firmware using
any ArduPilot ground station software. Updates should be done with the
*.apj firmware files.
5 changes: 5 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/BetaflightF4/defaults.parm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Bluejay installed by default
SERVO_BLH_AUTO 1
SERVO_BLH_BDMASK 15
SERVO_DSHOT_ESC 2
MOT_PWM_TYPE 6
43 changes: 43 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/BetaflightF4/hwdef-bl.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

# hw definition file for processing by chibios_hwdef.py
# for BETAFLIGHTF4 hardware.
# thanks to betaflight for pin information

# MCU class and specific type
MCU STM32F4xx STM32F405xx

# board ID for firmware load
APJ_BOARD_ID 1177

# crystal frequency, setup to use external oscillator
OSCILLATOR_HZ 8000000

FLASH_SIZE_KB 1024

# bootloader starts at zero offset
FLASH_RESERVE_START_KB 0

# the location where the bootloader will put the firmware
FLASH_BOOTLOADER_LOAD_KB 48

# order of UARTs (and USB)
SERIAL_ORDER OTG1

# PA10 IO-debug-console
PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1

PA13 JTMS-SWDIO SWD
PA14 JTCK-SWCLK SWD

# default to all pins low to avoid ESD issues
DEFAULTGPIO OUTPUT LOW PULLDOWN


# Chip select pins
PA15 FLASH1_CS CS
PB12 OSD1_CS CS
PA4 GYRO1_CS CS

PB5 LED_BOOTLOADER OUTPUT LOW
define HAL_LED_ON 0
134 changes: 134 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/BetaflightF4/hwdef.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@

# hw definition file for processing by chibios_hwdef.py
# for BETAFLIGHTF4 hardware.
# thanks to betaflight for pin information

# MCU class and specific type
MCU STM32F4xx STM32F405xx

# board ID for firmware load
APJ_BOARD_ID 1177

# crystal frequency, setup to use external oscillator
OSCILLATOR_HZ 8000000

FLASH_SIZE_KB 1024

# bootloader takes first sector
FLASH_RESERVE_START_KB 48

define HAL_STORAGE_SIZE 16384
define STORAGE_FLASH_PAGE 1

STM32_ST_USE_TIMER 5

# SPI devices

# SPI1
PA5 SPI1_SCK SPI1
PA6 SPI1_MISO SPI1
PA7 SPI1_MOSI SPI1

# SPI2
PB13 SPI2_SCK SPI2
PB14 SPI2_MISO SPI2
PB15 SPI2_MOSI SPI2

# SPI3
PC10 SPI3_SCK SPI3
PC11 SPI3_MISO SPI3
PC12 SPI3_MOSI SPI3

# Chip select pins
PA15 FLASH1_CS CS
PB12 OSD_CS CS
PA4 GYRO1_CS CS

# Beeper
PB4 BUZZER OUTPUT GPIO(80) LOW
define HAL_BUZZER_PIN 80

# SERIAL ports
SERIAL_ORDER OTG1 USART1 USART2 EMPTY EMPTY USART6
# PA10 IO-debug-console
PA11 OTG_FS_DM OTG1
PA12 OTG_FS_DP OTG1

# USART1
PA10 USART1_RX USART1
PA9 USART1_TX USART1

# USART2
PA2 USART2_TX USART2
PA3 USART2_RX USART2


# USART6
PC6 USART6_TX USART6 NODMA
PC7 USART6_RX USART6 NODMA

# I2C ports
I2C_ORDER I2C2

# I2C2
PB10 I2C2_SCL I2C2
PB11 I2C2_SDA I2C2


# ADC ports

# ADC1
PC1 BATT_CURRENT_SENS ADC1 SCALE(1)
define HAL_BATT_CURR_PIN 11
define HAL_BATT_CURR_SCALE 25.0
PC2 BATT_VOLTAGE_SENS ADC1 SCALE(1)
define HAL_BATT_VOLT_PIN 12
define HAL_BATT_VOLT_SCALE 11.0
define HAL_BATT_MONITOR_DEFAULT 4

# MOTORS
PB0 TIM3_CH3 TIM3 PWM(1) GPIO(50) # M1
PB1 TIM3_CH4 TIM3 PWM(2) GPIO(51) # M2
PC9 TIM8_CH4 TIM8 PWM(3) GPIO(52) # M3
PC8 TIM8_CH3 TIM8 PWM(4) GPIO(53) # M4
PB6 TIM4_CH1 TIM4 PWM(5) GPIO(54) # M5

# LEDs

PB5 LED0 OUTPUT LOW GPIO(90)
define HAL_GPIO_A_LED_PIN 90


# Dataflash setup
SPIDEV dataflash SPI3 DEVID1 FLASH1_CS MODE3 104*MHZ 104*MHZ

define HAL_LOGGING_DATAFLASH_ENABLED 1

# OSD setup
SPIDEV osd SPI2 DEVID1 OSD_CS MODE0 10*MHZ 10*MHZ


define HAL_OSD_TYPE_DEFAULT 1
ROMFS_WILDCARD libraries/AP_OSD/fonts/font*.bin

# IMU setup
SPIDEV bmi270 SPI1 DEVID1 GYRO1_CS MODE3 2*MHZ 10*MHZ
IMU BMI270 SPI:bmi270 ROTATION_NONE
DMA_NOSHARE TIM3_UP TIM8_UP TIM4_UP SPI1*
DMA_PRIORITY TIM3_UP TIM8_UP TIM4_UP SPI1*

# Baro Setup
BARO BMP280 I2C:0:0x76

# no built-in compass, but probe the i2c bus for all possible
# external compass types
define ALLOW_ARM_NO_COMPASS
define HAL_PROBE_EXTERNAL_I2C_COMPASSES
define HAL_I2C_INTERNAL_MASK 0
define HAL_COMPASS_AUTO_ROT_DEFAULT 2
define HAL_DEFAULT_INS_FAST_SAMPLE 3
# Motor order implies Betaflight/X for standard ESCs
define HAL_FRAME_TYPE_DEFAULT 12

include ../include/minimize_common.inc
AUTOBUILD_TARGETS Copter
2 changes: 1 addition & 1 deletion modules/DroneCAN/DSDL
2 changes: 1 addition & 1 deletion modules/DroneCAN/dronecan_dsdlc
2 changes: 1 addition & 1 deletion modules/gbenchmark
Submodule gbenchmark updated 144 files
2 changes: 1 addition & 1 deletion modules/gtest
Submodule gtest updated 372 files
2 changes: 1 addition & 1 deletion modules/lwip
Submodule lwip updated 82 files
+1 −1 .github/workflows/ci-linux.yml
+7 −0 .gitignore
+5 −0 CHANGELOG
+3 −1 codespell_check.sh
+36 −4 contrib/apps/ping/ping.c
+1 −0 contrib/apps/ping/ping.h
+2 −2 contrib/examples/example_app/lwipopts.h
+1 −0 contrib/examples/mqtt/mqtt_example.c
+1 −0 contrib/examples/tftp/tftp_example.c
+5 −6 contrib/ports/unix/lib/lwipopts.h
+1 −1 contrib/ports/unix/posixlib/CMakeLists.txt
+1 −1 contrib/ports/unix/posixlib/include/posix/sockets.h
+4 −0 contrib/ports/win32/include/arch/cc.h
+57 −0 contrib/ports/win32/msvc/libcheck.vcxproj
+447 −0 contrib/ports/win32/msvc/lwIP.vcxproj
+22 −2 contrib/ports/win32/msvc/lwIP_Test.sln
+114 −2 contrib/ports/win32/msvc/lwIP_Test.vcxproj
+78 −0 contrib/ports/win32/msvc/lwIP_fuzz.sln
+79 −2 contrib/ports/win32/msvc/lwIP_pcapif.vcxproj
+21 −2 contrib/ports/win32/msvc/lwIP_unittests.sln
+476 −0 contrib/ports/win32/msvc/lwip_fuzz.vcxproj
+72 −0 contrib/ports/win32/msvc/lwip_unittests.vcxproj
+74 −2 contrib/ports/win32/msvc/makefsdata.vcxproj
+7 −2 contrib/ports/win32/pcapif.c
+1 −1 contrib/ports/win32/pcapif_helper.c
+1 −1 doc/doxygen/lwip.Doxyfile
+2 −2 src/Filelists.cmake
+1 −1 src/api/netdb.c
+86 −47 src/api/sockets.c
+1 −1 src/api/tcpip.c
+13 −4 src/apps/altcp_tls/altcp_tls_mbedtls.c
+34 −22 src/apps/http/http_client.c
+32 −18 src/apps/http/httpd.c
+4 −0 src/apps/http/makefsdata/makefsdata.c
+11 −4 src/apps/http/makefsdata/tinydir.h
+1 −1 src/apps/lwiperf/lwiperf.c
+1 −1 src/apps/mdns/mdns.c
+11 −4 src/apps/mqtt/mqtt.c
+1 −1 src/apps/netbiosns/netbiosns.c
+1 −1 src/apps/smtp/smtp.c
+1 −1 src/apps/snmp/snmp_core.c
+1 −1 src/apps/snmp/snmp_msg.c
+2 −1 src/apps/sntp/sntp.c
+1 −1 src/apps/tftp/tftp.c
+23 −0 src/core/def.c
+5 −2 src/core/init.c
+1 −1 src/core/ipv4/acd.c
+1 −1 src/core/ipv4/dhcp.c
+1 −0 src/core/ipv4/icmp.c
+2 −1 src/core/ipv6/ip6.c
+15 −1 src/core/ipv6/ip6_frag.c
+3 −3 src/core/ipv6/nd6.c
+11 −24 src/core/mem.c
+1 −1 src/core/netif.c
+16 −7 src/core/pbuf.c
+12 −2 src/core/tcp_in.c
+4 −1 src/core/tcp_out.c
+1 −1 src/core/udp.c
+2 −2 src/include/lwip/apps/http_client.h
+2 −0 src/include/lwip/apps/mqtt.h
+2 −2 src/include/lwip/apps/sntp_opts.h
+1 −1 src/include/lwip/arch.h
+10 −0 src/include/lwip/def.h
+2 −2 src/include/lwip/init.h
+1 −1 src/include/lwip/mem.h
+35 −5 src/include/lwip/opt.h
+1 −0 src/include/lwip/prot/nd6.h
+1 −1 src/include/lwip/snmp.h
+4 −1 src/include/lwip/stats.h
+1 −1 src/include/netif/ppp/pppoe.h
+1 −1 src/include/netif/ppp/vj.h
+2 −2 src/netif/ppp/auth.c
+3 −2 src/netif/ppp/fsm.c
+1 −1 src/netif/ppp/lcp.c
+6 −4 test/fuzz/fuzz_common.c
+1 −1 test/unit/api/test_sockets.c
+90 −1 test/unit/ip6/test_ip6.c
+6 −0 test/unit/lwip_unittests.c
+24 −1 test/unit/lwipopts.h
+1 −1 test/unit/mqtt/test_mqtt.c
+1 −1 test/unit/tcp/test_tcp.c
+2 −2 test/unit/tcp/test_tcp_oos.c
Loading