玩转cubieboard(一)

一、掀起你的盖头来 cubieboard初体验

1、安装交叉编译工具

使用串口查看cubieboard自带系统的启动信息,进入u-boot模式后,输入version命令,查看版本信息,自带系统是由arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2010.09-50) 4.5.1这个版本的交叉编译器编译的。笔者是在ubuntu10.04下进行开发,命令仅供参考。

HELLO! BOOT0 is starting!
boot0 version : 1.5.1
dram size =1024
Succeed in opening nand flash.
Succeed in reading Boot1 file head.
The size of Boot1 is 0x0003c000.
The file stored in 0X00000000 of block 2 is perfect.
Check is correct.
Ready to disable icache.
Succeed in loading Boot1.
Jump to Boot1.
[       0.133] boot1 version : 1.4.0
[       0.133] pmu type = 3
[       0.134] bat vol = 0
[       0.159] axi:ahb:apb=3:2:2
[       0.159] set dcdc2=1400, clock=1008 successed
[       0.161] key
[       0.174] no key found
[       0.174] flash init start
[       0.224] flash init finish
[       0.225] fs init ok
[       0.226] fattype FAT16
[       0.226] fs mount ok
[       0.233] script finish
[       0.234] power finish
[       0.242] BootMain start
[       0.242] 0
[       0.261] key value = 0
[       0.261] recovery key high 6, low 4
[       0.262] unable to find fastboot_key key_max value
[       0.270] test for multi os boot with display
[       0.272] show pic finish
[       0.274] load kernel start
[       0.298] load kernel successed
[       0.298] start address = 0x4a00000

U-Boot 2011.09-rc1 (Nov 26 2012 - 14:01:52) Allwinner Technology 

CPU:   SUNXI Family
Board: A10-EVB
DRAM:  512 MiB
NAND:  3776 MiB
In:    serial
Out:   serial
Err:   serial
--------fastboot partitions--------
-total partitions:11-
-name-        -start-       -size-      
bootloader  : 1000000       1000000     
env         : 2000000       1000000     
boot        : 3000000       2000000     
system      : 5000000       14000000    
data        : 19000000      20000000    
misc        : 39000000      1000000     
recovery    : 3a000000      2000000     
cache       : 3c000000      8000000     
private     : 44000000      1000000     
sysrecovery : 45000000      14000000    
UDISK       : 59000000      93000000    
-----------------------------------
Hit any key to stop autoboot:  0 
sunxi#version

U-Boot 2011.09-rc1 (Nov 26 2012 - 14:01:52) Allwinner Technology 
arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2010.09-50) 4.5.1
GNU ld (Sourcery G++ Lite 2010.09-50) 2.20.51.20100809
sunxi#

arm-none-linux-gnueabi-gcc 4.5.1版本下载地址 https://github.com/Evanok/arm-none-linux-gnueabi

下载并解压后,把交叉编译器文件夹复制到/usr/local 目录下,并修改环境变量,把该编译器路径/usr/local/arm-none-linux-gnueabi-master/bin 添加进/etc/environment,并使环境变量生效。然后,可查看arm-none-linux-gnueabi-gcc的版本号,确保正常使用。

# vim /etc/environment              
# source /etc/environment
# arm-none-linux-gnueabi-gcc –v

2、编译u-boot

u-boot-sunxi下载地址 https://github.com/linux-sunxi/u-boot-sunxi

# git clone git://github.com/linux-sunxi/linux-sunxi.git

解压后进入u-boot-sunxi目录,修改config.mk文件,指定交叉编译工具。

#
# Include the make variables (CC, etc...)
#
# Add by chenshuyi
CROSS_COMPILE=arm-none-linux-gnueabi-
# End add

在board/文件夹下,可查看不同芯片对应的配置,本文使用的开发板的对应配置在文件夹board/allwinner/cubieboard_512/中。回到u-boot-sunxi目录下,编译u-boot。

# make cubieboard_512

3、编译script.bin文件

下载sunxi-tools、sunxi-boards源码。

# git clone git://github.com/linux-sunxi/sunxi-tools.git
# git clone git://github.com/linux-sunxi/sunxi-boards.git

进入sunxi-tools目录,编译源码,得到fex2bin工具。进入sunxi-boards目录,在sysconfig/a10目录下找到cubieboard_512.fex,该文件是cubieboard A10芯片的配置文件。使用fex2bin工具生成script.bin。

# fex2bin cubieboard_512.fex script.bin

4TF卡分区

TF卡也就是micro-SD卡。使用fdisk对TF卡进行分区,分为两个主分区,第一个主分区大小为1M,用于存放bootloader和sunxi-spl.bin。剩下的是第二个主分区。使用m命令查看命令列表,使用n命令新建分区。

# dd if=/dev/zero of=/dev/sdb bs=1M count=1
# sfdisk -R /dev/sdb // 划分情况如下所示 Device Boot Start End Blocks Id System /dev/sdb1 1 1 7502 83 Linux /dev/sdb2 2 1021 7683660 83 Linux

划分完后,使用w命令保存并退出。重启OS,让设置生效。重启后,在dev/目录下多了sdb1和sdb2两个文件。使用mkfs.vfat格式化sdb1为vfat类型,使用mkfs.ext4格式化sdb2为ext4类型。

# mkfs.vfat /dev/sdb1
# mkfs.ext4 /dev/sdb2

5、烧写u-bootlinux

划分完分区后,即可写入u-boot到dev/sdb,首先写入第一阶段bootloader,sunxi-spl.bin,然后是第二阶段bootloader,u-boot.bin。

# dd if=spl/sun-spl.bin of=/dev/sdb bs=1024 seek=8
# dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32

 

posted @ 2013-05-23 09:47  chenshuyi  阅读(2105)  评论(0编辑  收藏  举报