What is a Device Driver in Embedded Linux?
Think of a device driver as a translator. Your hardware speaks electrical signals. Your OS speaks software instructions. The driver connects both worlds. In embedded Linux driver development, drivers handle:
- Hardware initialization
- Data transfer
- Interrupts
- Resource management
The Linux kernel device drivers are structured into subsystems — and for us, the most important are:
- I2C subsystem in Linux kernel
- SPI subsystem in Linux kernel

I2C Communication in Embedded Systems (Simple Explanation)
I2C is used when:
- Speed is not critical
- You want fewer pins
- Multiple devices share the same bus
Only two wires:
That’s why it’s everywhere in:
- Sensors
- RTC modules
- EEPROMs
Why Engineers Prefer I2C
- Saves PCB space
- Easy to scale
- Address-based communication
How Linux Handles I2C (Behind the Scenes)
The Linux kernel I2C framework is designed so you don’t have to deal with raw signals.
It has 3 layers:
- Adapter driver (hardware controller)
- Core framework
- Client driver (your device driver)
How it actually works:
- Device defined in device tree configuration for I2C devices
- Kernel matches compatible string
- Calls probe function
- Driver starts communication
How to Write I2C Device Driver in Linux
Let’s keep it practical. Every Linux I2C driver example follows this structure:
- Driver registration
- Probe function
- Remove function
- Read/write logic
Important APIs
- i2c_smbus_read_byte()
- i2c_smbus_write_byte()
- i2c_transfer()
Real-world tip:
Most beginners fail not in code — but in device tree mismatch.

SPI Communication in Embedded Systems
Now, when speed matters → SPI wins.
Unlike I2C, SPI uses:
Why SPI is Powerful
- Faster than I2C
- Full-duplex communication
- More reliable timing
Used in:
- Displays
- Flash memory
- ADC/DAC
- RF modules
SPI Subsystem in Linux Kernel
Similar to I2C, the Linux SPI core framework abstracts hardware.
Structure:
- SPI master driver
- SPI core
- SPI device driver
How to Develop SPI Driver in Embedded Linux
A basic SPI driver example in Linux kernel includes:
- Driver struct
- Probe/remove functions
- Data transfer using SPI APIs
Important APIs
- spi_sync()
- spi_write()
- spi_read()
Pro insight:
SPI debugging is easier than I2C because signals are independent — use logic analyzer.
I2C vs SPI in Embedded Systems (Engineer’s View)
| Feature | I2C | SPI |
|---|
| Speed | Low | High |
| Pins | 2 | 4 |
| Debugging | Hard | Easy |
| Use Case | Sensors | Displays/Flash |
Real decision rule:
- Use I2C → low-speed + multiple devices
- Use SPI → high-speed + real-time
Device Tree in Embedded Linux (Most Important Part)
If your driver isn’t loading, 90% of the time the issue is here.
The device tree in embedded Linux defines:
- Bus
- Address / Chip select
- Compatible driver
Why it matters:
Without correct device tree → driver won’t probe
Real Applications (Where This Is Used)
Industrial Embedded Systems
- Automation controllers
- Monitoring devices
- ECU communication
- Dashboard electronics
Conclusion
If you want to become a strong embedded engineer, mastering Linux I2C and SPI device driver development is not optional — it’s essential.
Once you understand:
- Linux kernel frameworks
- Device tree configuration
- Driver lifecycle
You can build real-world embedded Linux systems used in industry.
