Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rules/opentitan/qemu.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ def _test_dispatch(ctx, exec_env, firmware):
}
param["bootstrap_cmd"] = '--exec="no-op" # SKIPPING BOOTSTRAP'

# Attach SPI flash to SPI Host 0/SPI Device bus. Chosen model is W25Q256 (32MiB)
qemu_args += ["-global", "ot-earlgrey-board.spiflash0=w25q256"]
qemu_args += ["-drive", "if=mtd,file=spiflash0.bin,format=raw,bus=0"]

# Get the pre-test_cmd args.
args = get_fallback(ctx, "attr.args", exec_env)
args = " ".join(args).format(**param)
Expand Down
5 changes: 5 additions & 0 deletions rules/scripts/qemu_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ args=( __args__ )

mutable_flash="flash_img.bin"
mutable_otp="otp_img.raw"
spiflash0="spiflash0.bin"

test_args=( "$@" )
qemu_test_args=()
Expand Down Expand Up @@ -52,6 +53,7 @@ cleanup() {
wait "$qemu_pid"

rm -f "${mutable_otp}" "${mutable_flash}"
rm -f "${spiflash0}"
rm -f qemu-monitor qemu.log
}
trap cleanup EXIT
Expand All @@ -63,6 +65,9 @@ if [ -n "${flash}" ]; then
cp "${flash}" "${mutable_flash}" && chmod +w "${mutable_flash}"
fi

# create backing storage for flash device on SPI Host 0/SPI Device SPI bus
dd if=/dev/zero of="${spiflash0}" bs=1M count=32 status=none && chmod +w "${spiflash0}"

# QEMU disconnects from `stdout` when it daemonizes so we need to stream
# the log through a pipe:
mkfifo qemu.log && cat qemu.log &
Expand Down
6 changes: 6 additions & 0 deletions sw/device/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5762,6 +5762,12 @@ opentitan_test(
""",
test_harness = "//sw/host/tests/chip/spi_device:spi_passthru",
),
qemu = qemu_params(
test_cmd = """
"{firmware:elf}"
""",
test_harness = "//sw/host/tests/chip/spi_device:spi_passthru",
),
silicon = silicon_params(
test_cmd = """
--bootstrap="{firmware}"
Expand Down
Loading