-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathremote_uboot_write_sd
executable file
·57 lines (40 loc) · 988 Bytes
/
remote_uboot_write_sd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
## hyphop ##
#= u-boot write to SD via ssh
[ $HOST] || HOST=root@vimu
UPATH=../../fenix/u-boot/fip/_tmp
UNAME=u-boot.bin.sd.bin
UPATH=$(dirname $0)/../share
UNAME=u-boot.sd.bin
[ -f "$1" ] && UBOOT="$1"
[ $DEV ] || DEV=mmcblk1
[ $UBOOT ] || {
for UBOOT in $UNAME $UPATH/$UNAME ; do
[ -f $UBOOT ] && break
done
}
RDEV=/dev/$DEV
[ -f "$UBOOT" ] || {
echo "[e] $UBOOT not found">&2
exit 1
}
grep -q "sd/emmc" $UBOOT || {
echo "[e] $UBOOT signature not found">&2
exit 1
}
echo "[w] $UBOOT > $HOST:$RDEV write $(stat -L -c%s $UBOOT) bytes">&2
scp $UBOOT $HOST:/tmp && {
echo "
echo SSH_UBOOT_WRITE
cat /sys/class/block/$DEV/device/name
[ -b "$RDEV" ] || {
echo \"[i] $RDEV not find / insert sd card plz\"
exit 1
}
echo \"[i] wait 2 sec before write to $HOST:$RDEV\"
sleep 2
dd of=/dev/$DEV conv=fsync,notrunc bs=444 count=1 if=/tmp/$UNAME
dd of=/dev/$DEV conv=fsync,notrunc bs=512 skip=1 seek=1 if=/tmp/$UNAME
echo DONE
" | ssh $HOST
}