1. 生成 sunxi_mbr.fex
需要生成如下1~5这些文件才可以生成
sunxi_mbr.fex
和dlinfo.fex
// 生成 sunxi_mbr.fex 和 dlinfo.fex
$ update_mbr sys_partition.bin 4
(1) 生成 sys_partition.bin
$ busybox unix2dos sys_partition.fex
$ script sys_partition.fex
(2) 生成 boot-resource.fex
$ fsbuild boot-resource.ini split_xxxx.fex // 注意boot-resource.ini文件里面的斜杠方向,可能根据windows或linux平台需要修改调整
(3) 生成env.fex
$ u_boot_env_gen env.cfg env.fex
(4) 生成boot.fex
// linux 编译过程
$ cp -vf arch/arm/boot/Image output/bImage
$ mkbootimg
--kernel output/bImage
--ramdisk output/rootfs.cpio.gz
--board sun8i_arm
--base 0x40000000
--kernel_offset 0x8000
--ramdisk_offset 0x01000000
-o output/boot.img
$ ln -sf boot.img boot.fex
(5) 生成rootfs.fex
$ ln -sf rootfs.ext4 rootfs.fex
不废话了,来个Makefile文件吧
.PHONY: boot0
boot0:
cp /home/rpdzkj/rpa40i/allwinner-boot/boot0-sunxi.bin /home/rpdzkj/rpa40i/allwinner-boot/test/
cp /home/rpdzkj/rpa40i/allwinner-boot/boot0-sunxi.bin /home/rpdzkj/rpa40i/linux/tools/pack/chips/sun8iw11p1/bin/boot0_sdcard_sun8iw11p1.bin
.PHONY: uboot
uboot:
cp /home/rpdzkj/rpa40i/linux/out/sun8iw11p1/linux/common/sunxi.dtb $(CURDIR)/sunxi.fex
./fastdtb sunxi.fex
cp /home/rpdzkj/rpa40i/u-boot-2014.07/u-boot-sun8iw11p1.bin $(CURDIR)/u-boot.fex
./update_uboot_fdt u-boot.fex sunxi.fex u-boot.fex
cp /home/rpdzkj/rpa40i/linux/tools/pack/chips/sun8iw11p1/configs/a40i-p3/sys_config.fex $(CURDIR)/
./script sys_config.fex
./update_uboot u-boot.fex sys_config.bin
cp /home/rpdzkj/rpa40i/linux/tools/pack/chips/sun8iw11p1/configs/default/boot_package.cfg $(CURDIR)/
./dragonsecboot -pack boot_package.cfg
rm -fr u-boot.fex sys_config.fex sys_config.bin sunxi.fex boot_package.cfg
.PHONE: uboot
mbr: boot-resource.fex env.fex boot.fex rootfs.fex sys_partition.bin
./update_mbr sys_partition.bin 4
./mbr_gen sunxi_mbr.fex mymbr
# cp /home/rpdzkj/rpa40i/linux/tools/pack/chips/sun8iw11p1/configs/default/image_linux.cfg $(CURDIR)/image.cfg
# sed -i 's/\\\\/\//g' image.cfg
# sed -i 's/^imagename/;imagename/g' image.cfg
# echo "imagename = sun8iw11p1_linux_a40i-p3_uart0.img" >> image.cfg
# echo "" >> image.cfg
# ./dragon image.cfg sys_partition.fex
# rm -fr sys_partition.bin boot-resource.fex env.fex boot.fex sunxi_mbr.fex dlinfo.fex
sys_partition.bin:
cp /home/rpdzkj/rpa40i/linux/tools/pack/chips/sun8iw11p1/configs/default/sys_partition_linux.fex $(CURDIR)/sys_partition.fex
busybox unix2dos sys_partition.fex
./script sys_partition.fex
# rm -fr sys_partition.fex
boot-resource.fex:
cp /home/rpdzkj/rpa40i/linux/tools/pack/chips/sun8iw11p1/boot-resource/boot-resource.ini $(CURDIR)/
sed -i 's/\\boot-resource/\/boot-resource/g' boot-resource.ini
cp /home/rpdzkj/rpa40i/linux/tools/pack/common/tools/split_xxxx.fex $(CURDIR)/
./fsbuild boot-resource.ini split_xxxx.fex
# rm -fr boot-resource.ini split_xxxx.fex
env.fex:
cp /home/rpdzkj/rpa40i/linux/tools/pack/chips/sun8iw11p1/configs/default/env.cfg $(CURDIR)/
./u_boot_env_gen env.cfg env.fex
# rm -fr env.cfg
boot.fex:
cp /home/rpdzkj/rpa40i/linux/linux-3.10/arch/arm/boot/Image $(CURDIR)/bImage
cp /home/rpdzkj/rpa40i/linux/linux-3.10/output/rootfs.cpio.gz $(CURDIR)/
./mkbootimg \
--kernel bImage \
--ramdisk rootfs.cpio.gz \
--board sun8i_arm \
--base 0x40000000 \
--kernel_offset 0x8000 \
--ramdisk_offset 0x01000000 \
-o boot.fex
rm -fr bImage rootfs.cpio.gz
rootfs.fex:
cp /home/rpdzkj/rpa40i/linux/out/sun8iw11p1/linux/common/rootfs.ext4 $(CURDIR)/rootfs.fex
2. 烧录 sunxi_mbr.fex
将 sunxi_mbr.fex 烧录 到 第 40960
sector位置
$ sudo dd if=./sunxi_mbr.fex of=/dev/sdb bs=512 seek=40960 && sync
3. 烧录 boot.fex (内核)
确定boot.fex的烧录位置:
这里从 sunxi_mbr.fex 里面可以找到boot分区的起始sector是 00 00 D8 00
即:55296,实际的烧录位置需要在55296基础上再加上 sunxi_mbr.fex的偏移,即实际的烧录位置是:55296+40960=96256
$ sudo dd if=./boot.fex of=/dev/sdb bs=512 seek=96256 && sync