The driver can be compiled together with the kernel or separately as a module. However, to facilitate driver debugging, the driver is usually compiled in a modular manner.
1. Compile the driver in modular Mode
The Linux kernel is 2.6.12 and the fl2440 driver is used as an example. Source File: Driver s3c2440_leds.c, test program led. C. Now, you only need to write a makefile segment to compile the LED driver. Content:
obj-m :=s3c2440_leds.oKERNELDIR ?= /root/linux-2440/linux-2.6.12PWD := $(shell pwd)default:$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
Then run the make command. The generated s3c2440_leds.ko is the driver module File we need. Then, generate the LED. C, and upload the led of the s3c2440_leds.ko program and the test program to the board. After changing the permission, run the following command:
#insmod s3c2440_leds.ko#./led
2. Compile with the kernel
Take the fl2440 and LED Drivers as examples. The Development Board of the Linux source package in the/root/linux-2440/linux-2.6.12 directory, the s3c2440_leds.c copy to the source package dirvers/Char directory, and modify the makefile under the drivers/Char directory, add the following content 1 in the corresponding location, and add content 2 in the corresponding location of the kconfig file:
1.obj-$(CONFIG_S3C2440_LEDS) += s3c2440_leds.o2.config S3C2440_LEDS tristate "S3C2440 LEDS Drivers" depends on ARCH_S3C2440 help SBC2440 User keys
Then, when you execute make menuconfig in the source package directory for Option Selection, The S3C2440 LEDs option appears under character drivers under the device driver option. After selecting the corresponding module, after the compilation is successful, download it to the Development Board and run the LED test program directly.