OpenWrt Forum Archive

Topic: Integrate my .ko file into /lib/modules/../ during compilation

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm trying to add a new module into the linux kernel of Openwrt. This module is a custom driver for my own peripheral device. The source files are located in openwrt/build_dir/target.../linux-.../compat-wireless-2016-05-13/drivers/mymodule after my patch file is applied. The mymodule.ko file can be found in the same directory. Below are my questions:

After I install the built image into my router (Atheros 93XX), I can not find mymodule.ko in /lib/modules/4.4.14/. However, (1) I can see ath9k.ko file which is also compiled from compat-wireless-2016-05-13 in that directory; (2) My .ko file works well after I scp it into the router and insmod it manually.

What I expect is that after I compile openwrt and install it into my router, I can see my module (mymodule.ko) added into /lib/module/4.4.13/ and automatically loaded when system starts. This behavior is just like the Atheros driver ath9k.

So what should I do to achieve what I want?

Standard way is best...

ponder the *.mk files in package/kernel/linux/modules/
choose the one that best fits your hardware category, add an entry (use existing as template) for your driver
link or copy your driver source to the corresponding place in kernel source
don't forget to select it in menuconfig

good luck

The discussion might have continued from here.