KernelModules not compiled in..?

Hey,

I've written a couple of KernelModules to support SPI-NAND flash.
They are compiled and everything but don't seem to be available at boot.
My V3s is booted from SPI-NAND, u-boot and SPL works after writing some patches and the SPL itself.
When I manually add CONFIG_MTD_SPI_NAND=y to the devices config, my kernel probes the SPI-NAND, mounts the FS and everything boots just fine. Since I don't like manually tinkering in "mainline-files" I added the SPI-NAND mtd-driver as KernelPackage and selected it via make menuconfig.
Again, the modules are compiled and .ko files are created. However they are not available at boot. By looking at the boot output, the SPI-NAND isn't even probed and my kernel panics about a missing rootfs. Am I missing something in the KernelPackage defines or why are those modules not in my Kernel?

define KernelPackage/mtd-nand
  TITLE:=mtd NAND driver
  SUBMENU:=$(BLOCK_MENU)
  KCONFIG:= \
    CONFIG_MTD_NAND \
    CONFIG_MTD_NAND_IDS \
    CONFIG_MTD_NAND_ECC \
    CONFIG_MTD_TESTS=n
  FILES:=$(LINUX_DIR)/drivers/mtd/nand/raw/nand.ko $(LINUX_DIR)/drivers/mtd/nand/raw/nand_ecc.ko 
  AUTOLOAD:=$(call AutoLoad,20,nand_ecc nand,1)
endef

$(eval $(call KernelPackage,mtd-nand))

define KernelPackage/mtd-nandcore
  TITLE:=Core mtd NAND driver
  SUBMENU:=$(BLOCK_MENU)
  KCONFIG:= \
    CONFIG_MTD_NAND_CORE
  DEPENDS:=+kmod-mtd-nand
  FILES:=$(LINUX_DIR)/drivers/mtd/nand/nandcore.ko
  AUTOLOAD:=$(call AutoLoad,20,nandcore,1)
endef

define KernelPackage/mtd-nandcore/description
  Kernel support for NAND mtd-devices
endef

$(eval $(call KernelPackage,mtd-nandcore))

define KernelPackage/mtd-spinand
  TITLE:=SPI-NAND mtd driver 
  SUBMENU:=$(BLOCK_MENU)
  KCONFIG:= \
    CONFIG_MTD_SPI_NAND \
    CONFIG_MTD_ROOTFS_ROOT_DEV=y \
    CONFIG_SPI=y \
    CONFIG_SPI_MASTER=y
  DEPENDS:=+kmod-mtd-nandcore +kmod-mtd-nand
  FILES:=$(LINUX_DIR)/drivers/mtd/nand/spi/spinand.ko
  AUTOLOAD:=$(call AutoLoad,20,spinand,1)
endef

define KernelPackage/mtd-spinand/description
  Kernel support for SPI-NAND mtd-devices
endef

$(eval $(call KernelPackage,mtd-spinand))

An external module (a .ko file) is not available on boot, as the module has to be read from the rootfs.

2 Likes

That's right. The kernel probably needs the SPI driver before it can even think to mount the root filesystem. Therefore, if you make it a module, you make it effectively unavailable.

The upstream SPI-NAND drivers and all related chip-definition files through 5.3 are already available.

See the ath79/nand target if your specific target is a different one. The driver is platform agnostic.

@jeff I know but they need to be activated, I only need the KernelPackage to set them to =y

But first I set them to =y and also AUTOLOAD:=$(call AutoLoad,20,nandcore,1), i.E. "needed for boot". Doesn't OpenWRT then should compile it in the kernel and not as module (=m)? The whole point (at least the boot flag) would be useless then.

If you set it to =y then it's added to your rootfs and if you set =m it's only build as kmod package and not included in your rootfs.

As @jeff pointed out, you have to add it to the target kernel config, for example into target/linux/ath79/nand/config_4.19, to compile the driver into the kernel image.
This is the only way to have the driver available for mounting your rootfs.

1 Like

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