@leaveye
2017-11-27T02:13:01.000000Z
字数 2278
阅读 903
w1302
enter work dir
cd ~/sd_files/20160331/
set argument for burn disk.
edit burn.config
file to have these lines:
# device node root name, to be partitioned
device=/dev/sdc
# directory where system automounts the partitions into
mountroot=/media
# tarballs to be installed
BOOT=repack-boot-20160331.tgz
ROOTFS=repack-rootfs-20160331.tgz
./burn-stage01-newcardonly
./burn-stage02-rewritecard
./burn-stage02-rewritecard
This code is for demo only !
# device node root name, to be partitioned
device=/dev/sdc
# directory where system automounts the partitions into
mountroot=/media
# tarballs to be installed
BOOT=repack-boot-20160331.tgz
ROOTFS=repack-rootfs-20160331.tgz
#ROOTFS=repack-rootfs160-20160331.tgz
#!/bin/bash
# reference command:
# ./format_sd.sh --device /dev/sdc --sdk /home/dev/ti-ezsdk_dm816x-evm_5_05_02_00
{ test -r burn.config && . ./burn.config; } ||
{ echo 'you need file "burn.config"'; exit 1; }
test -b "$device" ||
{ echo 'illegal "burn.config": no device specified'; exit 1; }
unmount() {
for i in `ls -1 $device?`; do
echo "unmounting '$i'"
umount $i 2>/dev/null
done
}
partition() {
# get the partition information.
total_size=`fdisk -l $device | grep Disk | awk '{print $5}'`
total_cyln=`echo $total_size/255/63/512 | bc`
# default number of cylinder for first parition
pc1=5
# do partition
{
echo ,$pc1,0x0C,*
echo ,,,-
} |
sfdisk -D -H 255 -S 63 -C $total_cyln $device
}
format() {
mkfs.vfat -F 32 -n BOOT ${device}1
mkfs.ext3 -j -L ROOTFS ${device}2
}
remount() {
mkdir -p /media/BOOT
mount ${device}1 /media/BOOT
mkdir -p /media/ROOTFS
mount ${device}2 /media/ROOTFS
}
unmount
erase0
partition
format
remount
#!/bin/bash
{ test -r burn.config && . ./burn.config; } ||
{ echo 'you need file "burn.config"'; exit 1; }
test -b "$device" ||
{ echo 'illegal "burn.config": no device specified'; exit 1; }
burn() {
SRC="$(eval "echo \"\$$1\"")"
DST="$mountroot/$1"
test -r "$SRC" || { echo "burn $1: no $SRC found"; return 1; }
test -d "$DST" || { echo "burn $1: no $DST found"; return 1; }
shift
case "$SRC" in
*.tar) opt=;;
*.tar.gz|*.tgz) opt=-z;;
*.tar.bz2) opt=-j;;
*) ;;
esac
pv -N "burn '$DST'" "$SRC" | {
( cd "$DST" && rm -rf * >/dev/null 2>&1; )
sudo tar -C "$DST" --no-same-owner $opt $* -x
}
return $?
}
{
echo '==== Round 1 ===='
burn BOOT &&
burn ROOTFS
} &&
{
echo '==== Round 2 ===='
burn BOOT &&
burn ROOTFS
} &&
echo '==== all DONE ===='