Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
105 changes: 63 additions & 42 deletions scripts/build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@ SOF_TOP=$(cd "$(dirname "$0")/.." && pwd)
print_usage()
{
cat <<EOFUSAGE
Deletes and re-builds from scratch CMake projects in the tools/
directory.
Attention: the list below is _not_ exhaustive. To re-build _everything_
from scratch don't select any particular target; this will build the

Configures and builds selected CMake projects in the tools/ directory.
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]
usage: $0 [-c|-f|-h|-l|-p|-t|-T|-X|-Y|-A]
-h Display help

-c Rebuild ctl/
-f Rebuild fuzzer/ # deprecated, see fuzzer/README.md
-l Rebuild logger/
-p Rebuild probes/
-T Rebuild topology/ (not topology/development/! Use ALL)
-X Rebuild topology1 only
-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.

-C No build, only CMake re-configuration. Shows CMake targets.
EOFUSAGE

warn_if_incremental_build
}

# generate Makefiles
Expand All @@ -37,12 +41,7 @@ reconfigure_build()
mkdir -p "$BUILD_TOOLS_DIR"

( cd "$BUILD_TOOLS_DIR"
cmake -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools"
)

mkdir "$BUILD_TOOLS_DIR/fuzzer"
( cd "$BUILD_TOOLS_DIR/fuzzer"
cmake -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools/fuzzer"
cmake -GNinja -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" "${SOF_REPO}/tools"
)
}

Expand All @@ -58,37 +57,45 @@ make_tool()
)
}

make_fuzzer()
{
( set -x
cmake --build "$BUILD_TOOLS_DIR"/fuzzer -- -j "$NO_PROCESSORS"
)
}

print_build_info()
{
cat <<EOFUSAGE

Build commands for respective tools:
ctl: make -C "$BUILD_TOOLS_DIR" sof-ctl
logger: make -C "$BUILD_TOOLS_DIR" sof-logger
probes: make -C "$BUILD_TOOLS_DIR" sof-probes
topologies: make -C "$BUILD_TOOLS_DIR" topologies
test tplgs: make -C "$BUILD_TOOLS_DIR" tests
ctl: ninja -C "$BUILD_TOOLS_DIR" sof-ctl
logger: ninja -C "$BUILD_TOOLS_DIR" sof-logger
probes: ninja -C "$BUILD_TOOLS_DIR" sof-probes
topologies: ninja -C "$BUILD_TOOLS_DIR" topologies
topologies1: ninja -C "$BUILD_TOOLS_DIR" topologies1
topologies2: ninja -C "$BUILD_TOOLS_DIR" topologies2

test tplgs: ninja -C "$BUILD_TOOLS_DIR" tests
(or ./tools/test/topology/tplg-build.sh directly)

fuzzer: make -C "$BUILD_TOOLS_DIR/fuzzer"

list of targets:
make -C "$BUILD_TOOLS_DIR/" help
ninja -C "$BUILD_TOOLS_DIR/" help
EOFUSAGE

warn_if_incremental_build
}

warn_if_incremental_build()
{
$warn_incremental_build || return 0
cat <<EOF

WARNING: building tools/ is now incremental by default!
To build from scratch delete: $BUILD_TOOLS_DIR
or use the -C option.

EOF
}

main()
{
local DO_BUILD_ctl DO_BUILD_fuzzer DO_BUILD_logger DO_BUILD_probes \
DO_BUILD_tests DO_BUILD_topologies SCRIPT_DIR SOF_REPO CMAKE_ONLY \
BUILD_ALL
local DO_BUILD_ctl DO_BUILD_logger DO_BUILD_probes \
DO_BUILD_tests DO_BUILD_topologies1 DO_BUILD_topologies2 SCRIPT_DIR SOF_REPO \
CMAKE_ONLY BUILD_ALL
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SOF_REPO=$(dirname "$SCRIPT_DIR")
: "${BUILD_TOOLS_DIR:=$SOF_REPO/tools/build_tools}"
Expand All @@ -100,46 +107,62 @@ main()
fi

DO_BUILD_ctl=false
DO_BUILD_fuzzer=false
DO_BUILD_alsa=false
DO_BUILD_logger=false
DO_BUILD_probes=false
DO_BUILD_tests=false
DO_BUILD_topologies=false
DO_BUILD_topologies1=false
DO_BUILD_topologies2=false
CMAKE_ONLY=false

# better safe than sorry
local warn_incremental_build=true

# eval is a sometimes necessary evil
# shellcheck disable=SC2034
while getopts "cfhlptTC" OPTION; do
while getopts "cfhlptTCXYA" OPTION; do
case "$OPTION" in
c) DO_BUILD_ctl=true ;;
f) DO_BUILD_fuzzer=true ;;
l) DO_BUILD_logger=true ;;
p) DO_BUILD_probes=true ;;
t) DO_BUILD_tests=true ;;
T) DO_BUILD_topologies=true ;;
T) DO_BUILD_topologies1=true ; DO_BUILD_topologies2=true ;;
X) DO_BUILD_topologies1=true ;;
Y) DO_BUILD_topologies2=true ;;
C) CMAKE_ONLY=true ;;
A) DO_BUILD_alsa=true ;;
h) print_usage; exit 1;;
*) print_usage; exit 1;;
esac
done
shift "$((OPTIND - 1))"
reconfigure_build

if "$DO_BUILD_alsa"; then
$SOF_TOP/scripts/build-alsa-tools.sh
fi

if "$CMAKE_ONLY"; then
reconfigure_build
print_build_info
exit
fi

test -e "$BUILD_TOOLS_DIR"/build.ninja ||
test -e "$BUILD_TOOLS_DIR"/Makefile || {
warn_incremental_build=false
reconfigure_build
}

if "$BUILD_ALL"; then
# default CMake targets
make_tool # trust set -e

make_fuzzer
exit $?
warn_if_incremental_build
exit 0
fi

# Keep 'topologies' first because it's the noisiest.
for util in topologies tests; do
for util in topologies1 topologies2 tests; do
if eval '$DO_BUILD_'$util; then
make_tool $util
fi
Expand All @@ -151,9 +174,7 @@ main()
fi
done

if "$DO_BUILD_fuzzer"; then
make_fuzzer
fi
warn_if_incremental_build
}

main "$@"
6 changes: 3 additions & 3 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ make install
sof-logger is used to print logs delivered from FW dma_trace mechanism, by
searching log entries in *.ldc file generated by smex.

Every entry declared in FW is placed in elf output file (e.g. sof-apl) in
Every entry declared in FW is placed in elf output file (e.g. sof-tgl) in
.static_log_entries section in a form of struct defined in
sof/src/include/sof/trace.h in sof fw repo.

*.ldc file contains `snd_sof_logs_header` (defined in
rmbox/logger\_convert.c) following by `.static_log_entries` section
incorporated from FW elf file (e.g. sof-apl). `snd_sof_logs_header`
incorporated from FW elf file (e.g. sof-tgl). `snd_sof_logs_header`
contains basic information about `.static_log_entries` section
like `base_address` and `data_length`.

Expand Down Expand Up @@ -133,7 +133,7 @@ Usage sof-coredump-reader.py [-h] [-a ARCH] [-c] [-l COLUMNCOUNT] [-v]
We read from dump file into sof-coredump-reader.py,
then we pipe its output to xt-gdb, which operates on given elf-file.

$ ./sof-coredump-to-gdb.sh sof-apl dump_file
$ ./sof-coredump-to-gdb.sh sof-tgl dump_file

### tests

Expand Down
5 changes: 4 additions & 1 deletion tools/coredumper/sof-coredump-reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def stdout_print(*args, **kwargs):
]]
]

# Exception casues:
# Exception causes:
# CODE: [Exception cause, excvaddr loaded]
EXCCAUSE_CODE = {
0: ["IllegalInstructionCause: Illegal instruction", False],
Expand Down Expand Up @@ -719,6 +719,9 @@ def __init__(self, args):

stdoutOpen()

# disable confirmation request for undefined breakpoint
stdoutPrint("set confirm off\n")

# for XTOS SOF build
stdoutPrint("break _MemErrorVector\n")
# for Zephyr SOF build
Expand Down
21 changes: 21 additions & 0 deletions tools/corpus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SOF Corpus Directory

====================

The following directory is a special directory containing binary transcripts of
IPC messages from various devices. When OSS-Fuzz runs, it zips these files up
into a output directory to be used as seed material for the fuzzers.

Feel free to add more examples to this directory, more components and state
coverage the better.

## How to generate these files

These files are generated by live dumping the IPC messages, the initial batch
were created by adding a hook to write binary ipc window to the /tmp directory
from the kernel every time a IPC TX occurred. These files were then
concatenated together in order sent. A single file represents a single DSP
lifecycle. If you inspect the data, you will be able to parse out each IPC at
SOF_IPC_MSG_MAX_SIZE byte intervals.


1 change: 1 addition & 0 deletions tools/corpus/sof-ipc3/DELETE_ME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stub file until real data is added
1 change: 1 addition & 0 deletions tools/corpus/sof-ipc4/DELETE_ME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stub file until real data is added
4 changes: 4 additions & 0 deletions tools/ctl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ add_executable(sof-ctl
ctl.c
)

target_link_directories(sof-ctl BEFORE
PRIVATE "${SOF_ROOT_SOURCE_DIRECTORY}/../tools/lib")

target_link_libraries(sof-ctl PRIVATE
"-lasound"
)
Expand All @@ -13,6 +16,7 @@ target_compile_options(sof-ctl PRIVATE
)

target_include_directories(sof-ctl PRIVATE
"${SOF_ROOT_SOURCE_DIRECTORY}/../tools/include"
"${SOF_ROOT_SOURCE_DIRECTORY}/src/include"
"${SOF_ROOT_SOURCE_DIRECTORY}"
)
Expand Down
Loading
Loading