免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1306 | 回复: 0
打印 上一主题 下一主题

Building uImage [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-07 15:10 |只看该作者 |倒序浏览

                    u-boot是不支持zImage等linux内核格式的,所以你要用u-boot来引导linux的话,你就要建立一个u-boot能识别的linux内核格式来。u-boot有自己可引导的内核的格式---uImage,我不知道它确确的叫法,没有具体去查过,我这里先就叫它uImage吧。在linux 2.6以上的内核中,你可以用make uImage这样的语句去直接生成它,但是你是用linux 2.4或者更早的linux的话,你就要自己手动去生成它了。
生成uImage格式的办法很简单,只有几步而已:
1.生成linux.bin,纯二进制的linux内核,用以下命令:(这里假定你已经知道如何生成内核)
arm-linux-objcopy –O binary -R .note –R .comment -S vmlinux linux.bin
2.压缩内核
gzip -9 linux.bin
3.生成uImage格式内核(假定你会并且已经u-boot,mkimage就在$uboot/tools中)
mkimage –A arm –O linux –T kernel –C gzip –a 0x30008000 –e 0x30008000 –n “Linux Kernel Image” –d linux.bin.gz uImage
以上只是一个简单的过程,照着做的话应该是能够成功的。你还可以参照u-boot根目录下的README文件,在它里面有相应的描述。下面这段话来自u-boot官方的README:
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
   
    看到这么长的E文,除非你的英文很好,不然的话就像我一样晕菜了!^-^
   
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/49576/showart_680004.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP