这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 开源硬件 » 转帖:S5PV210 sd_fusing.sh SD卡镜像制作脚本分析

共3条 1/1 1 跳转至

转帖:S5PV210 sd_fusing.sh SD卡镜像制作脚本分析

助工
2015-02-03 23:06:48     打赏

这里转一个帖!由于SIN210是用S5PV210三星公司Cortex-A8处理器。他们编写一个程序!

执行SD卡引导任务!

#
# Copyright (C) 2010 Samsung Electronics Co., Ltd.
#              http://www.samsung.com/
#
# 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 字符串为"null".就是长度为0.
if [ -z $1 ] //判断输入参数是否为空,为空就显示sd_fusing.sh 脚本文件的作用
then
    echo "usage: ./sd_fusing.sh <SD Reader's device file>"
    exit 0
fi

if [ $1 = $reader_type1 ]// 如果输入参数=reader_type1 也就是等于="/dev/sdb"

then 
    partition1="$11"
    partition2="$12"
    partition3="$13"
    partition4="$14"

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

else     // 如果不是上面两个的参数名字,就提示不支持的SD卡
    echo "Unsupported SD reader"
    exit 0
fi
//[ -b 文件 ] 如果 文件 存在 而且 是一个 块-特殊 文件为真
if [ -b $1 ]              //如何设备/dev/sdb 存在,就提示SD卡识别,否则...
then
    echo "$1 reader is identified."
else
    echo "$1 is NOT identified."
    exit 0
fi

####################################
# make partition
echo "make sd card partition"
echo "./sd_fdisk $1" 
./sd_fdisk $1 // 仔细发现这个sd_fdisk.c里面只是给SD卡里面制作了一个10M的fat
    // 分区,所以导致我们在后面少些system.img 的时候还要在uboot      // 里面执行fdisk -c 0 命令,再次做一次分区,但是不明白为什么要    // 这样做呢,岂不是多此一举?一次性在PC端分好区不是OK了吗?
dd iflag=dsync oflag=dsync if=sd_mbr.dat of=$1 
rm sd_mbr.dat
#对/dev/sdb 设备执行sd_mbr.dat 之后删除sd_mbr.dat 
 
####################################
# format
umount $partition1 2> /dev/null
umount $partition2 2> /dev/null
umount $partition3 2> /dev/null
umount $partition4 2> /dev/null

echo "mkfs.vfat -F 32 $partition1"
mkfs.vfat -F 32 $partition1  // 建立一个fat32 分区

#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

echo "BL1 fusing"
./mkbl1 ../u-boot.bin SD-bl1-8k.bin 8192  #分离出SD-bl1-8k.bin 8K大小
dd iflag=dsync oflag=dsync if=SD-bl1-8k.bin of=$1 seek=$bl1_position
rm SD-bl1-8k.bin
 #写分离出SD-bl1-8k.bin 到SD卡bl1_position位置,然后删除bl1_position

####################################
#<u-boot fusing>
echo "u-boot fusing"
dd iflag=dsync oflag=dsync if=../u-boot.bin of=$1 seek=$uboot_position
#写u-boot.bin 到uboot_position位置

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

总结:这个sd_fusing.sh的目的就是创建一个fat32 分区,然后用dd(一定要创建FAT32 分区才能执行!) 命令把SD-bl1-8k.bin 和u-boot.bin 文件写到/dev/sdb里面去。但是内核是什么关系呢?又是怎么回事呢?




关键词: S5PV210处理器     SD卡     镜像脚本     引导    

专家
2015-02-04 21:08:13     打赏
2楼
收藏了,谢谢楼主分享

助工
2015-02-05 09:38:08     打赏
3楼

共3条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]