Try the simplest kernel module from LDD3 without any changes to the purpose-built kernel v4.1.0-rc6 for the Beagle Bone board with BusyBox v1.23.0. The code for the module is as follows:
#include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel world\n"); } module_init(hello_init); module_exit(hello_exit);
Makefile:
ARCH := arm CROSS_COMPILE := arm-cortex_a8-linux-gnueabi- obj-m := hello.o all: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C /path/to/linux/source/tree M=$(PWD) modules clean: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C /path/to/linux/source/tree M=$(PWD) clean
The module compiles and installs on rootfs just fine. it also loads:
$ insmod hello.ko [ 30.692404] Hello, world
But when I try to remove it, I get:
$ rmmod hello.ko Segmentation fault $modprobe -r hello.ko Segmentation fault $ lsmod hello 813 0 - Live 0xbf000000 (O)
The kernel is compiled with the ability to unload the module (both regular and forced).
What is the possible cause of this problem? What is the way to approach his research?
Update:
As suggested in the comments I tried, including linux/kernel.h , defining the characters MODULE , LINUX and __KERNEL__ . Added __init and __exit to functions. Removed static modifiers. Removed printk lines. The result is the same. dmesg shows only the initial greeting. It is surprisingly surprising that loading and unloading kernel modules such as gpio_keys or crypto/ccm gpio_keys Therefore, the only thing left to suspect is a way to compile the module.
Update 2
Updating the kernel to the most recent snapshot did not help. A compiled module with various optimization settings did not help. The next step, I think, I'm going to modify BusyBox rmmod to have some indication of the location of the problem.