OpenWrt Forum Archive

Topic: Add kernel module package (ata/ahci sata driver)

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I've added the following to ./package/kernel/modules/block.mk

define KernelPackage/ahci
    TITLE:=AHCI SATA support
    DESCRIPTION:=Kernel module for AHCI Serial ATA
    KCONFIG:=$(CONFIG_SATA_AHCI)
    SUBMENU:=$(BLMENU)
    AUTOLOAD:=$(call AutoLoad,30,scsi_mod libata sd_mod ahci)
    FILES:=$(MODULES_DIR)/kernel/drivers/ata/ahci.$(LINUX_KMOD_SUFFIX)
    DEPENDS:=+kmod-libata +kmod-ide-core +kmod-scsi-core
endef
$(eval $(call KernelPackage,ahci))

after looking through ./build_i386/linux/drivers/ata/Kconfig and ./build_i386/linux/drivers/ata/Makefile

But this doesnt seem to do the trick. It merely breaks things as such when running make menuconfig:

Collecting target info: merging...
Collecting target info: done
Collecting package info: package/kernelmodules/block.mk:23: *** missing `endef', unterminated `define'.  Stop.
ERROR: please fix package/kernel/Makefile

Collecting package info: merging...
Collecting package info: donetmp/.config-target.in:322:warning: 'select' used by config symbol 'LINUX_2_6_ADM5120_Atheros' refer to undefined symbol 'DEFAULT_kmod-ipt-nathelper'
tmp/.config-target.in:342:warning: 'select' used by config symbol 'LINUX_2_6_ADM5120_Texas' refer to undefined symbol 'DEFAULT_kmod-ipt-nathelper'
tmp/.config-target.in:361:warning: 'select' used by config symbol 'LINUX_2_6_ADM5120_None' refer to undefined symbol 'DEFAULT_kmod-ipt-nathelper'
<SNIP>
.config:1322:warning: trying to assign nonexistent symbol PACKAGE_kmod-net-prism54
.config:1323:warning: trying to assign nonexistent symbol PACKAGE_kmod-net-zd1211rw


Your configuration changes were NOT saved.

So I figure there is more to it; searching for ata_piix files I find several files under ./build_i386/linux-2.6-x86/packages/
and creates a kmod-ahci, using any files referencing ata_piix as a skelekton. But after finding ata_piix.ko in ./build_i386/linux-2.6-x86/packages/ipkg/kmod-ata-piix/lib/modules/2.6.19.2/ I kind of realised this was generated by the build process...

So, I'm basically wondering which files I need to be looking at. I've mostly been a FreeBSD guy and I'm more or less new to linux and buildroot, so please just point me in the right direction!

I've built the module (and the md/raid stuff) using make kernel_menuconfig and then make, mounted the image and copied them across and it works, but it would be nice to add it, in a, neater, way if you like - and to contribute the changes back ofcourse.

regards,
Bjørn

DOH!

After going over this for the millionth time now, I see I've managed to insert a tab in front of every line I added to ./package/kernel/modules/block.mk .. and strangely enough removing it helps. At least it builds, leaving testing for tomorrow..

(I'll be in the corner of shame if anyone needs me..)

But on a side note, dependencies for kernel modules. The Kconfig file only lists "depends on PCI" for the ata_piix driver, while block.mk lists "DEPENDS:=+kmod-libata +kmod-ide-core +kmod-scsi-core". While the latter more or less makes sense in one way, I dont quite understand it. Is it related to the way kernel modules are grouped in OpenWrt?

Bjorn

And here is the patch, created using 'svn diff' if you like create a ticket.

Index: target/linux/x86-2.6/config/default
===================================================================
--- target/linux/x86-2.6/config/default (revision 6933)
+++ target/linux/x86-2.6/config/default (working copy)
@@ -347,7 +347,7 @@
 # CONFIG_REGPARM is not set
 CONFIG_RTC=y
 CONFIG_RWSEM_XCHGADD_ALGORITHM=y
-# CONFIG_SATA_AHCI is not set
+CONFIG_SATA_AHCI=m
 CONFIG_SATA_INTEL_COMBINED=y
 # CONFIG_SATA_MV is not set
 # CONFIG_SATA_NV is not set
Index: package/kernel/modules/block.mk
===================================================================
--- package/kernel/modules/block.mk     (revision 6933)
+++ package/kernel/modules/block.mk     (working copy)
@@ -19,3 +19,14 @@
        DEPENDS:=+kmod-libata +kmod-ide-core +kmod-scsi-core
 endef
 $(eval $(call KernelPackage,ata-piix))
+
+define KernelPackage/ahci
+       TITLE:=AHCI SATA support
+       DESCRIPTION:=Kernel module for AHCI Serial ATA
+       KCONFIG:=$(CONFIG_SATA_AHCI)
+       SUBMENU:=$(BLMENU)
+       AUTOLOAD:=$(call AutoLoad,30,scsi_mod libata sd_mod ahci)
+       FILES:=$(MODULES_DIR)/kernel/drivers/ata/ahci.$(LINUX_KMOD_SUFFIX)
+       DEPENDS:=+kmod-libata +kmod-ide-core +kmod-scsi-core
+endef
+$(eval $(call KernelPackage,ahci))

I'll submit a patch for the remaining SATA drives in a couple of days, but I'm still not sure where to find the dependency information?

I guess its the #include statements in each .c file - but how do I get from

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <scsi/scsi_host.h>
#include <linux/libata.h>

to

    AUTOLOAD:=$(call AutoLoad,30,scsi_mod libata sd_mod ata_piix)
    DEPENDS:=+kmod-libata +kmod-ide-core +kmod-scsi-core

.. I'm willing to bet there isnt a dummys guide to linux kernel dependencies, but if anyone has a list of suggested literature I'd appreciate it!

(Last edited by beikeland on 12 Apr 2007, 15:16)

The discussion might have continued from here.