2020-02-06 10:05:55 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#############################################################################
|
2020-02-06 22:11:00 -05:00
|
|
|
# elf2hex <arch> <inputfile> <outputfile>
|
2020-02-06 10:05:55 -05:00
|
|
|
#
|
2020-03-26 12:20:00 -04:00
|
|
|
# Arch: e (for epiphany)
|
|
|
|
# rv32i/rv64i/etc (for riscv)
|
2020-02-06 10:05:55 -05:00
|
|
|
#
|
|
|
|
#############################################################################
|
2020-02-06 22:11:00 -05:00
|
|
|
import os
|
2020-02-06 10:05:55 -05:00
|
|
|
import sys
|
2020-02-06 22:11:00 -05:00
|
|
|
|
|
|
|
ARCH = sys.argv[1]
|
|
|
|
ELF = sys.argv[2]
|
|
|
|
HEX = sys.argv[3]
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
#SETUP
|
2020-03-26 12:20:00 -04:00
|
|
|
if(ARCH=="e"):
|
2020-02-06 22:11:00 -05:00
|
|
|
GCCROOT="e-"
|
2020-03-26 12:20:00 -04:00
|
|
|
else:
|
|
|
|
GCCROOT="riscv64-unknown-elf-"
|
2020-02-06 22:11:00 -05:00
|
|
|
|
|
|
|
##############################################
|
|
|
|
#RUN OBJCOPY
|
|
|
|
CMD=GCCROOT + "objcopy -Overilog" + " " + ELF + " " + HEX
|
|
|
|
print(CMD)
|
|
|
|
os.system(CMD)
|
2020-02-15 21:58:17 -05:00
|
|
|
#RUN OBJDUMP
|
|
|
|
CMD=GCCROOT + "objdump -D" + " " + ELF + " > " + HEX + ".dump"
|
|
|
|
print(CMD)
|
|
|
|
os.system(CMD)
|
2020-02-06 22:11:00 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|