Build an embedded Linux Device Driver Programming Environment

Source: Internet
Author: User

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

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.