Skip to content

Commit 10d0b3b

Browse files
singalsukv2019i
authored andcommitted
Scripts: Add xt-run build target for rebuild-testbench.sh
This patch adds to rebuild-testbench option -x <platform> that can be used to build testbench for xt-run execution. The enhanced script reuses native testbench build but with CC, LD, LDFLAGS, etc. defines to use the xt-xcc compiler for build. Currently TGL (HiFi3) is the only supported platform. More will be added later. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent a380d21 commit 10d0b3b

3 files changed

Lines changed: 196 additions & 12 deletions

File tree

scripts/rebuild-testbench.sh

Lines changed: 94 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,42 @@
55
# fail on any errors
66
set -e
77

8+
# Defaults
9+
BUILD_TYPE=native
10+
BUILD_DIR_NAME=build_testbench
11+
BUILD_TARGET=install
12+
813
print_usage()
914
{
1015
cat <<EOFUSAGE
11-
usage: $0 [-f]
16+
usage: $0 [-f] [-p <platform>]
17+
-p Build testbench binary for xt-run for selected platform, e.g. -p tgl
1218
-f Build testbench with compiler provided by fuzzer
1319
(default path: $HOME/sof/work/AFL/afl-gcc)
1420
EOFUSAGE
1521
}
1622

23+
# die is copy from xtensa-build-all.sh
24+
die()
25+
{
26+
>&2 printf '%s ERROR: ' "$0"
27+
# We want die() to be usable exactly like printf
28+
# shellcheck disable=SC2059
29+
>&2 printf "$@"
30+
exit 1
31+
}
32+
1733
rebuild_testbench()
1834
{
1935
cd "$BUILD_TESTBENCH_DIR"
2036

21-
rm -rf build_testbench
22-
23-
mkdir build_testbench
24-
cd build_testbench
37+
rm -rf "$BUILD_DIR_NAME"
38+
mkdir "$BUILD_DIR_NAME"
39+
cd "$BUILD_DIR_NAME"
2540

2641
cmake -DCMAKE_INSTALL_PREFIX=install ..
2742

28-
cmake --build . -- -j"$(nproc)" install
43+
cmake --build . -- -j"$(nproc)" $BUILD_TARGET
2944
}
3045

3146
export_CC_with_afl()
@@ -34,22 +49,89 @@ export_CC_with_afl()
3449
export CC=${SOF_AFL}
3550
}
3651

52+
setup_xtensa_tools_build()
53+
{
54+
BUILD_TYPE=xt
55+
BUILD_TARGET=
56+
BUILD_DIR_NAME=build_xt_testbench
57+
58+
# check needed environment variables
59+
test -n "${XTENSA_TOOLS_ROOT}" || die "XTENSA_TOOLS_ROOT need to be set.\n"
60+
61+
# Get compiler version for platform
62+
source "$SCRIPT_DIR/set_xtensa_params.sh" "$BUILD_PLATFORM"
63+
64+
test -n "${XTENSA_TOOLS_VERSION}" ||
65+
die "Illegal platform $BUILD_PLATFORM, no XTENSA_TOOLS_VERSION found.\n"
66+
test -n "${XTENSA_CORE}" ||
67+
die "Illegal platform $BUILD_PLATFORM, no XTENSA_CORE found.\n"
68+
69+
compiler="xt-xcc"
70+
install_bin=install/tools/$XTENSA_TOOLS_VERSION/XtensaTools/bin
71+
tools_bin=$XTENSA_TOOLS_ROOT/$install_bin
72+
testbench_sections="-Wl,--sections-placement $BUILD_TESTBENCH_DIR/testbench_xcc_sections.txt"
73+
export CC=$tools_bin/$compiler
74+
export LD=$tools_bin/xt-ld
75+
export OBJDUMP=$tools_bin/xt-objdump
76+
export LDFLAGS="-mlsp=sim -Wl,-LE $testbench_sections"
77+
export XTENSA_CORE
78+
}
79+
80+
export_xtensa_setup()
81+
{
82+
export_dir=$BUILD_TESTBENCH_DIR/$BUILD_DIR_NAME
83+
export_script=$export_dir/xtrun_env.sh
84+
xtbench=$export_dir/testbench
85+
xtbench_run="XTENSA_CORE=$XTENSA_CORE \$XTENSA_TOOLS_ROOT/$install_bin/xt-run $xtbench"
86+
cat <<EOFSETUP > "$export_script"
87+
export XTENSA_TOOLS_ROOT=$XTENSA_TOOLS_ROOT
88+
export XTENSA_CORE=$XTENSA_CORE
89+
XTENSA_PATH=$tools_bin
90+
EOFSETUP
91+
}
92+
93+
testbench_usage()
94+
{
95+
case "$BUILD_TYPE" in
96+
xt)
97+
export_xtensa_setup
98+
cat <<EOFUSAGE
99+
Success! Testbench binary for $BUILD_PLATFORM is in $xtbench
100+
it can be run with command:
101+
102+
$xtbench_run -h
103+
104+
Alternatively with environment setup to match build:
105+
106+
source $export_script
107+
\$XTENSA_PATH/xt-run $xtbench -h
108+
109+
EOFUSAGE
110+
esac
111+
}
112+
37113
main()
38114
{
39115
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
40116
SOF_REPO=$(dirname "$SCRIPT_DIR")
41117
BUILD_TESTBENCH_DIR="$SOF_REPO"/tools/testbench
42118
: "${SOF_AFL:=$HOME/sof/work/AFL/afl-gcc}"
43119

44-
while getopts "fh" OPTION; do
45-
case "$OPTION" in
46-
f) export_CC_with_afl;;
47-
h) print_usage; exit 1;;
48-
*) print_usage; exit 1;;
49-
esac
120+
while getopts "fhp:" OPTION; do
121+
case "$OPTION" in
122+
p)
123+
BUILD_PLATFORM="$OPTARG"
124+
setup_xtensa_tools_build
125+
;;
126+
f) export_CC_with_afl;;
127+
h) print_usage; exit 1;;
128+
*) print_usage; exit 1;;
129+
esac
50130
done
51131

52132
rebuild_testbench
133+
134+
testbench_usage
53135
}
54136

55137
main "$@"

scripts/set_xtensa_params.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright(c) 2023 Intel Corporation. All rights reserved.
3+
4+
# Sourced script argument is a non-standard bash extension
5+
platform=$1
6+
7+
# Note: This duplicates xtensa-build-zephyr.py
8+
9+
case "$platform" in
10+
tgl)
11+
PLATFORM="tgplp"
12+
XTENSA_CORE="cavs2x_LX6HiFi3_2017_8"
13+
HOST="xtensa-cnl-elf"
14+
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
15+
HAVE_ROM='yes'
16+
IPC4_CONFIG_OVERLAY="tigerlake_ipc4"
17+
# default key for TGL
18+
PLATFORM_PRIVATE_KEY="-D${SIGNING_TOOL}_PRIVATE_KEY=$SOF_TOP/keys/otc_private_key_3k.pem"
19+
;;
20+
tgl-h)
21+
PLATFORM="tgph"
22+
XTENSA_CORE="cavs2x_LX6HiFi3_2017_8"
23+
HOST="xtensa-cnl-elf"
24+
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
25+
HAVE_ROM='yes'
26+
# default key for TGL
27+
PLATFORM_PRIVATE_KEY="-D${SIGNING_TOOL}_PRIVATE_KEY=$SOF_TOP/keys/otc_private_key_3k.pem"
28+
;;
29+
imx8)
30+
PLATFORM="imx8"
31+
XTENSA_CORE="hifi4_nxp_v3_3_1_2_2017"
32+
HOST="xtensa-imx-elf"
33+
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
34+
;;
35+
imx8x)
36+
PLATFORM="imx8x"
37+
XTENSA_CORE="hifi4_nxp_v3_3_1_2_2017"
38+
HOST="xtensa-imx-elf"
39+
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
40+
;;
41+
imx8m)
42+
PLATFORM="imx8m"
43+
XTENSA_CORE="hifi4_mscale_v0_0_2_2017"
44+
HOST="xtensa-imx8m-elf"
45+
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
46+
;;
47+
imx8ulp)
48+
PLATFORM="imx8ulp"
49+
XTENSA_CORE="hifi4_nxp2_ulp_prod"
50+
HOST="xtensa-imx8ulp-elf"
51+
XTENSA_TOOLS_VERSION="RG-2017.8-linux"
52+
;;
53+
rn)
54+
PLATFORM="renoir"
55+
XTENSA_CORE="ACP_3_1_001_PROD_2019_1"
56+
HOST="xtensa-rn-elf"
57+
XTENSA_TOOLS_VERSION="RI-2019.1-linux"
58+
;;
59+
rmb)
60+
PLATFORM="rembrandt"
61+
ARCH="xtensa"
62+
XTENSA_CORE="LX7_HiFi5_PROD"
63+
HOST="xtensa-rmb-elf"
64+
XTENSA_TOOLS_VERSION="RI-2019.1-linux"
65+
;;
66+
mt8186)
67+
PLATFORM="mt8186"
68+
XTENSA_CORE="hifi5_7stg_I64D128"
69+
HOST="xtensa-mt8186-elf"
70+
XTENSA_TOOLS_VERSION="RI-2020.5-linux"
71+
;;
72+
mt8188)
73+
PLATFORM="mt8188"
74+
XTENSA_CORE="hifi5_7stg_I64D128"
75+
HOST="xtensa-mt8188-elf"
76+
XTENSA_TOOLS_VERSION="RI-2020.5-linux"
77+
;;
78+
mt8195)
79+
PLATFORM="mt8195"
80+
XTENSA_CORE="hifi4_8195_PROD"
81+
HOST="xtensa-mt8195-elf"
82+
XTENSA_TOOLS_VERSION="RI-2019.1-linux"
83+
;;
84+
esac
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# IRAM placement
3+
#
4+
# put: .iram0.text .literal
5+
# put: .iram0.text .text
6+
7+
#put: .iram0.text .static_uuids
8+
#put: .iram0.text .trace_ctx
9+
#put: .text .static_uuids
10+
#put: .text .trace_ctx
11+
put: .bss .static_uuids
12+
put: .bss .trace_ctx
13+
14+
# sections order
15+
16+
# .text
17+
# .static_uuids
18+
# .trace_ctx

0 commit comments

Comments
 (0)