Skip to content

Day 42 Learning Log

🧠 Key Insights

1. IIO layout is not struct-based

  • scan_index defines order
  • alignment may insert padding
  • userspace must not assume packed layout

2. Timestamp enforces alignment

  • 64-bit → requires 8-byte alignment
  • padding inserted automatically

3. FIFO streaming is fragile

  • streaming register requires strict transaction boundary
  • partial read breaks frame alignment

4. ret == len is NOT enough

Even if:

ret == 8

data may still be invalid


5. scan mask is driver responsibility

  • hardware still outputs full frame
  • driver decides what to export

6. buffer size ≠ useful data size

  • 1 channel still produces 16 bytes
  • due to alignment

🐛 Bugs Fixed

Bug 1 - FIFO misalignment

Cause:

  • streaming state not reset

Fix:

sensor_reg_reset_fifo_stream();

Bug 2 - sample rate mismatch

Cause:

  • wrong Hz ↔ register mapping

Fix:

  • correct lookup table

Bug 3 - scan packing offset

Cause:

  • incorrect offset calculation

Fix:

  • use index-based packing (u16 array)

📈 Result

  • stable FIFO reads
  • correct timestamp
  • correct scan mask behavior
  • predictable buffer layout

🏁 Conclusion

This day focuses on:

  • understanding real IIO buffer behavior
  • bridging hardware format and userspace format
  • handling alignment and dynamic layout
  • debugging across full data pipeline