分类: 嵌入式
2010-08-11 18:18:27
嵌入式学习入门 http://blog.chinaunix.net/u3/117680/showart.php?id=2300212
, 文章——>嵌入式学习入门 全面的讲述学习嵌入式linux中的每个步骤
首先 介绍如何将内核写进nand flash:
u-boot# nand erase 0x00030000 0x00100000
u-boot# tftp 0x31000000 zImage
u-boot# nand write 0x31000000 0x00030000 0x00100000
这里 我们有几种方法来实现自引导:
1.采用go的方法:
u-boot# tftp 0x31000000 zImage
u-boot# go 0x31000000
这是直接从内存引导的内核,我们可以将内核写进nand flash 让他自引导:
u-boot# nand erase 0x00030000 0x100000
u-boot# nand write 0x31000000 0x00030000 0x00100000
u-boot# setenv bootcmd nand read 0x30008000 0x00030000 0x00100000\;go 0x30008000
u-boot# saveenv
u-boot# boot
2.采用bootm的方法:
首先 我们需要用u-boot-1.2.0/tools/mkimage 工具来处理一下我们的内核文件zImage;
# mkimage -n 'linux-2.6.14' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008000 -d zImage zImage.img
Image Name: linux-2.6.14
Created: Fri Jan 12 17:14:50 2007
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1262504 Bytes = 1232.91 kB = 1.20 MB
Load Address: 0x30008000
Entry Point: 0x30008000
这里解释一下参数的意义:
-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'
-x ==> set XIP (execute in place)
接着 我们来通过u-boot来将内核zImage.img下载到内存中:
u-boot# tftp 0x31000000 zImage.img
u-boot# bootm 0x31000000
Booting image at 31000000 ...
Image Name: linun-2.6.14
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1263260 Bytes = 1.2 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
OK
Starting kernel ...
Uncompressing Linux.............................................................
下面是自引导的实现:
u-boot# nand erase 0x00030000 0x100000
u-boot# nand write 0x31000000 0x00030000 0x00100000
u-boot# setenv bootcmd nand read 0x31000000 0x30000 0x100000\;bootm 0x31000000
u-boot# saveenv
u-boot# boot
#################################################################
注意:
这里的内核大小是小于1M,如果你的内核大于1M,可以更改size的大小
将0x00100000改成比你的内核更大的值!