笔记 21-5c :彭老师 14章,系统移植,TF启动卡制作,启动卡制作脚本分析

(176)以下是 sd_fusing_exynos4x12.sh 的完整内容,笔记漏掉了一部分,修改后保存不当,不再重复整理了 :

bash 复制代码
#!/bin/sh
#
# 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/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)}'`
#
#$1 值为/dev/sdb,echo打印该字符串通过管道|传递给awk
#awk 提取输入的字符串的第一个字符串,并调用命令print打印substr()执行结果
#substr提取字符串$1 中 1-7个字符串,即/dev/sd
if [ "$param1" = "$reader_type1" ]
then 
    partition1=$1"1"
    partition2=$1"2"
    partition3=$1"3"
    partition4=$1"4"
#对应分区 partition1 /dev/sdb1 ,以此类推
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=1 && \
	echo "$2 image has been fused successfully."

#echo "zImage fusing..."
#dd iflag=dsync oflag=dsync if=../../TC4_Kernel_3.0/arch/arm/boot/zImage of=$1 seek=1024 && \
#	echo "zImage has been fused successfully."

#echo "ramdisk-uboot.img fusing..."
#dd iflag=dsync oflag=dsync if=../../TC4_GB_2.3.4/out/target/product/smdk4212/ramdisk-uboot.img of=$1 seek=9216 && \
#	echo "ramdisk-uboot.img has been fused successfully."

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

(177)

++ 至此,老师带着讲解完了这个重要的 shell 脚本。

(178)

(179)

(180)

谢谢

相关推荐
susplus2 天前
【IMX6ULL Linux系统移植】SD卡分区 | uboot详解
linux·arm·u-boot
剑指offer.6 天前
ARM裸机开发-SPI
arm开发·嵌入式硬件·嵌入式·arm
susplus8 天前
【ARM 裸机开发 (IMX6ULL-mini)】I2C协议详解
嵌入式·arm·i2c
今年下半年10 天前
【运维】windows虚拟机安装arm(aarch64)服务器
运维·windows·arm·虚拟机·aarch64
额额额对了10 天前
SPI通信
linux·c语言·汇编·单片机·嵌入式硬件·arm
一直C11 天前
【ARM嵌入式开发】LCD液晶屏显示原理、色彩模式与显存地址映射详解
lcd·嵌入式·arm·寄存器·cortex-a7
susplus11 天前
【ARM 裸机开发 (IMX6ULL-mini)】PWM 背光调节与 GT9147 多点触摸驱动
lcd·arm·多点触控·pwm背光调节
凉、介12 天前
深入理解 ARM SCP Firmware 的 Event 与 Notification 机制
学习·scp·嵌入式·arm
susplus12 天前
【ARM 裸机开发 (IMX6ULL-mini)】SPI 协议与ADXL345 三轴加速度传感器
arm·spi·adxl345加速度传感器
susplus12 天前
【ARM 裸机开发 (IMX6ULL-mini)】RGB-LCD 驱动与时序详解
arm·rgb_lcd