Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1324496
  • 博文数量: 281
  • 博客积分: 8800
  • 博客等级: 中将
  • 技术积分: 3345
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-17 22:31
文章分类

全部博文(281)

文章存档

2013年(1)

2012年(18)

2011年(16)

2010年(44)

2009年(86)

2008年(41)

2007年(10)

2006年(65)

我的朋友

分类: LINUX

2009-05-31 12:55:08

通常,u-boot为kernel提供一些kernel无法知道的信息,比如ramdisk在RAM中的地址。Kernel也必须为U-boot提供必要的信息,如通过mkimage这个工具(在u-boot代码的tools目录中)可以给zImage添加一个header,也就是使得通常编译的内核zImage添加一个数据头,把添加头后的image通常叫uImage,uImage是可以被U-boot直接引导的内核镜像。那么如何使用mkimage工具而产生uImage的呢?下面将具体介绍mkimage工具的使用:
 
1.首先查看mkimage的命令参数
[root@localhost tools]# ./mkimage
Usage: ./mkimage -l image
          -l ==> list image header information
       ./mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file

[:data_file...] image
          -A ==> set architecture to 'arch'   //用于指定CPU类型,比如ARM
          -O ==> set operating system to 'os'  //用于指定操作系统,比如Linux
          -T ==> set image type to 'type'      //用于指定image类型,比如Kernel
          -C ==> set compression type 'comp'   //指定压缩类型
          -a ==> set load address to 'addr' (hex)  //指定image的载入地址
          -e ==> set entry point to 'ep' (hex)     //内核的入口地址,一般是:image的载入地址+0x40(信息头的大小)
          -n ==> set image name to 'name'          //image在头结构中的命名
          -d ==> use image data from 'datafile'    //无头信息的image文件名
          -x ==> set XIP (execute in place)        //设置执行位置

2.制作添加头的uImage

[root@localhost boot]# ./mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 -n linux-2.6.13 -d zImage uImage
Image Name:   linux-2.6.13
Created:      Sat Dec 20 19:42:38 2008
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    1588584 Bytes = 1551.35 kB = 1.51 MB
Load Address: 0x30008000
Entry Point:  0x30008040
注意:大家可以根据创建的头信息来验证个参数的含义。比如Image Name就是-n选项指定的内容,Load Address就是-a选项指定的内容,Entry Point就是-e选项指定的内容。

3.下载并执行uImage。

u-boot(armzone)=> tftp 30008000 uImage
TFTP from server 192.168.0.3; our IP address is 192.168.0.7
Filename 'uImage'.
Load address: 0x30008000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###################################################
done
Bytes transferred = 1588648 (183da8 hex)
u-boot(armzone)=> bootm
## Booting image at 30008000 ...
   Image Name:   linux-2.6.13
   Created:      2008-12-20  11:42:38 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1588584 Bytes =  1.5 MB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
boot linux

Starting kernel ...

Uncompressing Linux......................................................................................................... done, booting the kernel.

该实验基于QT2410E开发板进行,该开发板具体介绍参考:。

 

 

 

实例:mkfs.jffs2 -r rootfs -o rootfs.jffs2 -e 0x4000 --pad=0x1000000 -s 0x200 -n

mkfs.jffs2: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree
Options:
-p, --pad[=SIZE]        
用16進制來表示所要輸出檔案的大小,也就是root.jffs2的size。
                                       很重要的是, 為了不浪費flash空間, 這個值最好符合flash driver所規劃的區塊大小。
                                       如果不足则使用0xff来填充补满。
-r, -d, --root=DIR      指定要做成image的源資料夾.(默认:当前文件夹)
-s, --pagesize=SIZE     节点页大小(默认: 4KiB)
-e, --eraseblock=SIZE   设定擦除块的大小为(默认: 64KiB)
-c, --cleanmarker=SIZE Size of cleanmarker (default 12)
-m, --compr-mode=MODE   Select compression mode (default: priortiry)
-x, --disable-compressor=COMPRESSOR_NAME
                          Disable a compressor
-X, --enable-compressor=COMPRESSOR_NAME
                          Enable a compressor
-y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
                          Set the priority of a compressor
-L, --list-compressors Show the list of the avaiable compressors
-t, --test-compression Call decompress and compare with the original (for test)
-n, --no-cleanmarkers   指明不添加清楚标记(nand flash 有自己的校检块,存放相关的信息。)
                          如果挂载后会出现类似:
                          CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0
                          的警告,则加上-n 就会消失。
-o, --output=FILE       指定輸出image檔案的文件名.(default: stdout)
-l, --little-endian     指定使用小端格式
-b, --big-endian        指定使用大端格式
-D, --devtable=FILE     Use the named FILE as a device table file
-f, --faketime          Change all file times to '0' for regression testing
-q, --squash            Squash permissions and owners making all files be owned by root
-U, --squash-uids       将所有文件的拥有者设为root用户
-P, --squash-perms      Squash permissions on all files
      --with-xattr        stuff all xattr entries into image
      --with-selinux      stuff only SELinux Labels into jffs2 image
      --with-posix-acl    stuff only POSIX ACL entries into jffs2 image
-h, --help              显示这些文字
-v, --verbose           Verbose operation
-V, --version           显示版本
-i, --incremental=FILE Parse FILE and generate appendage output for it
生成的rootfs.img可通过u-boot直接烧写至nand flash:
              nand erase 0x200000 0x3e00000//擦写
              tftp 0x30000000 rootfs.img//下载
              nand write.jffs2 0x200000 $(filesize)//烧入
阅读(1245) | 评论(0) | 转发(2) |
0

上一篇:hdparm命令

下一篇:u-boot移植步骤详解

给主人留下些什么吧!~~