mirror of
https://github.com/aolofsson/oh.git
synced 2025-01-17 20:02:53 +08:00
37 lines
748 B
Python
Executable File
37 lines
748 B
Python
Executable File
#!/usr/bin/env python3
|
|
#############################################################################
|
|
# elf2hex <arch> <inputfile> <outputfile>
|
|
#
|
|
# Arch: e (for epiphany)
|
|
# rv32i/rv64i/etc (for riscv)
|
|
#
|
|
#############################################################################
|
|
import os
|
|
import sys
|
|
|
|
ARCH = sys.argv[1]
|
|
ELF = sys.argv[2]
|
|
HEX = sys.argv[3]
|
|
|
|
#############################################
|
|
#SETUP
|
|
if(ARCH=="e"):
|
|
GCCROOT="e-"
|
|
else:
|
|
GCCROOT="riscv64-unknown-elf-"
|
|
|
|
##############################################
|
|
#RUN OBJCOPY
|
|
CMD=GCCROOT + "objcopy -Overilog" + " " + ELF + " " + HEX
|
|
print(CMD)
|
|
os.system(CMD)
|
|
#RUN OBJDUMP
|
|
CMD=GCCROOT + "objdump -D" + " " + ELF + " > " + HEX + ".dump"
|
|
print(CMD)
|
|
os.system(CMD)
|
|
|
|
|
|
|
|
|
|
|