-
Notifications
You must be signed in to change notification settings - Fork 1
/
hconfig.sh
executable file
·233 lines (211 loc) · 5.38 KB
/
hconfig.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/bin/bash
COLOR_RED="\033[0;1;31;40m"
COLOR_GREEN="\033[0;1;32;40m"
COLOR_YELLOW="\033[0;1;33;40m"
COLOR_ORIGIN="\033[0m"
ECHO="echo -e"
BUILD_CONFIG=./.config
HARDWARE_CONFIG=./.hwconfig
IS_ASSIGN_DTB=0
. $HARDWARE_CONFIG
XBOOT_CONFIG_ROOT=./boot/xboot/configs
UBOOT_CONFIG_ROOT=./boot/uboot/configs
KERNEL_CONFIG_ROOT=./linux/kernel/arch/arm/configs
DTB_CONFIG_ROOT=./linux/kernel/arch/arm/boot/dts
CHIPC_NAND_KERNEL_CONFIG=sp7021_chipC_emu_initramfs_defconfig
CHIPP_NAND_KERNEL_CONFIG=sp7021_chipP_emu_initramfs_defconfig
CHIPC_EMMC_KERNEL_CONFIG=sp7021_chipC_emu_defconfig
CHIPP_EMMC_KERNEL_CONFIG=sp7021_chipP_emu_defconfig
CHIPC_NOR_KERNEL_CONFIG=sp7021_chipC_emu_initramfs_defconfig
CHIPP_NOR_KERNEL_CONFIG=sp7021_chipP_emu_initramfs_defconfig
BOOT_TYPE=
save_hwconfig()
{
echo "IC_PROJ=pentagram" > $HARDWARE_CONFIG
echo "IC_NAME=sp7021" >> $HARDWARE_CONFIG
echo "IC_VER=${IC_VER}" >> $HARDWARE_CONFIG
echo "CHIP_TYPE=${CHIP_TYPE}" >> $HARDWARE_CONFIG
echo "HW_DTB=${HW_DTB}.dtb" >> $HARDWARE_CONFIG
echo "IS_ASSIGN_DTB=${IS_ASSIGN_DTB}" >> $HARDWARE_CONFIG
}
save_config()
{
echo "CROSS_COMPILE="$CROSS_COMPILE
echo "XBOOT_CONFIG=${XBOOT_CONFIG}" > $BUILD_CONFIG
echo "UBOOT_CONFIG=${UBOOT_CONFIG}" >> $BUILD_CONFIG
echo "KERNEL_CONFIG=${KERNEL_CONFIG}" >> $BUILD_CONFIG
echo "ROOTFS_CONFIG=${ROOTFS_CONFIG}" >> $BUILD_CONFIG
echo "CROSS_COMPILE="$CROSS_COMPILE >> $BUILD_CONFIG
echo "NEED_ISP="$NEED_ISP >> $BUILD_CONFIG
}
chip_nand_config()
{
if [ "$CHIP_TYPE" = "A" ];then
UBOOT_CONFIG=sp7021_nand_c_defconfig
KERNEL_CONFIG=$CHIPC_NAND_KERNEL_CONFIG
else
UBOOT_CONFIG=sp7021_nand_p_defconfig
KERNEL_CONFIG=$CHIPP_NAND_KERNEL_CONFIG
fi
}
chip_emmc_config()
{
if [ "$CHIP_TYPE" = "A" ];then
UBOOT_CONFIG=sp7021_emmc_c_defconfig
KERNEL_CONFIG=$CHIPC_EMMC_KERNEL_CONFIG
else
UBOOT_CONFIG=sp7021_emmc_p_defconfig
KERNEL_CONFIG=$CHIPP_EMMC_KERNEL_CONFIG
fi
}
chip_nor_config()
{
if [ "$CHIP_TYPE" = "A" ];then
UBOOT_CONFIG=sp7021_romter_c_defconfig
KERNEL_CONFIG=$CHIPC_NOR_KERNEL_CONFIG
else
UBOOT_CONFIG=sp7021_romter_p_defconfig
KERNEL_CONFIG=$CHIPP_NOR_KERNEL_CONFIG
fi
NEED_ISP=0
}
change_configs()
{
$ECHO $COLOR_GREEN"IC version ->"$COLOR_ORIGIN
$ECHO $COLOR_YELLOW"[1] A"$COLOR_ORIGIN
$ECHO $COLOR_YELLOW"[2] B"$COLOR_ORIGIN
read -p "current version ["$IC_VER"]: " ic_version_num
if [ ! -z $ic_version_num ]; then
case "$ic_version_num" in
1)
IC_VER=A
;;
2)
IC_VER=B
;;
*)
echo "Error: Unknow config!!"
exit 1
esac
echo $IC_VER" is selected"
fi
$ECHO $COLOR_GREEN"IC chip type ->"$COLOR_ORIGIN
$ECHO $COLOR_YELLOW"[1] A chip"$COLOR_ORIGIN
$ECHO $COLOR_YELLOW"[2] B chip"$COLOR_ORIGIN
read -p "current select ["$CHIP_TYPE"]: " ic_chip_type_num
if [ ! -z $ic_chip_type_num ]; then
case "$ic_chip_type_num" in
1)
CHIP_TYPE=A
;;
2)
CHIP_TYPE=B
;;
*)
echo "Error: Unknow config!!"
exit 1
esac
echo $CHIP_TYPE" is selected"
fi
}
assign_dtb()
{
$ECHO $COLOR_GREEN"Select dtb :"$COLOR_ORIGIN
$ECHO "================================================"
find $DTB_CONFIG_ROOT -maxdepth 1 -mindepth 1 -type f -name "*sp7021*.dts" | sort -i | sed "s,"$DTB_CONFIG_ROOT"/,,g" | nl -b an -w 3 | sed "s,\t,] ,g" | sed "s,^ , [,g" | sed "s/.dts//g"
$ECHO ""
read -p "current dtb ["$HW_DTB"]: " DTB_NUM
if [ ! -z $DTB_NUM ];then
if [ $DTB_NUM -gt 0 ]; then
HW_DTB=$(find $DTB_CONFIG_ROOT -maxdepth 1 -mindepth 1 -type f -name "*sp7021*.dts" | sort -i | sed "s,"$DTB_CONFIG_ROOT"/,,g" | nl -b an -w 3 | sed "s,\t, ,g" | sed "s/.dts//g" | sed -n $DTB_NUM"p" | sed -r "s, +[0-9]* ,,g")
IS_ASSIGN_DTB=1
fi
fi
echo "HW_DTB="$HW_DTB
echo "IS_ASSIGN_DTB="$IS_ASSIGN_DTB
}
BREAK=0
NEW_HW_CONFIG=0
CUR_SELECT=1
if [ -z $IC_NAME ]; then
NEW_HW_CONFIG=1
IC_NAME=sp7021
fi
# while [ $BREAK -eq 0 ]
# do
# $ECHO $COLOR_GREEN"Q628 configs <IC name: "$IC_NAME" , IC ver: "$IC_VER" ,chip: "$CHIP_TYPE">"$COLOR_ORIGIN
# if [ $IS_ASSIGN_DTB -eq 1 ]; then
# $ECHO $COLOR_GREEN"dtb: "$HW_DTB
# fi
# if [ $NEW_HW_CONFIG -eq 1 ]; then
# $ECHO $COLOR_YELLOW"[1] set hw config"$COLOR_ORIGIN
# else
# $ECHO $COLOR_YELLOW"[1] EMMC"$COLOR_ORIGIN
# $ECHO $COLOR_YELLOW"[2] SPI-NAND"$COLOR_ORIGIN
# $ECHO $COLOR_YELLOW"[3] NOR/romter"$COLOR_ORIGIN
# $ECHO $COLOR_YELLOW"[4] change configs"$COLOR_ORIGIN
# $ECHO $COLOR_YELLOW"[5] assign dtb"$COLOR_ORIGIN
# fi
# read -p "select ["$CUR_SELECT"]: " num
# if [ -z $num ];then
# num=$CUR_SELECT
# echo "num0="$num
# fi
# echo "select "$num
# BREAK=1
# if [ $NEW_HW_CONFIG -eq 1 ]; then
# case "$num" in
# 1)
# BREAK=0
# change_configs
# NEW_HW_CONFIG=0
# save_hwconfig
# ;;
# *)
# echo "Error: Unknow config!!"
# esac
# else
# case "$num" in
# 1)
# chip_emmc_config
# NEED_ISP=1
# ;;
# 2)
# chip_nand_config
# NEED_ISP=1
# ;;
# 3)
# chip_nor_config
# NEED_ISP=0
# ;;
# 4)
# BREAK=0
# change_configs
# save_hwconfig
# ;;
# 5)
# BREAK=0
# assign_dtb
# save_hwconfig
# ;;
# *)
# BREAK=0
# echo "Unknow config!!"
# esac
# fi
# done
# if [ "$IC_VER" = "A" ];then
# XBOOT_CONFIG=q628_defconfig
# elif [ "$IC_VER" = "B" ];then
# XBOOT_CONFIG=q628_Rev2_defconfig
# fi
# if [ "$CHIP_TYPE" = "A" ];then
# ROOTFS_CONFIG=v7
# CROSS_COMPILE=$1
# elif [ "$CHIP_TYPE" = "B" ];then
# ROOTFS_CONFIG=v5
# CROSS_COMPILE=$1
# fi
assign_dtb
save_hwconfig
# save_config