43 lines
747 B
Python
43 lines
747 B
Python
|
|
import os
|
|
import sys
|
|
import time
|
|
|
|
|
|
|
|
|
|
|
|
CC="riscv64-unknown-elf-gcc"
|
|
OBJCPY="riscv64-unknown-elf-objcopy"
|
|
OBJDUMP="riscv64-unknown-elf-objdump"
|
|
|
|
CFLAG=[
|
|
"-march=rv32i",
|
|
"-mabi=ilp32",
|
|
"-ffunction-sections",
|
|
"-fdata-sections",
|
|
"-ffast-math",
|
|
"-fno-common",
|
|
"-fno-builtin-printf",
|
|
"-Wall",
|
|
"-Werror",
|
|
"-g",
|
|
"-O0",
|
|
"-fno-omit-frame-pointer",
|
|
"-msave-restore"
|
|
]
|
|
|
|
SRC=[
|
|
"riscv/main.c",
|
|
"riscv/start.S"
|
|
]
|
|
|
|
LD_FILE="riscv.ld"
|
|
|
|
TARGET="riscv"
|
|
|
|
if __name__ == "__main__":
|
|
os.system(f"{CC} {' '.join(CFLAG)} {' '.join(SRC)} -T{LD_FILE} -Wall -Wextra -nostartfiles -Wl,-Map,\"{TARGET}.map\" -o {TARGET}.elf")
|
|
os.system(f"{OBJCPY} -O binary {TARGET}.elf {TARGET}.bin")
|
|
os.system(f"{OBJDUMP} -d {TARGET}.elf > {TARGET}.lst")
|