Finally, it is not easy to build the linux driver development environment on the board. Make a note.
First, build the compiling environment on the PC. Because the compiling Driver runs on the board, the first step is to install the cross compiler, that is, arm-none-linux-gnueabi-gcc or arm-linux-gcc. In fact, it is relatively simple. You can download it from the Internet or on a CD. Click here for a URL.
The first one is correct. After obtaining the compiler package, copy it to/usr/loca/for decompression. The key step is to set the environment variable, even if other programs can find arm gcc, there are several ways to set environment variables:
(1) Open/etc/profile in a text editor
Add
ARM_PATH =/usr/local/arm-2009q1/bin/# (this is the path of your compiler)
PATH = $ ARM_PATH/bin: $ PATH
Export ARM_PATH
Log out and log on again.
(2) modify the. bashrc File
This method is more secure. It can control the permissions to use these environment variables to the user level. If you need to grant a user permission to use these environment variables, you only need to modify. you can use the bashrc file.
The added items are the same as those above.
You also need to log out and log on again to take effect.
(3) I use the third method.
Open/etc/environment and add:/usr/local/arm-2009q1/bin/entries in the last item to separate them, or log off and log on again.
Test it. Enter the arm-and tab key in the terminal. If the key can be supplemented, it will be OK.
After the compiler is installed, the next step should be the library environment of the target machine. Because the final driver is running on the board, we need to have the Linux kernel code of the board to build the library. The Board uses a colleague's TQ2440 to download the kernel source code from the day-embedded Forum, decompress the kernel source code under the/usr/src directory, and enter the code directory. Here, you need to run three commands:
Make oldconfig;
Make prepare
At this time, an error may be prompted, and arm-linux-gcc cannot be found. If arm-none-linux-gnueabi-gcc is installed, You need to modify the Makefile in the kernel source code directory.
CROSS_COMPILE = arm-linux-changed
CROSS_COMPILE = arm-none-linux-gnueabi.
Make scripts/
In this way, the compiling environment has been set up. Next, we will test and use the hello program in linux driver to modify Makefile.
Ifneq ($ (KERNELRELEASE ),)
# Call from kernel build system
Obj-m: = hello. o
Else
KERNELDIR? =/Usr/src/linux-2.6.30.4/
# KERNELDIR? =/Lib/modules/$ (shell uname-r)/build
PWD: = $ (shell pwd)
Default:
$ (MAKE)-C $ (KERNELDIR) M = $ (PWD) modules
Endif
Clean:
Rm-rf *. o *~ Core. depend. *. cmd *. ko *. mod. c. tmp_versions
The red color is the path for compiling the local driver to be redeployed. Now it is changed to the kernel source code path on the board.
# Make
Get hello. ko