Jonathan Neuschäfer | 2459f67 | 2016-06-10 19:35:14 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # This script is based on: |
| 4 | # https://docs.google.com/document/d/1Pvf9Yxorcd3sbgs8WcomcTl3J4bmX6e1UE0ROCefR88 |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | usage() { |
| 9 | echo "This script converts a flat file into an ELF, that can be passed" |
| 10 | echo "to SPIKE, the RISC-V reference emulator." |
| 11 | echo "" |
| 12 | echo "Usage: $0 coreboot.rom coreboot.elf" |
| 13 | } |
| 14 | |
| 15 | if [ $# -ne 2 ]; then |
| 16 | usage |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | FLAT_FILE="$1" |
Jonathan Neuschäfer | 3af80a9 | 2018-01-08 18:31:42 +0100 | [diff] [blame] | 21 | OBJECT_FILE=$(mktemp /tmp/coreboot-spike.XXXXXX) |
Jonathan Neuschäfer | 2459f67 | 2016-06-10 19:35:14 +0200 | [diff] [blame] | 22 | ELF_FILE="$2" |
| 23 | TOOL_PATH="$(dirname "$0")" |
Ronald G. Minnich | 3401f5a | 2016-10-12 00:18:01 +0200 | [diff] [blame] | 24 | XGCC_BIN="$TOOL_PATH/../crossgcc/xgcc/bin" |
Jonathan Neuschäfer | 2459f67 | 2016-06-10 19:35:14 +0200 | [diff] [blame] | 25 | |
Ronald G. Minnich | 3401f5a | 2016-10-12 00:18:01 +0200 | [diff] [blame] | 26 | "$XGCC_BIN/riscv64-elf-objcopy" -I binary -O elf64-littleriscv \ |
Ronald G. Minnich | aa9df0f | 2016-10-07 06:57:03 -0700 | [diff] [blame] | 27 | -B riscv "$FLAT_FILE" "$OBJECT_FILE" |
Ronald G. Minnich | 3401f5a | 2016-10-12 00:18:01 +0200 | [diff] [blame] | 28 | "$XGCC_BIN/riscv64-elf-ld" "$OBJECT_FILE" -T "$TOOL_PATH/spike-elf.ld" \ |
Ronald G. Minnich | aa9df0f | 2016-10-07 06:57:03 -0700 | [diff] [blame] | 29 | -o "$ELF_FILE" |
Jonathan Neuschäfer | 2459f67 | 2016-06-10 19:35:14 +0200 | [diff] [blame] | 30 | rm "$OBJECT_FILE" |