Jackson White

Creating a Custom Board Config in Arduino IDE

The Arduino IDE makes it surprisingly easy to program microcontrollers that aren’t part of the Arduino ecosystem—like STM32 devices. This is a useful feature for my project with the Matek H743 flight controller, which runs on an STM32H743 chip. It’s not a typical development board, but with a bit of extra effort, I’ve managed to get it working.

Handling DFU Mode

Programming an STM32 board isn’t as straightforward as plugging it in and hitting upload. These chips rely on Device Firmware Update (DFU) mode for flashing code, which means you have to pull the boot pin high, connect the board, and then upload the program. It’s an extra step that can be a bit inconvenient, and I’m experimenting with ways to automate the switch to serial mode after uploading—similar to how Betaflight handles firmware updates.

Creating a Custom Board Definition

Because the Matek H743 is a drone flight controller, not a standard development board, there wasn’t a pre-existing configuration I could just drop into the Arduino IDE. So, I had to build my own. It took some trial and error, but I eventually created a custom board definition for STM32Duino.

Pin mapping turned out to be a bigger challenge than expected. The available documentation was sparse, often labeling pins with vague descriptions or just voltage levels. I eventually figured it out by digging into the Betaflight GitHub repository. The Betaflight Unified Target had the pin definitions I needed—I just had to reformat them into an Arduino-compatible header file.

Testing with LEDs

Once the board configuration was set, I uploaded a basic Arduino sketch to blink the onboard LEDs. It was a simple test, but it confirmed that the pin definitions were correct and that the Arduino IDE was communicating with the board. Since I haven’t set up serial communication yet, the blinking LED is my only feedback that the code is actually running.

#include "MatekH743_Pinout.h"

void setup() {
    pinMode(LED1_PIN, OUTPUT);
    pinMode(LED2_PIN, OUTPUT);
}

void loop() {
    digitalWrite(LED1_PIN, HIGH);
    digitalWrite(LED2_PIN, LOW);
    delay(500);

    digitalWrite(LED1_PIN, LOW);
    digitalWrite(LED2_PIN, HIGH);
    delay(500);
}

This simple sketch alternates the LEDs on and off every half second, giving me a quick visual indicator that the board is running the uploaded code.

Working on Serial Communication

The next step is getting serial communication working. The goal is for the microcontroller to exit DFU mode after flashing and show up as a virtual COM port, letting me stream live telemetry data back to my computer. This is crucial for testing with Aurora—I need that real-time feedback to monitor system performance. Eventually, I want to build a dedicated flight telemetry GUI, but that depends on solving the serial communication issue.

I’m exploring a few options, including UART-based solutions and ways to automate the DFU-to-serial transition. It’s a bit of a puzzle, but each step forward brings me closer to a working development setup for the Matek H743. The process has been hands-on, but it’s rewarding to see what these STM32 devices can do when customized for a specific application.


MatekH743 Pinout Header File

If anyone else wants to use the Matek H743 board with the Arduino IDE/PlatformIO, here’s the header file I created (MatekH743_Pinout.h), hopefully it can save you a little work!

#pragma once

// Beeper
#define BEEPER_PIN PA15

// Motors
#define MOTOR1 PB0
#define MOTOR2 PB1
#define MOTOR3 PA0
#define MOTOR4 PA1
#define MOTOR5 PA2
#define MOTOR6 PA3
#define MOTOR7 PD12
#define MOTOR8 PD13

// Servos
#define SERVO1 PE5
#define SERVO2 PE6

// LED
#define LED1_PIN PE3
#define LED2_PIN PE4
#define LED_STRIP_PIN PA8

// UART
#define UART1_TX PA9
#define UART1_RX PA10
#define UART2_TX PD5
#define UART2_RX PD6
#define UART3_TX PD8
#define UART3_RX PD9
#define UART4_TX PB9
#define UART4_RX PB8
#define UART6_TX PC6
#define UART6_RX PC7
#define UART7_TX PE8
#define UART7_RX PE7
#define UART8_TX PE1
#define UART8_RX PE0

// I2C
#define I2C1_SCL PB6
#define I2C1_SDA PB7
#define I2C2_SCL PB10
#define I2C2_SDA PB11

// SPI
#define SPI1_SCK PA5
#define SPI1_MISO PA6
#define SPI1_MOSI PD7
#define SPI2_SCK PB13
#define SPI2_MISO PB14
#define SPI2_MOSI PB15
#define SPI3_SCK PB3
#define SPI3_MISO PB4
#define SPI3_MOSI PB5
#define SPI4_SCK PE12
#define SPI4_MISO PE13
#define SPI4_MOSI PE14

// ADC
#define ADC_BATT PC0
#define ADC_CURR PC1
#define ADC_RSSI PC5
#define ADC_EXT PC4

// SDIO (for SD card)
#define SDIO_CK PC12
#define SDIO_CMD PD2
#define SDIO_D0 PC8
#define SDIO_D1 PC9
#define SDIO_D2 PC10
#define SDIO_D3 PC11

// Pin I/O
#define PINIO1 PD10
#define PINIO2 PD11

// OSD
#define OSD_CS PB12

// Gyro and IMU
#define GYRO_EXTI1 PB2
#define GYRO_EXTI2 PE15
#define GYRO_CS1 PC15
#define GYRO_CS2 PE11

// SPI3 chip select pads
#define SPI3_CS1 PD4
#define SPI3_CS2 PE2

// PPM and other signals
#define PPM_PIN PC7