Chinaunix首页 | 论坛 | 博客
  • 博客访问: 11433
  • 博文数量: 11
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-21 14:28
文章分类

全部博文(11)

文章存档

2015年(11)

我的朋友
最近访客

分类: LINUX

2015-08-26 17:11:52

#
# Copyright (C) 2010 Samsung Electronics Co., Ltd.
#               /> #
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
####################################
reader_type1="/dev/sdb"
reader_type2="/dev/mmcblk0"
#-z 检测字符串长度是否为0,为0返回 true。如果没有$1,失败退出
if [ -z $1 ]
then
    echo "usage: ./nand_fusing.sh <SD Reader's device file>"
    exit 0
fi
#如果 $1 参数为"/dev/sdb",设置变量partition="/dev/sdb1,2,3,4"
if [ $1 = $reader_type1 ]
then 
    partition1="$11"
    partition2="$12"
    partition3="$13"
    partition4="$14"
#如果 $1 参数为"/dev/mmcblk0",设置变量partition
elif [ $1 = $reader_type2 ]
then 
    partition1="$1p1"
    partition2="$1p2"
    partition3="$1p3"
    partition4="$1p4"
#否则,不支持的SD卡类型
else
    echo "Unsupported SD reader"
    exit 0
fi
#检测 $1 是否是块设备文件,是返回1
if [ -b $1 ]
then
    echo "$1 reader is identified."
else
    echo "$1 is NOT identified."
    exit 0
fi


#执行sd_fdisk 分区,用dd写入数据到"/dev/sdb",然后删除sd_mbr.dat
# make partition
echo "make sd card partition"
echo "./sd_fdisk $1" 
./sd_fdisk $1 
dd iflag=dsync oflag=dsync if=sd_mbr.dat of=$1 
rm sd_mbr.dat
 
#格式化,"/dev/sdb1,2,3,4",先解除挂载设备
# format
umount $partition1 2> /dev/null
umount $partition2 2> /dev/null
umount $partition3 2> /dev/null
umount $partition4 2> /dev/null
#运行mkfs.vafat fat32系统,/dev/sdb1
echo "mkfs.vfat -F 32 $partition1"
mkfs.vfat -F 32 $partition1


#echo "mkfs.ext2 $partition2"
#mkfs.ext2 $partition2  


#echo "mkfs.ext2 $partition3"
#mkfs.ext2 $partition3  


#echo "mkfs.ext2 $partition4"
#mkfs.ext2 $partition4  


####################################
# mount 
#umount /media/sd 2> /dev/null
#mkdir -p /media/sd
#echo "mount -t vfat $partition1 /media/sd"
#mount -t vfat $partition1 /media/sd


####################################
#<BL1 fusing>
bl1_position=1
uboot_position=49 
# dd写入8k的BL1 到 1 个字节位置 
echo "BL1 fusing"
./mkbl1 ./uboot.bin SD-bl1-8k.bin 8192
dd iflag=dsync oflag=dsync if=SD-bl1-8k.bin of=$1 seek=$bl1_position
rm SD-bl1-8k.bin


# dd写入u-boot 到 49 个字节的位置
#<u-boot fusing>
echo "u-boot fusing"
dd iflag=dsync oflag=dsync if=./uboot.bin of=$1 seek=$uboot_position


####################################
#<Message Display>
echo "U-boot image is fused successfully."
echo "Eject SD card and insert it again."

阅读(733) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~