.. | .. |
---|
2 | 2 | |
---|
3 | 3 | BOARD_CONFIG_DIR=longan/device/config/chips/ |
---|
4 | 4 | BOARD_CONFIG_FILE=longan/device/.BoardConfig.mk |
---|
| 5 | +DTS_DIR=$BOARD_CONFIG_DIR/a133/configs/c3 |
---|
5 | 6 | |
---|
6 | | -function build_lunch() |
---|
7 | | -{ |
---|
8 | | - TARGET_BOARD_PATH_ARRAY=( $(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" ) ) |
---|
9 | | - TARGET_BOARD_ARRAY=( $(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" | sed 's#.*/##' | sort) ) |
---|
10 | | - echo "======you are building a133 android======" |
---|
11 | | - echo "${TARGET_BOARD_ARRAY[@]}" |xargs -n 1 | sed "=" | sed "N;s/\n/. /" |
---|
| 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 | +) |
---|
12 | 15 | |
---|
13 | | - while true; do |
---|
14 | | - read -p "which board would you like (1-${#TARGET_BOARD_ARRAY[@]}): " INDEX |
---|
15 | | - if [[ "$INDEX" =~ ^[0-9]+$ ]] && ((INDEX >= 1 && INDEX <= ${#TARGET_BOARD_ARRAY[@]})); then |
---|
16 | | - INDEX=$(($INDEX - 1)) |
---|
17 | | - BUILD_TARGET_BOARD="${TARGET_BOARD_PATH_ARRAY[$INDEX]}" |
---|
| 16 | +function build_lunch() { |
---|
| 17 | + TARGET_BOARD_PATH_ARRAY=($(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" | sort)) |
---|
| 18 | + TARGET_BOARD_ARRAY=($(find $BOARD_CONFIG_DIR -name "BoardConfig-a133*.mk" | sed 's#.*/##' | sort)) |
---|
| 19 | + echo "======you are building a133 android======" |
---|
| 20 | + echo "${TARGET_BOARD_ARRAY[@]}" | xargs -n 1 | sed "=" | sed "N;s/\n/. /" |
---|
18 | 21 | |
---|
19 | | - break |
---|
20 | | - else |
---|
21 | | - echo "Invalid input. Please enter a number between 1 and ${#TARGET_BOARD_ARRAY[@]}." |
---|
22 | | - fi |
---|
23 | | - done |
---|
| 22 | + while true; do |
---|
| 23 | + read -p "which board would you like (1-${#TARGET_BOARD_ARRAY[@]}): " INDEX |
---|
| 24 | + if [[ "$INDEX" =~ ^[0-9]+$ ]] && ((INDEX >= 1 && INDEX <= ${#TARGET_BOARD_ARRAY[@]})); then |
---|
| 25 | + INDEX=$(($INDEX - 1)) |
---|
| 26 | + BUILD_TARGET_BOARD="${TARGET_BOARD_PATH_ARRAY[$INDEX]}" |
---|
24 | 27 | |
---|
25 | | - cp -f $BUILD_TARGET_BOARD $BOARD_CONFIG_FILE |
---|
| 28 | + break |
---|
| 29 | + else |
---|
| 30 | + echo "Invalid input. Please enter a number between 1 and ${#TARGET_BOARD_ARRAY[@]}." |
---|
| 31 | + fi |
---|
| 32 | + done |
---|
26 | 33 | |
---|
27 | | - echo -e "build target board configuration: $BUILD_TARGET_BOARD\n" |
---|
28 | | - #select partition table |
---|
29 | | - source $BOARD_CONFIG_FILE |
---|
30 | | - echo "you board is ${DTS_NAME}" |
---|
| 34 | + cp -f $BUILD_TARGET_BOARD $BOARD_CONFIG_FILE |
---|
31 | 35 | |
---|
32 | | - source $BOARD_CONFIG_FILE |
---|
33 | | - longan/build/mkcommon.sh autoconfig -i a133 -o android -b c3 |
---|
| 36 | + echo -e "build target board configuration: $BUILD_TARGET_BOARD\n" |
---|
| 37 | + #select partition table |
---|
| 38 | + source $BOARD_CONFIG_FILE |
---|
| 39 | + echo "you board is ${DTS_NAME}" |
---|
| 40 | + |
---|
| 41 | + ln -rsf "${DTS_DIR}/${DTS_NAME}.fex" "${DTS_DIR}/sys_config.fex" |
---|
| 42 | + echo "Start clean kerenl" |
---|
| 43 | + |
---|
| 44 | + cd longan/kernel/linux-4.9 && make clean -j32 && cd - |
---|
| 45 | + source $BOARD_CONFIG_FILE |
---|
| 46 | + longan/build/mkcommon.sh autoconfig -i a133 -o android -b c3 |
---|
34 | 47 | } |
---|
35 | 48 | |
---|
36 | | -if [ "x$1" == "xlunch" ];then |
---|
37 | | - build_lunch && exit 0 |
---|
38 | | -else |
---|
39 | | - source $BOARD_CONFIG_FILE |
---|
40 | | - if [ x"$1" == "xuboot" ] || [ x"$1" == "xu" ] || [ x"$1" == "x" ] ;then |
---|
41 | | - echo "Start build uboot" |
---|
42 | | - cd longan/brandy/brandy-2.0 && ./build.sh -p sun50iw10p1 && cd - |
---|
43 | | - if [ $? -eq 0 ]; then |
---|
44 | | - echo "Build uboot ok!" |
---|
45 | | - else |
---|
46 | | - echo "Build uboot failed!" |
---|
47 | | - exit 1 |
---|
| 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 |
---|
48 | 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 | + |
---|
| 75 | + source $BOARD_CONFIG_FILE |
---|
| 76 | + |
---|
| 77 | + if [ x"$1" == "xuboot" ] || [ x"$1" == "xu" ] || [ x"$1" == "x" ]; then |
---|
| 78 | + echo "Start build uboot" |
---|
| 79 | + cd longan/brandy/brandy-2.0 |
---|
| 80 | + ./build.sh -p sun50iw10p1 |
---|
| 81 | + if [ $? -eq 0 ]; then |
---|
| 82 | + echo "Build uboot ok!" |
---|
| 83 | + else |
---|
| 84 | + echo "Build uboot failed!" |
---|
| 85 | + cd - |
---|
| 86 | + exit 1 |
---|
| 87 | + fi |
---|
| 88 | + cd - |
---|
49 | 89 | fi |
---|
50 | 90 | |
---|
51 | | - if [ x"$1" == "xkernel" ] || [ x"$1" == "xk" ] || [ x"$1" == "x" ] ;then |
---|
52 | | - echo "Start build kernel" |
---|
53 | | - cd longan && ./build.sh autoconfig -o android -i a133 -b c3 && ./build.sh && cd - |
---|
54 | | - if [ $? -eq 0 ]; then |
---|
55 | | - echo "Build kernel ok!" |
---|
56 | | - else |
---|
57 | | - echo "Build kernel failed!" |
---|
58 | | - exit 1 |
---|
59 | | - fi |
---|
| 91 | + if [ x"$1" == "xkernel" ] || [ x"$1" == "xk" ] || [ x"$1" == "x" ]; then |
---|
| 92 | + echo "Start build kernel" |
---|
| 93 | + cd longan |
---|
| 94 | + ./build.sh autoconfig -o android -i a133 -b c3 |
---|
| 95 | + ./build.sh |
---|
| 96 | + if [ $? -eq 0 ]; then |
---|
| 97 | + echo "Build kernel ok!" |
---|
| 98 | + else |
---|
| 99 | + echo "Build kernel failed!" |
---|
| 100 | + cd - |
---|
| 101 | + exit 1 |
---|
| 102 | + fi |
---|
| 103 | + cd - |
---|
60 | 104 | fi |
---|
61 | 105 | |
---|
62 | 106 | # android envsetup |
---|
.. | .. |
---|
66 | 110 | extract-bsp |
---|
67 | 111 | cd - |
---|
68 | 112 | |
---|
69 | | - if [ x"$1" == "xandroid" ] || [ x"$1" == "xa" ] || [ x"$1" == "x" ] ;then |
---|
70 | | - echo "Start build Android" |
---|
71 | | - cd android |
---|
72 | | - make installclean |
---|
73 | | - make BUILD_NUMBER=ido-a133 -j32 |
---|
74 | | - cd - |
---|
| 113 | + if [ x"$1" == "xandroid" ] || [ x"$1" == "xa" ] || [ x"$1" == "x" ]; then |
---|
| 114 | + echo "Start build Android" |
---|
| 115 | + cd android |
---|
| 116 | + make installclean |
---|
| 117 | + make BUILD_NUMBER=ido-a133 -j32 |
---|
| 118 | + if [ $? -eq 0 ]; then |
---|
| 119 | + echo "Build android ok!" |
---|
| 120 | + else |
---|
| 121 | + echo "Build android failed!" |
---|
| 122 | + cd - |
---|
| 123 | + exit 1 |
---|
| 124 | + fi |
---|
| 125 | + cd - |
---|
75 | 126 | fi |
---|
76 | 127 | |
---|
77 | 128 | # pack image |
---|
.. | .. |
---|
80 | 131 | pack |
---|
81 | 132 | cd - |
---|
82 | 133 | |
---|
83 | | -fi |
---|
| 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 | + |
---|
| 161 | +fi |
---|