Embedded Buses & Debug Cheatsheet
Quick overview of common hardware buses (UART, I2C, SPI, GPIO, CAN) and Linux user-space debug tools.
Bus Comparison
| Bus | Signal Wires | Mode | Typical Speed | Common Use Cases |
|---|---|---|---|---|
| UART | 2 (TX, RX) | Async, point-to-point | 9600 – 921600 bps | Console logs, GPS, modems |
| I2C | 2 (SDA, SCL) | Sync, addressed multi-device | 100 kHz / 400 kHz | Sensors, EEPROM, PMIC, RTC |
| SPI | 4 (MOSI, MISO, SCLK, CS) | Sync, full-duplex | 1 – 50+ MHz | NOR/NAND flash, displays, ADCs |
| CAN | 2 differential (CANH, CANL) | Broadcast, noise-resilient | 125 kbps – 1 Mbps (higher on FD) | Automotive, industrial, robotics |
| GPIO | 1 wire / pin | Digital In/Out | SoC-dependent | LEDs, 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