Kernel modules not found in final image

I'm trying to build an image for my router with additional kernel modules. I usually add them directly into the kernel from make kernel_menuconfig as <*>, but this time the kernel got too big to fit into the kernel partition, so i selected some of them as modules <M>. I expected to find all these modules in rom /lib/modules, but they are not there.
Is this the intended behaviour of OpenWrt buld system, or is there something wrong with my system?
Thanks.

1 Like

Yes. You need to enable the kmod packages containing the desired *.ko files in the normal menuconfig. If you just enable modules in kernel_menuconfig they will get built but not be part of any package and thus do not end up in the final rootfs.

1 Like

I feel the need to make this a feature request!

I see no drawbacks. The modules are there; a simple copy operation would include them in the rom. A user like me with a specific need would not be forced to write a new package for a module that probably very few people (if any) would use if package is published, which is, again, complicated.

1 Like

I tried to modify ./include/rootfs.mk. I added a find -name *.ko in the kernel build dir and copy all of them to rootfs. This does the job, but also includes all the kernel modules that were selected in make menuconfig, not just those from make kernel_menuconfig.

Is there any way to separate these? Is there any list of modules that were built by menuconfig, not kernel_menuconfig?
Thank you.

1 Like

Likewise I'm running into a problem getting vhost-net module to be included in the kernel. It's not obvious to me where this is in menuconfig and/or what CONFIG option to set.
Any suggestions ?
AlP

1 Like

Realized after searching through the forums that there is a search capability in the menuconfig's using '/'. That helps.
So I am able to find VHOST_NET module and have set it to be built-in to the kernel.

But when I boot the final image, there is no /dev/vhost-net created and there is no vhost.ko or vhost-net.ko.
Do I have to specifically create a package for vhost-net in the feeds ?

If you add it as a module (<M> in make kernel_menuconfig), it will be built, but OpenWrt will not include it into the image, as jow said above. You can search for the corresponding module (.ko file) in the build directory and copy it to the router later. You must also add a command to load it when the router boots.

If you add it as built-in (<*> in make kernel_menuconfig), it will be inside the kernel. There is no separate .ko file. In this case, it will always be loaded. If you don't see it in /dev, then there is something wrong with the kernel: you didn't make clean and the build result is a mess, you wrote the wrong image, or there is an error loading the driver (search for it in kernel log).
I strongly recommend to add support for /proc/config.gz (CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC). With this you can see the configuration of the kernel you are actually running: zcat /proc/config.gz and you can see for certain if the driver is in there or not.

Thanks. make clean helped.
It doesn't exactly work as expected but I now have modules that I can manually insert and use.