U-Boot中Linux的image文件头的定义(启动时间优化)

Linux Support:
==============
Although U-Boot should support any OS or standalone application
easily, the main focus has always been on Linux during the design of
U-Boot.
U-Boot includes many features that so far have been part of some
special "boot loader" code within the Linux kernel. Also, any
"initrd" images to be used are no longer part of one big Linux image;
instead, kernel and "initrd" are separate images. This implementation
serves several purposes:
- the same features can be used for other OS or standalone
  applications (for instance: using compressed images to reduce the
  Flash memory footprint)
- it becomes much easier to port new Linux kernel versions because
  lots of low-level, hardware dependent stuff are done by U-Boot
- the same Linux kernel image can now be used with different "initrd"
  images; of course this also means that different kernel images can
  be run with the same "initrd". This makes testing easier (you don't
  have to build a new "zImage.initrd" Linux image when you just
  change a file in your "initrd"). Also, a field-upgrade of the
  software is easier now.


Linux HOWTO:
============
Porting Linux to U-Boot based systems:
---------------------------------------
U-Boot cannot save you from doing all the necessary modifications to
configure the Linux device drivers for use with your target hardware
(no, we don't intend to provide a full virtual machine interface to
Linux :-).
But now you can ignore ALL boot loader code (in arch/ppc/mbxboot).
Just make sure your machine specific header file (for instance
include/asm-ppc/tqm8xx.h) includes the same definition of the Board
Information structure as we define in include/u-boot.h, and make
sure that your definition of IMAP_ADDR uses the same value as your
U-Boot configuration in CFG_IMMR.


Configuring the Linux kernel:
-----------------------------
No specific requirements for U-Boot. Make sure you have some root
device (initial ramdisk, NFS) for your target system.


Building a Linux Image:
-----------------------
With U-Boot, "normal" build targets like "zImage" or "bzImage" are
not used. If you use recent kernel source, a new build target
"uImage" will exist which automatically builds an image usable by
U-Boot. Most older kernels also have support for a "pImage" target,
which was introduced for our predecessor project PPCBoot and uses a
100% compatible format.
Example:
 make TQM850L_config
 make oldconfig
 make dep
 make uImage
The "uImage" build target uses a special tool (in 'tools/mkimage') to
encapsulate a compressed Linux kernel image with header  information,
CRC32 checksum etc. for use with U-Boot. This is what we are doing:
* build a standard "vmlinux" kernel image (in ELF binary format):
* convert the kernel into a raw binary image:
 ${CROSS_COMPILE}-objcopy -O binary \
     -R .note -R .comment \
     -S vmlinux linux.bin
* compress the binary image:
 gzip -9 linux.bin
* package compressed binary image for U-Boot:
 mkimage -A ppc -O linux -T kernel -C gzip \
  -a 0 -e 0 -n "Linux Kernel Image" \
  -d linux.bin.gz uImage


The "mkimage" tool can also be used to create ramdisk images for use
with U-Boot, either separated from the Linux kernel image, or
combined into one file. "mkimage" encapsulates the images with a 64
byte header containing information about target architecture,
operating system, image type, compression method, entry points, time
stamp, CRC32 checksums, etc.
"mkimage" can be called in two ways: to verify existing images and
print the header information, or to build new images.
In the first form (with "-l" option) mkimage lists the information
contained in the header of an existing U-Boot image; this includes
checksum verification:
 tools/mkimage -l image
   -l ==> list image header information
The second form (with "-d" option) is used to build a U-Boot image
from a "data file" which is used as image payload:
 tools/mkimage -A arch -O os -T type -C comp -a addr -e ep \
        -n name -d data_file image
   -A ==> set architecture to 'arch'
   -O ==> set operating system to 'os'
   -T ==> set image type to 'type'
   -C ==> set compression type 'comp'
   -a ==> set load address to 'addr' (hex)
   -e ==> set entry point to 'ep' (hex)
   -n ==> set image name to 'name'
   -d ==> use image data from 'datafile'
Right now, all Linux kernels for PowerPC systems use the same load
address (0x00000000), but the entry point address depends on the
kernel version:
- 2.2.x kernels have the entry point at 0x0000000C,
- 2.3.x and later kernels have the entry point at 0x00000000.
So a typical call to build a U-Boot image would read:
 -> tools/mkimage -n '2.4.4 kernel for TQM850L' \
 > -A ppc -O linux -T kernel -C gzip -a 0 -e 0 \
 > -d /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux.gz \
 > examples/uImage.TQM850L
 Image Name:   2.4.4 kernel for TQM850L
 Created:      Wed Jul 19 02:34:59 2000
 Image Type:   PowerPC Linux Kernel Image (gzip compressed)
 Data Size:    335725 Bytes = 327.86 kB = 0.32 MB
 Load Address: 0x00000000
 Entry Point:  0x00000000
To verify the contents of the image (or check for corruption):
 -> tools/mkimage -l examples/uImage.TQM850L
 Image Name:   2.4.4 kernel for TQM850L
 Created:      Wed Jul 19 02:34:59 2000
 Image Type:   PowerPC Linux Kernel Image (gzip compressed)
 Data Size:    335725 Bytes = 327.86 kB = 0.32 MB
 Load Address: 0x00000000
 Entry Point:  0x00000000
NOTE: for embedded systems where boot time is critical you can trade
speed for memory and install an UNCOMPRESSED image instead: this
needs more space in Flash, but boots much faster since it does not
need to be uncompressed:
 -> gunzip /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux.gz
 -> tools/mkimage -n '2.4.4 kernel for TQM850L' \
 > -A ppc -O linux -T kernel -C none -a 0 -e 0 \
 > -d /opt/elsk/ppc_8xx/usr/src/linux-2.4.4/arch/ppc/coffboot/vmlinux \
 > examples/uImage.TQM850L-uncompressed
 Image Name:   2.4.4 kernel for TQM850L
 Created:      Wed Jul 19 02:34:59 2000
 Image Type:   PowerPC Linux Kernel Image (uncompressed)
 Data Size:    792160 Bytes = 773.59 kB = 0.76 MB
 Load Address: 0x00000000
 Entry Point:  0x00000000


Similar you can build U-Boot images from a 'ramdisk.image.gz' file
when your kernel is intended to use an initial ramdisk:
 -> tools/mkimage -n 'Simple Ramdisk Image' \
 > -A ppc -O linux -T ramdisk -C gzip \
 > -d /LinuxPPC/images/SIMPLE-ramdisk.image.gz examples/simple-initrd
 Image Name:   Simple Ramdisk Image
 Created:      Wed Jan 12 14:01:50 2000
 Image Type:   PowerPC Linux RAMDisk Image (gzip compressed)
 Data Size:    566530 Bytes = 553.25 kB = 0.54 MB
 Load Address: 0x00000000
 Entry Point:  0x00000000
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值