您的位置:首页 > 其它

a5d27 emmc烧写脚本

2016-06-20 15:18 411 查看
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                                文件系统
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: