inav icon indicating copy to clipboard operation
inav copied to clipboard

Brother h743

Open sensei-hacker opened this issue 8 months ago • 1 comments

Support for Brother Hobby H743, being handled as per the new hardware policy.

  • [x] Samples received
  • [X] Flash firmware
  • [X] Calibrate
  • [x] Orientation matches
  • [x] Gyro working
  • [x] Accel working
  • [x] Baro working
  • [x] Voltage correct
  • [x] Current correct
  • [x] Mag I2C Bus
  • [x] Additional I2C2 Buses (Airspeed/other accessories)
  • [x] UART1
  • [x] UART2
  • [x] UART3
  • [x] UART4
  • [x] UART6
  • [x] UART7
  • [x] UART8
  • [ ] Analog Camera working
  • [x] Video Out working
  • [x] OSD working
  • [x] LEDs working
  • [x] Buzzer working
  • [x] Motor outputs
  • [x] DShot support on m1-4
  • [x] Servo outputs
  • [x] Blackbox
  • [ ] PINIO1
  • [ ] PINIO2

sensei-hacker avatar Apr 06 '25 22:04 sensei-hacker

After correcting the i2c bus for the pitot and temperature sensors, the remaining issue is the camera inputs. I see no video, only OSD over a black background, for both C1 and C2. I tested with USER1 and USER2 on and off. I tested with two different cameras.

sensei-hacker avatar Apr 07 '25 05:04 sensei-hacker

Camera now working

sensei-hacker avatar Aug 30 '25 18:08 sensei-hacker

/analyze

sensei-hacker avatar Aug 30 '25 18:08 sensei-hacker

The analyze command only supports the following languages: python, py, javascript, js, jsx, typescript, ts, tsx, kotlin, kt, kts, go, java, cpp, c++, cs, c#, csharp

qodo-code-review[bot] avatar Aug 30 '25 18:08 qodo-code-review[bot]

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
⚡ Recommended focus areas for review

Duplicate Macro

USE_IMU_ICM42605 is defined twice for dual IMU; confirm the build system or headers tolerate repeated defines or guard with conditional checks to avoid redefinition conflicts across compilers.

#define USE_IMU_ICM42605

#define IMU_ICM42605_ALIGN      CW90_DEG
#define ICM42605_SPI_BUS        BUS_SPI1
#define ICM42605_CS_PIN         PC15

// *************** SPI4 IMU1 ICM42605 **************
#define USE_SPI_DEVICE_4
#define SPI4_SCK_PIN            PE12
#define SPI4_MISO_PIN           PE13
#define SPI4_MOSI_PIN           PE14

#define USE_IMU_ICM42605

Timer DMA Indexing

Timer hardware entries use mixed DMA indices including zeros and comments indicating DMA_NONE; verify the DMA indices and flags match actual DMA availability to avoid LED/beeper/pwm glitches or resource conflicts.

    DEF_TIM(TIM4, CH1, PD12, TIM_USE_OUTPUT_AUTO, 0, 6),   // S7
    DEF_TIM(TIM4, CH2, PD13, TIM_USE_OUTPUT_AUTO, 0, 7),   // S8
    DEF_TIM(TIM4, CH3, PD14, TIM_USE_OUTPUT_AUTO, 0, 0),   // S9
    DEF_TIM(TIM4, CH4, PD15, TIM_USE_OUTPUT_AUTO, 0, 0),   // S10 DMA_NONE

    DEF_TIM(TIM15, CH1, PE5, TIM_USE_OUTPUT_AUTO, 0, 0),   // S11
    DEF_TIM(TIM15, CH2, PE6, TIM_USE_OUTPUT_AUTO, 0, 0),   // S12 DMA_NONE

    DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 9),    // LED_2812
    DEF_TIM(TIM2, CH1, PA15, TIM_USE_BEEPER, 0, 0),  // BEEPER PWM
};
Config Defaults

Sets PINIO permanent IDs and enables beeper PWM by default; ensure these defaults align with user expectations and don’t conflict with existing box IDs or board beeper polarity/inversion.

void targetConfiguration(void)
{
    pinioBoxConfigMutable()->permanentId[0] = BOX_PERMANENT_ID_USER1;
    pinioBoxConfigMutable()->permanentId[1] = BOX_PERMANENT_ID_USER2;
    beeperConfigMutable()->pwmMode = true;

qodo-code-review[bot] avatar Aug 30 '25 18:08 qodo-code-review[bot]

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Add IMU data-ready interrupts

Both ICM42605 registrations use NONE for the EXTI/data-ready line, which forces
polled sampling and can cause timing jitter, aliasing, and desynchronization
between the dual IMUs on H7. Expose and define the DRDY pins for each IMU in
target.h and pass the corresponding EXTI tags to BUSDEV_REGISTER_SPI_TAG so the
driver can run interrupt-driven sampling. This will materially improve gyro
timing, filter behavior, and overall stability, especially with dual sensors.

Examples:

src/main/target/BROTHERHOBBYH743/target.c [29-30]
BUSDEV_REGISTER_SPI_TAG(busdev_icm42605,   DEVHW_ICM42605,  ICM42605_SPI_BUS,   ICM42605_CS_PIN,   NONE,   0,  DEVFLAGS_NONE,  IMU_ICM42605_ALIGN);
BUSDEV_REGISTER_SPI_TAG(busdev_icm42605_2,   DEVHW_ICM42605,  ICM42605_SPI_BUS_2,   ICM42605_CS_PIN_2,   NONE,   0,  DEVFLAGS_NONE,  IMU_ICM42605_ALIGN_2);

Solution Walkthrough:

Before:

// src/main/target/BROTHERHOBBYH743/target.h
// ...
// No data-ready interrupt pins are defined for the IMUs.

// src/main/target/BROTHERHOBBYH743/target.c
// ...
// IMUs are registered without an interrupt pin, forcing polled mode.
BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, ..., ICM42605_CS_PIN, NONE, ...);
BUSDEV_REGISTER_SPI_TAG(busdev_icm42605_2, ..., ICM42605_CS_PIN_2, NONE, ...);
// ...

After:

// src/main/target/BROTHERHOBBYH743/target.h
// ...
// Define data-ready interrupt pins for both IMUs.
#define ICM42605_INT_PIN        PC13 // Example pin
#define ICM42605_INT_PIN_2      PE10 // Example pin

// src/main/target/BROTHERHOBBYH743/target.c
// ...
// Register IMUs with interrupt pins to enable interrupt-driven sampling.
BUSDEV_REGISTER_SPI_TAG(busdev_icm42605, ..., ICM42605_CS_PIN, ICM42605_INT_PIN, ...);
BUSDEV_REGISTER_SPI_TAG(busdev_icm42605_2, ..., ICM42605_CS_PIN_2, ICM42605_INT_PIN_2, ...);
// ...

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical performance issue in the IMU configuration, where polling is used instead of interrupts, and proposes a correct fix that will significantly improve flight stability.

High
Possible issue
Fix DMA channel conflicts

The DMA channel assignments for S9 and S10 are both set to 0, which may cause
conflicts. Each timer output should have a unique DMA channel assignment to
prevent resource conflicts during PWM operations.

src/main/target/BROTHERHOBBYH743/target.c [43-44]

-DEF_TIM(TIM4, CH3, PD14, TIM_USE_OUTPUT_AUTO, 0, 0),   // S9
-DEF_TIM(TIM4, CH4, PD15, TIM_USE_OUTPUT_AUTO, 0, 0),   // S10 DMA_NONE
+DEF_TIM(TIM4, CH3, PD14, TIM_USE_OUTPUT_AUTO, 0, 8),   // S9
+DEF_TIM(TIM4, CH4, PD15, TIM_USE_OUTPUT_AUTO, 0, 9),   // S10 DMA_NONE
  • [ ] Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that multiple timer outputs (S1, S9, S10, S11, S12, and BEEPER) are assigned to DMA channel index 0, which can cause resource conflicts and lead to incorrect PWM operation. This is a critical bug for a flight controller.

High
Resolve DMA channel duplication

Both S11 and S12 timer outputs have DMA channel 0 assigned, which creates a
resource conflict. Assign unique DMA channels to prevent timer interference and
ensure proper PWM functionality.

src/main/target/BROTHERHOBBYH743/target.c [46-47]

-DEF_TIM(TIM15, CH1, PE5, TIM_USE_OUTPUT_AUTO, 0, 0),   // S11
-DEF_TIM(TIM15, CH2, PE6, TIM_USE_OUTPUT_AUTO, 0, 0),   // S12 DMA_NONE
+DEF_TIM(TIM15, CH1, PE5, TIM_USE_OUTPUT_AUTO, 0, 10),   // S11
+DEF_TIM(TIM15, CH2, PE6, TIM_USE_OUTPUT_AUTO, 0, 11),   // S12 DMA_NONE
  • [ ] Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies that multiple timer outputs (S1, S9, S10, S11, S12, and BEEPER) are assigned to DMA channel index 0, which can cause resource conflicts and lead to incorrect PWM operation. This is a critical bug for a flight controller.

High
  • [ ] More

qodo-code-review[bot] avatar Aug 30 '25 18:08 qodo-code-review[bot]