[otbn] Port smoke test to use the new multi-segment ELF support
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/ip/otbn/dv/smoke/run_smoke.sh b/hw/ip/otbn/dv/smoke/run_smoke.sh
index 131a9a0..dc258cb 100755
--- a/hw/ip/otbn/dv/smoke/run_smoke.sh
+++ b/hw/ip/otbn/dv/smoke/run_smoke.sh
@@ -12,6 +12,7 @@
}
set -o pipefail
+set -e
SCRIPT_DIR="$(dirname "$(readlink -e "$BASH_SOURCE")")"
UTIL_DIR="$(readlink -e "$SCRIPT_DIR/../../../../../util")" || \
@@ -24,23 +25,23 @@
mkdir -p $SMOKE_BIN_DIR
-$REPO_TOP/hw/ip/otbn/util/build.sh $SMOKE_SRC_DIR/smoke_test.S \
- $SMOKE_BIN_DIR/smoke || fail "Software build failed"
+OTBN_UTIL=$REPO_TOP/hw/ip/otbn/util
-pushd $REPO_TOP
+$OTBN_UTIL/otbn-as -o $SMOKE_BIN_DIR/smoke_test.o $SMOKE_SRC_DIR/smoke_test.S || \
+ fail "Failed to assemble smoke_test.S"
+$OTBN_UTIL/otbn-ld -o $SMOKE_BIN_DIR/smoke.elf $SMOKE_BIN_DIR/smoke_test.o || \
+ fail "Failed to link smoke_test.o"
-fusesoc --cores-root=. run --target=sim --setup --build \
- lowrisc:ip:otbn_top_sim || fail "HW Sim build failed"
-
-popd
+(cd $REPO_TOP;
+ fusesoc --cores-root=. run --target=sim --setup --build \
+ lowrisc:ip:otbn_top_sim || fail "HW Sim build failed")
RUN_LOG=`mktemp`
trap "rm -rf $RUN_LOG" EXIT
timeout 5s \
$REPO_TOP/build/lowrisc_ip_otbn_top_sim_0.1/sim-verilator/Votbn_top_sim \
- --meminit=imem,$SMOKE_BIN_DIR/smoke_imem.elf \
- --meminit=dmem,$SMOKE_BIN_DIR/smoke_dmem.elf | tee $RUN_LOG
+ --load-elf=$SMOKE_BIN_DIR/smoke.elf | tee $RUN_LOG
if [ $? -eq 124 ]; then
fail "Simulation timeout"
diff --git a/hw/ip/otbn/util/build.sh b/hw/ip/otbn/util/build.sh
deleted file mode 100755
index f15c8dd..0000000
--- a/hw/ip/otbn/util/build.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/bash
-# Copyright lowRISC contributors.
-# Licensed under the Apache License, Version 2.0, see LICENSE for details.
-# SPDX-License-Identifier: Apache-2.0
-
-set -e
-
-if [ "$#" -ne 2 ]; then
- echo "Basic script to build a binary from a single OTBN assembly file. Input file is"
- echo "first argument, prefix for output files is second argument. Only use .data and"
- echo ".text sections in input asm"
- echo ""
- echo "$0 input.S out_dir/prog"
- echo ""
- echo "Will produce:"
- echo ""
- echo "* out_dir/prog.o - input.S assembled object file"
- echo "* out_dir/prog.elf - Linked binary"
- echo "* out_dir/prog.dis - Disassembled binary"
- echo "* out_dir/prog_imem.elf - .text section alone"
- echo "* out_dir/prog_dmem.elf - .data section alone"
- exit 1
-fi
-
-SCRIPT_FILE=$(readlink -f "$BASH_SOURCE")
-OTBN_UTIL_DIR=$(dirname "$SCRIPT_FILE")
-
-$OTBN_UTIL_DIR/otbn-as $1 -o $2.o
-$OTBN_UTIL_DIR/otbn-ld $2.o -o $2.elf
-$OTBN_UTIL_DIR/otbn-objdump -f -h -S -D $2.elf > $2.dis
-riscv32-unknown-elf-objcopy -j .text $2.elf $2_imem.elf
-riscv32-unknown-elf-objcopy -j .data $2.elf $2_dmem.elf