Pages

Monday, June 8, 2015

Compiling a single Linux Kernel module inside the Kernel tree

I recently find out a faster way to compile a single module in the Linux Kernel tree thanks to this post:

$ time make modules SUBDIRS=drivers/media/platform/vivid
Building modules, stage 2.
MODPOST 1 modules
CC drivers/media/platform/vivid/vivid.mod.o
LD [M] drivers/media/platform/vivid/vivid.ko
real 0m2.279s
user 0m0.847s
sys 0m0.924s
view raw gistfile1.sh hosted with ❤ by GitHub
What I was doing before was taking much more time:

$ time make drivers/media/platform/vivid/vivid.ko
CHK include/config/kernel.release
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CHK include/generated/bounds.h
CHK include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
MODPOST 4059 modules
CC drivers/media/platform/vivid/vivid.mod.o
LD [M] drivers/media/platform/vivid/vivid.ko
real 2m26.061s
user 0m13.959s
sys 0m29.722s
view raw gistfile1.sh hosted with ❤ by GitHub
Or a pure make -j5, even if I had already compiled my Kernel once and just modified one module, was taking me ~5 minutes. So each tiny test I made (like changing a the contents of a string) was taking me that long, now it takes some seconds using the make modules SUBDIRS=path/to/module command \o/

To update the module I just copy the .ko to the right place:

sudo cp /path/to/my/module/module.ko /lib/modules/`uname -r`/kernel/path/to/my/module/module.ko
view raw gistfile1.sh hosted with ❤ by GitHub
It usually works if you made a simple change in the code. Or you can use the SUBDIRS too:

sudo make modules_install SUBDIRS=drivers/media/platform/vivid
view raw gistfile1.sh hosted with ❤ by GitHub

No comments:

Post a Comment