forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxtensa-build-all.sh
More file actions
executable file
·484 lines (428 loc) · 12.3 KB
/
xtensa-build-all.sh
File metadata and controls
executable file
·484 lines (428 loc) · 12.3 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Intel Corporation. All rights reserved.
# stop on most errors
set -e
# Platforms built and tested by default in CI using the `-a` option.
# They must have a toolchain available in the latest Docker image.
DEFAULT_PLATFORMS=(
tgl tgl-h
imx8 imx8x imx8m imx8ulp
rn rmb
mt8186 mt8195
)
# Work in progress can be added to this "staging area" without breaking
# the -a option for everyone.
SUPPORTED_PLATFORMS=( "${DEFAULT_PLATFORMS[@]}" )
# Not actually "supported" in the main branch anymore (go to stable-v2.3
# instead) but kept here for historical reasons and experimentation
# convenience.
SUPPORTED_PLATFORMS+=( byt hsw cht bdw apl skl kbl cnl sue icl jsl )
BUILD_ROM=no
BUILD_DEBUG=no
BUILD_FORCE_UP=no
BUILD_JOBS=$(nproc --all)
BUILD_VERBOSE=
PLATFORMS=()
SOF_TOP=$(cd "$(dirname "$0")/.." && pwd)
# As CMake forks one compiler process for each source file, the XTensa
# compiler spends much more time idle waiting for the license server
# over the network than actually using CPU or disk. A factor 3 has been
# found optimal for 16 nproc 25ms away from the server; your mileage may
# vary.
#
# The entire, purely local gcc build is so fast (~ 1s) that observing
# any difference between -j nproc and -j nproc*N is practically
# impossible so let's not waste RAM when building with gcc.
if [ -n "$XTENSA_TOOLS_ROOT" ]; then
BUILD_JOBS=$((BUILD_JOBS * 3))
fi
die()
{
>&2 printf '%s ERROR: ' "$0"
# We want die() to be usable exactly like printf
# shellcheck disable=SC2059
>&2 printf "$@"
exit 1
}
print_usage()
{
cat <<EOF
Re-configures and re-builds SOF using the corresponding compiler and the
<platform>_defconfig file. Implements and saves the manual configuration
described in
https://thesofproject.github.io/latest/developer_guides/firmware/cmake.html
usage: $0 [options] platform(s)
-r Build rom if available (gcc only)
-a Build all default platforms fully supported by the latest Docker image and CI
-u Force CONFIG_MULTICORE=n
-d Enable debug build
-c Interactive menuconfig
-o arg, copies src/arch/xtensa/configs/override/<arg>.config
to the build directory after invoking CMake and before Make.
-k Configure rimage to use a non-default \${RIMAGE_PRIVATE_KEY}
DEPRECATED: use the more flexible \${PRIVATE_KEY_OPTION} below.
-v Verbose Makefile log
-i Optional IPC_VERSION: can be set to IPC3, IPC4 or an empty string.
If set to "IPCx" then CONFIG_IPC_MAJOR_x will be set. If set to
IPC4 then a platform specific overlay may be used.
-j n Set number of make build jobs. Jobs=#cores when no flag.
Infinite when not specified.
-m path to MEU tool. CMake disables rimage signing which produces a
.uns[igned] file signed by MEU. For a non-default key use the
PRIVATE_KEY_OPTION, see below.
To use a non-default key you must define the right CMake parameter in the
following environment variable:
PRIVATE_KEY_OPTION='-DMEU_PRIVATE_KEY=path/to/key' $0 -m /path/to/meu ...
or:
PRIVATE_KEY_OPTION='-DRIMAGE_PRIVATE_KEY=path/to/key' $0 ...
This script supports XtensaTools but only when installed in a specific
directory structure, example:
myXtensa/
└── install/
├── builds/
│ ├── RD-2012.5-linux/
│ │ └── Intel_HiFiEP/
│ └── RG-2017.8-linux/
│ ├── LX4_langwell_audio_17_8/
│ └── X4H3I16w2D48w3a_2017_8/
└── tools/
├── RD-2012.5-linux/
│ └── XtensaTools/
└── RG-2017.8-linux/
└── XtensaTools/
$ XTENSA_TOOLS_ROOT=/path/to/myXtensa $0 ...
Known platforms: ${SUPPORTED_PLATFORMS[*]}
EOF
}
# parse the args
while getopts "rudi:j:ckvao:m:" OPTION; do
case "$OPTION" in
r) BUILD_ROM=yes ;;
u) BUILD_FORCE_UP=yes ;;
d) BUILD_DEBUG=yes ;;
i) IPC_VERSION=$OPTARG ;;
j) BUILD_JOBS=$OPTARG ;;
c) MAKE_MENUCONFIG=yes ;;
k) USE_PRIVATE_KEY=yes ;;
o) OVERRIDE_CONFIG=$OPTARG ;;
v) BUILD_VERBOSE='VERBOSE=1' ;;
a) PLATFORMS=("${DEFAULT_PLATFORMS[@]}") ;;
m) MEU_TOOL_PATH=$OPTARG ;;
*) print_usage; exit 1 ;;
esac
done
shift $((OPTIND-1))
#default signing tool
SIGNING_TOOL=RIMAGE
if [ -n "${OVERRIDE_CONFIG}" ]
then
OVERRIDE_CONFIG="${SOF_TOP}/src/arch/xtensa/configs/override/$OVERRIDE_CONFIG.config"
[ -f "${OVERRIDE_CONFIG}" ] || die 'Invalid override config file %s\n' "${OVERRIDE_CONFIG}"
fi
if [ -n "${MEU_TOOL_PATH}" ]
then
[ -d "${MEU_TOOL_PATH}" ] || die 'Invalid MEU TOOL PATH %s\n' "${MEU_TOOL_PATH}"
MEU_PATH_OPTION=-DMEU_PATH="${MEU_TOOL_PATH}"
SIGNING_TOOL=MEU
fi
# parse platform args
for arg in "$@"; do
platform=none
for i in "${SUPPORTED_PLATFORMS[@]}"; do
if [ x"$i" = x"$arg" ]; then
PLATFORMS=("${PLATFORMS[@]}" "$i")
platform=$i
shift || true
break
fi
done
if [ "$platform" == "none" ]; then
echo "Error: Unknown platform specified: $arg"
echo "Known platforms are: ${SUPPORTED_PLATFORMS[*]}"
exit 1
fi
done
# check target platform(s) have been passed in
if [ ${#PLATFORMS[@]} -eq 0 ];
then
echo "Error: No platform specified. Known platforms: " \
"${SUPPORTED_PLATFORMS[*]}"
print_usage
exit 1
fi
if [ "x$USE_PRIVATE_KEY" == "xyes" ]
then
>&2 printf \
'WARNING: -k and RIMAGE_PRIVATE_KEY are deprecated, see usage.\n'
if [ -z ${RIMAGE_PRIVATE_KEY+x} ]
then
echo "Error: No variable specified for RIMAGE_PRIVATE_KEY"
exit 1
fi
PRIVATE_KEY_OPTION="-DRIMAGE_PRIVATE_KEY=${RIMAGE_PRIVATE_KEY}"
fi
OLDPATH=$PATH
CURDIR="$(pwd)"
# build platforms
for platform in "${PLATFORMS[@]}"
do
HAVE_ROM='no'
DEFCONFIG_PATCH=''
PLATFORM_PRIVATE_KEY=''
case $platform in
byt)
PLATFORM="baytrail"
XTENSA_CORE="Intel_HiFiEP"
HOST="xtensa-byt-elf"
XTENSA_TOOLS_VERSION="RD-2012.5-linux"
;;
cht)
PLATFORM="cherrytrail"
XTENSA_CORE="CHT_audio_hifiep"
HOST="xtensa-byt-elf"
XTENSA_TOOLS_VERSION="RD-2012.5-linux"
;;
bdw)
PLATFORM="broadwell"
XTENSA_CORE="LX4_langwell_audio_17_8"
HOST="xtensa-hsw-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
;;
hsw)
PLATFORM="haswell"
XTENSA_CORE="LX4_langwell_audio_17_8"
HOST="xtensa-hsw-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
;;
apl)
PLATFORM="apollolake"
XTENSA_CORE="X4H3I16w2D48w3a_2017_8"
# test APL compiler aliases
if command -v xtensa-bxt-elf-gcc; then
HOST="xtensa-bxt-elf"
else
HOST="xtensa-apl-elf"
fi
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
;;
skl)
PLATFORM="skylake"
XTENSA_CORE="X4H3I16w2D48w3a_2017_8"
# test APL compiler aliases
if command -v xtensa-bxt-elf-gcc; then
HOST="xtensa-bxt-elf"
else
HOST="xtensa-apl-elf"
fi
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
;;
kbl)
PLATFORM="kabylake"
XTENSA_CORE="X4H3I16w2D48w3a_2017_8"
# test APL compiler aliases
if command -v xtensa-bxt-elf-gcc; then
HOST="xtensa-bxt-elf"
else
HOST="xtensa-apl-elf"
fi
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
;;
cnl)
PLATFORM="cannonlake"
XTENSA_CORE="X6H3CNL_2017_8"
HOST="xtensa-cnl-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
;;
sue)
PLATFORM="suecreek"
XTENSA_CORE="X6H3CNL_2017_8"
HOST="xtensa-cnl-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
;;
icl)
PLATFORM="icelake"
XTENSA_CORE="X6H3CNL_2017_8"
HOST="xtensa-cnl-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
;;
tgl)
PLATFORM="tgplp"
XTENSA_CORE="cavs2x_LX6HiFi3_2017_8"
HOST="xtensa-cnl-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
IPC4_CONFIG_OVERLAY="tigerlake_ipc4"
# default key for TGL
PLATFORM_PRIVATE_KEY="-D${SIGNING_TOOL}_PRIVATE_KEY=$SOF_TOP/keys/otc_private_key_3k.pem"
;;
tgl-h)
PLATFORM="tgph"
XTENSA_CORE="cavs2x_LX6HiFi3_2017_8"
HOST="xtensa-cnl-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
# default key for TGL
PLATFORM_PRIVATE_KEY="-D${SIGNING_TOOL}_PRIVATE_KEY=$SOF_TOP/keys/otc_private_key_3k.pem"
;;
jsl)
PLATFORM="jasperlake"
XTENSA_CORE="X6H3CNL_2017_8"
HOST="xtensa-cnl-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
HAVE_ROM='yes'
;;
imx8)
PLATFORM="imx8"
XTENSA_CORE="hifi4_nxp_v3_3_1_2_2017"
HOST="xtensa-imx-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
;;
imx8x)
PLATFORM="imx8x"
XTENSA_CORE="hifi4_nxp_v3_3_1_2_2017"
HOST="xtensa-imx-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
;;
imx8m)
PLATFORM="imx8m"
XTENSA_CORE="hifi4_mscale_v0_0_2_2017"
HOST="xtensa-imx8m-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
;;
imx8ulp)
PLATFORM="imx8ulp"
XTENSA_CORE="hifi4_nxp2_ulp_prod"
HOST="xtensa-imx8ulp-elf"
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
;;
rn)
PLATFORM="renoir"
XTENSA_CORE="ACP_3_1_001_PROD_2019_1"
HOST="xtensa-rn-elf"
XTENSA_TOOLS_VERSION="RI-2019.1-linux"
;;
rmb)
PLATFORM="rembrandt"
ARCH="xtensa"
XTENSA_CORE="LX7_HiFi5_PROD"
HOST="xtensa-rmb-elf"
XTENSA_TOOLS_VERSION="RI-2019.1-linux"
;;
mt8186)
PLATFORM="mt8186"
XTENSA_CORE="hifi5_7stg_I64D128"
HOST="xtensa-mt8186-elf"
XTENSA_TOOLS_VERSION="RI-2020.5-linux"
;;
mt8195)
PLATFORM="mt8195"
XTENSA_CORE="hifi4_8195_PROD"
HOST="xtensa-mt8195-elf"
XTENSA_TOOLS_VERSION="RI-2019.1-linux"
;;
esac
test -z "${PRIVATE_KEY_OPTION}" || PLATFORM_PRIVATE_KEY="${PRIVATE_KEY_OPTION}"
if [ -n "$XTENSA_TOOLS_ROOT" ]
then
XTENSA_TOOLS_DIR="$XTENSA_TOOLS_ROOT/install/tools/$XTENSA_TOOLS_VERSION"
XTENSA_BUILDS_DIR="$XTENSA_TOOLS_ROOT/install/builds/$XTENSA_TOOLS_VERSION"
# make sure the required version of xtensa tools is installed
if [ -d "$XTENSA_TOOLS_DIR" ]
then
XCC="xt-xcc"
else
XCC="none"
>&2 printf 'WARNING: %s
\t is not a directory, reverting to gcc\n' "$XTENSA_TOOLS_DIR"
fi
fi
# CMake uses ROOT_DIR for includes and libraries a bit like
# --sysroot would.
ROOT="$SOF_TOP/../xtensa-root/$HOST"
if [ "$XCC" == "xt-xcc" ]
then
TOOLCHAIN=xt
ROOT="$XTENSA_BUILDS_DIR/$XTENSA_CORE/xtensa-elf"
# CMake cannot set (evil) build-time environment variables at configure time:
# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-get-or-set-environment-variables
export XTENSA_SYSTEM=$XTENSA_BUILDS_DIR/$XTENSA_CORE/config
printf 'XTENSA_SYSTEM=%s\n' "${XTENSA_SYSTEM}"
PATH=$XTENSA_TOOLS_DIR/XtensaTools/bin:$OLDPATH
COMPILER="xcc"
else
TOOLCHAIN=$HOST
PATH=$SOF_TOP/../$HOST/bin:$OLDPATH
COMPILER="gcc"
case "$platform" in
byt|cht|cnl|sue) DEFCONFIG_PATCH="_gcc";;
*) DEFCONFIG_PATCH="";;
esac
fi
BUILD_DIR=build_${platform}_${COMPILER}
printf "Build in %s\n" "$BUILD_DIR"
# only delete binary related to this build
rm -fr "$BUILD_DIR"
mkdir "$BUILD_DIR"
cd "$BUILD_DIR"
printf 'PATH=%s\n' "$PATH"
( set -x # log the main commands and their parameters
cmake -DTOOLCHAIN="$TOOLCHAIN" \
-DROOT_DIR="$ROOT" \
-DMEU_OPENSSL="${MEU_OPENSSL}" \
"${MEU_PATH_OPTION}" \
"${PLATFORM_PRIVATE_KEY}" \
-DINIT_CONFIG=${PLATFORM}${DEFCONFIG_PATCH}_defconfig \
-DEXTRA_CFLAGS="${EXTRA_CFLAGS}" \
"$SOF_TOP"
)
if [ -n "$OVERRIDE_CONFIG" ]
then
cp "$OVERRIDE_CONFIG" override.config
fi
if [[ "x$MAKE_MENUCONFIG" == "xyes" ]]
then
cmake --build . -- menuconfig
fi
case "$IPC_VERSION" in
'') ;;
IPC3)
echo 'CONFIG_IPC_MAJOR_3=y' >> override.config
;;
IPC4)
test -z "$IPC4_CONFIG_OVERLAY" ||
cat "${SOF_TOP}/src/arch/xtensa/configs/override/$IPC4_CONFIG_OVERLAY.config" \
>> override.config
echo 'CONFIG_IPC_MAJOR_4=y' >> override.config
;;
*) die "Invalid -i '%s' argument\n" "$IPC_VERSION" ;;
esac
if [[ "x$BUILD_DEBUG" == "xyes" ]]
then
echo "CONFIG_DEBUG=y" >> override.config
fi
if [[ "x$BUILD_ROM" == "xyes" && "x$HAVE_ROM" == "xyes" ]]
then
echo "CONFIG_BUILD_VM_ROM=y" >> override.config
fi
if [ "x$BUILD_FORCE_UP" == "xyes" ]
then
echo "Force building UP(xtensa)..."
echo "CONFIG_MULTICORE=n" >> override.config
fi
if [ -e override.config ]
then
cmake --build . -- overrideconfig
fi
cmake --build . -- bin -j "${BUILD_JOBS}" ${BUILD_VERBOSE}
cd "$CURDIR"
done # for platform in ...
# list all the images
ls -l build_*/*.ri build_*/src/arch/xtensa/rom*.bin || true
ls -l build_*/sof