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-22 02:35:08 +00:00
|
|
|
riscv32-unknown-elf-as -march=rv32i -mabi=ilp32 ${FOLDER}/${NAME}.S -o ${NAME}.o
|
2023-11-20 13:20:42 +00:00
|
|
|
riscv32-unknown-elf-ld -Ttext=0x0 ${NAME}.o -o ${NAME}.elf
|
2023-11-20 05:21:26 +00:00
|
|
|
riscv32-unknown-elf-objcopy -O binary ${NAME}.elf ${NAME}.bin
|
2023-11-20 13:20:42 +00:00
|
|
|
|
2023-11-22 02:35:08 +00:00
|
|
|
rm -rf ${NAME}.o ${NAME}.elf
|
|
|
|
|
|
|
|
exit 0
|