|
| 1 | +# SOF testbench |
| 2 | + |
| 3 | +### Features |
| 4 | + |
| 5 | + * Simulate IPC3 and IPC4 SOF versions with run of set of processing |
| 6 | + components based on desired topology. |
| 7 | + * Replaces host and dai components with file I/O with raw binary |
| 8 | + S16_LE/S24_LE/S32_LE or text format files for audio waveforms. |
| 9 | + * Much faster than real-time execution in native build, e.g. x86 on |
| 10 | + Linux for efficient validation usage. |
| 11 | + * With xtensa DSP build offers cycles accurate simulated environment |
| 12 | + execution. And also with options for similation speed vs. model |
| 13 | + accuracy. |
| 14 | + * Allows easy use of conventional debugger, profiler, leak and memory check |
| 15 | + tools usage for DSP firmware code. |
| 16 | + |
| 17 | +### Quick how-to |
| 18 | + |
| 19 | +The simplest way to build and execute testbench is with supplied |
| 20 | +scripts. It executes a simple chirp waveform test for a number of |
| 21 | +processing components. Corrupted audio or failure in execution |
| 22 | +results to fail of test. |
| 23 | + |
| 24 | +The commands "build-tools.sh -t" and "host-testbench.sh" are currently |
| 25 | +valid only for default IPC3 build of testbench. |
| 26 | + |
| 27 | +``` |
| 28 | +cd $SOF_WORKSPACE/sof |
| 29 | +scripts/build-tools.sh -t |
| 30 | +scripts/rebuild-testbench.sh |
| 31 | +scripts/host-testbench.sh |
| 32 | +``` |
| 33 | + |
| 34 | +### Manual run of IPC3 testbench |
| 35 | + |
| 36 | +As an example, process a wav file and listen it. The example |
| 37 | +proceccing component is DC block. The wav file is first converted with |
| 38 | +sox to raw 32 bit 48 kHz stereo format, then processed by testbench, |
| 39 | +converted back to wav. |
| 40 | + |
| 41 | +``` |
| 42 | +cd $SOF_WORKSPACE/sof |
| 43 | +sox --encoding signed-integer /usr/share/sounds/alsa/Front_Left.wav -L -r 48000 -c 2 -b 32 in.raw |
| 44 | +tools/testbench/build_testbench/install/bin/testbench -r 48000 -R 48000 -c 2 -n 2 -b S32_LE \ |
| 45 | + -t tools/build_tools/test/topology/test-playback-ssp5-mclk-0-I2S-dcblock-s32le-s32le-48k-24576k-codec.tplg \ |
| 46 | + -i in.raw -o out.raw |
| 47 | +sox --encoding signed-integer -L -r 48000 -c 2 -b 32 in.raw out.wav |
| 48 | +aplay out.wav |
| 49 | +``` |
| 50 | + |
| 51 | +The testbench binary can be debugged and profiled with native |
| 52 | +executable tools like gdb, ddd (GUI for gdb), gprof, and valgrind. |
| 53 | + |
| 54 | +### Profiling of testbench run on xtensa |
| 55 | + |
| 56 | +Fist, the testbench is build in this example for Intel MTL |
| 57 | +platform. This needs access to Cadence Xplorer toolchain with the core |
| 58 | +confiration for the platform. |
| 59 | + |
| 60 | +``` |
| 61 | +cd $SOF_WORKSPACE/sof |
| 62 | +export XTENSA_TOOLS_ROOT=~/xtensa/XtDevTools |
| 63 | +export ZEPHYR_TOOLCHAIN_VARIANT=xt-clang |
| 64 | +scripts/rebuild-testbench.sh -p mtl |
| 65 | +source tools/testbench/build_xt_testbench/xtrun_env.sh |
| 66 | +``` |
| 67 | + |
| 68 | +Next the testbench is run with xt-run simulator. The example component |
| 69 | +is dynamic range processing (DRC). For proling data generate use |
| 70 | +option --profile. Note that this is a lot slower than native run. An |
| 71 | +1s extract of a pink noise file is used as example. |
| 72 | + |
| 73 | +``` |
| 74 | +sox --encoding signed-integer /usr/share/sounds/alsa/Noise.wav -L -r 48000 -c 2 -b 32 in.raw trim 0.0 1.0 |
| 75 | +$XTENSA_PATH/xt-run --profile=profile.out tools/testbench/build_xt_testbench/testbench \ |
| 76 | + -q -r 48000 -R 48000 -c 2 -n 2 -b S32_LE \ |
| 77 | + -t tools/build_tools/test/topology/test-playback-ssp5-mclk-0-I2S-drc-s32le-s32le-48k-24576k-codec.tplg \ |
| 78 | + -i in.raw -o out.raw 2> trace.txt |
| 79 | +``` |
| 80 | + |
| 81 | +Then convert the profiler data to readable format and check it. |
| 82 | + |
| 83 | +Note: Current version of testbench does not have functional quiet mode |
| 84 | +"-q" switch to suppress trace. Due all debug traces print |
| 85 | +out. Majority of performance is spent in printing. |
| 86 | + |
| 87 | +``` |
| 88 | +$XTENSA_PATH/xt-gprof tools/testbench/build_xt_testbench/testbench profile.out > example_profile.txt |
| 89 | +less example_profile.txt |
| 90 | +``` |
| 91 | + |
| 92 | +### Perform audio processing quality checks |
| 93 | + |
| 94 | +This step needs Matlab or Octave tool with signal processing |
| 95 | +package. A number of tests is performed for IIR equalizer component as |
| 96 | +example. The script opens plot windows and outputs a text report in |
| 97 | +the end. A simple pass/fail criteria is used to report a verdict of |
| 98 | +the test run. |
| 99 | + |
| 100 | +``` |
| 101 | +cd $SOF_WORKSPACE/sof/tools/test/audio |
| 102 | +octave -q --eval "pkg load signal io; [n_fail]=process_test('eq-iir', 32, 32, 48000, 1, 1); input('Press ENTER'); exit(n_fail)" |
| 103 | +``` |
| 104 | + |
| 105 | +See from interactive Octave shell command "help process_test" the |
| 106 | +explanation for the test run parameters. |
| 107 | + |
| 108 | +### Manual run of IPC4 testbench |
| 109 | + |
| 110 | +Apply this patch to SOF and rebuild it. |
| 111 | + |
| 112 | +``` |
| 113 | +diff --git a/src/arch/host/configs/library_defconfig b/src/arch/host/configs/library_defconfig |
| 114 | +index d150690aa..6d167dfba 100644 |
| 115 | +--- a/src/arch/host/configs/library_defconfig |
| 116 | ++++ b/src/arch/host/configs/library_defconfig |
| 117 | +@@ -21,8 +21,8 @@ CONFIG_COMP_VOLUME=y |
| 118 | + CONFIG_COMP_VOLUME_LINEAR_RAMP=y |
| 119 | + CONFIG_COMP_VOLUME_WINDOWS_FADE=y |
| 120 | + CONFIG_DEBUG_MEMORY_USAGE_SCAN=n |
| 121 | +-CONFIG_IPC_MAJOR_3=y |
| 122 | +-CONFIG_IPC_MAJOR_4=n |
| 123 | ++CONFIG_IPC_MAJOR_3=n |
| 124 | ++CONFIG_IPC_MAJOR_4=y |
| 125 | + CONFIG_LIBRARY=y |
| 126 | + CONFIG_LIBRARY_STATIC=y |
| 127 | + CONFIG_MATH_IIR_DF2T=y |
| 128 | +``` |
| 129 | + |
| 130 | +Then process a wav file and listen. The example proceccing component |
| 131 | +is DC blocker. The wav file is first converted with sox to raw 32 bit |
| 132 | +48 kHz stereo format, then processed by testbench, converted back to |
| 133 | +wav. |
| 134 | + |
| 135 | +``` |
| 136 | +cd $SOF_WORKSPACE/sof |
| 137 | +sox --encoding signed-integer /usr/share/sounds/alsa/Front_Center.wav -L -r 48000 -c 2 -b 32 in.raw |
| 138 | +tools/testbench/build_testbench/install/bin/testbench -r 48000 -R 48000 -c 2 -n 2 -b S32_LE -p 1,2 \ |
| 139 | + -t tools/build_tools/topology/topology2/development/sof-hda-benchmark-dcblock32.tplg \ |
| 140 | + -i in.raw -o out.raw |
| 141 | +sox --encoding signed-integer -L -r 48000 -c 2 -b 32 in.raw out.wav |
| 142 | +aplay out.wav |
| 143 | +``` |
| 144 | + |
| 145 | +The difference in command line is the use of other topology for IPC4 |
| 146 | +and use of -p command line option to select pipelines 1 and 2 from |
| 147 | +this topology for scheduling and connecting to input and output files. |
| 148 | +In this topology the host playback pipeline is 1 and the dai playback |
| 149 | +side pipeline is 2. Capture side pipelines would be 3 and 4. And |
| 150 | +running both playback and capture would need more input and output |
| 151 | +files to be added to -i and -o as comma separated. The more advanced |
| 152 | +use cases simulations with IPC4 are still under work. |
| 153 | + |
| 154 | +The debugging and profiling of IPC4 testench is similar as with IPC3. |
0 commit comments