a5d27 emmc烧写脚本


DRIVE="/dev/mmcblk0"

flash_boot=no
flash_root=no
flash_root=no

if [ -z $1 ]; then
	echo "no parameter"
	flash_all=yes
fi

while [ "$1" ]; do
	case "$1" in
		-all)
			flash_all=yes
			echo "flash_all"
			;;
		-boot)
			flash_boot=yes
			echo "flash_boot"
			;;
		-root)
			flash_root=yes
			echo "flash_root"
			;;
	esac
	shift
done


flash_all_fun()
{
	dd if=/dev/zero of=$DRIVE bs=4k count=1
	sync
	sync

	SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
	echo $SIZE

#这块代码必须要顶到头
sfdisk $DRIVE << EOF
,65536,,
,,,
EOF


	mkfs.msdos ${DRIVE}p1
	mkfs.ext3 ${DRIVE}p2

	mkdir tmp_boot
	mkdir tmp_rootfs
	mount -t vfat ${DRIVE}p1 tmp_boot
	mount -t ext3 ${DRIVE}p2 tmp_rootfs

	cp BOOT.bin tmp_boot/
	cp u-boot.bin tmp_boot/
	cp zImage tmp_boot/
	cp at91-sama5d2_xplained.dtb tmp_boot/
	tar zxvf rootfs.tar.gz -C tmp_rootfs/
	sync
	sync
	umount ${DRIVE}p1
	umount ${DRIVE}p2
}

flash_boot_fun()
{
	mkdir tmp_boot
	mount -t vfat ${DRIVE}p1 tmp_boot

	cp BOOT.bin tmp_boot/
	cp u-boot.bin tmp_boot/
	cp zImage tmp_boot/
	cp at91-sama5d2_xplained.dtb tmp_boot/
	sync
	sync
	umount ${DRIVE}p1
}

flash_root_fun()
{
	mkfs.ext3 ${DRIVE}p2
	mkdir tmp_rootfs
	mount -t ext3 ${DRIVE}p2 tmp_rootfs

	tar zxvf rootfs.tar.gz -C tmp_rootfs/
	sync
	sync
	umount ${DRIVE}p2
}

if [ "${flash_all}" = yes ]; then
	flash_all_fun || exit 1
fi
if [ "${flash_boot}" = yes ]; then
	flash_boot_fun || exit 1
fi
if [ "${flash_root}" = yes ]; then
	flash_root_fun || exit 1
fi


参数-all将烧写所有文件

参数-boot只烧写bootloader,kernel,dtb文件

参数-root只烧写文件系统


使用sd启动系统后,将需要烧写的文件放到和烧写脚本同一目录下,执行脚本即可

一共需要以下文件

BOOT.bin                                   第1级bootloader

u-boot.bin                                   第2级bootloader

zImage                                       内核

at91-sama5d2_xplained.dtb         设备树

rootfs.tar.gz                                文件系统

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值