forked from DHDAXCW/build-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mk_uboot.sh
executable file
·150 lines (129 loc) · 3.19 KB
/
mk_uboot.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
#!/bin/bash
WORKSPACE_PATH=${PWD}
UBOOT_SRC="${WORKSPACE_PATH}/uboot"
SCRIPT_NAME=${0##*/}
# SCRIPT_PATH=`S=\`readlink "$0"\`; [ -z "$S" ] && S=$0; dirname $S`
SCRIPT_PATH=$(dirname $(readlink -f $0))
source ${SCRIPT_PATH}/common.sh
init() {
if [ ! -e "${UBOOT_SRC}" ]; then
echo "Please link the uboot source directory to 'uboot'."
exit 1
fi
ENV_FILE="${SCRIPT_PATH}/env/${SCRIPT_NAME}"
source ${ENV_FILE}
HOST_ARCH=$(uname -m)
# Common Variable
export PATH="${PATH}:${TOOLCHAIN_PATH}/${TOOLCHAIN_NAME}/bin"
if [ "${ARM_TOOLCHAIN_NAME}" != "" ]; then
export PATH="$PATH:${TOOLCHAIN_PATH}/${ARM_TOOLCHAIN_NAME}/bin"
fi
BUILD_PATH="${WORKSPACE_PATH}/.build_uboot"
BUILD_ARGS="-j$(nproc) O=${BUILD_PATH}"
if [ "${ATF_PLAT}" != "" ]; then
ATF_SRC="${WORKSPACE_PATH}/arm-trusted-firmware"
ATF_BIN=${ATF_SRC}/build/${ATF_PLAT}/release/bl31/bl31.elf
if [ -e "${ATF_BIN}" ]; then
export BL31=${ATF_BIN}
fi
fi
cd "${UBOOT_SRC}"
UBOOT_VERSION=$(make ubootversion)
}
build_info() {
echo "================ Build Info ================"
echo -e "BOARD_NAME: ${BOARD_NAME}"
echo -e "CPU_INFO: ${CPU_INFO}"
echo -e "ARCH: ${ARCH}"
echo -e "UBOOT_VERSION: ${UBOOT_VERSION}"
echo -e "DEFCONFIG: ${DEFCONFIG}"
echo -e "ATF_PLAT: ${ATF_PLAT}"
echo -e "ATF(BL31)" ${BL31}
echo -e "BUILD_ARGS: ${BUILD_ARGS}"
echo -e "CROSS_COMPILE: ${CROSS_COMPILE}"
}
process() {
echo "process"
}
build_atf() {
if [ "${ATF_PLAT}" == "" ]; then
echo "ATF_PLAT not set"
return
fi
if [ ! -e "${ATF_SRC}" ]; then
git clone https://github.com/ARM-software/arm-trusted-firmware.git ${ATF_SRC}
fi
cd ${ATF_SRC}
unset BL31
make clean
make distclean
git pull
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=${ATF_PLAT}
}
build_probe() {
# link dts
if [ "${DT_FILE}" != "" ]; then
DT_PATH="${SCRIPT_PATH}/boot/dts/${VENDOR}/mainline/${DT_FILE}"
DT_PATH_LINK="${UBOOT_SRC}/arch/arm/dts/"
check_path DTS "${DT_PATH}.dts"
ln -s -f "${DT_PATH}.dts" ${DT_PATH_LINK}
if [ -e "${DT_PATH}-u-boot.dtsi" ]; then
ln -s -f "${DT_PATH}-u-boot.dtsi" ${DT_PATH_LINK}
fi
fi
# link defconfig
if [ "${DEFCONFIG}" != "" ]; then
DEFCONFIG_PATH="${SCRIPT_PATH}/u-boot/${VENDOR}/u-boot-${UBOOT_VERSION}/${DEFCONFIG}"
check_path "DEFCONFIG" "${DEFCONFIG_PATH}"
ln -s -f ${DEFCONFIG_PATH} "${UBOOT_SRC}/configs/"
fi
}
show_menu() {
cd "${UBOOT_SRC}"
echo "================ Menu Option ================"
echo -e "\t[0]. Build ATF(arm64 only)"
echo -e "\t[1]. Use Default Config"
echo -e "\t[2]. Menu Config"
echo -e "\t[3]. Build U-boot"
echo -e "\t[4]. Process"
echo -e "\t[5]. Clean"
read -p "Please Select: >> " OPT
case ${OPT} in
"0")
build_atf
;;
"1")
build_probe
make ${DEFCONFIG} ${BUILD_ARGS}
;;
"2")
make menuconfig ${BUILD_ARGS}
;;
"3")
TIME="Total Time: %E\tExit:%x" time make ${BUILD_ARGS}
;;
"4")
process
;;
"5")
make clean ${BUILD_ARGS}
;;
"mrproper")
# Hide Option
make mrproper
;;
"0")
# Hide Option
echo "apt install flex bison time bc kmod u-boot-tools libncurses5-dev libgmp-dev libmpc-dev libssl-dev"
;;
*)
echo "Not Support Option: [${OPT}]"
;;
esac
}
main() {
init
build_info
show_menu
}
main