2018-10-12 13:07:17 +08:00
|
|
|
#!/bin/bash
|
2019-06-02 04:58:16 +08:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright(c) 2018 Intel Corporation. All rights reserved.
|
2020-05-22 08:51:21 +08:00
|
|
|
set -e
|
2018-10-12 13:07:17 +08:00
|
|
|
|
2020-03-23 15:01:16 +08:00
|
|
|
SUPPORTED_PLATFORMS=(byt cht bdw hsw apl icl skl kbl cnl imx8 imx8x imx8m)
|
2019-01-17 18:56:40 +08:00
|
|
|
READY_MSG="6c 00 00 00 00 00 00 70"
|
2018-10-12 13:07:17 +08:00
|
|
|
|
2020-05-22 08:10:58 +08:00
|
|
|
SOF_DIR=$(cd "$(dirname "$0")" && cd .. && pwd)
|
|
|
|
|
|
|
|
: "${SOF_BUILDS:=${SOF_DIR}}"
|
|
|
|
|
2018-10-12 13:07:17 +08:00
|
|
|
rm -f dump-*.txt
|
|
|
|
|
2020-05-22 08:44:52 +08:00
|
|
|
die()
|
|
|
|
{
|
|
|
|
>&2 printf '%s ERROR: ' "$0"
|
2020-06-27 13:20:38 +08:00
|
|
|
# We want die() to be usable exactly like printf
|
|
|
|
# shellcheck disable=SC2059
|
2020-05-22 08:44:52 +08:00
|
|
|
>&2 printf "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2020-04-18 23:24:23 +08:00
|
|
|
print_usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
2020-05-22 07:02:45 +08:00
|
|
|
usage: qemu-check.sh [ platform(s) ]
|
2020-04-18 23:24:23 +08:00
|
|
|
Supported platforms are ${SUPPORTED_PLATFORMS[*]}
|
2020-05-22 07:02:45 +08:00
|
|
|
Runs all supported platforms by default.
|
2020-04-18 23:24:23 +08:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2020-05-22 08:44:52 +08:00
|
|
|
find_qemu_xtensa()
|
|
|
|
{
|
|
|
|
local xhs=xtensa-host.sh
|
|
|
|
for d in . ../qemu* qemu*; do
|
|
|
|
if test -e "$d"/$xhs; then
|
|
|
|
printf '%s' "$d"/$xhs;
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
die '%s not found\n' $xhs
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-18 23:24:23 +08:00
|
|
|
while getopts "" OPTION; do
|
|
|
|
case "$OPTION" in
|
|
|
|
*) print_usage; exit 1 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND-1))
|
|
|
|
|
2020-04-18 23:12:58 +08:00
|
|
|
PLATFORMS=()
|
2020-04-18 23:24:23 +08:00
|
|
|
if [ "$#" -eq 0 ]; then
|
2020-04-18 23:12:58 +08:00
|
|
|
PLATFORMS=("${SUPPORTED_PLATFORMS[@]}")
|
2018-10-12 13:07:17 +08:00
|
|
|
else
|
2020-04-18 23:24:23 +08:00
|
|
|
for arg in "$@"; do
|
|
|
|
platform=unknown
|
|
|
|
for sp in "${SUPPORTED_PLATFORMS[@]}"; do
|
|
|
|
if [ x"$sp" = x"$arg" ]; then
|
|
|
|
PLATFORMS=("${PLATFORMS[@]}" "$sp")
|
|
|
|
platform=$sp
|
|
|
|
shift
|
|
|
|
break
|
2018-10-12 13:07:17 +08:00
|
|
|
fi
|
|
|
|
done
|
2020-04-19 00:21:07 +08:00
|
|
|
if [ "$platform" = "unknown" ]; then
|
|
|
|
echo "Error: Unknown platform specified: $arg"
|
|
|
|
echo "Supported platforms: ${SUPPORTED_PLATFORMS[*]}"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-10-12 13:07:17 +08:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2020-04-18 23:43:40 +08:00
|
|
|
for platform in "${PLATFORMS[@]}"
|
2018-10-12 13:07:17 +08:00
|
|
|
do
|
2020-04-18 23:43:40 +08:00
|
|
|
FWNAME="sof-$platform.ri"
|
|
|
|
PLATFORM=$platform
|
2020-02-28 13:06:34 +08:00
|
|
|
# reset variable to avoid issue in random order
|
|
|
|
ROM=''
|
|
|
|
OUTBOX_OFFSET=''
|
2020-04-18 23:43:40 +08:00
|
|
|
|
|
|
|
has_rom=false
|
|
|
|
case "$platform" in
|
|
|
|
byt)
|
|
|
|
READY_IPC="00 88 02 70 00 00 00 80"
|
|
|
|
SHM_IPC_REG=qemu-bridge-shim-io
|
|
|
|
SHM_MBOX=qemu-bridge-mbox-io
|
|
|
|
;;
|
|
|
|
cht)
|
|
|
|
READY_IPC="00 88 02 70 00 00 00 80"
|
|
|
|
SHM_IPC_REG=qemu-bridge-shim-io
|
|
|
|
SHM_MBOX=qemu-bridge-mbox-io
|
|
|
|
;;
|
|
|
|
bdw)
|
|
|
|
READY_IPC="00 3c 01 80"
|
|
|
|
OUTBOX_OFFSET="9e000"
|
|
|
|
SHM_IPC_REG=qemu-bridge-shim-io
|
|
|
|
SHM_MBOX=qemu-bridge-dram-mem
|
|
|
|
;;
|
|
|
|
hsw)
|
|
|
|
READY_IPC="00 fc 00 80"
|
|
|
|
OUTBOX_OFFSET="7e000"
|
|
|
|
SHM_IPC_REG=qemu-bridge-shim-io
|
|
|
|
SHM_MBOX=qemu-bridge-dram-mem
|
|
|
|
;;
|
|
|
|
apl)
|
|
|
|
READY_IPC="00 00 00 f0"
|
|
|
|
SHM_IPC_REG="qemu-bridge-ipc(|-dsp)-io"
|
|
|
|
OUTBOX_OFFSET="7000"
|
|
|
|
SHM_MBOX=qemu-bridge-hp-sram-mem
|
|
|
|
has_rom=true
|
|
|
|
;;
|
|
|
|
skl)
|
|
|
|
READY_IPC="00 00 00 f0"
|
|
|
|
SHM_IPC_REG="qemu-bridge-ipc(|-dsp)-io"
|
|
|
|
OUTBOX_OFFSET="7000"
|
|
|
|
SHM_MBOX=qemu-bridge-hp-sram-mem
|
|
|
|
has_rom=true
|
|
|
|
;;
|
|
|
|
kbl)
|
|
|
|
READY_IPC="00 00 00 f0"
|
|
|
|
SHM_IPC_REG="qemu-bridge-ipc(|-dsp)-io"
|
|
|
|
OUTBOX_OFFSET="7000"
|
|
|
|
SHM_MBOX=qemu-bridge-hp-sram-mem
|
|
|
|
has_rom=true
|
|
|
|
;;
|
|
|
|
cnl)
|
|
|
|
READY_IPC="00 00 00 f0"
|
|
|
|
SHM_IPC_REG="qemu-bridge-ipc(|-dsp)-io"
|
|
|
|
OUTBOX_OFFSET="5000"
|
|
|
|
SHM_MBOX=qemu-bridge-hp-sram-mem
|
|
|
|
has_rom=true
|
|
|
|
;;
|
|
|
|
icl)
|
|
|
|
READY_IPC="00 00 00 f0"
|
|
|
|
SHM_IPC_REG="qemu-bridge-ipc(|-dsp)-io"
|
|
|
|
OUTBOX_OFFSET="5000"
|
|
|
|
SHM_MBOX=qemu-bridge-hp-sram-mem
|
|
|
|
has_rom=true
|
|
|
|
;;
|
|
|
|
imx8 | imx8x | imx8m)
|
|
|
|
READY_IPC="00 00 00 00 00 00 04 c0"
|
|
|
|
SHM_IPC_REG=qemu-bridge-mu-io
|
|
|
|
SHM_MBOX=qemu-bridge-mbox-io
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if $has_rom; then
|
2020-06-27 13:20:38 +08:00
|
|
|
ROM=(-r "${SOF_BUILDS}/build_${platform}_gcc/src/arch/xtensa/rom-$platform.bin")
|
2020-02-20 20:03:34 +08:00
|
|
|
fi
|
2018-10-12 13:07:17 +08:00
|
|
|
|
2020-05-22 08:44:52 +08:00
|
|
|
xtensa_host_sh=$(find_qemu_xtensa)
|
|
|
|
|
|
|
|
${xtensa_host_sh} "$PLATFORM" -k \
|
2020-05-22 08:10:58 +08:00
|
|
|
"${SOF_BUILDS}"/build_"${platform}"_gcc/src/arch/xtensa/"$FWNAME" \
|
2020-06-27 13:20:38 +08:00
|
|
|
"${ROM[@]}" \
|
2020-05-22 08:51:21 +08:00
|
|
|
-o 2.0 "${SOF_BUILDS}"/dump-"$platform".txt || true # timeout
|
2018-10-12 13:07:17 +08:00
|
|
|
# dump log into sof.git incase running in docker
|
|
|
|
|
2019-10-30 11:56:30 +08:00
|
|
|
# use regular expression to match the SHM IPC REG file name
|
|
|
|
SHM_IPC_REG_FILE=$(ls /dev/shm/ | grep -E $SHM_IPC_REG)
|
|
|
|
|
2019-01-17 18:56:40 +08:00
|
|
|
# check if ready ipc header is in the ipc regs
|
2020-06-27 13:24:03 +08:00
|
|
|
IPC_REG=$(hexdump -C /dev/shm/"$SHM_IPC_REG_FILE" |
|
|
|
|
grep "$READY_IPC") || true
|
|
|
|
|
2019-01-17 18:56:40 +08:00
|
|
|
# check if ready ipc message is in the mbox
|
2020-06-27 13:24:03 +08:00
|
|
|
IPC_MSG=$(hexdump -C /dev/shm/$SHM_MBOX | grep -A 4 "$READY_MSG" |
|
|
|
|
grep -A 4 "$OUTBOX_OFFSET") || true
|
2019-01-17 18:56:40 +08:00
|
|
|
|
|
|
|
if [ "$IPC_REG" ]; then
|
|
|
|
echo "ipc reg dump:"
|
|
|
|
# directly output the log to be nice to look
|
2020-05-22 07:02:45 +08:00
|
|
|
hexdump -C /dev/shm/"$SHM_IPC_REG_FILE" | grep "$READY_IPC"
|
2019-01-17 18:56:40 +08:00
|
|
|
if [ "$IPC_MSG" ]; then
|
|
|
|
echo "ipc message dump:"
|
|
|
|
# directly output the log to be nice to look
|
|
|
|
hexdump -C /dev/shm/$SHM_MBOX | grep -A 4 "$READY_MSG" | grep -A 4 "$OUTBOX_OFFSET"
|
|
|
|
else
|
|
|
|
echo "Error mailbox failed"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Error ipc reg failed"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$IPC_REG" && "$IPC_MSG" ]]; then
|
2018-10-12 13:07:17 +08:00
|
|
|
echo "Boot success";
|
|
|
|
else
|
|
|
|
echo "Error boot failed"
|
2020-05-22 08:10:58 +08:00
|
|
|
tail -n 50 "${SOF_BUILDS}"/dump-"$platform".txt
|
2018-10-12 13:07:17 +08:00
|
|
|
exit 2;
|
|
|
|
fi
|
|
|
|
done
|