1717# File : core_portme.mak
1818
1919RISCV_ARCH = rv32i_zicsr
20- RISCV_ABI = ilp32
2120
2221# Flag : OUTFLAG
2322# Use this flag to define how to to get an executable (e.g -o)
2423OUTFLAG = -o
2524# Flag : CC
2625# Use this flag to define compiler to use
27- CC = riscv64 -unknown-elf-gcc
26+ CC = riscv32 -unknown-elf-gcc
2827# Flag : LD
2928# Use this flag to define compiler to use
30- LD = riscv64 -unknown-elf-gcc
29+ LD = riscv32 -unknown-elf-gcc
3130# Flag : AS
3231# Use this flag to define compiler to use
33- AS = riscv64 -unknown-elf-gcc
32+ AS = riscv32 -unknown-elf-gcc
3433# Flag : CFLAGS
3534# Use this flag to define compiler options. Note, you can add compiler options from the command line using XCFLAGS="other flags"
36- PORT_CFLAGS = -march=$(RISCV_ARCH ) -mabi= $( RISCV_ABI ) -nostdlib -nostartfiles -static -lgcc --compile -O0 -g
35+ PORT_CFLAGS = -march=$(RISCV_ARCH ) --compile -O0 -g -nostdlib -nostartfiles
3736FLAGS_STR = "$(PORT_CFLAGS ) $(XCFLAGS ) $(XLFLAGS ) $(LFLAGS_END ) "
3837CFLAGS = $(PORT_CFLAGS ) -I$(PORT_DIR ) -I. -DFLAGS_STR=\"$(FLAGS_STR ) \"
3938# Flag : LFLAGS_END
@@ -43,20 +42,20 @@ SEPARATE_COMPILE=1
4342# Flag : SEPARATE_COMPILE
4443# You must also define below how to create an object file, and how to link.
4544OBJOUT = -o
46- LFLAGS = -march= $( RISCV_ARCH ) -nostdlib -nostartfiles -static -lgcc - T$(PORT_DIR ) /../../rust/mlogv32/link.x
47- ASFLAGS = -march= $( RISCV_ARCH ) -mabi= $( RISCV_ABI ) - -compile
45+ LFLAGS = -T$(PORT_DIR ) /../../rust/mlogv32/link.x -nostartfiles
46+ ASFLAGS = --compile
4847OFLAG = -o
4948COUT = -c
5049
5150LFLAGS_END =
5251# Flag : PORT_SRCS
5352# Port specific source files can be added here
5453# You may also need cvt.c if the fcvt functions are not provided as intrinsics by your compiler!
55- PORT_SRCS = $(PORT_DIR ) /core_portme.c $(PORT_DIR ) /ee_printf.c $(PORT_DIR ) /ecall.c
54+ PORT_SRCS = $(PORT_DIR ) /core_portme.c $(PORT_DIR ) /ee_printf.c $(PORT_DIR ) /ecall.c $( PORT_DIR ) /entry.s
5655vpath % .c $(PORT_DIR )
5756vpath % .s $(PORT_DIR )
5857
59- PORT_OBJS = $(PORT_DIR ) /core_portme.o $(PORT_DIR ) /ee_printf.o $(PORT_DIR ) /ecall.o
58+ PORT_OBJS = $(PORT_DIR ) /core_portme.o $(PORT_DIR ) /ee_printf.o $(PORT_DIR ) /ecall.o $( PORT_DIR ) /entry.o
6059
6160# Flag : LOAD
6261# For a simple port, we assume self hosted compile and run, no load needed.
@@ -68,7 +67,7 @@ LOAD = echo "Please set LOAD to the process of loading the executable to the fla
6867RUN = echo "Please set LOAD to the process of running the executable (e.g. via jtag, or board reset)"
6968
7069OEXT = .o
71- EXE = .bin
70+ EXE = .out
7271
7372$(OPATH )$(PORT_DIR ) /% $(OEXT ) : % .c
7473 $(CC ) $(CFLAGS ) $(XCFLAGS ) $(COUT ) $< $(OBJOUT ) $@
@@ -79,11 +78,42 @@ $(OPATH)%$(OEXT) : %.c
7978$(OPATH )$(PORT_DIR ) /% $(OEXT ) : % .s
8079 $(AS ) $(ASFLAGS ) $< $(OBJOUT ) $@
8180
82- # Target : port_pre% and port_post%
83- # For the purpose of this simple port, no pre or post steps needed.
84-
85- .PHONY : port_prebuild port_postbuild port_prerun port_postrun port_preload port_postload
86- port_pre% port_post% :
81+ PORT_CLEAN = $(OPATH ) coremark.bin $(OPATH ) coremark.dump
82+
83+ .PHONY : port_prebuild
84+ port_prebuild :
85+
86+ # Target: port_postbuild
87+ # Generate any files that are needed after actual build end.
88+ # E.g. change format to srec, bin, zip in order to be able to load into flash
89+ .PHONY : port_postbuild
90+ port_postbuild :
91+ riscv32-unknown-elf-objcopy --output-target binary $(OUTFILE ) $(OPATH ) coremark.bin
92+ riscv32-unknown-elf-objdump --disassemble $(OUTFILE ) > $(OPATH ) coremark.dump
93+
94+ # Target: port_prerun
95+ # Do platform specific before run stuff.
96+ # E.g. reset the board, backup the logfiles etc.
97+ .PHONY : port_prerun
98+ port_prerun :
99+
100+ # Target: port_postrun
101+ # Do platform specific after run stuff.
102+ # E.g. reset the board, backup the logfiles etc.
103+ .PHONY : port_postrun
104+ port_postrun :
105+
106+ # Target: port_preload
107+ # Do platform specific before load stuff.
108+ # E.g. reset the reset power to the flash eraser
109+ .PHONY : port_preload
110+ port_preload :
111+
112+ # Target: port_postload
113+ # Do platform specific after load stuff.
114+ # E.g. reset the reset power to the flash eraser
115+ .PHONY : port_postload
116+ port_postload :
87117
88118# FLAG : OPATH
89119# Path to the output folder. Default - current folder.
0 commit comments