2016-06-10 19:35:14 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This script is based on:
|
|
|
|
# https://docs.google.com/document/d/1Pvf9Yxorcd3sbgs8WcomcTl3J4bmX6e1UE0ROCefR88
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
echo "This script converts a flat file into an ELF, that can be passed"
|
|
|
|
echo "to SPIKE, the RISC-V reference emulator."
|
|
|
|
echo ""
|
|
|
|
echo "Usage: $0 coreboot.rom coreboot.elf"
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
FLAT_FILE="$1"
|
2018-01-08 18:31:42 +01:00
|
|
|
OBJECT_FILE=$(mktemp /tmp/coreboot-spike.XXXXXX)
|
2016-06-10 19:35:14 +02:00
|
|
|
ELF_FILE="$2"
|
|
|
|
TOOL_PATH="$(dirname "$0")"
|
2016-10-12 00:18:01 +02:00
|
|
|
XGCC_BIN="$TOOL_PATH/../crossgcc/xgcc/bin"
|
2016-06-10 19:35:14 +02:00
|
|
|
|
2016-10-12 00:18:01 +02:00
|
|
|
"$XGCC_BIN/riscv64-elf-objcopy" -I binary -O elf64-littleriscv \
|
2016-10-07 15:57:03 +02:00
|
|
|
-B riscv "$FLAT_FILE" "$OBJECT_FILE"
|
2016-10-12 00:18:01 +02:00
|
|
|
"$XGCC_BIN/riscv64-elf-ld" "$OBJECT_FILE" -T "$TOOL_PATH/spike-elf.ld" \
|
2016-10-07 15:57:03 +02:00
|
|
|
-o "$ELF_FILE"
|
2016-06-10 19:35:14 +02:00
|
|
|
rm "$OBJECT_FILE"
|