Skip to content

Day33 - Minimal IIO Driver

Objective

  • Implement a minimal IIO driver
  • Verify sysfs interface generation
  • Understand read path mapping

Step 1 - Build Driver

make

Step 2 - Load IIO Core (if needed)

sudo modprobe industrialio

Step 3 - Insert Module

sudo insmod myiio_dummy.ko

Step 4 - Verify Probe

dmesg | tail -n 20

Expected:

myiio_dummy: module loaded
myiio probe start

Step 5 - Check IIO Device

ls /sys/bus/iio/devices/

Expected:

iio:device0

Step 6 - Explore sysfs

cd /sys/bus/iio/devices/iio:device0
find . | sort

Step 7 - Read Values

cat name
cat in_voltage0_raw
cat in_voltage0_scale

Expected:

myiio_dummy
1234
0.001000

Step 8 - Modify Raw Value

Edit:

static int fake_adc_value = 2048;

Rebuild and reload:

make
sudo rmmod myiio_dummy
sudo insmod myiio_dummy.ko

Verify:

cat in_voltage0_raw

Step 9 - Remove SCALE Attribute (Optional)

Modify:

.info_mask_separate = BIT(IIO_CHAN_INFO_RAW);

Reload driver and verify:

ls

Expected:

in_voltage0_raw

Result

Successfully verified:

  • sysfs auto-generation
  • channel mapping
  • read_raw() data path