Adding a new kernel module into the uClinux distribution
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 Config.in 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:
- 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.osubdir-$(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.
- 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 - 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 - A configuration option for the drivers must also be added in Config.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/Config.in:
source drivers/acme/Config.inThe Config.in 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
endmenuThe 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. - Finally, a description of the driver is added by editing the file uClinux-dist/linux-2.4.x/Documentation/Configure.help
CONFIG_ACME
This option enables the ACME driver.
A 'make xconfig; make dep; make' builds the driver as part of the linux kernel.
Comments:
Post a comment: