This post shows you how to build a Linux kernel driver that reads from the device-tree in 5 min.
Before you Start
Read and follow the ARM instructions listed in 15 Minute Setup to Find, Change, Recompile and Test an ARM or x86 Linux Kernel Change in 12 Seconds at [link]
Steps
Set Up the Makefiles
1. Type cd ~/tla/linux-4.10.6
2. Type mkdir -p drivers/demo
3. Type vi drivers/Makefile
4. Add obj-y += demo/
5. Save the file with :w and quit with :q
6. Type vi drivers/demo/Makefile
7. Add obj-y += demo.o
8. Save the file with :w and quit with :q
Write the Driver
1. Type cd ~/tla/linux-4.10.6
2. Type vi drivers/demo/demo.c
3. Enter:
4. Save the file with :w and quit with :q
Compile and Run It
1. Type cd ~/tla/linux-4.10.6
2. Type source ~/envset.sh
3. Type make
You should see:
4. Run it by typing:
You should see (look for >>>>>>>>>> Hello, ARM Versatile PB <<<<<<<<<<):
5. Type Control-a x to quit QEMU
References