huangcm
2025-04-26 2868c607307b8de19383692485d1cbe1b64eb94d
build.sh
....@@ -2,6 +2,16 @@
22
33 BOARD_CONFIG_DIR=longan/device/config/chips/
44 BOARD_CONFIG_FILE=longan/device/.BoardConfig.mk
5
+DTS_DIR=$BOARD_CONFIG_DIR/a133/configs/c3
6
+
7
+LCD_DTS=(
8
+ "lcd-lvds-7-1024-600.dtsi"
9
+ "lcd-lvds-21-1920-1080.dtsi"
10
+ "lcd-mipi-10-800-1280-v1.dtsi"
11
+ "lcd-mipi-10-800-1280-v2.dtsi"
12
+ "lcd-mipi-8-800-1280.dtsi"
13
+ "lcd-mipi-5-720-1280.dtsi"
14
+)
515
616 function build_lunch() {
717 TARGET_BOARD_PATH_ARRAY=($(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" | sort))
....@@ -28,16 +38,42 @@
2838 source $BOARD_CONFIG_FILE
2939 echo "you board is ${DTS_NAME}"
3040
41
+ ln -rsf "${DTS_DIR}/${DTS_NAME}.fex" "${DTS_DIR}/sys_config.fex"
3142 echo "Start clean kerenl"
43
+
3244 cd longan/kernel/linux-4.9 && make clean -j32 && cd -
3345 source $BOARD_CONFIG_FILE
3446 longan/build/mkcommon.sh autoconfig -i a133 -o android -b c3
3547 }
3648
37
-if [ "x$1" == "xlunch" ]; then
38
- build_lunch && exit 0
39
-else
49
+function build() {
50
+ DTS_FILE=${DTS_DIR}/${DTS_NAME}.dts
51
+ for config in "${LCD_DTS[@]}"; do
52
+ # 检查未被注释的配置行(支持行首空格)
53
+ if grep -q -E "^[[:space:]]*#include \"${config}\"" "$DTS_FILE"; then
54
+ # 提取 lcd- 之后 .dtsi 之前的内容(去除头尾字符)
55
+ LCD_NAME=$(echo "$config" | sed 's/^lcd-\(.*\)\.dtsi$/\1/')
56
+ break
57
+ fi
58
+ done
59
+
60
+
61
+sed -i -E "
62
+/^[[:space:]]*export LCD_NAME=/ {
63
+ s|^(export LCD_NAME=).*$|\1${LCD_NAME}|
64
+ h
65
+ \$!{x;b};x
66
+ b done
67
+}
68
+
69
+1 i export LCD_NAME=${LCD_NAME}
70
+
71
+:done
72
+" "${BOARD_CONFIG_FILE}"
73
+
74
+
4075 source $BOARD_CONFIG_FILE
76
+
4177 if [ x"$1" == "xuboot" ] || [ x"$1" == "xu" ] || [ x"$1" == "x" ]; then
4278 echo "Start build uboot"
4379 cd longan/brandy/brandy-2.0
....@@ -95,4 +131,31 @@
95131 pack
96132 cd -
97133
134
+
135
+}
136
+
137
+if [ "x$1" == "xlunch" ]; then
138
+ build_lunch && exit 0
139
+else
140
+ source $BOARD_CONFIG_FILE
141
+ if [ "x$1" == "xall" ]; then
142
+ for config in "${LCD_DTS[@]}"; do
143
+ echo "正在切换设备树: $config"
144
+ # Step 1: 注释所有 LCD 相关行(无论原始是否已注释)
145
+ sed -i -E '/#include "lcd-/s|^([[:space:]]*)(//)?|\1//|' "$DTS_DIR/$DTS_NAME.dts"
146
+
147
+ # Step 2: 解除目标配置的注释
148
+ sed -i -E "s|^([[:space:]]*)//#include \"$config\"|\1#include \"$config\"|" "$DTS_DIR/$DTS_NAME.dts"
149
+
150
+ # # 提取 lcd- 之后 .dtsi 之前的内容(去除头尾字符)
151
+ # LCD_DTS_FILE=$(echo "$config" | sed 's/^lcd-\(.*\)\.dtsi$/\1/')
152
+
153
+ # 执行编译
154
+ echo "开始编译..."
155
+ build
156
+ done
157
+ else
158
+ build $@ && exit 0
159
+ fi
160
+
98161 fi