Embedded Linux Development Kit------ELDK说明

 

 

 

1. Embedded Linux Development Kit

The Embedded Linux Development Kit (ELDK) includes the GNU cross development tools, such as the compilers, binutils, gdb, etc., and a number of pre-built target tools and libraries necessary to provide some functionality on the target system.

It is provided for free with full source code, including all patches, extensions, programs and scripts used to build the tools.

Starting from version 4.1, the ELDK is available in two versions, which use Glibc resp. uClibc as the main C library for the target packages.

Packaging and installation is based on the RPM package manager.

1.1. ELDK Availability

The ELDK is available

1.2. Supported Host Systems

The ELDK can be installed onto and operate with the following operating systems:

 

Users also reported successful installation and use of the ELDK on the following host systems:

 

Note: It may be necessary, and is usually recommended, to install the latest available software updates on your host system. For example, on Fedora Core systems, you can use one of yum, apt-get or up2date to keep your systems current.

1.3. Supported Target Architectures

The ELDK for ARM systems supports processors complying with the ARM architecture version 2 to 5. This includes ARM7, ARM9, XScale, AT91RM9200 and other ARM based systems.

There is also an ELDK for PowerPC and MIPS systems.

1.4. Installation

1.4.1. Product Packaging

Stable versions of the ELDK are distributed in the form of an ISO image, which can be either burned onto a CD or mounted directly, using the loopback Linux device driver (Linux host only).

 

Development versions of the ELDK are available as directory trees so it is easy to update individual packages; instructions for download of these trees and creation of ISO images from it is described in section 1.4.2. Downloading the ELDK.

The ELDK contains an installation utility and a number of RPM packages, which are installed onto the hard disk of the cross development host by the installation procedure. The RPM packages can be logically divided into two parts:

 

  • Embedded Linux Development Tools (ELDT)
  • Target components

The first part contains the cross development tools that are executed on the host system. Most notably, these are the GNU cross compiler, binutils, and gdb. For a full list of the provided ELDT packages, refer to section 1.8.1. List of ELDT Packages below.

The target components are pre-built tools and libraries which are executed on the target system. The ELDK includes necessary target components to provide a minimal working NFS-based environment for the target system. For a list of the target packages included in the ELDK, refer to section 1.8.2. List of Target Packages below.

The ELDK contains several independent sets of the target packages, one for each supported target architecture CPU family. Each set has been built using compiler code generation and optimization options specific to the respective target CPU family.

1.4.2. Downloading the ELDK

You can either download the ready-to-burn ISO-images from one of the mirror sites (see 1.1. ELDK Availability), or you can download the individual files of the ELDK from the development directory tree and either use these directly for installation or create an ISO image that can be burned on CD-ROM.

Change to a directory with sufficient free disk space; for the ARM version of the ELDK you need about 250 MiB, or twice as much (500 MiB) if you also want to create an ISO image in this directory.

To download the ISO image from the arm-linux-x86/iso directory of one of the mirror sites you can use standard tools like wget or ncftpget, for example:

bash$ wget ftp://ftp.sunet.se/pub/Linux/distributions/eldk/4.1/arm-linux-x86/iso/arm-2007-01-21.iso

If you want to download the whole ELDK directory tree instead you can - for example - use the ncftp FTP client:

bash$ ncftp ftp.sunet.se
...
ncftp / > cd /pub/Linux/distributions/eldk/4.1
ncftp /pub/Linux/distributions/eldk/4.1 > bin
ncftp /pub/Linux/distributions/eldk/4.1 > get -R arm-linux-x86/distribution
...
ncftp /pub/Linux/distributions/eldk/4.1 > bye

Depending on your combination of host and target architecture, you should download one of the following directories:

 

  • arm-linux-x86/iso    resp.
    arm-linux-x86/distribution for ARM targets and x86 Linux hosts.
  • mips-linux-x86/iso    resp.
    mips-linux-x86/distribution for MIPS targets and x86 Linux hosts, or
  • ppc-linux-x86/iso    resp.
    ppc-linux-x86/distribution for PowerPC targets and x86 Linux hosts,

Note: If you don't find the ncftp tool on your system you can download the NcFTP client from http://www.ncftp.com/download/

There are a few executable files (binaries and scripts) in the ELDK tree. Make sure they have the execute permissions set in your local copy:

 

bash$ for file in /
>       tools/bin/rpm /
>       tools/usr/lib/rpm/rpmd /
>       install /
>       ELDK_MAKEDEV /
>       ELDK_FIXOWNER
> do
> chmod +x arm-linux-x86/distribution/$file
> done

Now create an ISO image from the directory tree:

 

bash$ mkisofs /
> -A "ELDK-4.1 -- Target: ARM -- Host: x86 Linux" /
> -publisher "(C) `date "+%Y"` DENX Software Engineering,   www.denx.de" /
> -p "`id -nu`@`hostname` -- `date`" /
> -V arm-linux-x86 /
> -l -J -R -o eldk-arm-linux-x86.iso arm-linux-x86/distribution

This will create an ISO image eldk-arm-linux-x86.iso in your local directory that can be burned on CD or mounted using the loopback device and used for installation as described above. Of course you can use the local copy of the directory tree directly for the installation, too.

Please refer to section 1.9.2. Setting Up ELDK Build Environment for instructions on obtaining the build environment needed to re-build the ELDK from scratch.

1.4.3. Initial Installation

The initial installation is performed using the install utility located in the root of the ELDK ISO image directory tree. The install utility has the following syntax:

 

$ ./install [-d <dir>] [<cpu_family1>] [<cpu_family2>] ...

-d <dir>Specifies the root directory of the ELDK being installed. If omitted, the ELDK goes into the current directory.
<cpu_family>Specifies the target CPU family the user desires to install. If one or more <cpu_family> parameters are specified, only the target components specific to the respective CPU families are installed onto the host. If omitted, the target components for all supported target architecture CPU families are installed.

Note: Make sure that the "exec" option to the mount command is in effect when mounting the ELDK ISO image. Otherwise the install program cannot be executed. On some distributions, it may be necessary to modify the /etc/fstab file, adding the "exec" mount option to the cdrom entry - it may also be the case that other existing mount options, such as "user" prevent a particular configuration from mounting the ELDK CD with appropriate "exec" permission. In such cases, consult your distribution documentation or mount the CD explicitly using a command such as "sudo mount -o exec /dev/cdrom /mnt/cdrom" (sudo allows regular users to run certain privileged commands but may not be configured - run the previous command as root without "sudo" in the case that "sudo" has not been setup for use on your particular GNU/Linux system).

You can install the ELDK to any empty directory you wish, the only requirement being that you have to have write and execute permissions on the directory. The installation process does not require superuser privileges.

Depending on the parameters the install utility is invoked with, it installs one or more sets of target components. The ELDT packages are installed in any case.

Refer to section 1.5. Working with ELDK for a sample usage of the ELDK.

Note: If you intend to use the installation as a root filesystem exported over NFS, then you now have to finish the configuration of the ELDK following the instructions in 1.6. Mounting Target Components via NFS.

Note: Installation of the Glibc- and uClibc-based ELDK versions into one directory is not yet supported.

1.4.4. Installation and Removal of Individual Packages

The ELDK has an RPM-based structure. This means that on the ISO image, individual components of the ELDK are in the form of RPM packages, and after installation, the ELDK maintains its own database which contains information about installed packages. The RPM database is kept local to the specific ELDK installation, which allows you to have multiple independent ELDK installations on your host system. (That is, you can install several instances of ELDK under different directories and work with them independently). Also, this provides for easy installation and management of individual ELDK packages.

To list the installed ELDK RPM packages, use the following command:

 

bash$ ${CROSS_COMPILE}rpm -qa

To remove an ELDK package, use the following command:

 

bash$ ${CROSS_COMPILE}rpm -e <package_name>

To install a package, use the following command:

 

bash$ ${CROSS_COMPILE}rpm -i <package_file_name>

To update a package, use the following command:

 

bash$ ${CROSS_COMPILE}rpm -U <package_file_name>

For the above commands to work correctly, it is crucial that the correct rpm binary gets invoked. In case of multiple ELDK installations and RedHat-based host system, there may well be several rpm tools installed on the host system.

You must make sure, either by using an explicit path or by having set an appropriate PATH environment variable, that when you invoke rpm to install/remove components of a ELDK installation, it is the ELDK's rpm utility that gets actually invoked. The rpm utility is located in the bin subdirectory relative to the ELDK root installation directory.

To avoid confusion with the host OS (RedHat) rpm utility, the ELDK creates symlinks to its rpm binary with the names such that it could be invoked using the ${CROSS_COMPILE}rpm notation, for all supported $CROSS_COMPILE values.

Note: The standard (host OS) rpm utility allows various macros and configuration parameters to specified in user-specific ~/.rpmrc and ~/.rpmmacros files. The ELDK rpm tool also has this capability, but the names of the user-specific configuration files are ~/.eldk_rpmrc and ~/.eldk_rpmmacros, respectively.

1.4.5. Removal of the Entire Installation

To remove the entire ELDK installation, use the following command while in the ELDK root directory:

 

bash$ rm -rf <dir>

where <dir> specifies the root directory of the ELDK to be removed.

1.5. Working with ELDK

After the initial installation is complete, all you have to do to start working with the ELDK is to set and export the CROSS_COMPILE environment variable. Optionally, you may wish to add the bin and usr/bin directories of your ELDK installation to the value of your PATH environment variable. For instance, a sample ELDK installation and usage scenario looks as follows:

 

  • Create a new directory where the ELDK is to be installed, say:
    bash$ mkdir /opt/eldk
    
  • Mount a CD or an ISO image with the distribution:
    bash$ mount /dev/cdrom /mnt/cdrom
    
  • Run the installation utility included on the distribution to install into that specified directory:
    bash$ /mnt/cdrom/install -d /opt/eldk
    
  • After the installation utility completes, export the CROSS_COMPILE variable:
    bash$ export CROSS_COMPILE=arm-linux-
    
    Note: The trailing '-' character in the CROSS_COMPILE variable value is optional and has no effect on the cross tools behavior.

 

  • Add the directories /opt/eldk/usr/bin and /opt/eldk/bin to PATH:
    bash$ PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin
    
  • Compile a file:
    bash$ ${CROSS_COMPILE}gcc -o hello_world hello_world.c
    
    Note: You can also call the cross tools using the generic prefix arm-linux- for example:
    bash$ arm-linux-gcc -o hello_world hello_world.c
    

 

 

  • or, equivalently:
    bash /opt/eldk/usr/arm-linux/bin/gcc -o hello_world hello_world.c                                                                               
    

 

The value of the CROSS_COMPILE variable must correspond to the target CPU family you want the cross tools to work for. Refer to the table below for the supported CROSS_COMPILE variable values:

1.5.A Table of possible values for $CROSS_COMPILE

CROSS_COMPILE ValuePredefined Compiler FlagFPU present or not
arm-linux--mcpu=arm9No

 

 

 

1.5.1. Switching Between Multiple Installations

No special actions are required from the user to switch between multiple ELDK installations on the same host system. Which ELDK installation is used is determined entirely by the filesystem location of the binary that is being invoked. This approach can be illustrated using the following example.

 

Assume the directory /work/denx_tools/usr/bin, where the arm-linux-gcc compiler binary has been installed, is a part of the PATH environment variable. The user types the command as follows:

 

$ arm-linux-gcc -c myfile.c

 

To load the correct include files, find the correct libraries, spec files, etc., the compiler needs to know the ELDK root directory. The compiler determines this information by analyzing the shell command it was invoked with ( arm-linux-gcc - without specifying the explicit path in this example) and, if needed, the value of the PATH environment variable. Thus, the compiler knows that it has been executed from the /work/denx_tools/usr/bin directory.

Then, it knows that the compiler is installed in the usr/bin subdirectory of the root installation directory, so the ELDK, the compiler is a part of, has been installed in the subdirectories of the /work/denx_tools directory. This means that the target include files are in /work/denx_tools/<target_cpu_variant>/usr/include, and so on.

1.6. Mounting Target Components via NFS

The target components of the ELDK can be mounted via NFS as the root file system for your target machine. For instance, for an AT91-based target, and assuming the ELDK has been installed into the /opt/eldk directory, you can use the following directory as the NFS-based root file system:

 

/opt/eldk/arm

 

Note: Before the NFS-mounted root file system can work, you must create necessary device nodes in the <ELDK_root>/<target_cpu_variant>/dev directory. This process requires superuser privileges and thus cannot be done by the installation procedure (which typically runs as non-root). To facilitate creation of the device nodes, the ELDK provides a script named ELDK_MAKEDEV, which is located in the root of the ELDK distribution ISO image. The script acccepts the following optional arguments:

-d <dir>Specifies the root directory of the ELDK being installed. If omitted, then the current directory is assumed.
-a <cpu_family>Specifies the target CPU family directory. If omitted, all installed target architecture directories will be populated with the device nodes.
-hPrints usage.
NOTE: Compared to older versions of the ELDK, options and behaviour of this command have been changed significantly. Please read the documentation.

Note: Some of the target utilities included in the ELDK, such as mount and su, have the SUID bit set. This means that when run, they will have privileges of the file owner of these utilities. That is, normally, they will have the privileges of the user who installed the ELDK on the host system. However, for these utilities to work properly, they must have superuser privileges. This means that if the ELDK was not installed by the superuser, the file owner of the target ELDK utilities that have the SUID bit set must be changed to root before a target component may be mounted as the root file system. The ELDK distribution image contains an ELDK_FIXOWNER script, which you can use to change file owners of all the appropriate files of the ELDK installation to root. The script accepts the same arguments as the ELDK_MAKEDEV script above. Please note that you must have superuser privileges to run this script. For instance, if you have installed the ELDK in the /opt/eldk directory, you can use the following commands:

 

 

 

# cd /opt/eldk
# /mnt/cdrom/ELDK_FIXOWNER

Please note, that in the case that the installation directory, where the new ELDK distribution is being installed, is already populated with other ELDK distributions, the execution of the ELDK_FIXOWNER script without arguments will make the script work with all installed ELDK target architecture directories. This could take some time. To save the time, please use the -a argument to specify the appropriate target architecture. For instance:

# cd /opt/eldk
# /mnt/cdrom/ELDK_FIXOWNER -a arm

1.7. Rebuilding ELDK Components

 

1.7.1. ELDK Source Distribution

The ELDK is distributed with the full sources of all the components, so you may rebuild any ELDK package. The sources are provided in the form of SRPM packages, distributed as a separate ISO image.

To rebuild a target or ELDT package, you must first install the appropriate source RPM package from the ISO image into the ELDK environment. This can be done using the following command:

 

$ ${CROSS_COMPILE}rpm -i /mnt/cdrom/SRPMS/<source_rpm_file_name>.src.rpm

After an ELDK source RPM is installed using the above command, its spec file and sources can be found in the subdirectories of the <ELDK_root>/usr/src/denx subdirectory.

The sections that follow provide detailed instructions on rebuilding ELDT and target components of the ELDK.

 

1.7.2. Rebuilding Target Packages

All the target packages can be rebuilt from the provided source RPM packages. At first you have to install the Source RPM itself:

 

bash$ ${CROSS_COMPILE}rpm -iv <package_name>.src.rpm

Then you can rebuild the binary target RPM using the following command from the ELDK environment:

 

bash$ ${CROSS_COMPILE}rpmbuild -ba <package_name>.spec

In order for the rebuilding process to work correctly, the following conditions must be true:

 

  • The $CROSS_COMPILE environment variable must be set as appropriate for the target CPU family.

 

  • The <ELDK_root>/usr/arm-linux/bin directory must be in PATH before the /usr/bin directory. This is to make sure that the command gcc results in the fact that the ELDK cross compiler is invoked, rather than the host gcc.

 

1.7.3. Rebuilding ELDT Packages

All the ELDT packages allow for rebuilding from the provided source RPM packages using the following command from the ELDK environment:

 

$ unset CROSS_COMPILE
$ <ELDK_root>/usr/bin/rpmbuild -ba <package_name.spec>

In order for the rebuilding process to work correctly, make sure all of the following is true:

 

 

 

  • The <ELDK_root>/usr/arm-linux/bin directory must NOT be in PATH. This is to make sure that the command gcc causes invokation of the host gcc, rather than the ELDK cross compiler.

1.8. ELDK Packages

 

1.8.1. List of ELDT Packages

Package NamePackage Version
crosstool0.35-9
gdb6.3.0.0-1.21_3
genext2fs1.3-8
ldd0.1-1
make3.80-7_1
make-doc3.80-7_1
mkcramfs0.0.1-1
mkimage1.2.0-1
mtd_utils2-2
rpm4.4.1-21_5
rpm-build4.4.1-21_5

Note: The crosstool 0.35 ELDT package provides the following packages: gcc 4.0.0, gcc-c++ 4.0.0, cpp 4.0.0 and binutils 2.16.1. For more information about the crosstool package please refer to http://kegel.com/crosstool.

 

1.8.2. List of Target Packages

Package NamePackage Version
appWeb1.2.2-1_6
autoconf2.59-5_1
bash3.0-31_2
binutils2.16.1-2
boa0.94.14rc19-2
busybox1.3.0-1
byacc1.9-29_1
bzip21.0.2-16_1
bzip2-devel1.0.2-16_1
bzip2-libs1.0.2-16_1
coreutils5.2.1-48.1_1
cpio2.6-7_1
cpp4.0.0-4
cracklib2.8.2-1
cracklib-dicts2.8.2-1
crosstool0.35-9
db44.3.27-3_1
db4-devel4.3.27-3_1
db4-utils4.3.27-3_1
dhclient3.0.2-12_2
dhcp3.0.2-12_2
diffutils2.8.1-15_2
dosfstools2.10-3_1
dropbear0.43-1_2
e2fsprogs1.38-0.FC4.1_2
e2fsprogs-devel1.38-0.FC4.1_2
expat1.95.8-6_1
expat-devel1.95.8-6_1
file4.13-4_1
findutils4.2.20-1_1
flex2.5.4a-34_1
ftp0.17-26_1
gawk3.1.4-5_1
gcc4.0.0-4
gcc-c++4.0.0-4
gdb6.3.0.0-1.21_4
glib1.2.10-16_1
glib22.6.6-1_1
glib2-devel2.6.6-1_1
glib-devel1.2.10-16_1
grep2.5.1-48.2_1
groff1.18.1.1-5_1
gzip1.3.5-6_1
httpd2.0.54-10.2_2
httpd-devel2.0.54-10.2_2
httpd-manual2.0.54-10.2_2
initscripts8.11.1-1_3
iproute2.6.11-1_1
iputils20020927-22_2
kernel-headers2.6.19-1
kernel-source2.6.19-1
krb5-devel1.4.1-5_2
krb5-libs1.4.1-5_2
less382-7_1
libcap1.10-22_1
libcap-devel1.10-22_1
libtermcap2.0.8-41_1
libtermcap-devel2.0.8-41_1
libtool1.5.16.multilib2-2_2
libtool-ltdl1.5.16.multilib2-2_2
libuser0.53.7-1_2
libuser-devel0.53.7-1_2
logrotate3.7.1-10_2
lrzsz0.12.20-21_1
m41.4.3-1_2
mailcap2.1.19-1_1
make3.80-7_1
man1.5p-4_1
microwindows0.90-7
microwindows-fonts0.90-1
mingetty1.07-5_1
mktemp1.5-23_1
module-init-tools3.1-4_1
modutils2.4.22-8_2
modutils-devel2.4.22-8_2
mtd_utils1-4
ncompress4.2.4-42_1
ncurses5.4-17_1
ncurses-devel5.4-17_1
net-snmp5.2.1.2-1_2
net-snmp-devel5.2.1.2-1_2
net-snmp-libs5.2.1.2-1_2
net-snmp-utils5.2.1.2-1_2
net-tools1.60-52_2
nfs-utils1.0.7-12_3
ntp4.2.0.a.2004061-8_1
openssl0.9.7f-7.10_1
openssl-devel0.9.7f-7.10_1
pam0.79-9.5_2
pam-devel0.79-9.5_2
passwd0.69-3_2
patch2.5.4-24_1
pciutils2.1.99.test8-10_1
pciutils-devel2.1.99.test8-10_1
pcmcia-cs3.2.8-1_1
popt1.7-3
portmap4.0-65_2
procps3.2.5-6.3_2
psmisc21.5-5_2
rdate1.4-4_1
readline5.0-3_1
readline-devel5.0-3_1
routed0.17-12_1
rpm4.4.1-22_4
rpm-build4.4.1-22_4
rpm-devel4.4.1-22_4
rpm-libs4.4.1-22_4
rsh0.17-29_1
rsh-server0.17-29_1
sed4.1.4-1_1
SELF1.0-11
setup2.5.44-1.1_1
slang1.4.9-17_2
slang-devel1.4.9-17_2
strace4.5.11-1_3
sysklogd1.4.1-30_2
SysVinit2.85-39_1
tar1.15.1-10_2
tcp_wrappers7.6-39_2
telnet0.17-35_1
telnet-server0.17-35_1
termcap5.4-7_1
tftp0.40-6_1
tftp-server0.40-6_1
u-boot1.2.0-1
util-linux2.12p-9.12_3
vim-common6.3.086-0_1
vim-minimal6.3.086-0_1
wireless-tools28-1_1
wu-ftpd2.6.1-3
xinetd2.3.13-6_2
zlib1.2.2.2-3_1
zlib-devel1.2.2.2-3_1

Note 1: Not all packages will be installed automatically; for example the boa and thttpd web servers are mutually exclusive - you will have to remove one package before you can (manually) install the other one.

Note 2: The crosstool 0.35 target package provides the following packages: glibc 2.3.5, glibc-common 2.3.5, glibc-devel 2.3.5, libstdc++ 4.0.0 and libstdc++-devel 4.0.0. For more information about the crosstool package please refer to http://kegel.com/crosstool

1.9. Rebuilding the ELDK from Scratch

In this section, you will find instructions on how to build the ELDK from scratch, using the pristine package sources available on the Internet, and patches, spec files, and build scripts provided on the ELDK source CD-ROM.

 

1.9.1. ELDK Build Process Overview

The ELDK uses Fedora Core 4 Linux distribution as a source code reference. Any modifications to Fedora Core's sources the ELDK has introduced are in the form of patches applied by the RPM tool while building the packages. Also, the ELDK uses modified spec files for its RPM packages. So, the sources of almost every ELDK package consist of the following parts:

 

  • Fedora Core pristine sources or
  • ELDK source tarball,
  • ELDK patches,
  • ELDK spec file.

The Fedora Core pristine sources may be obtained from the Internet, see http://download.fedora.redhat.com/pub/fedora/linux/core.

The ELDK patches and spec files are available on the ELDK source CD-ROM and from the DENX anonymous CVS server. To access this CVS server please use the following command to log on:

cvs -d :pserver:anonymous@www.denx.de:/cvsroot login
When prompted for the "CVS password:" just press the return key (empty password).

Please use the following commands to check out a copy of one of the modules:

cvs -z6 -d :pserver:anonymous@www.denx.de:/cvsroot co -rversion -P module
The following ELDK modules are available:

Module NameContents
eldk_tarballsSource tarballs
eldk_buildBuild tools, patches, and spec files

Using the "-rversion" option makes sure you download exactly the files that belong to a specific release of the ELDK; for example, to get the files for ELDK release 4.0, please specify "-rELDK_4_0" .

It must be noted that some of the packages which are included in the ELDK are not included in Fedora Core. Examples of such packages are appWeb, microwindows, and wu-ftpd. For these packages tarballs are provided on the DENX anonymous CVS server.

To facilitate building of the ELDK, a build infrastructure has been developed. The infrastructure is composed of the following components:

 

  • ELDK_BUILD script
  • build.sh script
  • cpkgs.lst file
  • tpkgs.lst file
  • SRPMS.lst file
  • tarballs.lst file

The ELDK_BUILD script is the main script of the ELDK build procedure. It is the tool that you would normally use to build the ELDK from scratch. In the simplest case, the script may be invoked without arguments, and it will perform all necessary steps to build the ELDK in a fully automated way. You may pass the following optional arguments to the ELDK_BUILD script:

-d <arch>target architecture: "ppc", "arm" or "mips", defaults to "ppc".
-n <build_name>an identification string for the build. Defaults to the value based on the build architecture and current date, and has the following format: <arch>-YYYY-MM-DD
-ubuild the uClibc-based ELDK version.

 

Warning: The ELDK build scripts rely on standard behaviour of the RPM tool. Make sure you don't use non-standard settings in your personal ~/.rpmmacros file that might cause conflicts.

build.sh is a supplementary script that is called by ELDK_BUILD to accomplish certain steps of the build. Refer to section 1.9.3. build.sh Usage below for more details.

The cpkgs.lst and tpkgs.lst files are read by build.sh and must contain lines describing sub-steps of the eldt and trg build procedure steps. Essentially, the files contain the list of the ELDT and target packages to be included in the ELDK. The SRPMS.lst file contains the list of the Fedora Core source RPM packages used during the ELDK build. The tarballs.lst file contains the list of source tarballs of the packages that are included in the ELDK but are not present in Fedora Core 4.

For the ELDK_BUILD script to work correctly, it must be invoked from a certain build environment created on the host system. The build environment can be either checked out from the DENX CVS (see section 1.9.2. Setting Up ELDK Build Environment below for details) or copied from the ELDK build environment CD-ROM.

To be more specific, the following diagram outlines the build environment needed for correct operation of the ELDK_BUILD script:

 

<some_directory>/
                 build/cross_rpms/<package_name>/SPECS/...
                                                 SOURCES/...
                       target_rpms/<package_name>/SPECS/...
                                                  SOURCES/...
                       install/install.c
                               Makefile
                       misc/ELDK_MAKEDEV
                            ELDK_FIXOWNER
                            README.html
                       cpkgs.lst
                       tpkgs.lst
                       build.sh
                                                                                
                       ELDK_BUILD
                                                                                
                       SRPMS.lst
                                                                                
                       tarballs.lst

                 tarballs/....
                                                                                
                 SRPMS/....

In subdirectories of the cross_rpms and target_rpms directories, the sources and RPM spec files of, respectively, the ELDT and target packages are stored. The install subdirectory contains the sources of the installation utility which will be built and placed in the root of the ISO image. tarballs directory contains the source tarballs of the packages that are included in the ELDK but are not present in Fedora Core 4.

The SRPMS directory may contain the source RPM packages of Fedora Core 4. If some (or all) of the Fedora Core SRPMs needed for the build are missing in the directory, the ELDK_BUILD script will download the source RPMs automatically from the Internet.

The ELDK build environment CD-ROM provides a ready-to-use ELDK build environment. Please refer to section 1.9.2. Setting Up ELDK Build Environment below for detailed instructions on setting up the build environment.

The ELDK_BUILD script examines the contents of the ELDK_PREFIX environment variable to determine the root directory of the ELDK build environment. If the variable is not set when the script is invoked, it is assumed that the root directory of the ELDK build environment is /opt/eldk. To build the ELDK in the example directory layout given above, you must set and export the ELDK_PREFIX variable <some_directory> prior to invoking ELDK_BUILD.

After all the build steps are complete, the following subdirectories are created in the ELDK build environment:

 

build/<build_name>/work/             - full ELDK environment
build/<build_name>/logs/             - build procedure log files
build/<build_name>/results/b_cdrom/  - binary cdrom tree, ready for mkisofs
                   results/s_cdrom/  - source cdrom tree, ready for mkisofs

On Linux hosts, the binary and source ISO images are created automatically by the ELDK_BUILD script and placed in the results directory. On Solaris hosts, creating the ISO images is a manual step. Use the contents of the b_cdrom and s_cdrom directories for the contents of the ISO images.

1.9.2. Setting Up ELDK Build Environment

For your convenience, the ELDK build environment CD-ROM provides full ELDK build environment. All you need to do is copy the contents of the CD-ROM to an empty directory on your host system. Assuming the ELDK build environment CD-ROM is mounted at /mnt/cdrom, and the empty directory where you want to create the build environment is named /opt/eldk, use the following commands to create the build environment:

 

bash$ cd /opt/eldk
bash$ cp -r /mnt/cdrom/* .

These commands will create the directory structure as described in section 1.9.1. ELDK Build Process Overview above. All necessary scripts and ELDK specific source files will be placed in the build subdirectory, and the required tarballs can be found in the tarballs subdirectory. In the SRPMS subdirectory, you will find all the Fedora Core 4 SRPMS needed to build the ELDK.

Alternatively, you can obtain the ELDK build environment from the DENX anonymous CVS server. Two modules are provided for check out: eldk_build and eldk_tarballs. The first one contains the files for the build subdirectory in the build environment, and the second one contains source tarballs of the packages that are included in the ELDK but are not present in Fedora Core 4. To create the ELDK build environment from the DENX CVS server, use the following commands (the example below assumes that the root directory of the build environment is /opt/eldk):

 

bash$ cd /opt/eldk
bash$ cvs -d :pserver:anonymous@www.denx.de:/cvsroot login
bash$ cvs -z6 -d :pserver:anonymous@www.denx.de:/cvsroot co -P eldk_build
bash$ cvs -z6 -d :pserver:anonymous@www.denx.de:/cvsroot co -P eldk_tarballs

After the eldk_build and eldk_tarballs modules have been checked out, the only remaining piece that is needed for the build is the Fedora Core 4 source RPM packages, which will, if required, be automatically downloaded by the ELDK_BUILD script.

1.9.3. build.sh Usage

If you wish to perform only a part of the ELDK build procedure, for instance to re-build or update a certain package, it may sometimes be convenient to invoke the build.sh script manually, without the aid of the ELDK_BUILD script. Please note, however, that this approach is in general discouraged.

The whole build procedure is logically divided into six steps, and the build.sh must be told which of the build steps to perform. The build steps are defined as follows:

 

  • rpm - build RPM
  • eldt - build ELDT packages
  • seldt - save ELDT SRPM packages to create a source ISO image later on
  • trg - build target packages
  • biso - prepare the file tree to create the binary ISO image
  • siso - prepare the file tree to create the source ISO image

Further, the eldt and trg build steps are devided into sub-steps, as defined in the cpkgs.lst and tpkgs.lst

files (see below for details). You may specify which sub-steps of the build step are to be performed.

The formal syntax for the usage of build.sh is as follows:

 

bash$ ./build.sh [-a <arch>] [-n <name>] [-p <prefix>] [-r <result>] /
                 [-w <work>] <step_name> [<sub_step_number>]

-a <arch>target architecture: "ppc", "arm" or "mips", defaults to "ppc".
-n <build_name>an identification string for the build. It is used as a name for some directories created during the build. You may use for example the current date as the build name.
-p <prefix>is the name of the directory that contains the build environment. Refer to build overview above for description of the build environment.
-r <result>is the name of the directory where the resulting RPMs and SRPMs created on this step will be placed.
-w <work>is the name of the directory where the build is performed.
<stepname>is the name of the build step that is to be performed. Refer to the list of the build procedure steps above.
<sub_step_number>is an optional parameter which identifies sub-steps of the step which are to be performed. This is useful when you want to re-build only some specific packages. The numbers are defined in the cpkgs.lst and tpkgs.lst files discussed below. You can specify a range of numbers here. For instance, "2 5" means do steps from 2 to 5, while simply "2" means do all steps starting at 2.

By default, the invocation of build.sh assumes that the Glibc-based ELDK version is being built. For the uClibc-based ELDK build, set the UCLIBC environment variable to 1 prior to running build.sh :

 

bash$ export UCLIBC=1

Note: Please note that you must never use build.sh to build the ELDK from scratch. For build.sh to work correctly, the script must be invoked from the build environment after a successful build using the ELDK_BUILD script. A possible scenario of build.sh usage is such that you have a build environment with results of a build performed using the ELDK_BUILD script and want to re-build certain ELDT and target packages, for instance, because you have updated sources of a package or added a new package to the build.

When building the target packages (during the trg buildstep), build.sh examines the contents of the TARGET_CPU_FAMILY_LIST environment variable, which may contain a list indicating which target CPU variants the packages must be built for. Possible CPU variants are arm. For example, the command below rebuilds the target RPM listed in the tpckgs.lst file under the number of 47 (see section 1.9.4. Format of the cpkgs.lst and tpkgs.lst Files for description of the tpckgs.lst and cpkgs.lst files), for the arm CPU:

 

bash$ TARGET_CPU_FAMILY_LIST="arm" /
> /opt/eldk/build.sh -a arm /
>                    -n 2005-03-06 /
>                    -p /opt/eldk/build/arm-2005-12-24 /
>                    -r /opt/eldk/build/arm-2005-12-24/results /
>                    -w /opt/eldk/build/arm-2005-12-24/work /
>                    trg 47 47

 

Note: If you are going to invoke build.sh to re-build a package that has already been built in the build environment by the ELDK_BUILD script, then you must first manually uninstall the package from ELDK installation created by the build procedure under the work directory of the build environment.

Note: It is recommended that you use the build.sh script only at the final stage of adding/updating a package to the ELDK. For debugging purposes, it is much more convenient and efficient to build both ELDT and target packages using a working ELDK installation, as described in the sections 1.7.2. Rebuilding Target Packages and 1.7.3. Rebuilding ELDT Packages above.

1.9.4. Format of the cpkgs.lst and tpkgs.lst Files

Each line of these files has the following format:

 

<sub_step_number> <package_name> <spec_file_name> /
  <binary_package_name> <package_version>

The ELDK source CD-ROM contains the cpkgs.lst and tpkgs.lst files used to build this version of the ELDK distribution. Use them as reference if you want to include any additional packages into the ELDK, or remove unneeded packages.

To add a package to the ELDK you must add a line to either the cpkgs.lst file, if you are adding a ELDT package, or to the tpkgs.lst file, if it is a target package. Keep in mind that the relative positions of packages in the cpkgs.lst and tpkgs.lst files (the sub-step numbers) are very important. The build procedure builds the packages sequentially as defined in the *.lst files and installs the packages in the "work" environment as they are built. This implies that if a package depends on other packages, those packages must be specified earlier (with smaller sub-step numbers) in the *.lst files.

Note: For cpkgs.lst, the package_version may be replaced by the special keyword "RHAUX". Such packages are used as auxiliary when building ELDK 4.0 on non-Fedora hosts. These packages will be built and used during the build process, but will not be put into the ELDK 4.0 distribution ISO images.

 
1. 概要 这是嵌入式PowerPC, ARM和MIPS系统中使用DENX U-Boot和Linux的指导手册。文档中描述了如何在嵌入式PowerPC, ARM和MIPS系统上配置、编译、使用Das U-Boot(常常缩写为“U-Boot”)和Linux操作系统。文档中涵盖了所有你可能需要的用于配置、编译、运行U-Boot和Linux的工具。 2. 绪论 首先,我们介绍如何安装交叉编译开发工具Embedded Linux Development Kit(ELDK),这个开发套件你很有可能会用到——至少当你在标准的x86 PC上使用Linux或者Sun Solaris系统作为开发环境的时候,你会需要它的。 然后,我们会阐述通过串口与你的目标板连接:你需要配置一个终端控制程序,如cu或者kermit。 你常常需要通过网线把映像文件下载到你的目标板上。为了实现这个目的,你需要TFTP和DHCP/BOOTP服务器。文档中提供了简要的相关配置说明。 接下来则是描述如何配置和编译U-Boot使之适用于某个特定的平台,以及如何安装和在该硬件平台上运行。 下一步的工作是配置、建立和安装Linux。我们使用SELF(Simple Embedded Linux Framework)来展示如何建立一个开发环境(包括通过NFS挂载的根文件系统)和一个嵌入式目标板配置(从基于busybox的ramdisk映像文件中运行)。 本文档不会给出如何把U-Boot或者Linux移植到一个新的硬件平台,而是默认你的开发板已经被U-Boot和Linux所支持。 本手册各种文档格式的最新版本可以从以下网址获取: · HTML http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.html · plain ASCII text http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.txt · PostScript European A4 format http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.ps · PDF European A4 format http://www.denx.de/wiki/publish/DULG/DULG-canyonlands.pdf 3. 嵌入式Linux开发工具套件 嵌入式Linux开发工具套件(ELDK)包括GNU交叉开发工具,如编译器、binutils、gdb等工具,和一些已经编译好的目标工具以及负责提供在目标平台上函数调用的库文件。还免费提供了所有的源代码,包括全部补丁、扩展文件、以及用于编译开发工具使用的程序和脚本。安装包都是基于RPM包管理器。 3.1 获取ELDK 可以通过以下方式获得ELDK。 ·DENX计算机系统光盘 ·从以下服务器中下载 FTP方式 ftp://mirror.switch.ch/mirror/eldk/eldk/ ftp://sunsite.utk.edu/pub/linux/eldk/ ftp://ftp.sunet.se/pub/Linux/distributions/eldk/ ftp://ftp.leo.org/pub/eldk/ HTTP方式 http://mirror.switch.ch/ftp/mirror/eldk/eldk/ http://ftp.sunet.se/pub/Linux/distributions/eldk/ http://archiv.leo.org/pub/comp/os/unix/linux/eldk/ 3.2 初始安装 初始安装可以使用放在ELDK目录树根目录下的安装工具。安装工具使用语法如下; $ ./install [-d ] [] [] … -d 确定ELDK安装在哪个目录。如果省略ELDK安装在当前目录。 确定目标平台的CPU。如果此项设置了一项以上的参数,则会将这些CPU的支持都安装。如果省略将会安装所有CPU的支持。你也可以把ELDK安装到任何空目录下,这么做的唯一条件是你有那个目录的写和执行权限。安装过程并不需要超级用户的特权。由安装时的参数决定安装几个目标组件集合。ELDT包是肯定会安装的。 $ export CROSS_COMPILE=ppc_4xx- //加入环境变量 $ PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin //加入PATH 这样加入的话,每次重启系统后必须重新加入,一劳永逸的办法是编辑/root/.bashrc 加上 export CROSS_COMPILE=ppc_4xx- export PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin 重启系统后即可使用ELDK。 4. 系统设置 在目标平台上安装和配置U-Boot和Linux需要一些工具。特别是在开发过程中,你需要和目标平台保持联系。这一节将告诉你如何配置你的主机以达到上述目的。 4.1 设置串口 为了更好地使用U-Boot和Linux,你需要通过串口将目标板和你的主机连接。U-Boot和Linux可以配置成自动执行而不需要任何用户的干涉。 通过串口有很多种方法来控制你的目标板,比如说使用终端服务器。不过最常见的做法是使用你本机的串口,这时,你主机需要安装一个终端程序,如cu或者kermit。 4.2 配置“kermit” kermit这个名字就代表了它是连接串口和网络的通信软件。事实上在很多计算机和操作系统上使用它,能够很好地满足我们的目的。 kermit在执行其它命令之前,会执行你的用户目录下的初始文件.kermrc,所以可以非常简单的通过初始化命令来定制kermit。下面是使用U-Boot和Linux时推荐配置: ~/.kermrc: set line /dev/ttyS0 set speed 115200 set carrier-watch off set handshake none set flow-control none robust set file type bin set file name lit set rec pack 1000 set send pack 1000 set window 5 这个设置假定你使用的是主机第一个串口(/dev/ttyS0),以115200这个波特率与目标板的串口连接。 然后你可以连接目标板了: $ kermit -c Connecting to /dev/ttyS0, speed 115200. The escape character is Ctrl-\ (ASCII 28, FS) Type the escape character followed by C to get back, or followed by ? to see other options. —————————————————- 下载kermit这个软件时,你会发现有两个kermit包。你只需要安装ckermit。其中gkermit仅仅是实现kermit传输协议的一个命令行工具。如果你主机上的Linux系统没有安装kermit,你可以到kerimt的官方网站 http://www.columbia.edu/kermit/ 下载。 4.3 使用minicom minicom是另外一种非常流行的串口通信终端。很遗憾的是,很多用户发现在使用U-Boot和Linux时,minicom有很多问题,尤其是试图使用它来下载image的时候。因此,不推荐大家使用minicom。 4.4 配置TFTP服务器 使用U-Boot下载Linux内核或者应用程序的最快捷的方法是通过网络传输。为了这一目的,U-Boot实现了TFTP协议(参见U-Boot中的tftpboot命令)。为了使主机支持TFTP,你必须确保TFTP后台程序/usr/sbin/in.tftpd已经安装。在RedHat系统中,你可以运行下面的命令来确认: $ rpm -q tftp-server 如果没有安装,请从你的Linux安装盘或者其它媒介安装。 大多数的Linux发行版都默认关闭TFTP服务。以RedHat系统为例,如果要使能TFTP服务,编辑文件/etc/xinetd.d/tftp,移除这一行: disable = yes 或者注释掉它,或者修改disable = no 此外,确保/tftpboot目录存在,而且有访问权限(至少应该"dr-xr-xr-x")。 5. Das U-Boot 5.1 当前版本 Das U-Boot(或者简称“U-Boot”)是针对嵌入式PowerPC, ARM, MIPS和x86处理器的开放源代码软件。U-Boot项目已经在Sourceforge设立,你可以访问这个官方网站:http://www.denx.de/wiki/UBoot U-Boot最新版的源代码可以在Sourcefoge通过匿名CVS得到。当要求输入匿名用户anonymous的密码时只需要直接按下回车键。 $ cvs -d:pserver:anonymous@www.denx.de:/cvsroot login $ cvs -z6 -d:pserver:anonymous@www.denx.de:/cvsroot co -P u-boot 官方发布的U-Boot也可以通过FTP方式获取。你可以到ftp://ftp.denx.de/pub/u-boot/下载tar形式的压缩包。 或者通过git的方式获取: git clone git://www.denx.de/git/u-boot.git u-boot/ git clone http://www.denx.de/git/u-boot.git u-boot/ git clone rsync://www.denx.de/git/u-boot.git u-boot/ 5.2 源代码包的解压 如果你是通过CVS得到的U-Boot源代码,你可以跳过这一步,因为你得到的已经是解压后的目录树了。如果你是从FTP服务器上下载的tar压缩包,那么你需要按照以下步骤解压: $ cd /opt/eldk/usr/src $ wget ftp://ftp.denx.de/pub/u-boot/u-boot-1.3.2.tar.bz2 $ rm -f u-boot $ bunzip2 < u-boot-0.4.5.tar.bz2 | tar xf - $ ln -s u-boot-0.4.5 u-boot $ cd u-boot 5.3 配置 $ export BUILD_DIR=/opt/eldk/build //指定编译的输出目录 进入U-Boot源代码根目录后,可以先使用如下命令确保已经清除以前编译的结果: $ make distclean 下一步是为Makalu板配置U-Boot: $ make makalu_config (译者注:应该根据你自己的具体开发板配置,如$ make _config,如果没有相应的开发板,应该自己照着建立相应的目录和配置文件。) 最后我们可以开始编译U-Boot了: $ make all 5.4 安装 5.4.1 动手之前 5.4.1.1 安装所需 以下的章节假定你的开发板使用flash作为存储设备。如果不是,则以下的指令不会工作。如果你想使用U-Boot,需要换掉存储设备。 5.4.1.2 开发板识别数据 所有的Makalu开发板使用一个序列号加以识别。而且开发板需要分配一个以太网MAC地址。如果这些数据丢失,你可能会失去授权。在安装U-Boot或者改变开发板的配置之前,你需要搜集足够的信息。 5.4.2 使用BDM/JTAG调试器安装U-Boot.bin 把数据烧入flash中的一个简单而又快速的办法是通过BDM或者JTAG接口的调试器或者flash烧写器。当flash中没有任何数据(比如说一块新的开发板),这种方法是唯一的选择。 我们(强烈推荐)使用Abatron公司的BDI2000(见http://www.abatron.ch/BDI/bdiGDB.html )。 其它的BDM/JTAG调试器也可以使用,但是如何操作它们不是本文档要讨论的范围。如果你想使用别的工具请参照它们的说明文档。(我没有使用BDI2000,故略去操作BDI2000的方法。我烧写u-boot.bin就是简单地通过JTAG口。) 5.4.3 使用U-Boot安装U-Boot.bin 如果U-Boot已经在你的板子上安装运行,你可以使用这些命令来下载新的U-Boot映像来代替当前的。 警告:在你安装新的映像之前,你必须擦除当前的u-boot.bin。如果出现什么差错,你的开发板将不能运行。因此强烈建议: 做一个能工作的U-Boot映像文件的备份; 你清楚如何在一个新的开发板上安装u-boot.bin。 过程如下: => tftp 100000 /tftpboot/uboot.bin ARP broadcast 1 TFTP from server 10.0.0.2; our IP address is 10.0.0.100 Filename ””/tftpboot/uboot.bin””. Load address: 0×100000 Loading: ############################### done Bytes transferred = 155376 (25ef0 hex) => protect off 40000000 4003FFFF Un-Protected 5 sectors => era 40000000 4003FFFF Erase Flash from 0×40000000 to 0x4003ffff ……… done Erased 5 sectors => cp.b 100000 40000000 $(filesize) Copy to Flash… done => setenv filesize => saveenv Saving Enviroment to Flash… Un-Protected 1 sectors Erasing Flash… .. done Erased 1 sectors Writing to Flash… done Protected 1 sectors => reset 5.5 工具的安装 U-Boot加载Linux内核、Ramdisk或者其它映像时使用一种特殊的映像格式。这种格式包含了一些信息,如创建时间、操作系统、压缩格式、映像类型、映像名和CRC32校验和。 mkimage用来创建这种格式的映像文件或者显示它包含的信息。如果使用ELDK,那么mkimage这个命令已经包含在ELDK中。 如果你不想使用ELDK,你应该把mkimage安装在某个能够直接执行的目录里,比如: $ cp tools/mkimage /usr/local/bin/ 5.6 初始化 初始化你的Makalu板上的U-Boot,你需要通过终端连接板子的串口。 Makalu板的串口默认配置是波特率为115200/8N1(115200bps,每个字符8bit,无奇偶校验,1bit停止位,无握手)。 如果你的主机是Linux操作系统,我们建议你用kermit或者cu作为终端控制程序。确定硬件和软件控制流都已经关闭。 5.7 开始的步骤 在默认配置中,U-Boot运行在一种互动模式,它通过串口“UART1”提供命令行形式的用户接口。 这意味着U-Boot显示一个提示符(默认是:=>),等待着接受用户的输入。然后你输入一个命令,按下回车键。U-Boot将运行这个命令,然后又出现提示符等待下一条命令。 你可以使用help(或者简单地一个?)来查看所有的U-Boot命令。它将会列出在你当前配置下所有支持的命令。[请注意到尽管U-Boot提供了很多配置选项,并不是所有选项都支持各种处理器和开发板,有些选项可能在你的配置中并没有被选上。] => help ? – alias for ‘help’ askenv – get environment variables from stdin autoscr – run script from memory base – print or set address offset bdinfo – print Board Info structure boot – boot default, i.e., run ‘bootcmd’ bootd – boot default, i.e., run ‘bootcmd’ bootelf – Boot from an ELF image in memory bootm – boot application image from memory bootp – boot image via network using BootP/TFTP protocol bootstrap – program the I2C bootstrap EEPROM bootvx – Boot vxWorks from an ELF image cmp – memory compare coninfo – print console devices and information cp – memory copy crc32 – checksum calculation date – get/set/reset date & time dhcp – invoke DHCP client to obtain IP/boot params dtt – Digital Thermometer and Thermostat echo – echo args to console eeprom – EEPROM sub-system erase – erase FLASH memory exit – exit script ext2load- load binary file from a Ext2 filesystem ext2ls – list files in a directory (default /) fatinfo – print information about filesystem fatload – load binary file from a dos filesystem fatls – list files in a directory (default /) fdt – flattened device tree utility commands flinfo – print FLASH memory information getdcr – Get an AMCC PPC 4xx DCR’s value getidcr – Get a register value via indirect DCR addressing go – start application at address ‘addr’ help – print online help icrc32 – checksum calculation iloop – infinite loop on address range imd – i2c memory display iminfo – print header information for application image imls – list all images found in flash imm – i2c memory modify (auto-incrementing) imw – memory write (fill) imxtract- extract a part of a multi-image inm – memory modify (constant address) iprobe – probe to discover valid I2C chip addresses irqinfo – print information about IRQs isdram – print SDRAM configuration information itest – return true/false on integer compare loadb – load binary file over serial line (kermit mode) loads – load S-Record file over serial line loady – load binary file over serial line (ymodem mode) loop – infinite loop on address range loopw – infinite write loop on address range md – memory display mdc – memory display cyclic mii – MII utility commands mm – memory modify (auto-incrementing) mtest – simple RAM test mw – memory write (fill) mwc – memory write cyclic nand – NAND sub-system nboot – boot from NAND device nfs – boot image via network using NFS protocol nm – memory modify (constant address) pci – list and access PCI Configuration Space ping – send ICMP ECHO_REQUEST to network host printenv- print environment variables protect – enable or disable FLASH write protection rarpboot- boot image via network using RARP/TFTP protocol reginfo – print register information reset – Perform RESET of the CPU run – run commands in an environment variable saveenv – save environment variables to persistent storage setdcr – Set an AMCC PPC 4xx DCR’s value setenv – set environment variables setidcr – Set a register value via indirect DCR addressing sleep – delay execution for some time test – minimal test like /bin/sh tftpboot- boot image via network using TFTP protocol usb – USB sub-system usbboot – boot from USB device version – print monitor version =>使用help 你可以得到更多的命令信息: => help tftpboot tftpboot [loadAddress] [[hostIPaddr:]bootfilename] => => help setenv printenv setenv name value … - set environment variable ‘name’ to ‘value …’ setenv name - delete environment variable ‘name’ printenv - print values of all environment variables printenv name … - print value of environment variable ‘name’ => 大多数命令可以缩写,只要字符串的内容仍然可以被确定: => help fli tftp flinfo - print information for all FLASH memory banks flinfo N - print information for FLASH memory bank # N tftpboot [loadAddress] [[hostIPaddr:]bootfilename] => 5.8 首次上电 把主机指定的串口和在Makalu板上标有UART1的端口连接,运行终端程序,给Makalu板接上电源。你可以看到如下信息: => reset U-Boot 1.3.3-rc2-01466-g4f27098 (May 1 2008 – 13:57:57) CPU: AMCC PowerPC 460EX Rev. A at 600 MHz (PLB=200, OPB=100, EBC=100 MHz) Security/Kasumi support Bootstrap Option H – Boot ROM Location I2C (Addr 0×52) Internal PCI arbiter disabled 32 kB I-Cache 32 kB D-Cache Board: Canyonlands – AMCC PPC460EX Evaluation Board, 2*PCIe, Rev. 13 I2C: ready DTT: 1 is 48 C DRAM: 256 MB (ECC not enabled, 400 MHz, CL3) FLASH: 64 MB NAND: 32 MiB PCI: Bus Dev VenId DevId Class Int PCIE0: link is not up. PCIE0: initialization as root-complex failed PCIE1: link is not up. PCIE1: initialization as root-complex failed Net: ppc_4xx_eth0, ppc_4xx_eth1 Type run flash_nfs to mount root filesystem over NFS Hit any key to stop autoboot: 0 => => 你可以按下任意键来中止倒计数。如果你不那么做,你可能会看到一些(无关紧要的)错误,因为系统没有初始化。 有时你可能会看到一种信息: *** Warning – bad CRC, using default environment 这条信息没有害处,只要你初始化和保存环境变量之后,它就不会出现了。 首先,你必须输入你的开发板的序列号和网卡地址。需要特别注意的是,这些参数是写保护的,一旦保存了就无法改变(通常制造商已经设置好了)。使用U-Boot的setenv命令可以输入数据,命令后面跟上变量名和值,参数之间用空格(或者Tab符)隔开。例如,使用变量名serial#设置开发板的ID或者说序列号,变量名ethaddr用于设置以太网地址: => => setenv ethaddr !!!!!!FILL_THIS!!!!!! => setenv serial# CF56-216F-400A 使用printenv确认你已经输入正确的值: => printenv serial# ethaddr ## Error: "serial#" not defined ethaddr=5e:ed:18:38:81:85 => 请仔细核查显示值是否正确!等保存之后你将不能更正任何错误。如果发现错误,请重新启动开发板。如果检查无误,你可以使用saveenv命令永久保存这些参数。 => saveenv Saving Environment to Flash… Un-Protected 1 sectors Un-Protected 1 sectors Erasing Flash… . done Erased 1 sectors Writing to Flash… done Protected 1 sectors Protected 1 sectors => 5.9 U-Boot命令介绍 这一节将介绍U-Boot中最重要的指令。U-Boot可配置性非常强,所以并不是所有的命令都已经在你的硬件平台上安装,此外可能也有这儿没提到的命令。你可以使用help命令来显示根据你的配置所有可用的命令列表。 对于大多数命令,你不必打全这些命令,只需输入一些字符足以。比如,help可以简写为h。 一些命令的执行依赖于U-Boot的配置以及U-Boot中一些环境变量的定义。 所有的U-Boot命令都把输入的数字当作十六进制的格式。 不要使用除了退格键之外的其它编辑键,因为在诸如环境变量中隐藏的字符是很难被发现的。 具体命令略 6. Linux内核的编译 6.1 下载Linux内核 可以通过git下载到最新的内核,命令如下: $ cd /opt/eldk/usr/src $ git clone git://www.denx.de/git/linux-2.6-denx.git linux-2.6-denx $ cd linux-2.6-denx 6.2 内核的配置及编译 下面的步骤需要powerpc的交叉开发工具,所以您必须确认您的PATH变量中有ELDK的编译工具的地址。 首先使用下面的命令清除以前的编译信息: $ make mrproper 使用下面的命令导入适合Makalu开发板的默认配置,这些配置是经过官方多次测试的: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- makalu_defconfig //导入默认配置 注:这些默认的配置文件位于arch/powerpc/configs/XXX_defconfig ,根据您的开发板的型号选择。如果找不到相应的配置文件,可以去arch/ppc/configs/中寻找相应的配置文件,那里还有一些。makalu_defconfig这个就是位于arch/ppc/configs/下面,而arch/powerpc/configs/中没有。 当然您还可以自己去修改内核的配置,使用如下命令: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- config //手动改动配置 或者 $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- menuconfig //手动改动配置 注:因为一些问题(尤其是老版本的内核),"make xconfig"这个命令不被推荐 使用下面的命令编译内核: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- uImage //编译 编译生成的目标文件uImage是通过mkimage(位于U-Boot包中) 创建的,位于/opt/eldk/usr/src/linux-2.6-denx/arch/powerpc/boot/uImage,它可以通过U-Boot来下载和引导 配置和安装模块使用如下命令: $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- modules $ make ARCH=powerpc CROSS_COMPILE=ppc_4xx- INSTALL_MOD_PATH=/opt/eldk/ppc_4xx modules_install 6.3 安装 将文件复制到tftpboot目录下面,然后通过tftp烧写: $ cp arch/powerpc/boot/uImage /tftpboot/uImage 7. 根文件系统的设计与编译 7.1 根文件系统的设计 嵌入式开发中根文件系统的设计并不是很容易的事,主要的问题是: (1)里面要包括哪些内容 (2)使用哪种文件系统类型 (3)怎样存储和引导 现在假设根文件系统中的内容我们已经知道,那么我们主要关注后面两点。 我们使用ELDK安装时生成的镜像 SELF (Simple Embedded Linux Framework),它位于 /opt/eldk//images/ 文件夹下,ramdisk_image.gz这个文件便是。 (1)解压ramdisk: $ gzip -d -c -v /opt/eldk/ppc_4xx/images/ramdisk_image.gz >/tmp/ramdisk_image //解压 (2)挂载ramdisk $ mount -o loop /tmp/ramdisk_image /mnt/tmp //挂载 (3)创建压缩文件,为了避免下面步骤需要root权限,不包括设备文件 $ cd /mnt/tmp $ tar -zc –exclude=’dev/*’ -f /tmp/rootfs.tar.gz * //创建tarball,为了避免下面步骤需要root权限,不包括设备文件 (4)将设备文件创建成单独的压缩文件(使用cramfs) $ tar -zcf /tmp/devices.tar.gz dev/ //将设备文件创建成单独的tarball $ cd /tmp (5)取消挂载 $ umount /mnt/tmp //取消挂载 7.2 根文件系统的编译 我们使用ramdisk的形式来生成根文件系统的镜像文件,一般情况下,它使用ext2文件系统。 (1)创建目录,解压压缩文件 $ cd /opt/eldk/ $ mkdir rootfs $ cd rootfs $ tar zxf /tmp/rootfs.tar.gz (2)我们使用genext2fs来创建ramdisk镜像文件,因为它使用一个简单的文本文件来描述设备,因而不需要root权限。使用设备表rootfs_devices.tab: # /dev d 755 0 0 – - – - - /dev/console c 640 0 0 5 1 – - - /dev/fb0 c 640 0 0 29 0 – - - /dev/full c 640 0 0 1 7 – - - /dev/hda b 640 0 0 3 0 – - - /dev/hda b 640 0 0 3 1 1 1 16 /dev/kmem c 640 0 0 1 2 – - - /dev/mem c 640 0 0 1 1 – - - /dev/mtd c 640 0 0 90 0 0 2 16 /dev/mtdblock b 640 0 0 31 0 0 1 16 /dev/mtdr c 640 0 0 90 1 0 2 16 /dev/nftla b 640 0 0 93 0 – - - /dev/nftla b 640 0 0 93 1 1 1 8 /dev/nftlb b 640 0 0 93 16 – - - /dev/nftlb b 640 0 0 93 17 1 1 8 /dev/null c 640 0 0 1 3 – - - /dev/ptyp c 640 0 0 2 0 0 1 10 /dev/ptypa c 640 0 0 2 10 – - - /dev/ptypb c 640 0 0 2 11 – - - /dev/ptypc c 640 0 0 2 12 – - - /dev/ptypd c 640 0 0 2 13 – - - /dev/ptype c 640 0 0 2 14 – - - /dev/ptypf c 640 0 0 2 15 – - - /dev/ram b 640 0 0 1 0 0 1 2 /dev/ram b 640 0 0 1 1 – - - /dev/rtc c 640 0 0 10 135 – - - /dev/tty c 640 0 0 4 0 0 1 4 /dev/tty c 640 0 0 5 0 – - - /dev/ttyS c 640 0 0 4 64 0 1 8 /dev/ttyp c 640 0 0 3 0 0 1 10 /dev/ttypa c 640 0 0 3 10 – - - /dev/ttypb c 640 0 0 3 11 – - - /dev/ttypc c 640 0 0 3 12 – - - /dev/ttypd c 640 0 0 3 13 – - - /dev/ttype c 640 0 0 3 14 – - - /dev/ttypf c 640 0 0 3 15 – - - /dev/zero c 640 0 0 1 5 – - - 具体的格式描述请参见genext2fs的帮助文档。 (3)使用genext2fs来创建一个ext2文件系统的镜像: $ ROOTFS_DIR=/opt/eldk/rootfs # 路径 $ ROOTFS_SIZE=8192 # 文件系统镜像的大小,如果此值太小,当生成的文件超过此值时,会报错 $ ROOTFS_FREE=100 # free space wanted $ ROOTFS_INODES=380 # number of inodes $ ROOTFS_DEVICES=rootfs_devices.tab # device description file $ ROOTFS_IMAGE=ramdisk.img # generated file system image $ genext2fs -U \ -d ${ROOTFS_DIR} \ -D ${ROOTFS_DEVICES} \ -b ${ROOTFS_SIZE} \ -r ${ROOTFS_FREE} \ -i ${ROOTFS_INODES} \ ${ROOTFS_IMAGE} (4)压缩文件 $ gzip -v9 ramdisk.img (5)创建适合U-Boot的images: $ mkimage -T ramdisk -C gzip -n ‘Test Ramdisk Image’ \> -d ramdisk.img.gz uRamdisk 至此,ELDK的开发环境便基本搭建完成。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值