|
楼主 |
发表于 2010-6-19 20:11:11
|
显示全部楼层
如何使用这个交叉编译环境
本帖最后由 情灭缘尽 于 2010-6-23 15:11 编辑
Using Buildroot
Buildroot has a nice configuration tool similar to the one you can find in the Linux kernel (http://www.kernel.org/) or in Busybox (http://www.busybox.org/). Note that you can (and should) build everything as a normal user. There is no need to be root to configure and use Buildroot. The first step is to run the configuration assistant:
$ make menuconfig
to run the curses-based configurator, or
$ make xconfig
to run the Qt3-based configurator.
Both of these "make" commands will need to build a configuration utility, so you may need to install "development" packages for relevent libraries used by the configuration utilities. On Debian-like systems, the libncurses5-dev package is required to use the menuconfig interface, and the libqt3-mt-dev is required to use the xconfig interface.
For each menu entry in the configuration tool, you can find associated help that describes the purpose of the entry.
Once everything is configured, the configuration tool generates a .config file that contains the description of your configuration. It will be used by the Makefiles to do what's needed.
Let's go:
$ make
This command will generally perform the following steps:
Download source files (as required)
Configure cross-compile toolchain
Build/install cross-compile toolchain
Build/install selected target packages
Build a kernel image
Create a root filesystem in selected formats
Some of the above steps might not be performed if they are not selected in the Buildroot configuration.
Buildroot output is stored in a single directory, output/. This directory contains several subdirectories:
images/ where all the images (kernel image, bootloader and root filesystem images) are stored.
build/ where all the components except for the cross-compilation toolchain are built (this includes tools needed to run Buildroot on the host and packages compiled for the target). The build/ directory contains one subdirectory for each of these components.
staging/ which contains a hierarchy similar to a root filesystem hierarchy. This directory contains the installation of the cross-compilation toolchain and all the userspace packages selected for the target. However, this directory is not intended to be the root filesystem for the target: it contains a lot of development files, unstripped binaries and libraries that make it far too big for an embedded system. These development files are used to compile libraries and applications for the target that depend on other libraries.
target/ which contains almost the root filesystem for the target: everything needed is present except the device files in /dev/ (Buildroot can't create them because Buildroot doesn't run as root and does not want to run as root). Therefore, this directory should not be used on your target. Instead, you should use one of the images built in the images/ directory. If you need an extracted image of the root filesystem for booting over NFS, then use the tarball image generated in images/ and extract it as root.
Compared to staging/, target/ contains only the files and libraries needed to run the selected target applications: the development files (headers, etc.) are not present.
host/ contains the installation of tools compiled for the host that are needed for the proper execution of Buildroot except for the cross-compilation toolchain which is installed under staging/.
toolchain/ contains the build directories for the various components of the cross-compilation toolchain.
Offline builds
If you intend to do an offline build and just want to download all sources that you previously selected in the configurator (menuconfig or xconfig), then issue:
$ make source
You can now disconnect or copy the content of your dl directory to the build-host.
Building out-of-tree
Buildroot supports building out of tree with a syntax similar to the Linux kernel. To use it, add O=<directory> to the make command line:
$ make O=/tmp/build
All the output files will be located under /tmp/build.
Environment variables
Buildroot also honors some environment variables when they are passed to make:
HOSTCXX, the host C++ compiler to use
HOSTCC, the host C compiler to use
UCLIBC_CONFIG_FILE=<path/to/.config>, path to the uClibc configuration file to use to compile uClibc if an internal toolchain is being built
BUSYBOX_CONFIG_FILE=<path/to/.config>, path to the Busybox configuration file
LINUX26_KCONFIG=<path/to/.config>, path to the Linux kernel configuration file
BUILDROOT_COPYTO, an additional location to which the binary images of the root filesystem, kernel, etc. built by Buildroot are copied
BUILDROOT_DL_DIR to override the directory in which Buildroot stores/retrieves downloaded files
An example that uses config files located in the toplevel directory and in your $HOME:
$ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
If you want to use a compiler other than the default gcc or g++ for building helper-binaries on your host, then do
$ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
If you want the result of your build to be copied to another directory like /tftpboot for downloading to a board using tftp, then you can use BUILDROOT_COPYTO to specify your location
Typically, this is set in your ~/.bashrc file
$ export BUILDROOT_COPYTO=/tftpboot |
|