[OpenWrt-Devel] Kernel module development workflow

Rafał Miłecki zajec5 at gmail.com
Wed Jul 9 11:23:42 EDT 2014


On 8 July 2014 21:24, Tomas Daujotas <socconf at gmail.com> wrote:
> I was looking for a good reference for OpenWRT kernel module development
> workflow.

See attached file with commands. This allow you writing some external
module as an OpenWrt package.

helloworld/Makefile will have probably white spaces broken, you may
fix them by hand
-------------- next part --------------
cd package/kernel
mkdir -p helloworld/src

echo "obj-m += helloworld.o" > helloworld/src/Makefile

touch helloworld/src/helloworld.c

cat << 'EOF' > helloworld/Makefile
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=helloworld
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define KernelPackage/helloworld
  SECTION:=kernel
  CATEGORY:=Kernel modules
  TITLE:=Hello world kernel module
  FILES:= \
	$(PKG_BUILD_DIR)/helloworld.ko
  AUTOLOAD:=$(call AutoLoad,30,helloworld)
endef

define Build/Prepare
	# Copy sources
	mkdir -p $(PKG_BUILD_DIR)
	cp -R ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
	$(MAKE) -C "$(LINUX_DIR)" \
		CROSS_COMPILE="$(TARGET_CROSS)" \
		ARCH="$(LINUX_KARCH)" \
		SUBDIRS="$(PKG_BUILD_DIR)" \
		modules
endef

$(eval $(call KernelPackage,helloworld))
EOF
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list