Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Makefile options and reuse code from CoreMark #17

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-coremark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ echo "Start compilation"
make PORT_DIR=../riscv64 compile
mv coremark.riscv ../

make PORT_DIR=../riscv64-baremetal compile ITERATIONS=100
make PORT_DIR=../riscv64-baremetal compile
mv coremark.bare.riscv ../
10 changes: 10 additions & 0 deletions riscv64-baremetal/core_portme.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ void portable_free(void *p) {
#define TIMER_RES_DIVIDER 1
#define SAMPLE_TIME_IMPLEMENTATION 1
#endif

// Allow overriding EE_TICKS_PER_SEC
#ifndef EE_TICKS_PER_SEC
#define EE_TICKS_PER_SEC (NSECS_PER_SEC / TIMER_RES_DIVIDER)
#endif

#if SAMPLE_TIME_IMPLEMENTATION
/** Define Host specific (POSIX), or target specific global time variables. */
Expand Down Expand Up @@ -344,3 +348,9 @@ ee_u8 core_stop_parallel(core_results *res) {
#error "Please implement multicore functionality in core_portme.c to use multiple contexts."
#endif /* multithread implementations */
#endif

extern int putchar(int ch);

void uart_send_char (char ch) {
putchar(ch);
}
5 changes: 4 additions & 1 deletion riscv64-baremetal/core_portme.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Original Author: Shay Gal-on
Define to 1 if the platform has stdio.h and implements the printf function.
*/
#ifndef HAS_PRINTF
#define HAS_PRINTF 1
#define HAS_PRINTF 0
#endif

/* Configuration: CORE_TICKS
Expand Down Expand Up @@ -293,4 +293,7 @@ void portable_fini(core_portable *p);
#endif
#endif /* SEED_METHOD==SEED_VOLATILE */

extern void uart_send_char (char);
extern int ee_printf (const char *, ...);

#endif /* CORE_PORTME_H */
33 changes: 31 additions & 2 deletions riscv64-baremetal/core_portme.mak
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@

#File: core_portme.mak

# Flag: ARCH
# RISC-V ISA specification string
ARCH ?= rv64imafdc
# Flag: ABI
# RISC-V ABI
ABI ?= lp64d
ARCHFLAGS = -march=$(ARCH) -mabi=$(ABI)
# Flag: DEBUG
# Enable debugging output
DEBUG ?=
# Flag: TICKS_PER_SEC
# Hard-coded clock frequency of the tested CPU. Set to a reasonably low value
# when running in a RTL simulation.
TICKS_PER_SEC ?=
# Flag: RISCVTOOLS
# Use this flag to point to your RISCV tools
RISCVTOOLS=$(RISCV)
Expand All @@ -31,7 +45,13 @@ CC = $(RISCVTOOLS)/bin/$(RISCVTYPE)-gcc
# Flag: CFLAGS
# Use this flag to define compiler options. Note, you can add compiler options from the command line using XCFLAGS="other flags"
#PORT_CFLAGS = -O2 -static -std=gnu99
PORT_CFLAGS = -O2 -mcmodel=medany -static -std=gnu99 -fno-common -fno-tree-loop-distribute-patterns -nostdlib -nostartfiles -lm -lgcc -T $(PORT_DIR)/link.ld
PORT_CFLAGS = $(ARCHFLAGS) -O2 -mcmodel=medany -static -std=gnu99 -fno-common -fno-tree-loop-distribute-patterns -nostdlib -nostartfiles -fno-builtin -lm -lgcc -T $(PORT_DIR)/link.ld
ifneq ($(TICKS_PER_SEC),)
PORT_CFLAGS += -DEE_TICKS_PER_SEC=$(TICKS_PER_SEC)
endif
ifneq ($(DEBUG),)
PORT_CFLAGS += -DCORE_DEBUG=1
endif
FLAGS_STR = "$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END)"
CFLAGS = $(PORT_CFLAGS) -I$(PORT_DIR) -I. -DFLAGS_STR=\"$(FLAGS_STR)\"
#Flag: LFLAGS_END
Expand All @@ -40,14 +60,23 @@ CFLAGS = $(PORT_CFLAGS) -I$(PORT_DIR) -I. -DFLAGS_STR=\"$(FLAGS_STR)\"
LFLAGS_END +=
# Flag: PORT_SRCS
# Port specific source files can be added here
PORT_SRCS = $(PORT_DIR)/core_portme.c $(PORT_DIR)/syscalls.c $(PORT_DIR)/crt.S
PORT_SRCS = $(PORT_DIR)/core_portme.c $(PORT_DIR)/syscalls.c $(PORT_DIR)/crt.S $(PORT_DIR)/ee_printf.c barebones/cvt.c
# Flag: LOAD
# Define this flag if you need to load to a target, as in a cross compile environment.

# Flag: RUN
# Define this flag if running does not consist of simple invocation of the binary.
# In a cross compile environment, you need to define this.

# Instead of copying and manually modifying ee_printf.c file its done on the fly:
# - uart_send_char() is marked as weak. It's implemented in a different file
# - the #error directive is removed
# - ee_printf() buffer is increased to 1KB
$(PORT_DIR)/ee_printf.c: barebones/ee_printf.c
@sed '/uart_send_char(char c)/s/^/__attribute__((weak)) /' $< >$@
@sed -ie '/#error/d' $@
@sed -i 's/char buf\[256\]/char buf\[1024\]/g' $@

#For flashing and using a tera term macro, you could use
#LOAD = flash ADDR
#RUN = ttpmacro coremark.ttl
Expand Down
Loading