Skip to main content

Embedded Buses & Debug Cheatsheet

Quick overview of common hardware buses (UART, I2C, SPI, GPIO, CAN) and Linux user-space debug tools.

Bus Comparison​

BusSignal WiresModeTypical SpeedCommon Use Cases
UART2 (TX, RX)Async, point-to-point9600 – 921600 bpsConsole logs, GPS, modems
I2C2 (SDA, SCL)Sync, addressed multi-device100 kHz / 400 kHzSensors, EEPROM, PMIC, RTC
SPI4 (MOSI, MISO, SCLK, CS)Sync, full-duplex1 – 50+ MHzNOR/NAND flash, displays, ADCs
CAN2 differential (CANH, CANL)Broadcast, noise-resilient125 kbps – 1 Mbps (higher on FD)Automotive, industrial, robotics
GPIO1 wire / pinDigital In/OutSoC-dependentLEDs, buttons, reset, IRQs

Debugging UART on Linux​

ls /dev/ttyS* /dev/ttyUSB* /dev/ttyACM* # List serial devices
stty -F /dev/ttyUSB0 115200 cs8 -cstopb -parenb raw
cat /dev/ttyUSB0 # Quick raw read

On Windows, use WinSerial for keyword highlighting and automatic reconnect.

Debugging I2C (i2c-tools)​

i2cdetect -l # List I2C buses
i2cdetect -y 1 # Scan addresses on bus 1
i2cget -y 1 0x48 0x00 # Read 1 byte from register 0x00 of device 0x48
i2cset -y 1 0x48 0x01 0x60 # Write 0x60 to register 0x01
i2cdump -y 1 0x48 # Dump all registers

Debugging GPIO (libgpiod)​

gpiodetect # List gpiochips
gpioinfo gpiochip0 # Show line names and states
gpioget gpiochip0 17 # Read line 17
gpioset gpiochip0 17=1 # Drive line 17 high
gpiomon gpiochip0 17 # Watch rising/falling edge events

Debugging CAN (can-utils)​

sudo ip link set can0 up type can bitrate 500000
candump can0 # Stream CAN frames in real time
cansend can0 123#DEADBEEF # Send a standard CAN frame
ip -details -statistics link show can0

References​