-
Notifications
You must be signed in to change notification settings - Fork 26
/
build-uboot.sh
executable file
·155 lines (118 loc) · 4.58 KB
/
build-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
151
152
153
154
155
#!/bin/bash
export LC_ALL=C
DIR=$PWD
/bin/sh -e "${DIR}/gcc.sh" || { exit 1 ; }
. "${DIR}/.CC"
. "${DIR}/version.sh"
echo "CROSS_COMPILE=${CC}"
if [ ! "${CORES}" ] ; then
CORES=$(($(getconf _NPROCESSORS_ONLN) * 2)) # cores and thread
fi
mkdir -p "${DIR}/deploy/"
build_uboot() {
cd ${DIR}/u-boot
echo "Apply patch"
git apply -v --whitespace=fix ${DIR}/00004-add-u-boot-stm32mp157a-sodimm2-mx.patch || { echo "Error apply patch"; }
echo "============================================"
echo "Start build U-Boot: $(git branch --show-current)"
echo "Board: ${board}"
make ARCH=arm CROSS_COMPILE=${CC} distclean
#make ARCH=arm CROSS_COMPILE=${CC} stm32mp15_basic_defconfig # non trusted u-boot
make ARCH=arm CROSS_COMPILE=${CC} stm32mp15_trusted_defconfig
make ARCH=arm CROSS_COMPILE=${CC} DEVICE_TREE=${board} all u-boot.stm32 -j${CORES}
echo "============================================"
if [ -f u-boot.bin ]; then
echo "U-Boot Build Finish"
mkdir -p "${DIR}/deploy"
echo "Copy U-Boot to deploy folder"
# non trusted u-boot
#if [ -f ${DIR}/deploy/u-boot-spl.stm32 ]; then rm ${DIR}/deploy/u-boot-spl.stm32; fi
#if [ -f ${DIR}/deploy/u-boot.img ]; then rm ${DIR}/deploy/u-boot.img; fi
#if [ -f ${DIR}/deploy/u-boot.bin ]; then rm ${DIR}/deploy/u-boot.bin; fi
#cp -v u-boot-spl.stm32 ${DIR}/deploy
cp -v u-boot.bin ${DIR}/deploy
else
export ERROR_MSG="U-Boot: Build Failure: board ${board}"
/bin/sh -e "${DIR}/error.sh" && { exit 1 ; }
fi
cd "${DIR}/" || exit 0
}
build_arm_trusted_firmware() {
cd ${DIR}/arm-trusted-firmware
echo "Apply patch"
git apply -v --whitespace=fix ${DIR}/00005-add-at-f-stm32mp157a-sodimm2-mx.patch || { echo "Error apply patch"; }
echo "============================================"
echo "Start build Arm Trust Firmware: ${board} $(git branch --show-current)"
if [ -d ${DIR}/arm-trusted-firmware/build ]; then
rm -r ${DIR}/arm-trusted-firmware/build
fi
make -C ./tools/fiptool \
PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 CROSS_COMPILE=${CC} \
STM32MP_SDMMC=1 STM32MP_EMMC=1 \
AARCH32_SP=sp_min \
DTB_FILE_NAME=${board}.dtb \
BL33_CFG=${DIR}/u-boot/u-boot.dtb \
BL33=${DIR}/u-boot/u-boot-nodtb.bin \
-j${CORES}
make \
PLAT=stm32mp1 ARCH=aarch32 ARM_ARCH_MAJOR=7 CROSS_COMPILE=${CC} \
STM32MP_SDMMC=1 STM32MP_EMMC=1 \
AARCH32_SP=sp_min \
DTB_FILE_NAME=${board}.dtb \
BL33_CFG=${DIR}/u-boot/u-boot.dtb \
BL33=${DIR}/u-boot/u-boot-nodtb.bin \
all fip -j${CORES}
echo "============================================"
if [ -f ./build/stm32mp1/release/fip.bin ]; then
echo "Arm Trust Firmware Build Finish"
else
export ERROR_MSG="Arm Trust Firmware: Build Failure: board ${board}: $(git branch --show-current)"
/bin/sh -e "${DIR}/error.sh" && { exit 1 ; }
fi
if [ -f ${DIR}/deploy/tf-a-${board}.stm32 ]; then
rm ${DIR}/deploy/tf-a-${board}.stm32
fi
cp -v ./build/stm32mp1/release/tf-a-${board}.stm32 ${DIR}/deploy
if [ -f ${DIR}/deploy/fip.bin ]; then
rm ${DIR}/deploy/fip.bin
fi
cp -v ./build/stm32mp1/release/fip.bin ${DIR}/deploy
cd "${DIR}/" || exit 0
}
OPTIONS="${@:-allff}"
for option in ${OPTIONS}; do
# echo "processing option: $option"
case $option in
stm32mp157a-sodimm2-mx) board=${OPTIONS} ;;
stm32mp157c-dk2) board=${OPTIONS} ;;
stm32mp153c-dhcom-drc02) board=${OPTIONS} ;;
stm32mp157a-avenger96) board=${OPTIONS} ;;
stm32mp157a-ev1) board=${OPTIONS} ;;
stm32mp157a-iot-box) board=${OPTIONS} ;;
stm32mp157a-stinger96) board=${OPTIONS} ;;
stm32mp157c-dhcom-pdk2) board=${OPTIONS} ;;
stm32mp157c-ed1) board=${OPTIONS} ;;
stm32mp157c-ev1) board=${OPTIONS} ;;
stm32mp157c-lxa-mc1) board=${OPTIONS} ;;
stm32mp157c-odyssey) board=${OPTIONS} ;;
stm32mp157d-dk1) board=${OPTIONS} ;;
stm32mp157d-ed1) board=${OPTIONS} ;;
stm32mp157d-ev1) board=${OPTIONS} ;;
stm32mp157f-dk2) board=${OPTIONS} ;;
stm32mp157f-ed1) board=${OPTIONS} ;;
stm32mp157f-ev1) board=${OPTIONS} ;;
stm32mp157a-dk1) board=${OPTIONS} ;;
stm32mp157a-ed1) board=${OPTIONS} ;;
*) board="stm32mp157c-dk2" ;;
esac
done
build_uboot
build_arm_trusted_firmware
echo ""
echo "-----------------------------"
echo "Script Complete: board name: ${board}"
echo ""
echo "Trusted U-boot: ${DIR}/deploy/fib.bin"
echo "Config RAM: ${DIR}/deploy/tf-a-${board}.stm32"
echo "-----------------------------"
exit 0 ;