User kernel module "not found in directory"?

3.1k views Asked by At

I did a simple Linux kernel module. I can install the module temporarily via sudo insmod my_module.ko and use it.

But I tried and failed to load the module at boot time:

  • copied it to /lib/modules/5.4.0-1056-raspi/kernel/drivers/my_module/my_module.ko (uname -r gives 5.4.0-1056-raspi)

  • added my_module line to /etc/modules

  • rebooted

However, the module is not loaded: Module my_module not found in directory /lib/modules/5.4.0-1056-raspi.

But the module is there in the kernel/drivers/my_module/my_module.ko file!

lsmod does not list it.

Have in mind that this module worked perfectly before on the same machine, but the kernel at that point was 5.4.0-1047-raspi and now I see it is 5.4.0-1056-raspi, so I went on to install it again - but this time it doesn't work.

What could be done wrong?

p.s. When I tried to compile my_module.c on this newer kernel, I got the error about missing license, so I added the line MODULE_LICENSE("GPL"); to the c file - than it compiled fine. That's the only difference in the source.

1

There are 1 answers

0
Danijel On

For some reason I needed to run sudo depmod first to re-generate the module dependencies, than sudo modprobe my_module to make it all work again.