3 ways to compile the driver into the kernel-----(Take mini2440 key as an example)
Method 1: Compile and add to the kernel as a module (the simplest method)
Note: key.c (key_hui.c) is the driver code, Makefile is the compilation rule, key.ko is the driver. key_irq is the test code.
(1). In the source program directory, make arch=arm, and the key.ko file will be generated.
(2) After the system boots and enters the console, insmod key.ko
(3) View the device number cat /proc/devices
(4) Create a node: mknod /dev/globalmem c 235 0 (some kernels support automatic node creation while others do not)
Or: in the startup script of the file system, for example, add a line at the end of etc/profile: source /testshell, and then add the following loading command in the testshell in the root directory, the driver will be automatically loaded after the system starts, such as:
#!/bin/sh
ehco "i am testshell"
insmod /minitest/key.ko ----Mount the driver
mknod /dev/key_driver c 253 0 -----Create node
exec /minitest/key_irq -----Execute the application
(5) Uninstall the device: rmmod key.ko
Method 2: Compile directly into the kernel
(1) Rename the key.c source code to key_hui.c and put it in the linux-2.6.32/drivers/char directory
(2) Add the key compilation configuration option to the vim Kconfig file in the current directory, as shown below:
config KEYS_MINI2440
tristate "KEY Support for Mini2440 GPIO KEYS--add by youshaohui**"
depends on MACH_MINI2440
default y if MACH_MINI2440
help
This option enables support for key connected to GPIO lines on Mini2440 boards.
(3) Add the compilation of the key.c source code to the Makefile in the directory, vim Makefile, as shown below:
(obj-$(CONFIG_KEYS_MINI2440) += key_hui.o)
(4) Enter make menuconfig/device Drivers/Character devises/ and the menu will
See option [] S2C2410 KEY Driver ---SU, select it.
Open the key_hui.c file, remove the "__init" of the loading function name, and remove the "__exit" of the unloading function name, otherwise the compilation will fail.
Recompile and burn the kernel, burning method.
{
make zImage
Enter the cd /mini2440/linux-2.6.32.2/arch/arm/boot directory and use the u-boot/tools/mkimage tool to add the file headers required for u-boot booting to the kernel:
/mini2440/u-boot-201003/tools/mkimage -n 'linux-2.6.32' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage uImage.img
//The generated image is in: /mini2440/linux-2.6.32.2/arch/arm/boot
tftp 0x30008000 uImage.img
After downloading, you can burn it into flash
nand erase 0x80000 300000
nand write 0x30008000 0x80000 300000
set bootcmd 'nand read 0x30008000 0x80000 300000;bootm 0x30008000'
saveenv
reset
}
Method 3: Compile the kernel as a module in the kernel
(1) The first few steps are the same as those in method 2, except that (4) changes the option to [M].
(2) Make zImage to generate the kernel. At this time, the kernel does not contain the key driver.
(3) After compiling the kernel, you also need to compile the kernel module #make modules. key_hui.ko will be generated under linux-2.6.32/drivers/char
(4) Install kernel modules:
make modules_install INSTALL_MOD_PATH=/root/build_rootfs/rootfs. At this time, the /root/build_rootfs/rootfs/lib/modules/2.6.32.2-FriendlyARM directory will be created in the file system, and the compiled kernel module will be moved from the kernel source directory to the /lib/modules/2.6.32.2-FriendlyARM/kernel of the specified file system.
(5) Burn the kernel and file system (or use NFS to connect to the development version).
(6) Enter the development board/lib/modules/2.6.32.2-FriendlyARM/kernel/drivers/char. At this time, key_su.ko is in this directory. Then insmod key_su.ko and run the corresponding application.
Previous article:mini2440 ADC adjustable resistor driver development source code (miscellaneous device driver framework)
Next article:Analysis of UDA1341 audio driver architecture based on mini2440
Recommended ReadingLatest update time:2024-11-23 02:49
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- EEWORLD University - What is an antenna vibrator?
- Selling new and second-hand Xilinx development boards, both high-end and low-end
- [RISC-V MCU CH32V103 Review] First Look at CH32V103
- May was quite busy, and my hand broke.
- Important parameters of Rfid technology
- Pre-registration for the prize-winning live broadcast | Infineon system solutions make electric motorcycle design more reliable and efficient!
- Embedded systems and real-time software development
- What methods do you generally use to recruit or find jobs? Which platform is used more often?
- Summary of the points to note when using CCS8.0 to program MSP430G2553
- picture