-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathu-boot_for_amlogic
executable file
·103 lines (91 loc) · 2.79 KB
/
u-boot_for_amlogic
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
#!/bin/sh
# Usage function
function usage() {
cat >&2 <<EOF
${SH_FILE} is used to compile, generate and burn official U-Boot for Amlogic GXL/GXM SoC
Usage: ${SH_FILE} [a-] -b board [-d] [-g] [-h] [-n]
Where:
-a use official ARM ATF fimrware
-b name of the board to configure
-d compile firmware in debug mode (when allowed)
-g use gxlimg to generate image instead of aml_encrypt_gxl
-h this help page
-n don't compile Amlogic U-Boot (use pre-compiled binary blob)
Currently supported Amlogic boards are: khadas-vim, khadas-vim2, libretech-cc and libretech-ac
EOF
exit 0
}
# Error function
function error() {
echo -e "$@" >&2
exit 1
}
# Variable(s)
typeset -r SH_FILE=${0##*/}
typeset -i ATF_FW=0
typeset -i USE_GXLIMG=0
typeset -i COMPILE_AMLOGIC=1
typeset -i DEBUG=0
typeset GENERATE_OPTS="-c -s"
typeset GENERATE_ATF_OPTS=""
typeset AMLOGIC_U_BOOT_DIR
typeset AMLOGIC_U_BOOT_BOARD
typeset ATF_FW_BOARD
typeset BOARD
# Get options
while getopts "ab:dghn" ARG; do
case ${ARG} in
a) ATF_FW=1
GENERATE_OPTS+=" -a"
;;
b) BOARD=${OPTARG}
;;
d) DEBUG=1
GENERATE_ATF_OPTS+=" -d"
;;
g) USE_GXLIMG=1
GENERATE_OPTS+=" -g"
;;
n) COMPILE_AMLOGIC=0
GENERATE_OPTS+=" -n"
;;
h|*) usage
;;
esac
done
shift $((OPTIND-1))
# Board model must be filled!
[[ -z "${BOARD}" ]] \
&& error "Board model must be filled!"
case ${BOARD} in
khadas-vim)
(( COMPILE_AMLOGIC )) \
&& AMLOGIC_U_BOOT_DIR=~/git/github/u-boot-amlogic:khadas-vims-v2015.01 \
|| AMLOGIC_U_BOOT_DIR=~/firmware/amlogic-binary-blob/vim1
AMLOGIC_U_BOOT_BOARD="kvim"
ATF_FW_BOARD="gxl"
;;
khadas-vim2)
(( COMPILE_AMLOGIC )) \
&& AMLOGIC_U_BOOT_DIR=~/git/github/u-boot-amlogic:khadas-vims-v2015.01 \
|| AMLOGIC_U_BOOT_DIR=~/firmware/amlogic-binary-blob/vim2
AMLOGIC_U_BOOT_BOARD="kvim2"
ATF_FW_BOARD="gxm"
;;
libretech-ac|libretech-cc)
# && AMLOGIC_U_BOOT_DIR=~/git/github/u-boot-amlogic:khadas-vims-v2019.01 \
# AMLOGIC_U_BOOT_BOARD="kvim"
(( COMPILE_AMLOGIC )) \
&& AMLOGIC_U_BOOT_DIR=~/git/github/u-boot-baylibre:${BOARD} \
|| AMLOGIC_U_BOOT_DIR=~/firmware/amlogic-binary-blob/${BOARD}
AMLOGIC_U_BOOT_BOARD=${BOARD//-/_}
ATF_FW_BOARD="gxl"
;;
esac
# Compile official ARM Trusted Firmware if needed
(( ATF_FW )) && compile_mainline_atf -b ${ATF_FW_BOARD} ${GENERATE_ATF_OPTS}
# Compile official U-Boot for Amlogic based board and burn it on /dev/mmcblk0
compile_mainline_u-boot -a aarch64 -b ${BOARD} \
&& generate_gxl_gxm_bootloader -u ${AMLOGIC_U_BOOT_DIR} -b ${AMLOGIC_U_BOOT_BOARD} ${GENERATE_OPTS}
# Clean exit
exit $?