-
Notifications
You must be signed in to change notification settings - Fork 0
/
write-sdcard-boot
executable file
·119 lines (93 loc) · 2.59 KB
/
write-sdcard-boot
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/bash
NOT_SOURCED=0
test "X$(basename -- "$0")" = "Xwrite-sdcard-boot" && NOT_SOURCED=1
if [ $NOT_SOURCED = 1 ]; then
echo
echo "$(tput setaf 2)""Please source the script: source install-mix6000-linux""$(tput sgr 0)"
echo
exit 1
fi
echo
echo "$(tput setaf 2)""Please enter your sudo password:""$(tput sgr 0)"
sudo -p "" -v
CPWD=`pwd`
USERN=`whoami`
#Ubuntu mount paths differ
LSBVERSION=$(lsb_release -r)
VERION14=$(echo "$LSBVERSION" | awk '{if ($2 >= 14.04) print 1; else print 0}')
if [ $VERION14 -eq 1 ]; then
BOOT_PATH="/media/$USERN/BOOT"
FS_PATH="/media/$USERN/FS"
echo
echo "Ubuntu >=14.04 mount paths"
echo
else
BOOT_PATH="/media/BOOT"
FS_PATH="/media/FS"
echo
echo "Ubuntu <14.04 mount paths"
echo
fi
cd $CPWD/oe/deploy
cd $(ls | grep libc)
cd $(ls | grep image)
cd $(ls | grep sam)
OE_DEPLOY=`pwd`
SDCARD_DEV="mmcblk0"
read -p "Please reinsert the SDCARD (Remove and Insert to force update), then press enter"
echo
if [ ! -d $BOOT_PATH ]; then
echo
echo "$(tput setaf 2)""BOOT partition not found under $BOOT_PATH""$(tput sgr 0)"
echo
echo "$(tput setaf 2)""Run: source sdcard-format""$(tput sgr 0)"
echo
cd $CPWD
return
fi
echo
echo "$(tput setaf 2)""Reformatting boot partition on SDCARD...""$(tput sgr 0)"
echo
sudo umount $BOOT_PATH
sudo mkfs.msdos -F 32 /dev/${SDCARD_DEV}p1 -n BOOT
sync
read -p "Please reinsert the SDCARD (Remove and Insert to force update), then press enter"
if [ ! -d $BOOT_PATH ]; then
echo
echo "$(tput setaf 2)""Filesystem (FS) partition not found under $FS_PATH""$(tput sgr 0)"
echo
echo "$(tput setaf 2)""Run: source sdcard-format""$(tput sgr 0)"
echo
cd $CPWD
return
fi
echo
echo "$(tput setaf 2)""Copying files:""$(tput sgr 0)"
echo
cd $OE_DEPLOY
BOOT_BIN="$(ls | grep sdcard)"
echo "$(tput setaf 2)""$BOOT_BIN --> BOOT.BIN""$(tput sgr 0)"
sudo cp $BOOT_BIN $BOOT_PATH/BOOT.BIN
cd $OE_DEPLOY
UBOOT_BIN="$(ls | grep u-boot.bin)"
echo "$(tput setaf 2)""$UBOOT_BIN --> $UBOOT_BIN""$(tput sgr 0)"
sudo cp $UBOOT_BIN $BOOT_PATH
cd $CPWD/downloads
UBOOT_ENV=uboot.env
echo "$(tput setaf 2)""$UBOOT_ENV --> $UBOOT_ENV""$(tput sgr 0)"
sudo cp $UBOOT_ENV $BOOT_PATH
cd $OE_DEPLOY
UIMAGE=uImage
echo "$(tput setaf 2)""$UIMAGE --> $UIMAGE""$(tput sgr 0)"
sudo cp $UIMAGE $BOOT_PATH
cd $OE_DEPLOY
DTB="$(ls | grep 35ek.dtb)"
echo "$(tput setaf 2)""$DTB --> dtb""$(tput sgr 0)"
sudo cp $DTB $BOOT_PATH/dtb
echo
sync
sudo umount $BOOT_PATH
sudo umount $FS_PATH
echo "$(tput setaf 2)""$(tput bold)""BOOT partition updated. Safe to remove SDCARD." "$(tput sgr 0)"
echo
cd $CPWD