Skip to content

Day34 Log - IIO I2C Driver Implementation

Summary

Implemented a multi-channel IIO driver over I2C for a custom STM32-based sensor.

Key achievements:

  • Successful I2C communication with fake sensor
  • IIO device registration
  • Multi-channel sysfs interface
  • Dynamic data updates observed

Issues Encountered

1. Static values (no update)

Cause:

  • sensor_task_process() not called in main loop

Fix:

  • Move sensor execution to main loop

2. Module reload failure

insmod: Cannot allocate memory

Cause:

  • Attempted reload in invalid context / device state

Fix:

  • Ensure module removed
  • verify I2C device ready
  • reinsert module

3. Overlay warnings

memory leak will occur if overlay removed

Cause:

  • modifying bus node properties in overlay

Impact:

  • No functional issue for current use

Observations

1. Channel mapping works

ADC0 → in_voltage0_raw
ADC1 → in_voltage1_raw
ADC2 → in_voltage2_raw

2. Data pattern verified

Observed:

1229 / 1329 / 1429
1302 / 1402 / 1502

Confirms:

  • deterministic sample update
  • correct channel offset
  • correct register mapping

3. End-to-end pipeline validated

STM32 → I2C → IIO → sysfs

Key Learning

  • IIO integrates cleanly with I2C drivers
  • Channel metadata drives user-space interface
  • Time-driven sensor design is critical
  • Multi-channel support is natural in IIO

Reflection

This implementation bridges:

  • MCU firmware design
  • Linux driver development
  • IIO framework usage

It provides a complete vertical integration example.


Next Step

Day35:

  • Add data-ready GPIO (DRDY)
  • Introduce interrupt handling
  • Prepare for IIO buffer/trigger