Skip to content

Implement Kernel Module and Character Device Driver

Notifications You must be signed in to change notification settings

wh2per/Raspberry-Pi-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

Raspberry-Pi-3

To Do List

1. Kernel Module

  • export_var
  • linked_list
  • blocking I/O
  • character device driver
  • printk
  • ioctl
  • spinlock
  • kernel timer

2. Sensor Module

  • LED
  • wiring LED
  • PIR
  • timer with LED
  • wiring LCD

Manual

1. How to make Makefile

  obj-m := module_code.o
  KDIR := ~/Desktop/dev/rpi3_linux/linux
  
  default:
      make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C$(KDIR) M=$(shell pwd) modules
  clean:
      make -C$(KDIR) M=$(shell pwd) clean

2. How to make mknod.sh

  MODULE = "module_dev"
  MAJOR=$(awk "\$2==\"$MODULE\" {print \$1}" /proc/devices)
  
  mknod /dev/$MODULE c $MAJOR 0

3. How to Cross Compile

  $ arm-linux-gnueabif-gcc -o module_code_app module_code_app.c

4. How to Run

  $ sudo insmod module.ko       // load module code 
  $ sudo sh mknod.sh            // register device driver
  $ ./module_code_app           // run object file

5. How to Quit

  $ sudo rmmod module.ko        // remove module code
  $ rm /dev/module_dev          // remove device driver