完成SD卡分区操作后,你可以看到你现在已经有两个分区了假设为sdb1和sdb2。分别格式化成fat和ext3 的方式,然后把kernel和rootfs 放入相应的分区。
下面要详细介绍的是如何把 uboot 放入前面一直提到的保留区域内。利用Linux 系统的dd命令,就可以达到这个目的。具体命令如下所示,注意这个操作需要sudo超级权限。
dd if=./uboot of=/dev/sdb bs=1 count=442
dd if=./uboot of=/dev/sdb bs=512 skip=1 seek=1
其中 if 标识输入文件的名字,也就是说你要烧入的uboot的名字。 of代表输出设备的命名,也就是说将要被烧入的设备名。
经过上述步骤以后,一张带 uboot,kernel和rootfs 的卡片就制作完成了。你只要在uboot启动以后设置对应的bootarg,android的机器人界面应该马上可以看到了。
//将kernel及rootfs移入相应分区
root@ubuntu:~# mount /dev/sdb1 /mnt/fat32 //将1分区挂载到/mnt/fat32下
root@ubuntu:~# cp ./uImage /mnt/fat32 //将kernel拷贝到1区
root@ubuntu:~# umount /dev/sdb1 //卸载
root@ubuntu:~# mount /dev/sdb2 /mnt/ext3 //将2分区挂载到/mnt/ext3下
root@ubuntu:~# cp –r ./root /mnt/ext3 //将root拷贝放入2区
root@ubuntu:~# umount /dev/sdb2 //卸载
root@ubuntu:~#
root@ubuntu:~#
//442-512为SD卡信息等保存区域,不能擦除,否则kernel及rootfs等都找不到。所以烧入//uboot时需要跳过这段区域。
//具体是哪段区域,可以看uboot根目录的mksdcard中指明:
//sudo dd if=${BUILD_DIR}/${BINFILE} of=$1 bs=1 count=442
//sudo dd if=${BUILD_DIR}/${BINFILE} of=$1 bs=512 skip=1 seek=1
root@ubuntu:~# dd if=./u-boot-aml.bin of=/dev/sdb bs=1 count=442
root@ubuntu:~# dd if=./u-boot-aml.bin of=/dev/sdb bs=512 skip=1 seek=1
root@ubuntu:~#
root@ubuntu:~#
//设置uboot相应启动参数
8726M_MID # printenv
bootcmd=nand read 84100000 ${p0start} ${p0size};nand read ${loadaddr} ${normalst
art} ${normalsize};bootm
bootdelay=1
baudrate=115200
bootfile=uImage
loadaddr=0x82000000
testaddr=0x82400000
usbtty=cdc_acm
console=ttyS2,115200n8
mmcargs=setenv bootargs console=${console} boardname=m1_mid
chipname=8726m
machid=2956
bootargs=init=/init console=ttyS0,115200 mem=512M board_ver=v2 decopt=0 hdmitx=v
dacoff,powermode1,unplug_powerdown rootwait logo=osd1,0x84100000,lcd,full
…….
stdin=serial
stdout=serial
stderr=serial
Environment size: 971/8188 bytes
8726M_MID # setenv bootcmd ‘mmcinfo 0; fatload mmc 0 82000000 uImage;bootm’
8726M_MID# setenv bootargs root=/dev/cardblksd2 rw rootfstype=ext3 init=/init console=ttyS0,115200
8726M_MID #
8726M_MID # boot
Partition Map for UNKNOWN device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 316008 2875992 b
2 3192000 647976 83
Device: SDIO Port A
Manufacturer ID: 0
OEM: 0
Name: [1]Tran Speed: 40000000
Rd Block Len: 512
SD version 2.0
High Capacity: No
Capacity: 1967128576
Bus Width: 4-bit
Partition Map for UNKNOWN device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 316008 2875992 b
2 3192000 647976 83
reading uImage
2782077 bytes read
## Booting kernel from Legacy Image at 82000000 ...
Image Name: Linux-2.6.34
Image Type: ARM Linux Kernel Image (lzma compressed)
Data Size: 2782013 Bytes = 2.7 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Using machid 0xb8c from environment
Starting kernel ...
[ 0.000000] Linux version 2.6.34 (root@ubuntu) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #17 Sun Apr 3 00:32:57 PDT 2011
[ 0.000000] CPU: ARMv7 Processor [411fc091] revision 1 (ARMv7), cr=10c53c7f
[ 0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[ 0.000000] Machine: AMLOGIC MESON-M1 8726M SZ
……..
#
#
启动成功。
在uboot中修改相应启动参数重新编译,烧入SD卡相应区域,设置Amlogic Meson M1 8726M板从SD卡启动,启动信息如下:
U-Boot 2010.06-svn1550 (Jan 28 2011 - 11:35:57)
DRAM: 512 MiB
NAND: ID read ad,d7 hy27ubg8t2a page 8192 oob 448 erase size 2097152 BCH16 device
ID read ad,d7 hy27ubg8t2a page 8192 oob 448 erase size 2097152 BCH16 device
4096 MiB
In: serial
Out: serial
Err: serial
KGDB: ready
MMC: SDIO Port A: 0
LCD screen clear!
LCD: 800x480 24bbp
Dcache status 1
Icache status 1
tag = 3 !!!!!!!!!!!!!!!!!!
kernel_args = 0xeaac6099
NORMAL_BOOT...
powerkey: 1
powerkey: 1
powerkey: 1
powerkey: 1
powerkey: 1
powerkey: 1
powerkey: 1
powerkey: 1
powerkey: 1
Power Up!
NAND read: device 0 offset 0x1800000, size 0x800000
8388608 bytes read: OK
LCD backlight on!
get_adc_sample(4): 0x3ff
get_adc_sample(4): 0x3ff
get_adc_sample(4): 0x3ff
get_key(): 0
Normal Start...
Hit any key to stop autoboot: 1
Partition Map for UNKNOWN device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 316008 2875992 b
2 3192000 647976 83
Device: SDIO Port A
Manufacturer ID: 0
OEM: 0
Name: [1]Tran Speed: 40000000
Rd Block Len: 512
SD version 2.0
High Capacity: No
Capacity: 1967128576
Bus Width: 4-bit
Partition Map for UNKNOWN device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 316008 2875992 b
2 3192000 647976 83
reading uImage
2782077 bytes read
## Booting kernel from Legacy Image at 82000000 ...
Image Name: Linux-2.6.34
Image Type: ARM Linux Kernel Image (lzma compressed)
Data Size: 2782013 Bytes = 2.7 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Using machid 0xb8c from environment
Starting kernel ...
…….
#
#
SD卡成功启动。