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 文件系统
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 文件系统
相关文章推荐
- Dynamics CRM2016 关闭错误报告弹框提示
- iOS多线程
- js取当前时间年月日
- 单例模式
- PHP类的封装
- vector::resize()
- 记录AS工程R文件,RecyclerView等第三方库不识别的问题
- C语言的变量域和指针
- 推荐!国外程序员整理的Java资源大全
- iOS app自动检测版本更新的功能
- warning: remote HEAD refers to nonexistent ref, unable to checkout.
- Dynamics CRM2016 关闭错误报告弹框提示
- Dynamics CRM2016 关闭错误报告弹框提示
- Dynamics CRM2016 关闭错误报告弹框提示
- DHTML技术演示---selcet的使用(级联技术)
- [置顶] 使用lua语言做高并发限流
- 结构体练习
- 一种简单的差分进化算法(DE)的R语言实现
- climits
- kafka-深入剖析