Arpith Chacko Jacob - since 1982...

  Adding a new kernel module into the uClinux distribution

Saturday 24th 2004f July 2004, 09:16:10 am. Posted in: Embedded. 493 words.  

This article details the steps that need to be followed to add a kernel module to the uClinux build process.

In case a driver is being added to an existing directory, for example a serial driver in uClinux-dist/linux-2.4.x/drivers/char/, the existing Makefile and files need to be modified as detailed in steps 1, 4 and 5.

If however the driver is to be added to a new directory in uClinux-dist/linux-2.4.x/drivers/, all steps below must be followed:

  1. The directory, say acme, is created in uClinux-dist/linux-2.4.x/drivers/ and the file uClinux-dist/linux-2.4.x/drivers/acme/Makefile is created with the following contents:
    export-objs := i2s.o
    obj-$(CONFIG_ACME) += acme.o

    subdir-$(CONFIG_ACME_LCD) += lcd

    acme-objs := i2s.o pinpad.o

    acme.o: $(acme-objs)
            $(LD) -r -o $@ $(acme-objs)

    include $(TOPDIR)/Rules.make

    In the Makefile above, two objects to be linked with the kernel or to be built as modules (as the case may be) are created. acme.o is created in uClinux-dist/linux-2.4.x/drivers/acme/ from i2s.c and pinpad.c. i2s.c contains certain symbols that must be exported to the kernel symbol table (via the EXPORT_SYMBOL macro in the code). Hence it is added in the 'export-objs' variable. The second object file is created in the subdirectory 'lcd'. A corresponding Makefile and source code must exist in that subdirectory.

  2. Next, uClinux-dist/linux-2.4.x/drivers/Makefile is modified to include the new directory in the kernel build process:
    subdir-$(CONFIG_ACME) += acme
  3. The top level Makefile in uClinux-dist/linux-2.4.x/ is also modified to add the following lines:
    DRIVERS-$(CONFIG_ACME) += drivers/acme/acme.o
    DRIVERS-$(CONFIG_ACME_LCD) += drivers/acme/lcd/lcd.o
  4. A configuration option for the drivers must also be added in This can be done in the architecture specific directory, for example uClinux-dist/linux-2.4.x/arch/armnommu/, or in the driver directory. In the latter case the driver configuration must be included from the top level configuration file, by adding the following line in uClinux-dist/linux-2.4.x/arch/armnommu/
    source drivers/acme/

    The file contains options to select the driver during the configuration process, and can be added in an existing or new driver group.

    #                    A C M E
    mainmenu_option next_comment
    comment 'ACME Kernel module'
    tristate 'ACME driver support' CONFIG_ACME
    tristate 'ACME lcd support' CONFIG_ACME_LCD

    The selected configuration after a 'make xconfig' is saved in: uClinux-dist/linux-2.4.x/.config.
    CONFIG_ACME and CONFIG_ACME_LCD should be set to 'y' or 'm' to build the drivers as part of the kernel image or as modules respectively.

  5. Finally, a description of the driver is added by editing the file uClinux-dist/linux-2.4.x/Documentation/
      This option enables the ACME driver.

A 'make xconfig; make dep; make' builds the driver as part of the linux kernel.


No Comments for this post yet...

Post a comment:



Your email address will not be displayed on this site.

Comment text:

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, a, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
URLs, email, AIM and ICQs will be converted automatically.


Remember me (Set cookies for name, email & url)