mirror of https://github.com/thesofproject/sof.git
451 lines
11 KiB
Bash
Executable File
451 lines
11 KiB
Bash
Executable File
#!/bin/bash
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
# Copyright(c) 2018 Intel Corporation. All rights reserved.
|
|
|
|
# stop on most errors
|
|
set -e
|
|
|
|
# Platforms with a toolchain available in the latest Docker image and
|
|
# built by the -a option.
|
|
DEFAULT_PLATFORMS=( byt cht bdw hsw apl skl kbl cnl sue icl jsl \
|
|
imx8 imx8x imx8m imx8ulp tgl tgl-h rn mt8186 mt8195 )
|
|
|
|
# Work in progress can be added to this "staging area" without breaking
|
|
# the -a option for everyone.
|
|
SUPPORTED_PLATFORMS=( "${DEFAULT_PLATFORMS[@]}" )
|
|
|
|
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 platforms which have a toolchain in the latest Docker image
|
|
-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
|
|
-j n Set number of make build jobs. Jobs=#cores when no flag. \
|
|
Infinte 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 ...
|
|
|
|
Supported platforms ${SUPPORTED_PLATFORMS[*]}
|
|
|
|
EOF
|
|
}
|
|
|
|
# parse the args
|
|
while getopts "rudj:ckvao:m:" OPTION; do
|
|
case "$OPTION" in
|
|
r) BUILD_ROM=yes ;;
|
|
u) BUILD_FORCE_UP=yes ;;
|
|
d) BUILD_DEBUG=yes ;;
|
|
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 "Supported platforms are: ${SUPPORTED_PLATFORMS[*]}"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# check target platform(s) have been passed in
|
|
if [ ${#PLATFORMS[@]} -eq 0 ];
|
|
then
|
|
echo "Error: No platforms specified. Supported are: " \
|
|
"${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=''
|
|
|
|
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'
|
|
# default key for TGL
|
|
if [ -z "$PRIVATE_KEY_OPTION" ]
|
|
then
|
|
PRIVATE_KEY_OPTION="-D${SIGNING_TOOL}_PRIVATE_KEY=$SOF_TOP/keys/otc_private_key_3k.pem"
|
|
fi
|
|
;;
|
|
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
|
|
if [ -z "$PRIVATE_KEY_OPTION" ]
|
|
then
|
|
PRIVATE_KEY_OPTION="-D${SIGNING_TOOL}_PRIVATE_KEY=$SOF_TOP/keys/otc_private_key_3k.pem"
|
|
fi
|
|
;;
|
|
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"
|
|
HOST="xtensa-rn-elf"
|
|
XTENSA_TOOLS_VERSION="RF-2016.4-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
|
|
|
|
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"
|
|
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}" \
|
|
"${PRIVATE_KEY_OPTION}" \
|
|
-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
|
|
|
|
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
|