我参考了TI官网am335版块提供的create-sdcard.sh脚本,部分源码如下:
# find the avaible SD cards
echo " "
echo "Availible Drives to write images to: "
echo " "
ROOTDRIVE=`mount | grep 'on / ' | awk {'print $1'} | cut -c6-8`
echo "# major minor size name "
cat /proc/partitions | grep -v $ROOTDRIVE | grep '\' | grep -n ''
echo " "
ENTERCORRECTLY=0
while [ $ENTERCORRECTLY -ne 1 ]
do
read -p 'Enter Device Number: ' DEVICEDRIVENUMBER
echo " "
DEVICEDRIVENAME=`cat /proc/partitions | grep -v 'sda' | grep
'\' | grep -n '' | grep "${DEVICEDRIVENUMBER}:" | awk
'{print $5}'`
DRIVE=/dev/$DEVICEDRIVENAME
DEVICESIZE=`cat /proc/partitions | grep -v 'sda' | grep
'\' | grep -n '' | grep "${DEVICEDRIVENUMBER}:" | awk
'{print $4}'`
if [ -n "$DEVICEDRIVENAME" ]
then
ENTERCORRECTLY=1
else
echo "Invalid selection"
fi
echo ""
done
echo "$DEVICEDRIVENAME was selected"
#Check the size of disk to make sure its under 16GB
if [ $DEVICESIZE -gt 17000000 ] ; then
cat << EOM
################################################################################
**********WARNING**********
Selected Device is greater then 16GB
Continuing past this point will erase data from device
Double check that this is the correct SD Card
################################################################################
EOM
我们只需要取总块数,没必要那么麻烦,只需:
cat /proc/partitions | grep -v 'sda' | grep '\' | grep -n '' | grep "1:" | awk '{print $4}'
15558144
即可得到扇区数,我的16G卡是15558144。接下来就可要用dd命令烧写u-boot到指定位置(2416、6410要求在u-boot必须放在
sd卡末尾的一段区域,具体请看cpu对应的irom启动应用笔记)。需要注意的是,上述代码只针对SD卡挂载在sdb路径下,如果你的挂载路径不一样,
需要修改一下。
阅读(1995) | 评论(0) | 转发(0) |