forked from allwincnc/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_fw.sh
executable file
·102 lines (74 loc) · 2.15 KB
/
install_fw.sh
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
#!/bin/bash
source tools.sh
# var list
NAME="ARISC core firmware"
CHIP=""
DST_DIR="/boot"
SRC_DIR="./armbian/fw"
ALL_FILES=("arisc-fw.code" "fixup.cmd" "fixup.scr")
# greetings
log ""
log "--- Installing **${NAME}** -------"
# select a SoC from the arguments list
if [[ $# != 0 ]]; then
for arg in $*; do
case $arg in
"h3") CHIP="h3"; ;;
"H3") CHIP="h3"; ;;
"h5") CHIP="h5"; ;;
"H5") CHIP="h5"; ;;
"h6") CHIP="h6"; ;;
"H6") CHIP="h6"; ;;
esac
done
fi
# if no SoC selected yet
while [[ "${CHIP}" != "1" && "${CHIP}" != "2" && "${CHIP}" != "3" && \
"${CHIP}" != "h3" && "${CHIP}" != "H3" && \
"${CHIP}" != "h5" && "${CHIP}" != "H5" && \
"${CHIP}" != "h6" && "${CHIP}" != "H6" ]]; do
log "Please select your SoC:"
log " 1: Allwinner H3"
log " 2: Allwinner H5"
log " 3: Allwinner H6"
read -p "SoC: " CHIP
done
# set SoC
case "${CHIP}" in
"1") CHIP="h3"; ;;
"2") CHIP="h5"; ;;
"3") CHIP="h6"; ;;
"h3") CHIP="h3"; ;;
"H3") CHIP="h3"; ;;
"h5") CHIP="h5"; ;;
"H5") CHIP="h5"; ;;
"h6") CHIP="h6"; ;;
"H6") CHIP="h6"; ;;
*) CHIP="h3"; ;;
esac
# setup sources folder based on the SoC name
SRC_DIR="${SRC_DIR}/${CHIP}"
# check a folders
if [[ ! -d "${SRC_DIR}" ]]; then
log "!!ERROR!!: Can't find the **${SRC_DIR}** folder [**${0}:${LINENO}**]."
exit 1
fi
if [[ ! -d "${DST_DIR}" ]]; then
log "!!ERROR!!: Can't find the **${DST_DIR}** folder [**${0}:${LINENO}**]."
exit 1
fi
# check/copy files
for file in ${ALL_FILES[*]}; do
if [[ ! -f "${SRC_DIR}/${file}" ]]; then
log "!!ERROR!!: Can't find the **${SRC_DIR}/${file}** file [**${0}:${LINENO}**]."
exit 1
fi
sudo cp -f "${SRC_DIR}/${file}" "${DST_DIR}/${file}"
if [[ ! -f "${DST_DIR}/${file}" ]]; then
log "!!ERROR!!: Can't create the **${DST_DIR}/${file}** file [**${0}:${LINENO}**]."
exit 1
fi
done
log "@@NOTE@@: You must reboot the system to complete the installation"
log "--- **${NAME}** ++successfully installed++ -------"
log ""