Skip to content

Conversation

@sunyanmeng963
Copy link
Contributor

@sunyanmeng963 sunyanmeng963 commented Oct 16, 2025

User description

Description

Add new flight controller target BLUEBERRYF435WING

Configure ICM42688 gyro, SPL06 baro, AT7456E OSD, W25N01G flash

Setup 3 UARTs, 1 I2C sensors, 2 ADC channels

Define 9 PWM outputs ,1 LED strip ,1 BEEPER


PR Type

Enhancement


Description

This description is generated by an AI tool. It may have inaccuracies

  • Add new flight controller target BLUEBERRYF435WING for AT32F435 MCU

  • Configure ICM42605/ICM42688P gyro, SPL06 baro, MAX7456 OSD support

  • Setup 4 UARTs (USART1, USART3, USART7), I2C2 sensors, 2 ADC channels

  • Define 9 PWM outputs, LED strip (WS2811), beeper, and dual flash variants


Diagram Walkthrough

flowchart LR
  Target["BLUEBERRYF435WING Target"] --> MCU["AT32F435 MCU"]
  Target --> Sensors["Sensors Config"]
  Target --> IO["I/O Configuration"]
  Sensors --> Gyro["ICM42605/MPU6500/BMI270/LSM6DXX"]
  Sensors --> Baro["BMP280/DPS310 Baro"]
  Sensors --> OSD["MAX7456 OSD"]
  IO --> UART["4x UART Ports"]
  IO --> PWM["9x PWM Outputs"]
  IO --> Storage["Flash/SD Variants"]
Loading

File Walkthrough

Relevant files
Configuration changes
target.h
Define hardware configuration and pin mappings for target

src/main/target/BLUEBERRYF435WING/target.h

  • Define hardware pins for SPI1 (gyro), SPI2 (OSD/flash), I2C2
    (baro/mag)
  • Configure multiple IMU options: ICM42605, MPU6500, BMI270, LSM6DXX
  • Setup 4 UART ports, 2 ADC channels, LED strip, and beeper
  • Support both flash (W25N01G) and SD card storage variants
+197/-0 
target.c
Configure timer hardware for PWM outputs and LED                 

src/main/target/BLUEBERRYF435WING/target.c

  • Define 9 PWM timer outputs using TIM2, TIM3, TIM4 on various pins
  • Configure LED strip on PA8 using TIM1_CH1
  • Include commented alternative motor and LED configurations
+53/-0   
config.c
Configure default serial port functions and baudrates       

src/main/target/BLUEBERRYF435WING/config.c

  • Set USART7 for RX serial (CRSF receiver)
  • Configure USART3 for GPS and USART1 for MSP at 115200 baud
  • Include commented pinio box configuration option
+41/-0   
CMakeLists.txt
Add CMake build configuration for target variants               

src/main/target/BLUEBERRYF435WING/CMakeLists.txt

  • Add build targets for standard and SD card variants
+2/-0     

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Oct 16, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
- [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true -->

</details></td></tr>
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

qodo-code-review bot commented Oct 16, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Define only one hardware component per type

The target configuration incorrectly defines multiple drivers for the same
hardware types (IMU, barometer, flash). To prevent driver conflicts and ensure
correct operation, only one driver per hardware component should be enabled.

Examples:

src/main/target/BLUEBERRYF435WING/target.h [60-82]
#define USE_IMU_MPU6500
#define IMU_MPU6500_ALIGN       CW0_DEG 
#define MPU6500_SPI_BUS         BUS_SPI1
#define MPU6500_CS_PIN          SPI1_NSS_PIN

// ICM42605/ICM42688P
#define USE_IMU_ICM42605
#define IMU_ICM42605_ALIGN      CW0_DEG_FLIP

#define ICM42605_SPI_BUS        BUS_SPI1

 ... (clipped 13 lines)
src/main/target/BLUEBERRYF435WING/target.h [94-95]
#define USE_BARO_BMP280
#define USE_BARO_DPS310

Solution Walkthrough:

Before:

// src/main/target/BLUEBERRYF435WING/target.h

// Multiple IMUs defined
#define USE_IMU_MPU6500
#define USE_IMU_ICM42605
#define USE_IMU_BMI270
#define USE_IMU_LSM6DXX

// Multiple Baros defined
#define USE_BARO_BMP280
#define USE_BARO_DPS310

// Multiple Flash chips defined
#if !defined(BLUEBERRYF435WING_SD)
    #define USE_FLASH_M25P16
    #define USE_FLASH_W25N01G
#endif

After:

// src/main/target/BLUEBERRYF435WING/target.h

// Only one IMU should be defined, e.g. ICM42605
// #define USE_IMU_MPU6500
#define USE_IMU_ICM42605
// #define USE_IMU_BMI270
// #define USE_IMU_LSM6DXX

// Only one Baro should be defined, e.g. DPS310
// #define USE_BARO_BMP280
#define USE_BARO_DPS310

// Only one Flash chip should be defined, e.g. W25N01G
#if !defined(BLUEBERRYF435WING_SD)
    // #define USE_FLASH_M25P16
    #define USE_FLASH_W25N01G
#endif
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies a critical flaw where multiple mutually exclusive drivers for IMUs, barometers, and flash are enabled simultaneously, which will cause hardware conflicts and prevent the firmware from working correctly.

High
Possible issue
Add checks for serial port index

Add a check to ensure the index returned by findSerialPortIndexByIdentifier is
valid before accessing the portConfigs array to prevent potential out-of-bounds
access.

src/main/target/BLUEBERRYF435WING/config.c [36-39]

-serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART7)].functionMask = FUNCTION_RX_SERIAL;
-serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART3)].functionMask = FUNCTION_GPS;
-serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].functionMask = FUNCTION_MSP;
-serialConfigMutable()->portConfigs[findSerialPortIndexByIdentifier(SERIAL_PORT_USART1)].msp_baudrateIndex = BAUD_115200;
+int8_t portIndex;
 
+portIndex = findSerialPortIndexByIdentifier(SERIAL_PORT_USART7);
+if (portIndex > -1) {
+    serialConfigMutable()->portConfigs[portIndex].functionMask = FUNCTION_RX_SERIAL;
+}
+
+portIndex = findSerialPortIndexByIdentifier(SERIAL_PORT_USART3);
+if (portIndex > -1) {
+    serialConfigMutable()->portConfigs[portIndex].functionMask = FUNCTION_GPS;
+}
+
+portIndex = findSerialPortIndexByIdentifier(SERIAL_PORT_USART1);
+if (portIndex > -1) {
+    serialConfigMutable()->portConfigs[portIndex].functionMask = FUNCTION_MSP;
+    serialConfigMutable()->portConfigs[portIndex].msp_baudrateIndex = BAUD_115200;
+}
+
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a missing bounds check that could lead to an out-of-bounds write and a potential system crash, significantly improving the code's robustness.

Medium
Avoid defining multiple flash chips

Correct the configuration to enable only one SPI flash chip driver at a time, as
defining both USE_FLASH_M25P16 and USE_FLASH_W25N01G can lead to conflicts.

src/main/target/BLUEBERRYF435WING/target.h [129-139]

 #else
     #define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
     #define USE_FLASHFS
-    #define USE_FLASH_M25P16
-    #define M25P16_SPI_BUS          BUS_SPI2
-    #define M25P16_CS_PIN           PB5
+    // Enable one of the following flash chip definitions based on the hardware
+    // #define USE_FLASH_M25P16
+    // #define M25P16_SPI_BUS          BUS_SPI2
+    // #define M25P16_CS_PIN           PB5
 
     #define USE_FLASH_W25N01G
     #define W25N01G_SPI_BUS         BUS_SPI2
     #define W25N01G_CS_PIN          PB5
 #endif
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that defining two flash chips (USE_FLASH_M25P16 and USE_FLASH_W25N01G) can cause conflicts and proposes a fix, which improves the target's configuration clarity and prevents potential runtime issues.

Medium
  • Update

@sensei-hacker
Copy link
Member

sensei-hacker commented Oct 16, 2025

The suggestions from the bot can be ignored if the board has or may have all of those different components.

@sunyanmeng963
Copy link
Contributor Author

Sure, it's truly a smart robot.

@sensei-hacker
Copy link
Member

sensei-hacker commented Oct 18, 2025

  • Samples received
  • Flash firmware
  • Calibrate
  • Orientation matches
  • Gyro working
  • Accel working
  • Baro working
  • Blackbox
  • UART1
  • UART3
  • UART7
  • LEDs working
  • Buzzer working
  • Motor outputs
  • DShot support on m1-4
  • Servo outputs
  • Voltage ADC
  • Current ADC
  • Mag I2C Bus
  • Analog Camera working
  • Video Out working
  • OSD working
  • PINIO1

@sensei-hacker
Copy link
Member

It looks like someone started to define a PINIO pin, but commented it out. Is there a PINIO for the 9V BEC?

@sensei-hacker sensei-hacker self-assigned this Oct 20, 2025
@sensei-hacker sensei-hacker added New target This PR adds a new target Ready to merge labels Oct 20, 2025
@sensei-hacker sensei-hacker modified the milestones: 9.0, 8.1 Oct 20, 2025
@sensei-hacker
Copy link
Member

sensei-hacker commented Oct 20, 2025

@sunyanmeng963
Please merge https://github.com/sunyanmeng963/inav/pull/1/files which cleans up commented-out code, whitespace, etc.

@sunyanmeng963
Copy link
Contributor Author

Thank you for your review. I have incorporated your suggestions. @sensei-hacker

@sunyanmeng963
Copy link
Contributor Author

PINIO
9VBEC is not controlled by the MCU. Which pin do you mean by "PINO"? ADC3?In fact, it was originally there. Later, I changed it to PWM.

@sensei-hacker sensei-hacker changed the title Add new target buleberryF435wing Add new target blueberryF435wing Oct 20, 2025
@sensei-hacker
Copy link
Member

"PINIO" (pin IO) is what's used when a BEC is controlled by the user. If that's not used here, that's fine. We think we're all set

@sensei-hacker sensei-hacker merged commit 4d6054a into iNavFlight:master Oct 20, 2025
21 checks passed
@MrD-RC MrD-RC modified the milestones: 8.1, 9.0 Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New target This PR adds a new target Review effort 3/5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants