blob: a6b220c38538c0a813aff1faa5244aeb475c4daa (
plain)
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
156
157
158
159
160
161
162
163
164
165
166
|
#!/bin/bash
#
# Builds ARM Trusted Firmware, and generates FIPs with UEFI and optionally
# Trusted OS for the supported platforms.
# Not intended to be called directly, invoked from uefi-build.sh.
#
# Board configuration is extracted from
# parse-platforms.py and platforms.config.
#
TOOLS_DIR="`dirname $0`"
. "$TOOLS_DIR"/common-functions
OUTPUT_DIR="$PWD"/uefi-build
function usage
{
echo "usage:"
echo "atf-build.sh -e <EDK2 source directory> -t <UEFI build profile/toolchain> <platform>"
echo
}
function build_platform
{
if [ X"$EDK2_DIR" = X"" ];then
echo "EDK2_DIR not set!" >&2
return 1
fi
if [ X"`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o build_atf`" = X"" ]; then
echo "Platform '$1' is not configured to build ARM Trusted Firmware."
return 0
fi
ATF_PLATFORM=`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o atf_platform`
if [ X"$ATF_PLATFORM" = X"" ]; then
ATF_PLATFORM=$1
fi
#
# Read platform configuration
#
PLATFORM_NAME="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o longname`"
PLATFORM_ARCH="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o arch`"
PLATFORM_IMAGE_DIR="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o uefi_image_dir`"
unset BL30 BL31 BL32 BL33 SPD_OPTION
BL30="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o scp_bin`"
BL31="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o el3_bin`"
BL33="$EDK2_DIR/Build/$PLATFORM_IMAGE_DIR/$BUILD_PROFILE/FV/`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o uefi_bin`"
#
# Set up cross compilation variables (if applicable)
#
set_cross_compile
CROSS_COMPILE="$TEMP_CROSS_COMPILE"
echo "Building ARM Trusted Firmware for $PLATFORM_NAME - $BUILD_PROFILE"
echo "CROSS_COMPILE=\"$TEMP_CROSS_COMPILE\""
if [ X"$BL30" != X"" ]; then
BL30="${EDK2_DIR}"/"${BL30}"
fi
if [ X"$BL31" != X"" ]; then
BL31="${EDK2_DIR}"/"${BL31}"
fi
#
# BL32 requires more attention
# If TOS_DIR is not set, we assume user does not want a Trusted OS,
# even if the source directory and/or binary for it exists
#
if [ X"$TOS_DIR" != X"" ]; then
SPD="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o atf_spd`"
TOS_BIN=`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o tos_bin`
if [ X"$TOS_BIN" != X"" ]; then
BL32=$EDK2_DIR/Build/$PLATFORM_IMAGE_DIR/$BUILD_PROFILE/FV/$TOS_BIN
fi
if [ X"$SPD" != X"" ] && [ X"$BL32" != X"" ]; then
#
# Since SPD cannot be exported or undefined,
# we parametrise it here
#
SPD_OPTION="SPD=$SPD"
else
echo "WARNING: Proceeding without Trusted OS!"
echo " Please specify both ATF_SPD and TOS_BIN"
echo " if you wish to use a Trusted OS!"
fi
fi
export BL30 BL31 BL32 BL33 SPD_OPTION
echo "BL30=$BL30"
echo "BL31=$BL31"
echo "BL32=$BL32"
echo "BL33=$BL33"
echo "$SPD_OPTION"
#
# If a build was done with BL32, and followed by another without,
# the BL32 component remains in fip.bin, so we delete the build dir
# contents before calling make
#
rm -rf build/"$ATF_PLATFORM"/release/*
#
# Build ARM Trusted Firmware and create FIP
#
CROSS_COMPILE="$CROSS_COMPILE" make -j$NUM_THREADS PLAT="$ATF_PLATFORM" $SPD_OPTION all fip
if [ $? -eq 0 ]; then
#
# Copy resulting images to UEFI image dir
#
cp -a build/"$ATF_PLATFORM"/release/{bl1,fip}.bin "$EDK2_DIR/Build/$PLATFORM_IMAGE_DIR/$BUILD_PROFILE/FV/"
else
return 1
fi
}
# Check to see if we are in a trusted firmware directory
# refuse to continue if we aren't
if [ ! -d bl32 ]
then
echo "ERROR: we aren't in the arm-trusted-firmware directory."
usage
exit 1
fi
build=
if [ $# = 0 ]
then
usage
exit 1
else
while [ "$1" != "" ]; do
case $1 in
"-e" )
shift
EDK2_DIR="$1"
;;
"/h" | "/?" | "-?" | "-h" | "--help" )
usage
exit
;;
"-t" )
shift
BUILD_PROFILE="$1"
;;
* )
build="$1"
;;
esac
shift
done
fi
if [ X"$build" = X"" ]; then
echo "No platform specified!" >&2
echo
usage
exit 1
fi
build_platform $build
exit $?
|