Make kernel_menuconfig and modules

As far as I understand I can use make kernel_menuconfig to include kernel features in the build that are not selectable with make menuconfig. However, I am not fully clear on how kernel modules are then included in the build image. Are kernel modules, that do not have an OpenWRT ipk automatically included in the image. Do I need to laod the .ko files seperately? Or should I just include everything that I want with y fixed in the kernel? What is the right approach?

1 Like

You build them in statically, if you want to retain them as a module, you'll have to package them up.

Thank you, that's what I thought. Just out of curiosity, is there any howto/manual on how to package them up so that I can use modules?

Basically take a look at package/kernel/linux/modules/.... In essence, you'll need to declare a define KernelPackage/foo with the following variables:

  • KCONFIG:=... - list of CONFIG_whatever symbols to enable. Can be either in the form CONFIG_FOO (y/m value inherited from choice state of kmod-foo in menuconfig), CONFIG_FOO=y (Always enable builtin), CONFIG_FOO=m (Always enable as .ko), CONFIG_FOO=n (Forcibly disable symbol)
  • FILES:=... - list of *.ko files to package
  • AUTOLOAD:=... - module loading specification, either $(call AutoLoad,prio,names) (discouraged) or $(call AutoProbe,names) (preferred)

Example:

define KernelPackage/foo
  TITLE:=FOO support module
  DEPENDS:=kmod-lib-zlib-inflate
  KCONFIG:= \
    CONFIG_FOO \
    CONFIG_FOO_OVER_TCP \
    CONFIG_FOO_DEBUGFS=n \
    CONFIG_FOO_EXTRA_DEVICES=y
  FILES:= \
    $(LINUX_DIR)/drivers/misc/foo.ko \
    $(LINUX_DIR)/drivers/misc/foo_tcp.ko
  AUTOLOAD:=$(call AutoProbe,foo foo_tcp)
endef

define KernelPackage/foo/description
 Kernel module for FOO over TCP support
endef

$(eval $(call KernelPackage,foo))
4 Likes