forked from friendlyarm/h3_lichee
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen_script.sh
executable file
·110 lines (92 loc) · 2.85 KB
/
gen_script.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
103
104
105
106
107
108
109
110
#!/bin/bash
# usage:
# ./gen_script.sh nanopi_neo
# ./gen_script.sh nanopi_m1
SYS_CONFIG_DIR=./tools/pack/chips/sun8iw7p1/configs/nanopi-h3
DISP_TV_MOD_NONE=-1
DISP_TV_MOD_480I=0
DISP_TV_MOD_576I=1
DISP_TV_MOD_480P=2
DISP_TV_MOD_576P=3
DISP_TV_MOD_720P_50HZ=4
DISP_TV_MOD_720P_60HZ=5
DISP_TV_MOD_1080I_50HZ=6
DISP_TV_MOD_1080I_60HZ=7
DISP_TV_MOD_1080P_24HZ=8
DISP_TV_MOD_1080P_50HZ=9
DISP_TV_MOD_1080P_60HZ=10
function pt_error()
{
echo -e "\033[1;31mERROR: $*\033[0m"
}
function pt_warn()
{
echo -e "\033[1;31mWARN: $*\033[0m"
}
function pt_info()
{
echo -e "\033[1;32mINFO: $*\033[0m"
}
gen_script_for_m1()
{
TARGET_SCRIPT=script-m1-$2.bin
pt_info "generating ${TARGET_SCRIPT}"
SYS_CONFIG=${SYS_CONFIG_DIR}/sys_config.fex
if [ $1 -eq -1 ]; then
sed -i 's/\(^hdmi_used\) = \([0-9]\+\)/\1 = 0/g' ${SYS_CONFIG}
else
sed -i 's/\(^hdmi_used\) = \([0-9]\+\)/\1 = 1/g' ${SYS_CONFIG}
sed -i 's/\(^screen0_output_mode\) = \([0-9]\+\)/\1 = '$1'/g' ${SYS_CONFIG}
fi
./build.sh pack
[ -d ./script ] || mkdir script
cp -fv ./tools/pack/out/sys_config.bin ./script/${TARGET_SCRIPT}
}
gen_script_for_neo()
{
H3_SYS_CONFIG=${SYS_CONFIG_DIR}/boards/sys_config_nanopi_neo.fex
SYS_CONFIG=${SYS_CONFIG_DIR}/sys_config.fex
# backup current sys_config.fex
mv ${SYS_CONFIG} ${SYS_CONFIG_DIR}/boards/sys_config_current.fex
cp ${H3_SYS_CONFIG} ${SYS_CONFIG}
./build.sh pack
[ -d ./script ] || mkdir script
cp -fv ./tools/pack/out/sys_config.bin ./script/script-neo.bin
# restore current sys_config.fex
mv ${SYS_CONFIG_DIR}/boards/sys_config_current.fex ${SYS_CONFIG}
}
gen_script_for_air()
{
H3_SYS_CONFIG=${SYS_CONFIG_DIR}/boards/sys_config_nanopi_air.fex
SYS_CONFIG=${SYS_CONFIG_DIR}/sys_config.fex
# backup current sys_config.fex
mv ${SYS_CONFIG} ${SYS_CONFIG_DIR}/boards/sys_config_current.fex
cp ${H3_SYS_CONFIG} ${SYS_CONFIG}
./build.sh pack
[ -d ./script ] || mkdir script
cp -fv ./tools/pack/out/sys_config.bin ./script/script-air.bin
# restore current sys_config.fex
mv ${SYS_CONFIG_DIR}/boards/sys_config_current.fex ${SYS_CONFIG}
}
if [ $# -ne 1 ]; then
pt_warn "Usage: $0 board[nanopi-m1|nanopi-neo|nanopi-air]"
exit 1
else
BOARD=${1}
pt_info "board=${BOARD}"
fi
if [[ "x${BOARD}" = "xnanopi-m1" ]]; then
gen_script_for_m1 $DISP_TV_MOD_NONE "no-hdmi"
gen_script_for_m1 $DISP_TV_MOD_1080P_50HZ "1080p-50"
gen_script_for_m1 $DISP_TV_MOD_1080P_60HZ "1080p-60"
gen_script_for_m1 $DISP_TV_MOD_720P_50HZ "720p-50"
gen_script_for_m1 $DISP_TV_MOD_720P_60HZ "720p-60"
elif [ "x${BOARD}" = "xnanopi-neo" ]; then
gen_script_for_neo
elif [ "x${BOARD}" = "xnanopi-air" ]; then
gen_script_for_air
else
pt_error "Unsupported board"
exit 1
fi
cp -fv ./tools/pack/out/sys_config.bin ./tools/pack/out/script.bin