mb/dell: Add Latitude E5520 (Sandy Bridge)
[coreboot.git] / util / riscv / make-spike-elf.sh
blob135b62ad97727398e622317724d0c2d279741fe9
1 #!/usr/bin/env sh
3 # This script is based on:
4 # https://docs.google.com/document/d/1Pvf9Yxorcd3sbgs8WcomcTl3J4bmX6e1UE0ROCefR88
6 set -e
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"
15 if [ $# -ne 2 ]; then
16 usage
17 exit 1
20 FLAT_FILE="$1"
21 OBJECT_FILE=$(mktemp /tmp/coreboot-spike.XXXXXX)
22 ELF_FILE="$2"
23 TOOL_PATH="$(dirname "$0")"
24 XGCC_BIN="$TOOL_PATH/../crossgcc/xgcc/bin"
26 "$XGCC_BIN/riscv64-elf-objcopy" -I binary -O elf64-littleriscv \
27 -B riscv "$FLAT_FILE" "$OBJECT_FILE"
28 "$XGCC_BIN/riscv64-elf-ld" "$OBJECT_FILE" -T "$TOOL_PATH/spike-elf.ld" \
29 -o "$ELF_FILE"
30 rm "$OBJECT_FILE"