.. | .. |
---|
1 | 1 | #!/bin/bash |
---|
2 | 2 | |
---|
3 | | -if [ x"$1" == "xuboot" ] || [ x"$1" == "xu" ] || [ x"$1" == "x" ] ;then |
---|
4 | | - echo "Start build uboot" |
---|
5 | | - cd longan/brandy/brandy-2.0 && ./build.sh -p sun50iw10p1 && cd - |
---|
6 | | - if [ $? -eq 0 ]; then |
---|
7 | | - echo "Build uboot ok!" |
---|
8 | | - else |
---|
9 | | - echo "Build uboot failed!" |
---|
10 | | - exit 1 |
---|
11 | | - fi |
---|
| 3 | +BOARD_CONFIG_DIR=longan/device/config/chips/ |
---|
| 4 | +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 | +) |
---|
| 15 | + |
---|
| 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/. /" |
---|
| 21 | + |
---|
| 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]}" |
---|
| 27 | + |
---|
| 28 | + break |
---|
| 29 | + else |
---|
| 30 | + echo "Invalid input. Please enter a number between 1 and ${#TARGET_BOARD_ARRAY[@]}." |
---|
| 31 | + fi |
---|
| 32 | + done |
---|
| 33 | + |
---|
| 34 | + cp -f $BUILD_TARGET_BOARD $BOARD_CONFIG_FILE |
---|
| 35 | + |
---|
| 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 |
---|
| 47 | +} |
---|
| 48 | + |
---|
| 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 | + |
---|
| 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 - |
---|
| 89 | + fi |
---|
| 90 | + |
---|
| 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 - |
---|
| 104 | + fi |
---|
| 105 | + |
---|
| 106 | + # android envsetup |
---|
| 107 | + cd android |
---|
| 108 | + . ./build/envsetup.sh |
---|
| 109 | + lunch ceres_c3-userdebug |
---|
| 110 | + extract-bsp |
---|
| 111 | + cd - |
---|
| 112 | + |
---|
| 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 - |
---|
| 126 | + fi |
---|
| 127 | + |
---|
| 128 | + # pack image |
---|
| 129 | + echo "Start pack image" |
---|
| 130 | + cd android |
---|
| 131 | + pack |
---|
| 132 | + cd - |
---|
| 133 | + |
---|
| 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 | + |
---|
12 | 161 | fi |
---|
13 | | - |
---|
14 | | -if [ x"$1" == "xkernel" ] || [ x"$1" == "xk" ] || [ x"$1" == "x" ] ;then |
---|
15 | | - echo "Start build kernel" |
---|
16 | | - cd longan && ./build.sh autoconfig -o android -i a133 -b c3 && ./build.sh && cd - |
---|
17 | | - if [ $? -eq 0 ]; then |
---|
18 | | - echo "Build kernel ok!" |
---|
19 | | - else |
---|
20 | | - echo "Build kernel failed!" |
---|
21 | | - exit 1 |
---|
22 | | - fi |
---|
23 | | -fi |
---|
24 | | - |
---|
25 | | -# android envsetup |
---|
26 | | -cd android |
---|
27 | | -. ./build/envsetup.sh |
---|
28 | | -lunch ceres_c3-userdebug |
---|
29 | | -extract-bsp |
---|
30 | | -cd - |
---|
31 | | - |
---|
32 | | -if [ x"$1" == "xandroid" ] || [ x"$1" == "xa" ] || [ x"$1" == "x" ] ;then |
---|
33 | | - echo "Start build Android" |
---|
34 | | - cd android |
---|
35 | | - make installclean |
---|
36 | | - make BUILD_NUMBER=ido-a133 -j32 |
---|
37 | | - cd - |
---|
38 | | -fi |
---|
39 | | - |
---|
40 | | -# pack image |
---|
41 | | -echo "Start pack image" |
---|
42 | | -cd android |
---|
43 | | -pack |
---|
44 | | -cd - |
---|
45 | | - |
---|
46 | | - |
---|