OpenWrt Forum Archive

Topic: Adding device drivers as LKM

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

Hello,

I have experienced following problem: kernel package for non-standard device driver added with =m option appeared in staging_dir and ipkg packages but not in an image. It's name was missing from linux.default.install file, processed by /package/Makefile for populating build_dir (direct image source). Modifying package-ipkg.mk BuildTarget/ipkg did the job, but is it a bug or a feature? Actually having LKM option for development is a must.

Regards

It's a little tricky to understand your description, but it seems that you're saying that a package added in menuconfig, selected as a module, is not added to the final image.

This is the correct behaviour. Anything added =m is built but not included in the image. If you add it with a =y then it will be added to the final image.

Sorry for being imprecise, I'm in firefighting mode right now.

My post above is showing the complexity of stuff I had to review to discover this feature. Build process  should have informed me or die instead of doing silently something inconsequent. Short point summary on image populating process in case somebody stumbles upon this like I did:

  • kernel buit-in drivers marked y in menuconfig/buildroot packages are always in image (as kernel is)

  • loadable kernel modules marked m in menuconfig/buildroot packages are being installed in openwrt/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/root-ramips and are available after build as ipkg packages, but are not being placed in build directory (openwrt/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/root-ramips) which is data source for building image

  • kernel module names to be transferred to build directory from staging directory must be within openwrt/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/pkginfo/linux.default.install file

  • linux.default.install is being populated by openwrt/include/package-ipkg.mk makefile

  • following patch for package-ipkg.mk causes LKM's to be copied into build_dir: 

From 8f2f0df1499f3a91e97ca15c0ae77163ad963e6a Mon Sep 17 00:00:00 2001
From: egal <egal@egal.egal>
Date: Sun, 4 Dec 2016 13:21:54 +0100
Subject: [PATCH 3/3] Bugfix LKM installing into rootfs in build_dir. Build_dir is source for image rootfs.

---
 include/package-ipkg.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index eb4c874..b7ee957 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -102,7 +102,7 @@ ifeq ($(DUMP),)
         compile: $(PKG_INFO_DIR)/$(1).version
         endif
 
-        ifeq ($(CONFIG_PACKAGE_$(1)),y)
+        ifeq ($(CONFIG_PACKAGE_$(1)),$(filter $(CONFIG_PACKAGE_$(1)),y m))
           .PHONY: $(PKG_INSTALL_STAMP).$(1)
           compile: $(PKG_INSTALL_STAMP).$(1)
           $(PKG_INSTALL_STAMP).$(1):
-- 
1.9.1

Regards

The discussion might have continued from here.