PX4 Serial Port Silent or SD Card Failing? A Practical Porting Guide
In the UAVflight controller system, serial communication and SD card storage are the two most basic and critical functions. The former is responsible for interacting with peripherals such as GPS, remote control, and data transmission, while the latter is used for log recording and data analysis. However, when transplanting PX4 to the STM32H743 development board, the original hardware mapping and driver configuration often cannot be directly applied, and problems such as serial port mapping errors, drivers not enabled or improperly configured, hardware wiring errors, and SD card initialization failures are often prone to occur.
This article will focus on the above issues, share complete configuration steps and debugging methods, and help you quickly implement:Serial port remapping and communication test, SD card driver activation and log function verification。
01 Serial port transplantation
Function allocation plan

-
Confirm that the device nodes correspond to the hardware functions one-to-one. If the default mapping does not match the actual requirements, communication abnormalities will occur.
-
If there is no output from the serial port, it is often caused by an error in serial port allocation or mapping.
Key code modifications
Step 1: Pin Remapping Modify board.h to specify the physical pins:
#define GPIO_USART1_RX GPIO_USART1_RX_2 /* PA10 */
#define GPIO_USART1_TX GPIO_USART1_TX_2 /* PA9 */
#define GPIO_USART2_RX GPIO_USART2_RX_1 /* PA3 */
#define GPIO_USART2_TX GPIO_USART2_TX_1 /* PA2 */
#define GPIO_USART3_RX GPIO_USART3_RX_1 /* PB11 */
#define GPIO_USART3_TX GPIO_USART3_TX_1 /* PB10 */
#define GPIO_UART4_RX GPIO_UART4_RX_2 /* PA1 */
#define GPIO_UART4_TX GPIO_UART4_TX_2 /* PA0 */
#define GPIO_UART5_RX GPIO_UART5_RX_3 /* PD2 */
#define GPIO_UART5_TX GPIO_UART5_TX_3 /* PC12 */
#define GPIO_USART6_RX GPIO_USART6_RX_1 /* PC7 */
#define GPIO_USART6_TX GPIO_USART6_TX_1 /* PC6 */
-
STM32H743 supports multi-channel pin multiplexing, and the actual mapping needs to correspond to the development board schematic diagram.
-
Different pin multiplexing may affect driver initialization. It is recommended to give priority to the pins recommended by the reference design.
Step 2: Parameter configuration Set the buffer and working mode in defconfig:
CONFIG_STM32H7_UART4=y
CONFIG_STM32H7_UART5=y
CONFIG_STM32H7_USART1=y
CONFIG_STM32H7_USART2=y
CONFIG_STM32H7_USART3=y
CONFIG_STM32H7_USART6=y
CONFIG_STM32H7_USART_BREAKS=y
CONFIG_STM32H7_USART_INVERT=y
CONFIG_STM32H7_USART_SINGLEWIRE=y
CONFIG_STM32H7_USART_SWAP=y
CONFIG_UART4_BAUD=57600
CONFIG_UART4_RXBUFSIZE=600
CONFIG_UART4_TXBUFSIZE=800
CONFIG_UART5_BAUD=57600
CONFIG_UART5_RXBUFSIZE=600
CONFIG_UART5_TXBUFSIZE=800
CONFIG_USART1_BAUD=57600
CONFIG_USART1_RXBUFSIZE=180
CONFIG_USART1_SERIAL_CONSOLE=y
CONFIG_USART1_TXBUFSIZE=1500
CONFIG_USART2_BAUD=57600
CONFIG_USART2_RXBUFSIZE=600
CONFIG_USART2_TXBUFSIZE=3000
CONFIG_USART3_BAUD=57600
CONFIG_USART3_RXBUFSIZE=600
CONFIG_USART3_TXBUFSIZE=1500
CONFIG_USART6_BAUD=57600
CONFIG_USART6_RXBUFSIZE=600
CONFIG_USART6_TXBUFSIZE=1500
Hardware loopback testing
Step 1: Enable test command: add in default.px4board:
CONFIG_SYSTEMCMDS_SERIAL_TEST=y
Step 2: Execute the command after shorting the TX/RX pin:
serial_test -e -b 921600 -p /dev/ttyS1 -c -l 250

If tx/rx is short-circuited, the output is as shown below:

If tx/rx is not shorted as shown below:

This method can quickly verify the reliability of all serial port channels and avoid communication abnormalities caused by hardware failures. After confirming that the serial port driver is working properly through the hardware loopback test, you can connect GPS, data transmission and other peripherals for practical application testing.
02 SD card transplant
Hardware connection solution
According to the STM32H743 development board schematic diagram, the SD card interface pin mapping is as follows:

Interface description: Using 4-bit data bus (D0-D3) mode, the clock frequency can reach up to 48MHz.
Driver configuration
This development board uses SDMMC1,Revise boards/geek/h743/nuttx-config/nsh/ The sd-related parts of the defconfig file in the directory.
CONFIG_SDMMC1_SDIO_PULLUP=y # Configure the internal pull-up resistor
CONFIG_STM32H7_SDMMC1=y # Enable the SDMMC1 controller
SD card function test
Burn the compiled firmware to the development board, connect it to the QGCground control station, and test it.
Step 1: Enter sd_bench in the terminal as shown below:

Step 2: Log function verification, check at QGCground control station:
1. Enter Log download interface
2. Click refresh button
3. Confirm that the.ulg log file is displayed
Through the above tests, it can be confirmed that the SD card subsystem is working properly and provides reliable support for flight data recording and fault analysis.

03 A Guide to Avoiding Pitfalls
USB cannot connect to QGC
Troubleshooting: Whether the GPIO_OTGFS_VBUS pin is enabled (short to 3.3v)
DEBUG no output
[boot] Rev 0x0 : Ver 0x0 ICF6000000
[boot] Fault Log info File No 4 Length 3177 flags:0x01 state:1
[boot] Fault Log is Armed
[hardfault_log] Fault Log is Armed
Connect the DEBUG interface to the serial port assistant, only print the above information, delete CONFIG_DEV_CONSOLE is not set in the defconfig file
No output from serial port
Check the correspondence between the serial port device numbers in the default.px4board file
CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS1"
CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS2"
CONFIG_BOARD_SERIAL_GPS2="/dev/ttyS3"
CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS4"
CONFIG_BOARD_SERIAL_RC="/dev/ttyS5"
Resource Express
Source code link:
https://github.com/amovlgf/PX4-Autopilot/tree/geek_h743/boards/geek/h743
We will release a migration guide for I2C sensors and SPI bus devices (IMU, magnetic compass) in the future, so stay tuned!
