2023-11-22 02:35:08 +00:00
|
|
|
#!/bin/sh
|
2023-11-20 05:21:26 +00:00
|
|
|
|
|
|
|
if [ ! command -v riscv32-unknown-elf-as &> /dev/null ] \
|
|
|
|
|| [ ! command -v riscv32-unknown-elf-ld &> /dev/null ] \
|
|
|
|
|| [ ! command -v riscv32-unknown-elf-objcopy &> /dev/null ]
|
|
|
|
then
|
|
|
|
echo "riscv32-unknown-elf could not be found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
|
|
|
echo "Usage: $0 <file>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-11-22 02:35:08 +00:00
|
|
|
NAME=$(basename $1)
|
|
|
|
NAME=${NAME%.*}
|
|
|
|
FOLDER=$(dirname $1)
|
2023-11-20 05:21:26 +00:00
|
|
|
|
2023-11-25 14:18:24 +00:00
|
|
|
riscv32-unknown-elf-as -march=rv32i -mabi=ilp32 ${FOLDER}/${NAME}.S -o test.o
|
|
|
|
riscv32-unknown-elf-ld -Ttext=0x0 test.o -o test.elf
|
|
|
|
riscv32-unknown-elf-objcopy -O binary test.elf test.bin
|
2023-11-20 13:20:42 +00:00
|
|
|
|
2023-11-25 14:18:24 +00:00
|
|
|
rm -rf test.o test.elf
|
2023-11-22 02:35:08 +00:00
|
|
|
|
|
|
|
exit 0
|