3 ways to compile the driver into the kernel (using mini2440 key as an example)

Publisher:LianaiLatest update time:2024-06-20 Source: elecfansKeywords:Driver Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.


Keywords:Driver Reference address:3 ways to compile the driver into the kernel (using mini2440 key as an example)

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

Using UC3842 to realize low frequency electromagnetic drive
This is the SCH library component of UC3842 that I drew while learning. There are two packages, 8-pin and 14-pin. It can be seen clearly when designing the schematic diagram to avoid mistakes. I hope it can give some help and inspiration to the new juniors. I have marked my own understanding and precautio
[Power Management]
Using UC3842 to realize low frequency electromagnetic drive
A DC motor H-bridge drive circuit solution based on high power
This circuit uses NMOS field effect tube as power output device, designs and implements high-power DC motor H-bridge drive circuit, and performs closed-loop control on 25D60-24A DC motor with rated voltage of 24V and rated current of 3.8A. The circuit has strong anti-interference ability and strong applicability in th
[Power Management]
A DC motor H-bridge drive circuit solution based on high power
Driving Multiple LED Strings with a Single Current Loop
Central topic: * Automatically detect open LED strings and adjust accordingly Solution: * Add a sense resistor at the bottom of each LED string and use only one control loop * Automatically turn off the PNP and NPN transistors for the open LED string, removing the feedback voltage of this string from
[Power Management]
Driving Multiple LED Strings with a Single Current Loop
Linux-2.6.32.2 kernel transplantation on mini2440 (XVII) --- transplantation of PWM control buzzer
Migration environment 1. Host environment: CentOS 5.5 under VMare, 1G memory. 2. Integrated development environment: Eclipse IDE 3. Compilation environment: arm-linux-gcc v4.4.3, arm-none-linux-gnueabi-gcc v4.5.1. 4. Development board: mini2440, 2M nor flash, 128M nand flash. 5.u-boot version: u-boot-2009.08 6. Linux
[Microcontroller]
Linux-2.6.32.2 kernel transplantation on mini2440 (XVII) --- transplantation of PWM control buzzer
Current status and trend of LED driver ICs Thermal management cannot be ignored
In the past, light-emitting diodes ( LEDs ) were used only as indicator lights. Power consumption was low, current was even lower, and heat generation was not a problem. However, times have changed. LED currents have increased from a few milliamps to amps; in some cases, LED power has jumped from a f
[Power Management]
Digi-Key Announces Global Partnership with QuickLogic through Marketplace Platform
Digi-Key Electronics Announces Global Partnership with QuickLogic Corporation through the Digi-Key Marketplace Digi-Key Electronics, the global distributor of the broadest and fastest-stock electronic components, today announced a global partnership with QuickLogic® Corporation to distribute QuickLogic’s low-powe
[Internet of Things]
Digi-Key Announces Global Partnership with QuickLogic through Marketplace Platform
LED driver design without electrolytic capacitor
Many countries are actively developing LED lighting technology. In order for high-brightness LEDs to achieve long life and minimize light decay, temperature control is the key. Therefore, compared with other light sources, LED lamps require a relatively large heat sink. In order to achieve ideal heat dissipati
[Power Management]
LED driver design without electrolytic capacitor
Android JNI用于驱动測试
Hardware platform: S3C6410 Operating system: Ubuntu, Windows Board system: Android Development tools: jdk, ndk, eclipse 本次測试从linux内核模块编译開始。以S3C6410的pwm驱动为例。 pwm_6410.c: #include linux/module.h #include linux/kernel.h #include linux/fs.h
[Microcontroller]
Android JNI用于驱动測试
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号