Kernel module build but not installed to image

Hello everyone,

I have written several kernel modules and successfully added them to OpenWrt. They are all building nicely. There is the corresponding .ko-file in every $(BUILD_DIR). However one of them is build but the buildsystem does not install it to the image. The kernel module is build fine and if I manually copy the .ko file to the target it works as intended.

However, OpenWrt won't install it to the image. Its always missing in the sysupgrade images as well in the staging_dir root-folder.
Another module that I have written (which uses an identical makefile-template) is compiled and installed fine.
I've checked the configuration twice. Its enabled (CONFIG_PACKAGE_kmod-targetfsctl-module=y) in my config and all dependencies are fulfilled.

I've appended my makefile, maybe anyone can spot what is wrong.

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=targetfsctl-module
PKG_VERSION:=5.1.0
PKG_RELEASE:=3

REDIST_TARGET:=linux
REDIST_RELEASE:=5.1-05.02.2020

PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(REDIST_RELEASE)

include $(INCLUDE_DIR)/package.mk

define KernelPackage/targetfsctl-module
	SUBMENU:=Custom Modules
	TITLE:=Target-Controll via FS
	DEFAULT:=m
	VERSION:=$(LINUX_VERSION)+$(REDIST_RELEASE)-$(BOARD)-$(PKG_RELEASE)
	FILES:=$(PKG_BUILD_DIR)/targetfsctl.ko
	AUTOLOAD:=$(call AutoLoad,80,targetfsctl)
	DEPENDS:=+kmod-usb-core
	KCONFIG:= \
		CONFIG_TARGETFSCTL
endef

define KernelPackage/targetfsctl-module/description
My Testing Module
endef

define Build/Prepare
	$(call Build/Prepare/Default)
	$(CP) files/src/targetfsctl.c $(PKG_BUILD_DIR)/targetfsctl.c
	$(CP) files/Makefile $(PKG_BUILD_DIR)/Makefile
endef

EXTRA_KCONFIG:= \
	CONFIG_TARGETFSCTL=m

EXTRA_CFLAGS := \
	-Wpedantic

MAKE_OPTS:= \
	ARCH="$(LINUX_KARCH)" \
	CROSS_COMPILE="$(TARGET_CROSS)" \
	M="$(PKG_BUILD_DIR)"

define Build/Compile
	$(MAKE) -C "$(LINUX_DIR)" \
			$(MAKE_OPTS) \
			$(EXTRA_KCONFIG) \
			EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
			modules
endef


$(eval $(call KernelPackage,targetfsctl-module))

Edit:
I already tried to debug something. First I changed FILES:=$(PKG_BUILD_DIR)/targetfsctl.ko to FILES:=$(PKG_BUILD_DIR)/nonexisting.ko and surprisingly OpenWrt does not complain about the absence of this file.

FILES seems to point to where the .ko files go.

Typically, in the other kernel packages, it looks like this:

FILES:= \
	$(LINUX_DIR)/.../name.ko

hope that helps

according to the other kmods in Package/kernel it points to the files build:

define KernelPackage/button-hotplug
  SUBMENU:=Other modules
  TITLE:=Button Hotplug driver
  DEPENDS:=+kmod-input-core
  FILES:=$(PKG_BUILD_DIR)/button-hotplug.ko
  AUTOLOAD:=$(call AutoLoad,30,button-hotplug,1)
  KCONFIG:=
endef
1 Like

Sorry, was looking in package/kernel/linux/modules

How are you referencing it to get it built? did you add it to a target or selected it from menu/defconfig?
(button-hotplug is referenced in target/linux/x86/generic/target.mk for example).

Its a normal KernelPackage from a feed created by me. All other modules which are created the same way with the same origin work fine and are installed. But this particular one wont get installed.

Sorry again, I re-read your question and I had missed the part where you mention enabling it using CONFIG_PACKAGE_kmod-targetfsctl-module=y

Are you sure that this is getting picked up? The default for this package is =m aka build the ipk but don't install. Maybe you could try temporarily changing to =y and see if that changes anything (clutching at straws once more). I'll give it a run with bogus files later this evening on my environment otherwise to see if I can reproduce.

The thing is, that even the IPK is empty. There are no files inside it.

1 Like

and you also have this set to y? as I suspect that's required to bring everything in.

Last one for today (and far fetched) as I was trying to find conditions for which the KernelPackage wouldn't install in kernel.mk. I wonder if the name of the package is to blame because it already contains "mod" and that trips up a grep somewhere or something like that. I'd give it a shot and rename it targetfsctl. If that's not helping, we'll bring in a new set of eyes.

Also tried to rename it to not contain any "mod" related wording. Still no luck.

could you share the make logs in verbose when you build the package and it doesn't get installed (starting from a clean state for that package)?

After some fiddeling around I finally got a new message while building the module:

WARNING: kmod-ktargetfsctl is not available in the kernel config - generating empty package

So I assume something is wrong with the Kconfig file?

maybe not the Kconfig file, try to remove CONFIG_TARGETFSCTL from KCONFIG and only leave it in EXTRA_KCONFIG (see your button-hotplug reference Makefile)

the code that gives your the error is in kernel.mk and seems to be looking at KCONFIG (not EXTRA)

1 Like

Oh damn, now I understand the differences and real meanings of those two variables. It works! Thanks a lot!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.