Skip to content

targets: add commented CAN bus pins to 7 H7 targets#11631

Open
daijoubu wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
daijoubu:feature/audit-targets-canbus-pins
Open

targets: add commented CAN bus pins to 7 H7 targets#11631
daijoubu wants to merge 1 commit into
iNavFlight:maintenance-10.xfrom
daijoubu:feature/audit-targets-canbus-pins

Conversation

@daijoubu

@daijoubu daijoubu commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds commented-out CAN1 pin definitions to 7 H7 flight controller targets where CAN bus pins could be identified from the corresponding ArduPilot hwdef files.

Targets updated:

Target CAN1 RX CAN1 TX CAN1 STANDBY AP Source
AETH743Basic PD0 PD1 PD3 AET-H743-Basic
BROTHERHOBBYH743 PD0 PD1 PD3 BROTHERHOBBYH743
CORVON743V1 PB8 PB9 CORVON743V1
DAKEFPVH743PRO PD0 PD1 PD2 DAKEFPVH743Pro
MICOAIR743 PB8 PB9 MicoAir743
TBS_LUCID_H7 PD0 PD1 PD3 TBS_LUCID_H7
TBS_LUCID_H7_WING PD0 PD1 PD3 TBS_LUCID_H7_WING

Important: Definitions are commented out

These pin definitions are sourced from ArduPilot hwdef files and have not been validated on real hardware. We do not have any of these boards available for testing. The blocks are commented out by default so normal builds are completely unaffected.

The FDCAN1 peripheral can only be used as an alternate function on a limited number of pins, so the pin assignments are easy to audit.
STM32H743 has 2 FDCAN peripherals (FDCAN3 is only on H725/H730 variants — the H743 CMSIS header confirms IS_FDCAN_ALL_INSTANCE covers only FDCAN1+FDCAN2).

Both use AF9. From RM and Datasheet:

  • FDCAN1_RX: PA11, PB8, PD0, PH14 (all AF9)
  • FDCAN1_TX: PA12, PB9, PD1, PH13 (all AF9)
  • FDCAN2_RX: PB5, PB12 (AF9)
  • FDCAN2_TX: PB6, PB13 (AF9)

Users who have the hardware and want to test DroneCAN can uncomment the block in their local target.h and do a custom build. Confirmed working INAV DroneCAN targets (KAKUTEH7WING, MATEKH743, MATEKF765) served as the pattern reference.

What was checked before adding

  • Pin assignments cross-referenced against AP hwdef files (not guessed)
  • AP hwdef include chains checked to ensure child hwdefs do not override the CAN pins with UART or other functions (the DAKEFPVH743 non-PRO was excluded for exactly this reason — its AP hwdef repurposes PD0/PD1 for UART4)
  • CAN pins verified free in each INAV target.h (no UART, SPI, I2C, or other conflicts)
  • Standby pin polarity consistent with existing INAV targets (driven LOW = CAN enabled)

What was excluded and why

  • 76 H7/F7 targets with no AP equivalent — no reference source
  • 18 targets matched to AP but with no CAN in their hwdef — AP didn't define them, likely not routed to a connector
  • DAKEFPVH743 — CAN pins conflict with UART4 in both AP and INAV
  • TBS_LUCID_H7_WING_MINI — no dedicated AP hwdef; PCB differences from WING (different current sensor scale, missing cam switcher) mean pins cannot be safely inferred
  • KAKUTEH7WING, MATEKH743, MATEKF765 — already have CAN defined and active

Build matrix

All targets pass, zero warnings.

MCU Target Result
F4 MATEKF405 ✅ PASS
F7 MATEKF765 ✅ PASS
H7 KAKUTEH7WING ✅ PASS
AT32 IFLIGHT_BLITZ_ATF435 ✅ PASS
SITL SITL ✅ PASS

Add commented-out CAN1 pin definitions to AETH743Basic,
BROTHERHOBBYH743, CORVON743V1, DAKEFPVH743PRO, MICOAIR743,
TBS_LUCID_H7, and TBS_LUCID_H7_WING. Pins sourced from the
corresponding ArduPilot hwdef files. Blocks are commented by
default so normal builds are unaffected; users with CAN-capable
hardware can uncomment to enable DroneCAN support via a custom build.

CORVON743V1 and MICOAIR743 use PB8/PB9 (no standby pin in AP hwdef).
DAKEFPVH743PRO uses PD2 as standby (differs from the usual PD3).
Remaining five use PD0/PD1/PD3.
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Test firmware build ready — commit 8d16170

Download firmware for PR #11631

238 targets built. Find your board's .hex file by name on that page (e.g. MATEKF405SE.hex). Files are individually downloadable — no GitHub login required.

Development build for testing only. Use Full Chip Erase when flashing.

@bkleiner bkleiner mentioned this pull request Jun 9, 2026
30 tasks
// #define USE_DRONECAN
// #define CAN1_RX PD0
// #define CAN1_TX PD1
// #define CAN1_STANDBY PD3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

correct :)

Image

// #define USE_DRONECAN
// #define CAN1_RX PD0
// #define CAN1_TX PD1
// #define CAN1_STANDBY PD3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ditto. The Wing Mini has the same assignment.

@sensei-hacker

sensei-hacker commented Jun 9, 2026

Copy link
Copy Markdown
Member

I have four or five of these boards.
If we uncomment the definitions but add a separate line comment "CAN untested", then let them build, does it break anything if they are wrong (but not conflicting)? Does it break uart4, assuming no CAN equipment is configured?

@bkleiner

bkleiner commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

I have about half of these boards, or more. If we uncomment the definitions but add a separate line comment "CAN untested", then let them build, does it break anything if they are wrong (but not conflicting)? Does it break uart4, assuming no CAN equipment is configured?

No, @daijoubu is just being cautious. IMHO we should add the ones we can confirm the assigments on uncommented. #11635 (comment)

Obliviously i can do that the for the TBS ones, but i also have eg. the microair or the matek h7 boards on hand.

Excited for this to land BTW!

@daijoubu

daijoubu commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

I'm happy to uncomment the ones we can confirm and I appreciate the support. :) I only have a small stock of CAN capable boards and peripherals. If UART4 is not defined it won't conflict. I don't have a global off switch for CAN but will add it to my backlog, shouldn't be hard to implement. I'll have to look at how the UART hardware is initialized before deciding if both can be defined in the same target safely.

@daijoubu

daijoubu commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Thinking about this, I don't think you can share UART4 and CAN in an FC unless the board designer uses a variant of the TJA1051(or equivalent) that supports fully disabling the control interface. I have not seen this in the few implementations I've looked at. The S input on this schematic just disables TXD so the peripheral can't send to the BUS. RXD will always drive the voltage based on the state of the CAN datalines interfering with serial communications..

This is the typical hardware on the CAN Rx and Tx lines from the MCU.
image

image

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.

3 participants