【0003】SD卡烧写镜像

2021/9/2 23:11:22

本文主要是介绍【0003】SD卡烧写镜像,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

#!/bin/sh

reader_type1="/dev/sd"
reader_type2="/dev/mmcblk0"

if [ -z $2 ]
then
    echo "usage: ./sd_fusing.sh <SD Reader's device file> <filename>"
    exit 0
fi

param1=`echo "$1" | awk '{print substr($1,1,7)}'`

if [ "$param1" = "$reader_type1" ]
then 
    partition1=$1"1"
    partition2=$1"2"
    partition3=$1"3"
    partition4=$1"4"

elif [ "$1" = "$reader_type2" ]
then 
    partition1=$1"p1"
    partition2=$1"p2"
    partition3=$1"p3"
    partition4=$1"p4"

else
    echo "Unsupported SD reader"
    exit 0
fi

if [ -b $1 ]
then
    echo "$1 reader is identified."
else
    echo "$1 is NOT identified."
    exit 0
fi

####################################
# format
umount $partition1 2> /dev/null
umount $partition2 2> /dev/null
umount $partition3 2> /dev/null
umount $partition4 2> /dev/null

echo "$2 fusing..."
dd iflag=dsync oflag=dsync if=$2 of=$1 seek=1120 && \
	echo "$2 image has been fused successfully."

####################################
#<Message Display>
echo "Eject SD card"


这篇关于【0003】SD卡烧写镜像的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程