Kernel Exercise

Exercise gives bonus marks for Assignment 4 and practices topics required for Quiz 4.
Exercise must be done individually.

Learning Outcomes

  1. Building a specific version of the Linux kernel.
  2. Creating, cross-compiling, loading, and unloading, printing-to and reading-from a misc driver.
  3. Working with user data in read() and write() functions.
  4. Creating and controlling an LED trigger.

Overview

write()

read()

Marking

Worth up to 15 bonus marks of assignment 4.

[5] Correct LED operation and timing
[5] Correct read() behaviour
[2] Correct read with different buffer sizes
[3] Correctly return errors for bad pointers / memory access issues

Sample Output

debian@BeagleBone:/mnt/remote/drivers$ sudo insmod ./waveform.ko
debian@BeagleBone:/mnt/remote/drivers$ echo waveform > /sys/class/leds/beaglebone\:green\:usr0/trigger
debian@BeagleBone:/mnt/remote/drivers$ time echo "" | sudo tee /dev/waveform

real    0m0.108s
user    0m0.030s
sys 0m0.057s
debian@BeagleBone:/mnt/remote/drivers$ sudo cat /dev/waveform 
# times high: 0
# times low:  0
Longest high: 0
Longest low:  0
debian@BeagleBone:/mnt/remote/drivers$ time echo "----" | sudo tee /dev/waveform
----

real    0m1.107s
user    0m0.035s
sys 0m0.053s
debian@BeagleBone:/mnt/remote/drivers$ sudo cat /dev/waveform 
# times high: 1
# times low:  0
Longest high: 4
Longest low:  0
debian@BeagleBone:/mnt/remote/drivers$ time echo "______" | sudo tee /dev/waveform
______

real    0m1.612s
user    0m0.038s
sys 0m0.052s
debian@BeagleBone:/mnt/remote/drivers$ sudo cat /dev/waveform 
# times high: 1
# times low:  1
Longest high: 4
Longest low:  6
debian@BeagleBone:/mnt/remote/drivers$ time echo "-_-_-_-" | sudo tee /dev/waveform
-_-_-_-

real    0m1.860s
user    0m0.034s
sys 0m0.056s
debian@BeagleBone:/mnt/remote/drivers$ sudo cat /dev/waveform 
# times high: 5
# times low:  4
Longest high: 4
Longest low:  6
debian@BeagleBone:/mnt/remote/drivers$ time echo "abc-def-hij-klm-nop-qrs-t" | sudo tee /dev/waveform
abc-def-hij-klm-nop-qrs-t

real    0m1.612s
user    0m0.041s
sys 0m0.047s
debian@BeagleBone:/mnt/remote/drivers$ sudo cat /dev/waveform 
# times high: 6
# times low:  4
Longest high: 6
Longest low:  6
debian@BeagleBone:/mnt/remote/drivers$ time echo "----____----____----____----____----____" | sudo tee /dev/waveform
----____----____----____----____----____

real    0m10.121s
user    0m0.032s
sys 0m0.062s
debian@BeagleBone:/mnt/remote/drivers$ sudo cat /dev/waveform 
# times high: 11
# times low:  9
Longest high: 6
Longest low:  6
debian@BeagleBone:/mnt/remote/drivers$