Skip to content

Add HGLRCH743 #872

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add HGLRCH743 #872

wants to merge 1 commit into from

Conversation

HGLRC-T
Copy link
Contributor

@HGLRC-T HGLRC-T commented Aug 19, 2025

Checklist

  • passed schematics review
  • passed hardware samples testing
  • follows guidelines
  • follows connector standards
  • flight tested
  • comments/issues resolved

Summary by CodeRabbit

  • New Features
    • Added support for the HGLRC H743 flight controller (STM32H743).
    • Out-of-the-box support for onboard gyro/accelerometer and barometer.
    • Enabled on-screen display and onboard flash Blackbox logging.
    • Multiple UARTs and common peripheral buses available for accessories.
    • Supports up to 8 motors and 4 servos with flexible timer mapping.
    • Preconfigured ADC-based voltage, current, and RSSI monitoring.
    • Beeper and status LEDs supported.

Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Adds a new Betaflight board configuration header for HGLRCH743 (STM32H743), defining sensors, buses, peripherals, pin mappings, timers, DMA options, and default meter sources/devices.

Changes

Cohort / File(s) Change Summary
New Board Config: HGLRCH743
configs/HGLRCH743/config.h
Introduces a full board config: enables ICM42688P ACC/GYRO (SPI), DPS310 BARO (I2C), MAX7456, W25Q128FV flash; defines SPI1/2/3, I2C1/2, UART1–8, LEDs, beeper (inverted), motors (8), servos (4), ADCs (VBAT/CURRENT/RSSI); sets BLACKBOX_DEVICE_FLASH; CURRENT/VOLTAGE meter sources and scales; BARO_I2C=1, MAG_I2C=2; extensive TIMER_PIN_MAPPING; ADC1/ADC3 DMA options; PINIO1 and BOX constants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • haslinghuis
  • ot0tot
  • nerdCopter
  • blckmn

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or `` to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
configs/HGLRCH743/config.h (3)

107-121: TIMER_PIN_MAPPING: suspicious entry for PD15 (value 14) and mixed flags; verify channels/AF/DMA.

  • Most entries have the last field -1 or 0, but PD15 (Line 119) uses 14, which stands out. Make sure this aligns with the timer/channel and DMA/AF expectations for H743.
  • Ensure LED_STRIP on PA0 (index 12) does not conflict with motor timers in terms of DMA usage/DMAMUX. H7 improves DMAMUX flexibility, but practical conflicts can still occur depending on driver assumptions.

Please confirm timer instances and channels for:

  • PE9/11/13/14 (TIM1 CH1–CH4) for motors 1–4,
  • PA2/PA3/PB0/PB1 (TIM2/TIM3 channels) for motors 5–8,
  • PD12–PD15 (likely TIM4 CH1–CH4) for servos,
  • PA0 for LED_STRIP.

If PD15 truly requires a non-default selector (14), consider adding a brief comment noting the reason for maintainability.


100-103: ADC channels and default scales: please calibrate/confirm.

  • VBAT: PC0, CURRENT: PC1, RSSI: PC4 are plausible ADC inputs for H743.
  • DEFAULT_CURRENT_METER_SCALE=200 and DEFAULT_VOLTAGE_METER_SCALE=210 are board-specific. Please confirm these against resistor dividers and shunt specs; otherwise users will see inaccurate OSD values. If uncertain, consider leaving defaults closer to known-good Betaflight baselines and document expected CLI calibration.

Also applies to: 128-131


68-68: LED_STRIP on PA0 shares AFs with UART4_TX; callout for future maintenance.

You’ve placed LED_STRIP on PA0, which is also a common UART4_TX pin. That’s fine if intended by hardware, but worth noting to avoid future remaps that inadvertently collide.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between df10848 and 7cf4478.

📒 Files selected for processing (1)
  • configs/HGLRCH743/config.h (1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: haslinghuis
PR: betaflight/config#835
File: configs/HDZERO_HALO_MPU6000/config.h:44-56
Timestamp: 2025-07-14T16:16:56.822Z
Learning: For Betaflight board configurations of boards already in production, pin assignments in config.h files reflect the actual hardware design and cannot be changed, even if they present potential conflicts with debug interfaces. The configuration must match the physical board layout, not ideal software design preferences.
Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the BOARD_NAME define in each config.h matches the directory name it resides in (e.g., configs/AXISFLYINGF7AIO/config.h must have #define BOARD_NAME AXISFLYINGF7AIO). This check is required for all Betaflight board configuration reviews.
📚 Learning: 2025-07-14T16:16:56.822Z
Learnt from: haslinghuis
PR: betaflight/config#835
File: configs/HDZERO_HALO_MPU6000/config.h:44-56
Timestamp: 2025-07-14T16:16:56.822Z
Learning: For Betaflight board configurations of boards already in production, pin assignments in config.h files reflect the actual hardware design and cannot be changed, even if they present potential conflicts with debug interfaces. The configuration must match the physical board layout, not ideal software design preferences.

Applied to files:

  • configs/HGLRCH743/config.h
📚 Learning: 2025-07-03T04:33:57.480Z
Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the BOARD_NAME define in each config.h matches the directory name it resides in (e.g., configs/AXISFLYINGF7AIO/config.h must have #define BOARD_NAME AXISFLYINGF7AIO). This check is required for all Betaflight board configuration reviews.

Applied to files:

  • configs/HGLRCH743/config.h
📚 Learning: 2025-07-03T04:33:57.480Z
Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the `BOARD_NAME` define in config.h files exactly matches the directory name where the config file is located. For example, if the config file is in configs/AXISFLYINGF7AIO/config.h, then the BOARD_NAME should be defined as "AXISFLYINGF7AIO". This ensures proper board identification and configuration loading in Betaflight.

Applied to files:

  • configs/HGLRCH743/config.h
📚 Learning: 2025-06-02T16:16:20.197Z
Learnt from: haslinghuis
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-06-02T16:16:20.197Z
Learning: In STM32F405-based flight controller configurations, timer pin mappings must be carefully analyzed for DMA stream conflicts, especially between motor timers, LED strip timers, and SPI DMA assignments. Changes to TIMER_PIN_MAPPING should include verification that all required peripherals (motors, LED strip, blackbox SPI) can coexist without DMA conflicts.

Applied to files:

  • configs/HGLRCH743/config.h
📚 Learning: 2025-05-31T17:01:39.423Z
Learnt from: haslinghuis
PR: betaflight/config#798
File: configs/FURYF4OSD/config.h:88-88
Timestamp: 2025-05-31T17:01:39.423Z
Learning: For STM32F4xx platforms, PB1 pin timer definitions are:
1 = DEF_TIM(TIM1, CH3N, PB1, 0, 0)
2 = DEF_TIM(TIM3, CH4, PB1, 0, 0) 
3 = DEF_TIM(TIM8, CH3N, PB1, 0, 0)
Timer instance 2 (TIM3, CH4) is the correct mapping for PB1 motor control on STM32F4xx platforms as defined in src/platform/STM32/timer_stm32f4xx.c

Applied to files:

  • configs/HGLRCH743/config.h
📚 Learning: 2025-07-14T15:41:14.364Z
Learnt from: ot0tot
PR: betaflight/config#834
File: configs/RADIOLINKF405/config.h:79-88
Timestamp: 2025-07-14T15:41:14.364Z
Learning: In STM32F405 configurations, PB1 typically maps to TIM3_CH4 and PC9 typically maps to TIM8_CH4. These are different timers and do not share DMA resources, so there is no conflict when both pins are used simultaneously (e.g., PB1 for LED_STRIP and PC9 for MOTOR4).

Applied to files:

  • configs/HGLRCH743/config.h
📚 Learning: 2025-07-23T13:43:50.456Z
Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-23T13:43:50.456Z
Learning: For Betaflight board configuration reviews, always verify that serial port defines (like ESC_SENSOR_UART, MSP_UART, GPS_UART, etc.) use valid SERIAL_PORT identifiers that match those defined in the Betaflight codebase at src/main/io/serial.h. Common valid identifiers include SERIAL_PORT_USART1, SERIAL_PORT_USART2, SERIAL_PORT_USART3, SERIAL_PORT_UART4, SERIAL_PORT_UART5, etc. Invalid identifiers like SERIAL_PORT_UART3 (should be SERIAL_PORT_USART3) will cause build failures.

Applied to files:

  • configs/HGLRCH743/config.h
🔇 Additional comments (9)
configs/HGLRCH743/config.h (9)

24-28: BOARD_NAME and MCU look consistent.

BOARD_NAME matches the directory (HGLRCH743) and MCU is correctly set to STM32H743.


80-81: UART4 TX on PD1 looks unsupported; please verify and select a valid AF pair.

For STM32H743, UART4 TX/RX are commonly on PA0/PA1 or PC10/PC11. PD1 is not a known UART4 TX pin. If LED_STRIP is already on PA0, consider mapping UART4 to PC10/PC11 instead—provided that matches the actual hardware wiring.

If the PCB does not use UART4 on these pins, adjust the UART index here to match the real peripheral routed to PD1/PA1 (if any). Please confirm against the hardware schematic.


39-45: Gyro over SPI1 mapping looks sane.

SPI1 pins and GYRO CS/EXTI are commonly used and consistent with ICM42688P on SPI1.


46-51: MAX7456 on SPI2 mapping looks standard.

PB13/14/15 with PB12 as CS is the typical SPI2 assignment for MAX7456.


91-95: I2C assignments look fine; instance selection for BARO/MAG is reasonable.

I2C1 on PB8/PB7 and I2C2 on PB10/PB11 are usual. BARO on I2CDEV_1 is common. MAG instance is set but USE_MAG isn’t enabled—okay if the board has no magnetometer; enable USE_MAG if present.


59-59: Beeper polarity: verify matches hardware transistor drive.

BEEPER_INVERTED is correct only if the beeper drive is active-low. Please confirm to avoid silent or constantly-on beeper behavior.

Also applies to: 136-136


37-38: Flash device selection looks correct.

USE_FLASH with W25Q128FV and SPI3 CS on PA15 is in line with common H7 designs. Pending the MOSI fix, this should enable BLACKBOX_DEVICE_FLASH as default.

Also applies to: 55-58


52-57: Ignore SPI3_SDO_PIN change: PB2 is a valid SPI3 MOSI pin on STM32H743 (AF7). No update needed.

Likely an incorrect or invalid review comment.


52-57: Confirm STM32H743 package & AF mappings for SPI3, UART4 and UART5

Before merging, please verify that the pin assignments in configs/HGLRCH743/config.h truly exist on your STM32H743 part–number and package (e.g. H743ZIT6, Vx, GIx). According to the ST community and datasheet references, some mappings are only available on specific packages:

  • SPI3_SDO_PIN = PB2 (lines 52–57)
    • Official AF6 (SPI3_MOSI) is valid on PB5 and PC12; PB2 (and PD6) appear only on certain packages¹².
    → Confirm PB2 supports AF6/SPI3_MOSI on your package via the STM32H743 datasheet or STM32CubeMX.

  • UART4 TX/RX pins (lines 80–81)
    • Valid mappings are PA0/PA1 or PC10/PC11³⁴.
    → Ensure your board’s pins match one of these pairs.

  • UART5 TX/RX pins (lines 82–83)
    • Valid mappings are PC12 (TX) and PD2 (RX)⁵⁶.
    → Verify these are routed and enabled in your package’s AF tables.

Please supply your MCU part-number/package and cite the exact “Pin/ball definition” table lines from the STM32H743 datasheet (or a CubeMX screenshot) to finalize these assignments.

References:

  1. https://community.st.com/t5/stm32-mcus-products/nucleo-h745ziq-spi-1-and-spi-3-mosi-pin-mapping-issue/td-p/174416
  2. https://pdf.elecfans.com/STMICROELECTRONICS/STM32H743XIH6.html
  3. https://community.st.com/t5/stm32-mcus-products/what-are-the-exact-pins-and-ports-for-uart1-uart4-in-stm32h745i/td-p/108331
  4. https://pdf.elecfans.com/STMICROELECTRONICS/STM32H743XIH6.html
  5. https://pdf.elecfans.com/STMICROELECTRONICS/STM32H743XIH6.html
  6. https://www.digikey.com/en/htmldatasheets/production/3038075/0/0/1/stm32h753xi-datasheet

Comment on lines +82 to +83
#define UART5_TX_PIN PB6
#define UART5_RX_PIN PB5
Copy link
Contributor

@coderabbitai coderabbitai bot Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

UART5 pin mapping is invalid for H743; use PC12 (TX) and PD2 (RX).

PB6/PB5 are typically USART1 TX/RX (or I2C1), not UART5. UART5 on H743 is conventionally PC12 (TX) and PD2 (RX). The current mapping will not function.

Proposed correction (assuming these pins are actually wired for UART5):

-#define UART5_TX_PIN            PB6
-#define UART5_RX_PIN            PB5
+#define UART5_TX_PIN            PC12
+#define UART5_RX_PIN            PD2

If the PCB actually routes a different UART to PB6/PB5 (e.g., USART1), then the port labels here should be updated to match the real peripheral instance. Please verify with the schematic before changing.


Critical: UART5 pin mapping invalid for H743 – update to PC12/PD2

The STM32H743 uses PC12 for UART5 TX and PD2 for UART5 RX. PB6/PB5 are tied to USART1 (or I²C1), so the current configuration will not activate UART5.

Please correct the definitions in configs/HGLRCH743/config.h:

• File: configs/HGLRCH743/config.h
Lines: 82–83

- #define UART5_TX_PIN            PB6
- #define UART5_RX_PIN            PB5
+ #define UART5_TX_PIN            PC12
+ #define UART5_RX_PIN            PD2

If your PCB routes UART signals differently (e.g., UART5 on other pins or PB6/PB5 for USART1), adjust the macro names or pin assignments to match the actual schematic before merging.

🤖 Prompt for AI Agents
In configs/HGLRCH743/config.h around lines 82 to 83, the UART5 pin defines are
wrong (currently PB6/PB5); change them to use PC12 for UART5_TX and PD2 for
UART5_RX to match the STM32H743 hardware. Update the #define macros so
UART5_TX_PIN maps to PC12 and UART5_RX_PIN maps to PD2, and if your PCB uses
different routing, instead rename the macros or set the pin values to the actual
schematic pin assignments before committing.

Copy link
Contributor

@osirisinferi osirisinferi Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai PB6/PB5 is fine, UART5_TX/UART5_RX are listed as their alternate function in the pin/ball definition table of the STM32H743 datasheet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

🌐 Web query:

STM32H743 pin mapping PB5 PB6 UART5 alternate functions datasheet

💡 Result:

For the STM32H743, the detailed pin mapping and alternate function assignments for PB5 and PB6 in relation to UART5 are given in the datasheet's "Port B alternate functions" table[4][8].

Summary:

  • UART5_TX can be mapped to PB6.
  • UART5_RX is not available on PB5 nor PB6.

Here are the relevant details extracted from the datasheet:

Pin UART5 Function AF Number Other Major Alternate Functions
PB5 No UART5 -- I2C1_SMBA (AF4), SPI1_MOSI (AF5), TIM3_CH2 (AF2)
PB6 UART5_TX AF8 I2C1_SCL (AF4), TIM4_CH1 (AF2), CAN2_TX (AF9)

Details and References:

  • According to the STM32H743 datasheet, specifically the "Port B alternate functions" table, PB6 can be assigned as UART5_TX when set to AF8[4][8].
  • PB5 does not support any UART5 function—its alternate functions do not include UART5_RX or UART5_TX, only other uses like I2C, SPI, and TIM are available[4][8].
  • The assignment of alternate functions is managed by configuring the pin in the GPIOx_AFRL (Alternate Function Low Register) to the appropriate AF number (here, AF8 for UART5_TX on PB6)[4][5].

How to use in code (HAL example):

// To use PB6 as UART5_TX:
GPIO_InitStruct.Pin = GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF8_UART5;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

Schematic Planning Note:

  • If using UART5 with the STM32H743, choose PB6 for UART5_TX. For UART5_RX, select another pin such as PD2 or PC12, as listed in the alternate functions table—PB5 cannot be used for UART5_RX on this device[4][7][8].

Citations:


@osirisinferi Thank you for the correction! You're right about PB6 being valid for UART5_TX (AF8), and I apologize for that error in my initial assessment.

However, based on the STM32H743 datasheet's alternate function table, PB5 cannot be used for UART5_RX. PB5's alternate functions are limited to:

  • I2C1_SMBA (AF4)
  • SPI1_MOSI (AF5)
  • TIM3_CH2 (AF2)

For UART5_RX on the STM32H743, valid pins include PD2 or PC12. So the current configuration has:

  • UART5_TX_PIN PB6 - Valid (AF8)
  • UART5_RX_PIN PB5 - Invalid (no UART5 alternate function)

Could you verify the schematic to confirm which pin is actually connected for UART5_RX? If it's indeed PB5, then a different UART peripheral might be intended for that pin.


✏️ Learnings added
Learnt from: osirisinferi
PR: betaflight/config#872
File: configs/HGLRCH743/config.h:82-83
Timestamp: 2025-08-19T18:29:36.097Z
Learning: For STM32H743, UART5_TX can use PB6 (AF8), but UART5_RX cannot use PB5. PB5 has no UART5 alternate functions - it only supports I2C1_SMBA (AF4), SPI1_MOSI (AF5), and TIM3_CH2 (AF2). Valid UART5_RX pins include PD2 and PC12.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: haslinghuis
PR: betaflight/config#835
File: configs/HDZERO_HALO_MPU6000/config.h:44-56
Timestamp: 2025-07-14T16:16:56.822Z
Learning: For Betaflight board configurations of boards already in production, pin assignments in config.h files reflect the actual hardware design and cannot be changed, even if they present potential conflicts with debug interfaces. The configuration must match the physical board layout, not ideal software design preferences.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the `BOARD_NAME` define in config.h files exactly matches the directory name where the config file is located. For example, if the config file is in configs/AXISFLYINGF7AIO/config.h, then the BOARD_NAME should be defined as "AXISFLYINGF7AIO". This ensures proper board identification and configuration loading in Betaflight.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the BOARD_NAME define in each config.h matches the directory name it resides in (e.g., configs/AXISFLYINGF7AIO/config.h must have #define BOARD_NAME AXISFLYINGF7AIO). This check is required for all Betaflight board configuration reviews.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-23T13:43:50.456Z
Learning: For Betaflight board configuration reviews, always verify that serial port defines (like ESC_SENSOR_UART, MSP_UART, GPS_UART, etc.) use valid SERIAL_PORT identifiers that match those defined in the Betaflight codebase at src/main/io/serial.h. Common valid identifiers include SERIAL_PORT_USART1, SERIAL_PORT_USART2, SERIAL_PORT_USART3, SERIAL_PORT_UART4, SERIAL_PORT_UART5, etc. Invalid identifiers like SERIAL_PORT_UART3 (should be SERIAL_PORT_USART3) will cause build failures.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-23T13:43:50.456Z
Learning: For Betaflight board configuration reviews, always verify that serial port defines use valid identifiers from the serialPortIdentifier_e enum in src/main/io/serial.h. Valid identifiers include: SERIAL_PORT_USB_VCP (20), SERIAL_PORT_SOFTSERIAL1 (30), SERIAL_PORT_SOFTSERIAL2 (31), SERIAL_PORT_LPUART1 (40), SERIAL_PORT_UART0 (50, if SERIAL_UART_FIRST_INDEX == 0), SERIAL_PORT_USART1 (51 or 50), SERIAL_PORT_USART2, SERIAL_PORT_USART3, SERIAL_PORT_UART4, SERIAL_PORT_UART5, SERIAL_PORT_USART6, SERIAL_PORT_USART7, SERIAL_PORT_USART8, SERIAL_PORT_UART9, SERIAL_PORT_USART10. While some aliases exist (like SERIAL_PORT_UART3 = SERIAL_PORT_USART3), prefer using the primary identifiers as referenced in the serialPortIdentifiers array to avoid build failures.

Learnt from: haslinghuis
PR: betaflight/config#822
File: configs/AXISFLYINGH7MINI/config.h:29-37
Timestamp: 2025-06-23T18:43:31.746Z
Learning: In Betaflight configuration files, feature enablement macros like USE_MAG are build options that can be controlled at compile time, while hardware instance definitions like MAG_I2C_INSTANCE are predefined in board configurations to assist with hardware mapping when those features are enabled at build time.

Learnt from: haslinghuis
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T15:17:30.040Z
Learning: In Betaflight configurations, when a target name suggests dual IMUs (like JHEF7DUAL) but specific hardware variants only have one gyro available, the preferred solution is to use DEFAULT_GYRO_TO_USE macro to specify which gyro to use by default rather than pruning gyro defines or creating redundant configurations. This approach maintains compatibility when the same target is used by multiple hardware variants from the same manufacturer.

Learnt from: ot0tot
PR: betaflight/config#834
File: configs/RADIOLINKF405/config.h:52-53
Timestamp: 2025-07-14T15:38:06.837Z
Learning: In Betaflight flight controller configurations, it's common and intentional for UART2_RX_PIN and RX_PPM_PIN to share the same GPIO pin (like PA3) because they represent mutually exclusive receiver input protocols. The pin can be configured for either serial receiver input (UART2) or PPM input, but not both simultaneously. This is a standard design pattern in flight controller hardware.

Learnt from: ot0tot
PR: betaflight/config#834
File: configs/RADIOLINKF405/config.h:79-88
Timestamp: 2025-07-14T15:41:14.364Z
Learning: In STM32F405 configurations, PB1 typically maps to TIM3_CH4 and PC9 typically maps to TIM8_CH4. These are different timers and do not share DMA resources, so there is no conflict when both pins are used simultaneously (e.g., PB1 for LED_STRIP and PC9 for MOTOR4).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai You are incorrect again, the "Port B alternate functions" table lists UART5_RX as AF14 for the PB5 pin in the STM32H743 datasheet. Also, UART5_TX for the PB6 pin is not AF8 as you claim, but also AF14. You're basing your assumptions on incorrect sources and/or are hallucinating.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@osirisinferi You're absolutely right, and I apologize for the repeated incorrect information. Thank you for the correction - both PB5 (UART5_RX) and PB6 (UART5_TX) do use AF14 on the STM32H743, not AF8 as I incorrectly stated.

The original configuration in the file is indeed valid:

#define UART5_TX_PIN            PB6  // AF14
#define UART5_RX_PIN            PB5  // AF14

I appreciate your patience in correcting my misunderstanding of the STM32H743 alternate function mappings.


✏️ Learnings added
Learnt from: osirisinferi
PR: betaflight/config#872
File: configs/HGLRCH743/config.h:82-83
Timestamp: 2025-08-19T18:34:22.850Z
Learning: For STM32H743, both UART5_TX (PB6) and UART5_RX (PB5) use alternate function AF14, not AF8. The Port B alternate functions table in the STM32H743 datasheet confirms PB5 supports UART5_RX and PB6 supports UART5_TX, both using AF14.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


⛔ Learnings removed
Learnt from: osirisinferi
PR: betaflight/config#872
File: configs/HGLRCH743/config.h:82-83
Timestamp: 2025-08-19T18:29:36.097Z
Learning: For STM32H743, UART5_TX can use PB6 (AF8), but UART5_RX cannot use PB5. PB5 has no UART5 alternate functions - it only supports I2C1_SMBA (AF4), SPI1_MOSI (AF5), and TIM3_CH2 (AF2). Valid UART5_RX pins include PD2 and PC12.

🧠 Learnings used
Learnt from: haslinghuis
PR: betaflight/config#835
File: configs/HDZERO_HALO_MPU6000/config.h:44-56
Timestamp: 2025-07-14T16:16:56.822Z
Learning: For Betaflight board configurations of boards already in production, pin assignments in config.h files reflect the actual hardware design and cannot be changed, even if they present potential conflicts with debug interfaces. The configuration must match the physical board layout, not ideal software design preferences.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the `BOARD_NAME` define in config.h files exactly matches the directory name where the config file is located. For example, if the config file is in configs/AXISFLYINGF7AIO/config.h, then the BOARD_NAME should be defined as "AXISFLYINGF7AIO". This ensures proper board identification and configuration loading in Betaflight.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the BOARD_NAME define in each config.h matches the directory name it resides in (e.g., configs/AXISFLYINGF7AIO/config.h must have #define BOARD_NAME AXISFLYINGF7AIO). This check is required for all Betaflight board configuration reviews.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-23T13:43:50.456Z
Learning: For Betaflight board configuration reviews, always verify that serial port defines (like ESC_SENSOR_UART, MSP_UART, GPS_UART, etc.) use valid SERIAL_PORT identifiers that match those defined in the Betaflight codebase at src/main/io/serial.h. Common valid identifiers include SERIAL_PORT_USART1, SERIAL_PORT_USART2, SERIAL_PORT_USART3, SERIAL_PORT_UART4, SERIAL_PORT_UART5, etc. Invalid identifiers like SERIAL_PORT_UART3 (should be SERIAL_PORT_USART3) will cause build failures.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-23T13:43:50.456Z
Learning: For Betaflight board configuration reviews, always verify that serial port defines use valid identifiers from the serialPortIdentifier_e enum in src/main/io/serial.h. Valid identifiers include: SERIAL_PORT_USB_VCP (20), SERIAL_PORT_SOFTSERIAL1 (30), SERIAL_PORT_SOFTSERIAL2 (31), SERIAL_PORT_LPUART1 (40), SERIAL_PORT_UART0 (50, if SERIAL_UART_FIRST_INDEX == 0), SERIAL_PORT_USART1 (51 or 50), SERIAL_PORT_USART2, SERIAL_PORT_USART3, SERIAL_PORT_UART4, SERIAL_PORT_UART5, SERIAL_PORT_USART6, SERIAL_PORT_USART7, SERIAL_PORT_USART8, SERIAL_PORT_UART9, SERIAL_PORT_USART10. While some aliases exist (like SERIAL_PORT_UART3 = SERIAL_PORT_USART3), prefer using the primary identifiers as referenced in the serialPortIdentifiers array to avoid build failures.

Learnt from: haslinghuis
PR: betaflight/config#822
File: configs/AXISFLYINGH7MINI/config.h:29-37
Timestamp: 2025-06-23T18:43:31.746Z
Learning: In Betaflight configuration files, feature enablement macros like USE_MAG are build options that can be controlled at compile time, while hardware instance definitions like MAG_I2C_INSTANCE are predefined in board configurations to assist with hardware mapping when those features are enabled at build time.

Learnt from: haslinghuis
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T15:17:30.040Z
Learning: In Betaflight configurations, when a target name suggests dual IMUs (like JHEF7DUAL) but specific hardware variants only have one gyro available, the preferred solution is to use DEFAULT_GYRO_TO_USE macro to specify which gyro to use by default rather than pruning gyro defines or creating redundant configurations. This approach maintains compatibility when the same target is used by multiple hardware variants from the same manufacturer.

Learnt from: osirisinferi
PR: betaflight/config#872
File: configs/HGLRCH743/config.h:82-83
Timestamp: 2025-08-19T18:29:36.097Z
Learning: For STM32H743, UART5_TX can use PB6 (AF8), but UART5_RX cannot use PB5. PB5 has no UART5 alternate functions - it only supports I2C1_SMBA (AF4), SPI1_MOSI (AF5), and TIM3_CH2 (AF2). Valid UART5_RX pins include PD2 and PC12.

Learnt from: ot0tot
PR: betaflight/config#834
File: configs/RADIOLINKF405/config.h:52-53
Timestamp: 2025-07-14T15:38:06.837Z
Learning: In Betaflight flight controller configurations, it's common and intentional for UART2_RX_PIN and RX_PPM_PIN to share the same GPIO pin (like PA3) because they represent mutually exclusive receiver input protocols. The pin can be configured for either serial receiver input (UART2) or PPM input, but not both simultaneously. This is a standard design pattern in flight controller hardware.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderabbitai read the previous comment. Valid UART assignments are in serial_uart_{platform}.c as shown above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ot0tot Thank you for providing the definitive source! You're absolutely correct - the serial_uart_stm32h7xx.c file in the Betaflight codebase is indeed the authoritative reference for valid UART pin assignments on STM32H7xx platforms.

I can see from your reference that lines 244-249 confirm PB6/PB5 as valid UART5 TX/RX pins for the STM32H743. This is the proper way to validate UART configurations rather than relying on general MCU datasheets alone.

The original configuration in the file is correct:

#define UART5_TX_PIN            PB6
#define UART5_RX_PIN            PB5

I appreciate you pointing me to the right source for future UART validation in Betaflight configurations.


✏️ Learnings added
Learnt from: ot0tot
PR: betaflight/config#872
File: configs/HGLRCH743/config.h:82-83
Timestamp: 2025-08-20T02:54:58.553Z
Learning: For Betaflight board configuration reviews, the definitive source for validating UART pin assignments is the serial_uart_{platform}.c file in the Betaflight codebase (e.g., serial_uart_stm32h7xx.c for STM32H7xx platforms), not generic MCU datasheets. These files contain the exact pin mappings that Betaflight supports for each UART peripheral.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: haslinghuis
PR: betaflight/config#835
File: configs/HDZERO_HALO_MPU6000/config.h:44-56
Timestamp: 2025-07-14T16:16:56.822Z
Learning: For Betaflight board configurations of boards already in production, pin assignments in config.h files reflect the actual hardware design and cannot be changed, even if they present potential conflicts with debug interfaces. The configuration must match the physical board layout, not ideal software design preferences.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the `BOARD_NAME` define in config.h files exactly matches the directory name where the config file is located. For example, if the config file is in configs/AXISFLYINGF7AIO/config.h, then the BOARD_NAME should be defined as "AXISFLYINGF7AIO". This ensures proper board identification and configuration loading in Betaflight.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T04:33:57.480Z
Learning: Always verify that the BOARD_NAME define in each config.h matches the directory name it resides in (e.g., configs/AXISFLYINGF7AIO/config.h must have #define BOARD_NAME AXISFLYINGF7AIO). This check is required for all Betaflight board configuration reviews.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-23T13:43:50.456Z
Learning: For Betaflight board configuration reviews, always verify that serial port defines (like ESC_SENSOR_UART, MSP_UART, GPS_UART, etc.) use valid SERIAL_PORT identifiers that match those defined in the Betaflight codebase at src/main/io/serial.h. Common valid identifiers include SERIAL_PORT_USART1, SERIAL_PORT_USART2, SERIAL_PORT_USART3, SERIAL_PORT_UART4, SERIAL_PORT_UART5, etc. Invalid identifiers like SERIAL_PORT_UART3 (should be SERIAL_PORT_USART3) will cause build failures.

Learnt from: ot0tot
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-23T13:43:50.456Z
Learning: For Betaflight board configuration reviews, always verify that serial port defines use valid identifiers from the serialPortIdentifier_e enum in src/main/io/serial.h. Valid identifiers include: SERIAL_PORT_USB_VCP (20), SERIAL_PORT_SOFTSERIAL1 (30), SERIAL_PORT_SOFTSERIAL2 (31), SERIAL_PORT_LPUART1 (40), SERIAL_PORT_UART0 (50, if SERIAL_UART_FIRST_INDEX == 0), SERIAL_PORT_USART1 (51 or 50), SERIAL_PORT_USART2, SERIAL_PORT_USART3, SERIAL_PORT_UART4, SERIAL_PORT_UART5, SERIAL_PORT_USART6, SERIAL_PORT_USART7, SERIAL_PORT_USART8, SERIAL_PORT_UART9, SERIAL_PORT_USART10. While some aliases exist (like SERIAL_PORT_UART3 = SERIAL_PORT_USART3), prefer using the primary identifiers as referenced in the serialPortIdentifiers array to avoid build failures.

Learnt from: haslinghuis
PR: betaflight/config#822
File: configs/AXISFLYINGH7MINI/config.h:29-37
Timestamp: 2025-06-23T18:43:31.746Z
Learning: In Betaflight configuration files, feature enablement macros like USE_MAG are build options that can be controlled at compile time, while hardware instance definitions like MAG_I2C_INSTANCE are predefined in board configurations to assist with hardware mapping when those features are enabled at build time.

Learnt from: haslinghuis
PR: betaflight/config#0
File: :0-0
Timestamp: 2025-07-03T15:17:30.040Z
Learning: In Betaflight configurations, when a target name suggests dual IMUs (like JHEF7DUAL) but specific hardware variants only have one gyro available, the preferred solution is to use DEFAULT_GYRO_TO_USE macro to specify which gyro to use by default rather than pruning gyro defines or creating redundant configurations. This approach maintains compatibility when the same target is used by multiple hardware variants from the same manufacturer.

Learnt from: osirisinferi
PR: betaflight/config#872
File: configs/HGLRCH743/config.h:82-83
Timestamp: 2025-08-19T18:34:22.887Z
Learning: For STM32H743, both UART5_TX (PB6) and UART5_RX (PB5) use alternate function AF14, not AF8. The Port B alternate functions table in the STM32H743 datasheet confirms PB5 supports UART5_RX and PB6 supports UART5_TX, both using AF14.

Comment on lines +108 to +112
TIMER_PIN_MAP(0, PE9, 1, 4) \
TIMER_PIN_MAP(1, PE11, 1, 5) \
TIMER_PIN_MAP(2, PE13, 1, 6) \
TIMER_PIN_MAP(3, PE14, 1, 7) \
TIMER_PIN_MAP(4, PA2, 2, 0) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start counting the DMA opts from 0 instead of 4:

Suggested change
TIMER_PIN_MAP(0, PE9, 1, 4) \
TIMER_PIN_MAP(1, PE11, 1, 5) \
TIMER_PIN_MAP(2, PE13, 1, 6) \
TIMER_PIN_MAP(3, PE14, 1, 7) \
TIMER_PIN_MAP(4, PA2, 2, 0) \
TIMER_PIN_MAP(0, PE9, 1, 0) \
TIMER_PIN_MAP(1, PE11, 1, 1) \
TIMER_PIN_MAP(2, PE13, 1, 2) \
TIMER_PIN_MAP(3, PE14, 1, 3) \
TIMER_PIN_MAP(4, PA2, 2, 4) \

Comment on lines +113 to +115
TIMER_PIN_MAP(5, PA3, 2, 0) \
TIMER_PIN_MAP(6, PB0, 2, 0) \
TIMER_PIN_MAP(7, PB1, 2, 0) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect DMA opt for motor pins, are overwriting (each others) previous "0" DMA opt assignment.

Suggested change
TIMER_PIN_MAP(5, PA3, 2, 0) \
TIMER_PIN_MAP(6, PB0, 2, 0) \
TIMER_PIN_MAP(7, PB1, 2, 0) \
TIMER_PIN_MAP(5, PA3, 2, 5) \
TIMER_PIN_MAP(6, PB0, 2, 6) \
TIMER_PIN_MAP(7, PB1, 2, 7) \

TIMER_PIN_MAP(6, PB0, 2, 0) \
TIMER_PIN_MAP(7, PB1, 2, 0) \
TIMER_PIN_MAP(8, PD12, 1, -1) \
TIMER_PIN_MAP(9, PD13, 1, 0) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect DMA opt for servo pin, no DMA required (and is overwriting previous "0" DMA opt).

Suggested change
TIMER_PIN_MAP(9, PD13, 1, 0) \
TIMER_PIN_MAP(9, PD13, 1, -1) \

TIMER_PIN_MAP(8, PD12, 1, -1) \
TIMER_PIN_MAP(9, PD13, 1, 0) \
TIMER_PIN_MAP(10, PD14, 1, -1) \
TIMER_PIN_MAP(11, PD15, 1, 14) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect DMA opt for servo pin, no DMA required.

Suggested change
TIMER_PIN_MAP(11, PD15, 1, 14) \
TIMER_PIN_MAP(11, PD15, 1, -1) \

TIMER_PIN_MAP(9, PD13, 1, 0) \
TIMER_PIN_MAP(10, PD14, 1, -1) \
TIMER_PIN_MAP(11, PD15, 1, 14) \
TIMER_PIN_MAP(12, PA0, 1, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect DMA opt for pin, is overwriting previous "0" DMA opt assignment.

Suggested change
TIMER_PIN_MAP(12, PA0, 1, 0)
TIMER_PIN_MAP(12, PA0, 1, 10)

#define MAG_I2C_INSTANCE I2CDEV_2

#define DEFAULT_CURRENT_METER_SOURCE CURRENT_METER_ADC
#define DEFAULT_CURRENT_METER_SCALE 200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this FC be part of a stack? If not, the DEFAULT_CURRENT_METER_SCALE option should not be set.

#define FC_TARGET_MCU STM32H743

#define BOARD_NAME HGLRCH743
#define MANUFACTURER_ID HGLRC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define MANUFACTURER_ID HGLRC
#define MANUFACTURER_ID HGLR

#define SPI3_SCK_PIN PB3
#define SPI3_SDI_PIN PB4
#define SPI3_SDO_PIN PB2
#define FLASH_CS_PIN PA15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👾

#define PINIO1_BOX 40
#define PINIO2_BOX 41

#define BEEPER_INVERTED
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No newline on EOF

Suggested change
#define BEEPER_INVERTED
#define BEEPER_INVERTED

Comment on lines +107 to +123
#define TIMER_PIN_MAPPING \
TIMER_PIN_MAP(0, PE9, 1, 4) \
TIMER_PIN_MAP(1, PE11, 1, 5) \
TIMER_PIN_MAP(2, PE13, 1, 6) \
TIMER_PIN_MAP(3, PE14, 1, 7) \
TIMER_PIN_MAP(4, PA2, 2, 0) \
TIMER_PIN_MAP(5, PA3, 2, 0) \
TIMER_PIN_MAP(6, PB0, 2, 0) \
TIMER_PIN_MAP(7, PB1, 2, 0) \
TIMER_PIN_MAP(8, PD12, 1, -1) \
TIMER_PIN_MAP(9, PD13, 1, 0) \
TIMER_PIN_MAP(10, PD14, 1, -1) \
TIMER_PIN_MAP(11, PD15, 1, 14) \
TIMER_PIN_MAP(12, PA0, 1, 0)

#define ADC1_DMA_OPT 8
#define ADC3_DMA_OPT 9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define TIMER_PIN_MAPPING \
TIMER_PIN_MAP(0, PE9, 1, 4) \
TIMER_PIN_MAP(1, PE11, 1, 5) \
TIMER_PIN_MAP(2, PE13, 1, 6) \
TIMER_PIN_MAP(3, PE14, 1, 7) \
TIMER_PIN_MAP(4, PA2, 2, 0) \
TIMER_PIN_MAP(5, PA3, 2, 0) \
TIMER_PIN_MAP(6, PB0, 2, 0) \
TIMER_PIN_MAP(7, PB1, 2, 0) \
TIMER_PIN_MAP(8, PD12, 1, -1) \
TIMER_PIN_MAP(9, PD13, 1, 0) \
TIMER_PIN_MAP(10, PD14, 1, -1) \
TIMER_PIN_MAP(11, PD15, 1, 14) \
TIMER_PIN_MAP(12, PA0, 1, 0)
#define ADC1_DMA_OPT 8
#define ADC3_DMA_OPT 9
#define TIMER_PIN_MAPPING \
TIMER_PIN_MAP(0, PE5, 1, -1) \
TIMER_PIN_MAP(1, PE9, 1, 0) \
TIMER_PIN_MAP(2, PE11, 1, 1) \
TIMER_PIN_MAP(3, PE13, 1, 2) \
TIMER_PIN_MAP(4, PE14, 1, 3) \
TIMER_PIN_MAP(5, PA2, 2, 4) \
TIMER_PIN_MAP(6, PA3, 2, 5) \
TIMER_PIN_MAP(7, PB0, 2, 6) \
TIMER_PIN_MAP(8, PB1, 2, 7) \
TIMER_PIN_MAP(9, PA0, 1, 8) \
TIMER_PIN_MAP(10, PD12, 1, -1) \
TIMER_PIN_MAP(11, PD13, 1, -1) \
TIMER_PIN_MAP(12, PD14, 1, -1) \
TIMER_PIN_MAP(13, PD15, 1, -1)
#define TIMUP1_DMA_OPT 9
#define TIMUP5_DMA_OPT 10
#define ADC1_DMA_OPT 11
#define ADC3_DMA_OPT 12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants