lichee编译u-boot(Allwinner A80)

在下面这个文件中定制u-boot的命令

brandy/u-boot-2011.09/include/configs/sun9iw1p1.h

添加lib

vi brandy/u-boot-2011.09/Makefile

编译u-boot

cd brandy/u-boot-2011.09/
make sun9iw1p1_config
make

 

产生u-boot文件

ll tools/pack/chips/sun9iw1p1/bin/
boot0_nand_sun9iw1p1.bin
boot0_sdcard_sun9iw1p1.bin
fes1_sun9iw1p1.bin
u-boot-sun9iw1p1.bin

 

uboot相关的config默认是在tools/pack/chips/sun9iw1p1/configs/cubieboard4下

env.cfg                    ---env分区内容,保存uboot命令的一些环境变量

sys_partition.fex   ----用pack脚本打包时的分区布局

sys_config.fex       ----u-boot硬件参数

更新boot0

boot0有两种,从sd卡启动用boot0_sdcard.fex, 从nand启动用boot0_nand.fex

cd ${LICHEE_ROOT}/tools/pack

#copy boot0
cp -fv chips/sun9iw1p1/bin/boot0_nand_sun9iw1p1.bin out/boot0_nand.fex
cp -fv chips/sun9iw1p1/bin/boot0_sdcard_sun9iw1p1.bin out/boot0_sdcard.fex
cp -fv chips/sun9iw1p1/bin/fes1_sun9iw1p1.bin out/fes1.fex

unix2dos out/sys_config.fex

#compile fex file
pctools/linux/mod_update/script out/sys_config.fex

#patch boot0
pctools/linux/mod_update/update_boot0 out/boot0_sdcard.fex out/sys_config.bin SDMMC_CARD
pctools/linux/mod_update/update_boot0 out/boot0_nand.fex out/sys_config.bin NAND
pctools/linux/mod_update/update_fes1 out/fes1.fex out/sys_config.bin

 

把boot0烧写到卡上

dd if=boot0_sdcard.fex of=/dev/sdc bs=1k seek=8
dd if=boot0_sdcard.fex of=/dev/nand bs=1k seek=8

 

更新u-boot

cd ${LICHEE_ROOT}/tool/pack
cp -fv chips/sun9iw1p1/configs/optimus/sys_config.fex out/sys_config.fex
cp -fv chips/sun9iw1p1/bin/u-boot-sun9iw1p1.bin out/u-boot.fex
unix2dos out/sys_config.fex
pctools/linux/mod_update/script out/sys_config.fex
pctools/linux/mod_update/update_uboot out/u-boot.fex out/sys_config.bin

 

把u-boot烧写到卡上

dd if=u-boot.fex of=/dev/sdc bs=1k seek=19096

这样,板子上电启动后就能进到u-boot的命令行界面了,可以从串口上读取并显示

 

接着,再制作一个启动分区,不用太大,注意启始扇区从2048开始,大小的话32MB足够了

Command (m for help): p
Disk /dev/sdc: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-15523839, default 2048): 

Last sector, +sectors or +size{K,M,G,T,P} (2048-15523839, default 15523839): +32M

Created a new partition 1 of type 'Linux' and of size 32 MiB.

Command (m for help): t
Selected partition 1
Partition type (type L to list all types): c
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): p
Disk /dev/sdc: 7.4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start   End Sectors Size Id Type
/dev/sdc1        2048 67583   65536  32M  c W95 FAT32 (LBA)


格式化成fat16,卷标名为boot

mkfs.vfat -n boot /dev/sdc1

把把linux内核uImage放到该分区中就可以从u-boot加载

 

查看env

cubieboard4#printenv 
baudrate=115200
boot_fastboot=fastboot
boot_normal=sunxi_flash read 40007800 boot;bootm 40007800
boot_recovery=sunxi_flash read 40007800 recovery;boota 40007800
bootargs=console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 init=/init loglevel=8 partitions=
bootcmd=run setargs_mmc boot_normal
bootdelay=3
console=ttyS0,115200
ethact=eth0
init=/init
loglevel=8
mmc_root=/dev/mmcblk0p2
nand_root=/dev/nandd
setargs_mmc=setenv bootargs console=${console} root=${mmc_root} rootfstype=ext4 init=${init} loglevel=${loglevel} partitions=${partitions}
setargs_nand=setenv bootargs console=${console} root=${nand_root} rootfstype=ext4 init=${init} loglevel=${loglevel} partitions=${partitions}
stderr=serial
stdin=serial
stdout=serial

Environment size: 767/131068 bytes


操作fat分区

cubieboard4#fatinfo mmc 0:1
Interface:  MMC
  Device 0: Vendor: MID 000003 PSN 2a1d0c8e Rev: PRV 8.0 Prod: PNM SU08G
            Type: Removable Hard Disk
            Capacity: 7580.0 MB = 7.4 GB (15523840 x 512)
Partition 1: Filesystem: FAT16 "boot       "
cubieboard4#fatls mmc 0:1 
  2817256   uimage 

1 file(s), 0 dir(s)

 

加载kernel

fatload mmc 0:1 40007800 uimage
cubieboard4#bootm 40007800 
## Booting kernel from Legacy Image at 40007800 ...
   Image Name:   Linux-3.4.39
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2817192 Bytes = 2.7 MiB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK
[    336.190][mmc]: MMC Device 2 not found
[    336.193][mmc]:  mmc  not find, so not exit
[    336.198]
Starting kernel ...

Uncompressing Linux... done, booting the kernel.

 

你可能感兴趣的:(cubieboard4,cubieboard4,u-boot,lichee,全志A80)