Hi, this is a compendium of multiple didactic Linux Kernel modules, I am doing this due to the fact that many times somebody says that the LDD book is too complicated, well here is a series of examples that might be helpful.
In my opinion a really good start for really newbies Linux Modules Developers WAS (past time on purpose) The Linux Kernel Module Programming Guide (http://www.tldp.org/LDP/lkmpg/2.6/html/). However, this guide is based on the Kernel 2.6.. which has many deprecated parts in relationship with the 3.~ kernel
Well this project tries to update the source code of that guide to the latest a version of the kernel (please update and improve as possible), hopefully, if many folks agree the guide will be updated, just as its authors wanted.
- Fedora
Download all the kernel dev packages (in case of Fedora):
https://fedoraproject.org/wiki/Building_a_custom_kernel
You might have some problems with the livna.repo, please temporary remove it
- CentOS
In case of CentOS:
yum -y groupinstall "Development Tools"
yum -y install ncurses-devel \
hmaccalc \
zlib-devel \
binutils-devel \
elfutils-libelf-devel \
bc \
openssl-devel \
kernel-devel \
kernel-headers
If you want to build the kernel we have a Dockerfile image, just run:
make iamge
docker run build_kernel:latest
Is important to customize a shared volume to copy the kernel uimage, the build_kernel docker image just build the upstream kernel (adjust the git clone to your needs)
1) make MODULE="<name_of_module>" // DO NOT add the .c, just the name of
the module. If no name is passed the makefile will build the basic hello
world module
2) make clean: will clean the module
insmod module.ko
modprobe module.ko
REMOVE:
rmmod module
Check printk message:
dmesg
or
cat /var/log/syslog