Reputation: 131
I'm writing a simple kernel module for Openwrt. I have working code that loads and does what it needs to do. What I am missing is how to get the code into the build process of Openwrt. I have a Makefile as below:
# Copyright (C) 2006-2012 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
# name
PKG_NAME:=HelloWorld
# version of what we are downloading
PKG_VERSION:=1.0
# version of this makefile
PKG_RELEASE:=0
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
PKG_CHECK_FORMAT_SECURITY:=0
include $(INCLUDE_DIR)/package.mk
define KernelPackage/$(PKG_NAME)
SUBMENU:=Other modules
TITLE:=helloworld lkm
FILES:= $(PKG_BUILD_DIR)/hello.ko
endef
define KernelPackage/$(PKG_NAME)/description
A sample kernel module.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)"
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef
$(eval $(call KernelPackage,$(PKG_NAME)))
I'm trying to follow the instructions here: https://wiki.openwrt.org/doc/devel/packages#creating_packages_for_kernel_modules
Right now, I can see the module in the make menuconfig and select it. However when I run the build in QEMU I don't see the module. I can actually copy the *.ko module over and load it and that works. I just want the module to load automatically. How can I do that?
Upvotes: 4
Views: 4033
Reputation: 1891
In Build/Compile
, you need a line to include your module.
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
CONFIG_<your mod>=m \ # THIS LINE IS MISSING
modules
endef
This are some good examples in the tree. Check out exfat-nofuse.
Upvotes: 4