SocketCAN compatibility for the STM32H7 core board from AliExpress, implementing a USB to CAN adapter using the gs_usb protocol.
# Download from ARM official site or install via package manager
# Version tested: gcc-arm-none-eabi-10.3-2021.10
sudo apt update
sudo apt install gcc-arm-none-eabi# For flashing the STM32 via ST-Link
sudo apt install stlink-toolssudo apt install make
# Version tested: GNU Make 4.3# For CAN interface management and testing
sudo apt install can-utils- ST-Link V2 programmer (for flashing firmware)
- WeAct Studio MiniDebugger: A compatible debugger for this board. Link
- Logic analyzer or oscilloscope (for debugging)
This project uses the WeAct STM32H743VIT6 Core Board available on AliExpress:
- MCU: STM32H743VIT6 (Cortex-M7, 480MHz)
- Flash: 2MB
- RAM: 1MB
- Package: LQFP-100
- Key features: USB-C connector, onboard LED, user buttons
- LED1: PE3 (Status indicator)
- USER_BTN_K1: Configurable. See troubleshooting for notes on PC13, PE3, and PB12.
- CAN1/CAN2: Pins for external CAN transceiver.
- USB: USB-C connector for communication.
You'll need external CAN transceivers (e.g., TJA1050, MCP2551) to interface with actual CAN buses, as the STM32 only provides the CAN controller, not the physical layer.
git clone https://github.com/yourusername/gs_can_weact_H7_coreboard.git
cd gs_can_weact_H7_coreboard
make clean
make# Using st-flash utility
make flash
# Or manually:
st-flash --reset write build/DevEBoxH7_fw.bin 0x8000000# Bring up the CAN interface
sudo ip link set can0 up type can bitrate 500000
# Verify interface is up
ip link show can0# For 125 kbps
sudo ip link set can0 up type can bitrate 125000
# For 250 kbps
sudo ip link set can0 up type can bitrate 250000
# For 1 Mbps
sudo ip link set can0 up type can bitrate 1000000# Bring down the interface
sudo ip link set can0 down- Connect the STM32H7 board via USB-C.
- Set up the CAN interface (see above).
- Press the K1 button on the board.
- Observe the CAN message transmission.
The button sends a test frame:
- CAN ID: 0x123
- Data:
11 22 34 44 55 66 77 88 - Length: 8 bytes
# Monitor all CAN traffic
candump can0
# Example output:
# can0 123 [8] 11 22 34 44 55 66 77 88# Send a test message
cansend can0 456#DEADBEEFIf the K1 button doesn't send messages:
- Check CAN interface status: Ensure
can0is UP. - Verify host channel is active: The firmware only sends when the CAN channel is enabled from the host software.
- Pin Configuration: The button's GPIO pin is critical.
- PC13: This pin is connected to button labeled K1 on the board. It must be set as PULLDOWN to work properly
- PE3: This pin is connected to the onboard LED. See board.c and board.h for details and configuration.
# Reset CAN interface
sudo ip link set can0 down
sudo ip link set can0 up type can bitrate 500000
# Check kernel logs for errors
dmesg | grep canModify the task_queue_from_host() function in Core/Src/main.c to add custom CAN frame processing.
The onboard LCD display can also be used to do funny things
- Solid ON: CAN channel active.
- Blinking: CAN traffic activity.
MIT License.