Linux Kernel Programming: Driver Modification Tutorial
ฝัง
- เผยแพร่เมื่อ 10 ม.ค. 2025
- In this video, we dive into modifying and compiling a Linux kernel driver, focusing on the pcnet32 driver. The tutorial covers key aspects such as ABI compatibility and module loading. This video is the first of many aimed at advancing practical knowledge in kernel development.
Commands:
Step 1: Install Necessary Tools
sudo apt update
sudo apt install build-essential libncurses-dev bison flex libssl-dev libelf-dev
Step 2: Install the Kernel Source Package
cd /usr/src/
sudo apt install linux-source-{version} # replace version
sudo tar -xjf linux-source-{version}.tar.bz2 # replace version
cd linux-source-{version} # replace version
sudo chown -R {user}:{user} /usr/src/linux-source-{version} # replace version
Step 3: Modify the pcnet driver
nvim drivers/net/ethernet/amd/pcnet32.c
Step 4: Configure the Kernel
cp /boot/config-$(uname -r) .config
make oldconfig
Step 5: Compile
make modules_prepare
cd drivers/net/ethernet/amd
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
Step 6: Unload and Reload new module
lsmod | grep pcnet32
sudo rmmod pcnet32
lsmod | grep pcnet32
sudo insmod ./pcnet32.ko
lsmod | grep pcnet32
sudo dmesg | less
Great ! Thanks to you i'm able to run my old USB Line-6 audio device under Ubuntu 22.04.
Wow, isn't this just a standalone 10-minute tutorial?
Great tutorial for learning how Linux kernel modules work in vm's
Thanks for this! I was banging my head against "insmod: ERROR: could not insert module drivers/block/floppy.ko: Invalid module format" and the missing Module.symvers for longer than I care to admit XD
Trying to hack a second floppy drive into existence on a mobo that only supports one :)
Awesome tutorial 🫶
If that's the case then how do I convert it for that architecture or do I have to recompile it or something?
Great job ! thank you