diff --git a/.github/workflows/testbench.yml b/.github/workflows/testbench.yml index c6d16920abd0..d1a974e1c510 100644 --- a/.github/workflows/testbench.yml +++ b/.github/workflows/testbench.yml @@ -31,6 +31,8 @@ on: jobs: build-and-test: runs-on: ubuntu-24.04 + env: + SOF_WORKSPACE=$HOME:/work/sof/sof steps: - name: Checkout SOF repository (PR source) diff --git a/.gitignore b/.gitignore index 9d50048ab954..6a86f90f48fd 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,6 @@ tools/test/audio/zeros_in.raw __pycache__ .checkpatch-camelcase.git.* -build*/ # Eclipse project metadata .settings diff --git a/scripts/build-tools.sh b/scripts/build-tools.sh index 6304265820cd..1891a12a3b37 100755 --- a/scripts/build-tools.sh +++ b/scripts/build-tools.sh @@ -16,7 +16,7 @@ Attention: the list of selected shortcuts below is _not_ exhaustive. To build _everything_ don't select any particular target; this will build CMake's default target "ALL". -usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A] +usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A|-d] -h Display help -c Rebuild ctl/ @@ -27,6 +27,7 @@ usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A] -Y Rebuild topology2 only -t Rebuild test/topology/ (or tools/test/topology/tplg-build.sh directly) -A Clone and rebuild local ALSA lib and utils. + -d Deployment build -C No build, only CMake re-configuration. Shows CMake targets. EOFUSAGE @@ -98,8 +99,9 @@ main() CMAKE_ONLY BUILD_ALL SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) SOF_REPO=$(dirname "$SCRIPT_DIR") - : "${BUILD_TOOLS_DIR:=$SOF_REPO/tools/build_tools}" + : "${BUILD_TOOLS_DIR:=$SOF_REPO/../build-tools-tplg}" : "${NO_PROCESSORS:=$(nproc)}" + DEPLOY_DIR="$SOF_REPO/../build-sof-staging" BUILD_ALL=false if [ $# -eq 0 ]; then @@ -113,6 +115,7 @@ main() DO_BUILD_tests=false DO_BUILD_topologies1=false DO_BUILD_topologies2=false + DO_DEPLOYMENT=false CMAKE_ONLY=false # better safe than sorry @@ -120,7 +123,7 @@ main() # eval is a sometimes necessary evil # shellcheck disable=SC2034 - while getopts "cfhlptTCXYA" OPTION; do + while getopts "cfhlptTCXYAd" OPTION; do case "$OPTION" in c) DO_BUILD_ctl=true ;; l) DO_BUILD_logger=true ;; @@ -131,6 +134,7 @@ main() Y) DO_BUILD_topologies2=true ;; C) CMAKE_ONLY=true ;; A) DO_BUILD_alsa=true ;; + d) DO_DEPLOYMENT=true ;; h) print_usage; exit 1;; *) print_usage; exit 1;; esac @@ -174,6 +178,14 @@ main() fi done + if "$DO_DEPLOYMENT"; then + # copy Intel topology2 files to output directory + # This will need updated when other uses topology2 + cp -ap "$BUILD_TOOLS_DIR"/topology/topology2/production/*.tplg \ + $DEPLOY_DIR/lib/firmware/intel/sof-ipc4-tplg/ + echo "Deployment build done" + fi + warn_if_incremental_build } diff --git a/scripts/rebuild-testbench.sh b/scripts/rebuild-testbench.sh index fee09fd243ae..4becc32c753a 100755 --- a/scripts/rebuild-testbench.sh +++ b/scripts/rebuild-testbench.sh @@ -5,16 +5,32 @@ # stop on most errors set -e -SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) -SOF_REPO=$(dirname "$SCRIPT_DIR") -TESTBENCH_DIR="$SOF_REPO"/tools/testbench +# This script can be executed from the sof firmware toplevel or workspace directory +# First check for the worksapce environment variable +if [ -z "$SOF_WORKSPACE" ]; then + # Environment variable is empty or unset so use default + BASE_DIR="$HOME/work/sof" +else + # Environment variable exists and has a value + BASE_DIR="$SOF_WORKSPACE" +fi +cd "$BASE_DIR" + +# check we are in the workspace directory +if [ ! -d "sof" ]; then + echo "Error: can't find SOF firmware directory. Please check your installation." + exit 1 +fi + +TESTBENCH_DIR=$BASE_DIR/sof/tools/testbench # Defaults BUILD_BACKEND='make' BUILD_TYPE=native -BUILD_DIR_NAME=build_testbench +BUILD_DIR_NAME=$BASE_DIR/build_testbench BUILD_TARGET=install : "${SOF_AFL:=$HOME/sof/work/AFL/afl-gcc}" +SCRIPT_DIR=$BASE_DIR/sof/scripts print_usage() { @@ -59,7 +75,7 @@ setup_xtensa_tools_build() { BUILD_TYPE=xt BUILD_TARGET= - BUILD_DIR_NAME=build_xt_testbench + BUILD_DIR_NAME=$BASE_DIR/build_xt_testbench # check needed environment variables test -n "${XTENSA_TOOLS_ROOT}" || die "XTENSA_TOOLS_ROOT need to be set.\n" @@ -90,7 +106,7 @@ setup_xtensa_tools_build() export_xtensa_setup() { - export_dir=$TESTBENCH_DIR/$BUILD_DIR_NAME + export_dir=$BUILD_DIR_NAME export_script=$export_dir/xtrun_env.sh xtbench=$export_dir/sof-testbench4 xtbench_run="XTENSA_CORE=$XTENSA_CORE \$XTENSA_TOOLS_ROOT/$install_bin/xt-run $xtbench" @@ -114,14 +130,14 @@ Success! For temporary, interactive Kconfiguration use: - $BUILD_BACKEND -C $TESTBENCH_DIR/$BUILD_DIR_NAME/sof_ep/build/ menuconfig + $BUILD_BACKEND -C $BUILD_DIR_NAME/sof_ep/build/ menuconfig Permanent configuration is "src/arch/host/configs/library_defconfig". For instant, incremental build: $src_env_msg - $BUILD_BACKEND -C $TESTBENCH_DIR/$BUILD_DIR_NAME/ -j$(nproc) + $BUILD_BACKEND -C $BUILD_DIR_NAME/ -j$(nproc) EOF0 diff --git a/scripts/sof-testbench-build-profile.sh b/scripts/sof-testbench-build-profile.sh index 342f0710ff23..9ff2e6ed39b4 100755 --- a/scripts/sof-testbench-build-profile.sh +++ b/scripts/sof-testbench-build-profile.sh @@ -9,18 +9,32 @@ usage() { echo " -h shows this text" echo " -p sets platform for scripts/rebuild-testbench.sh" echo + echo "This script must be run from the sof firmware toplevel or workspace directory" } MODULES_S32="asrc dcblock drc drc_multiband eqfir eqiir gain src tdfb" MODULES_S24="aria" -if [ -z "${SOF_WORKSPACE}" ]; then - echo "Error: environment variable SOF_WORKSPACE need to be set to top level sof directory" +# This script can be executed from the sof firmware toplevel or workspace directory +# First check for the worksapce environment variable +if [ -z "$SOF_WORKSPACE" ]; then + # Environment variable is empty or unset so use default + BASE_DIR="$HOME/work/sof" +else + # Environment variable exists and has a value + BASE_DIR="$SOF_WORKSPACE" +fi +cd "$BASE_DIR" + +# check we are in the workspace directory +if [ ! -d "sof" ]; then + echo "Error: can't find SOF firmware directory. Please check your installation." exit 1 fi +#set default values PLATFORM=none -PDIR=$SOF_WORKSPACE/sof/tools/testbench/profile +PDIR=$PWD/testbench/profile while getopts "hp:d:" opt; do case "${opt}" in @@ -43,7 +57,7 @@ done shift $((OPTIND-1)) # Build -SCRIPTS=$SOF_WORKSPACE/sof/scripts +SCRIPTS=$PWD/sof/scripts mkdir -p "$PDIR" "$SCRIPTS"/rebuild-testbench.sh -p "$PLATFORM" HELPER="$SCRIPTS"/sof-testbench-helper.sh diff --git a/scripts/sof-testbench-helper.sh b/scripts/sof-testbench-helper.sh index 5de7d8d43a7b..3c3310a0e060 100755 --- a/scripts/sof-testbench-helper.sh +++ b/scripts/sof-testbench-helper.sh @@ -10,10 +10,9 @@ usage() { echo " -c , default 2" echo " -h shows this text" echo " -i , default /usr/share/sounds/alsa/Front_Center.wav" - echo " -k keep temporary files in /tmp" + echo " -k keep temporary files in data directory" echo " -m , default gain" echo " -n , default 1,2" - echo " -o , default none" echo " -p , use with -x, default none" echo " -r , default 48000" echo " -t , default none, e.g. production/sof-hda-generic.tplg" @@ -29,14 +28,25 @@ usage() { echo "Example: check component eqiir with valgrind" echo "$0 -v -m eqiir" echo + echo This script must be run from the sof firmware toplevel or workspace directory } -if [ -z "${SOF_WORKSPACE}" ]; then - echo "Error: environment variable SOF_WORKSPACE need to be set to top level sof directory" +# First check for the workspace environment variable +if [ -z "$SOF_WORKSPACE" ]; then + # Environment variable is empty or unset so use default + BASE_DIR="$HOME/work/sof" +else + # Environment variable exists and has a value + BASE_DIR="$SOF_WORKSPACE" +fi +cd "$BASE_DIR" + +# check we are in the workspace directory +if [ ! -d "sof" ]; then + echo "Error: can't find SOF firmware directory. Please check your installation." exit 1 fi -OUTWAV= CLIP=/usr/share/sounds/alsa/Front_Center.wav MODULE=gain BITS=32 @@ -45,10 +55,6 @@ RATE_OUT=48000 CHANNELS_IN=2 CHANNELS_OUT=2 PIPELINES="1,2" -INFILE1=$(mktemp --tmpdir=/tmp in-XXXX.raw) -OUTFILE1=$(mktemp --tmpdir=/tmp out-XXXX.raw) -TRACEFILE=$(mktemp --tmpdir=/tmp trace-XXXX.txt) -PROFILEOUT=$(mktemp --tmpdir=/tmp profile-XXXX.out) KEEP_TMP=false XTRUN=false PROFILE=false @@ -71,7 +77,7 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do i) CLIP=${OPTARG} ;; - k) + k) KEEP_TMP=true ;; m) @@ -97,7 +103,7 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do v) VALGRIND=valgrind ;; - x) + x) XTRUN=true ;; *) @@ -108,6 +114,19 @@ while getopts "b:c:hi:km:n:o:p:r:t:vx" opt; do done shift $((OPTIND-1)) +# Get the current date and time in a specific format (YYYYMMDD_HHMMSS) +timestamp=$(date +"%Y%m%d_%H%M%S") + +# Combine the prefix and timestamp to create the filename +INFILE1="$PWD/testbench_data/in-${MODULE}-${timestamp}.raw" +OUTFILE1="$PWD/testbench_data/out-${MODULE}-${timestamp}.raw" +TRACEFILE="$PWD/testbench_data/trace-${MODULE}-${timestamp}.txt" +PROFILEOUT="$PWD/testbench_data/profile-${MODULE}-${timestamp}.out" +OUTWAV="$PWD/testbench_data/outwav-${MODULE}-${timestamp}.wav" + +# make the data directory if it doesn't exist +mkdir -p $PWD/testbench_data + echo Converting clip "$CLIP" to raw input if [[ "$BITS" == "24" ]]; then # Sox does not support S24_4LE format @@ -118,14 +137,14 @@ if [[ "$BITS" == "24" ]]; then else sox --encoding signed-integer "$CLIP" -L -r "$RATE_IN" -c "$CHANNELS_IN" -b "$BITS" "$INFILE1" fi - -TB4="$SOF_WORKSPACE/sof/tools/testbench/build_testbench/install/bin/sof-testbench4" -XTB4="$SOF_WORKSPACE/sof/tools/testbench/build_xt_testbench/sof-testbench4" -XTB4_SETUP="$SOF_WORKSPACE/sof/tools/testbench/build_xt_testbench/xtrun_env.sh" +TOOLSDIR="$PWD/build_tools/testbench" +TB4="$PWD/build-testbench/install/bin/sof-testbench4" +XTB4="$PWD/build-xt-testbench/sof-testbench4" +XTB4_SETUP="$PWD/build-xt-testbench/xtrun_env.sh" if [ -z "$TPLG0" ]; then - TPLG="$SOF_WORKSPACE/sof/tools/build_tools/topology/topology2/development/sof-hda-benchmark-${MODULE}${BITS}.tplg" + TPLG="$PWD/build_tools/topology/topology2/development/sof-hda-benchmark-${MODULE}${BITS}.tplg" else - TPLG="$SOF_WORKSPACE/sof/tools/build_tools/topology/topology2/$TPLG0" + TPLG="$PWD/build_tools/topology/topology2/$TPLG0" fi FMT="S${BITS}_LE" OPTS="-r $RATE_IN -R $RATE_OUT -c $CHANNELS_IN -c $CHANNELS_OUT -b $FMT -p $PIPELINES -t $TPLG -i $INFILE1 -o $OUTFILE1" @@ -169,16 +188,17 @@ else fi fi -if [ -n "$OUTWAV" ]; then +# Generate the outwav if we are keeping our data files for inspection. +if [[ "$KEEP_TMP" == false ]]; then + echo Deleting temporary files + rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT" +else echo Converting raw output to "$OUTWAV" if [[ "$BITS" == "24" ]]; then - sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 "$OUTFILE1" "$OUTWAV" vol 256 + sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b 32 \ + "$OUTFILE1" "$OUTWAV" vol 256 else - sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" "$OUTFILE1" "$OUTWAV" + sox --encoding signed-integer -L -r "$RATE_OUT" -c "$CHANNELS_OUT" -b "$BITS" \ + "$OUTFILE1" "$OUTWAV" fi fi - -if [[ "$KEEP_TMP" == false ]]; then - echo Deleting temporary files - rm -f "$INFILE1" "$OUTFILE1" "$TRACEFILE" "$PROFILEOUT" -fi diff --git a/tools/test/audio/comp_run.sh b/tools/test/audio/comp_run.sh index 096ff2c341c0..6beaf74f5fa0 100755 --- a/tools/test/audio/comp_run.sh +++ b/tools/test/audio/comp_run.sh @@ -132,13 +132,13 @@ run_testbench () parse_args "$@" # Path to topologies -TPLG_DIR=../../build_tools/test/topology +TPLG_DIR=../../../../build_tools/test/topology # Testbench path and executable if [[ -z $XTRUN ]]; then - PATH_TESTBENCH=../../testbench/build_testbench/install/bin/$TESTBENCH + PATH_TESTBENCH=../../../../build_testbench/install/bin/$TESTBENCH else - BUILD_DIR=../../testbench/build_xt_testbench + BUILD_DIR=../../../../build_xt_testbench PATH_TESTBENCH="$BUILD_DIR"/$TESTBENCH source "$BUILD_DIR"/xtrun_env.sh XTRUN_CMD=$XTENSA_PATH/$XTRUN @@ -168,7 +168,7 @@ PIPELINES= [[ $DIRECTION == "playback" ]] && PIPELINES="-p 1,2" [[ $DIRECTION == "capture" ]] && PIPELINES="-p 3,4" TPLGFN=sof-hda-benchmark-${COMP}${BITS_IN}.tplg - TPLG_DIR="../../build_tools/topology/topology2/development" + TPLG_DIR="../../../../build_tools/topology/topology2/development" TPLG_BUILD_TIP="Please run scripts/build-tools.sh" }