-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
111 lines (87 loc) · 2.84 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright(C) 2019 Hex Five Security, Inc.
# 10-MAR-2019 Cesare Garlati
#############################################################
# GNU Toolchain definitions
#############################################################
ifndef RISCV
$(error RISCV not set)
endif
export CROSS_COMPILE := $(abspath $(RISCV))/bin/riscv64-unknown-elf-
export CC := $(CROSS_COMPILE)gcc
export OBJDUMP := $(CROSS_COMPILE)objdump
export OBJCOPY := $(CROSS_COMPILE)objcopy
export GDB := $(CROSS_COMPILE)gdb
export AR := $(CROSS_COMPILE)ar
#############################################################
# Platform definitions
#############################################################
BOARD ?= X300
ifeq ($(BOARD),E31)
RISCV_ARCH := rv32imac
RISCV_ABI := ilp32
else ifeq ($(BOARD),N25)
RISCV_ARCH := rv32imac
RISCV_ABI := ilp32
else ifeq ($(BOARD),X300)
RISCV_ARCH := rv32imac
RISCV_ABI := ilp32
else
$(error Unsupported board $(BOARD))
endif
BSP_BASE := ../bsp
BSP_DIR := $(BSP_BASE)/$(BOARD)
#############################################################
# Arguments/variables available to all submakes
#############################################################
export RISCV_ARCH
export RISCV_ABI
export BSP_BASE
export BSP_DIR
#############################################################
# Rules for building all benchmarks
#############################################################
.PHONY: all
all:
$(MAKE) -C ctx_switch
.PHONY: clean
clean:
$(MAKE) -C ctx_switch clean
#############################################################
# Load benchmark
#############################################################
TEST ?= ctx_switch
ifndef OPENOCD
$(error OPENOCD not set)
endif
OPENOCD := $(abspath $(OPENOCD))/bin/openocd
OPENOCDCFG ?= bsp/$(BOARD)/openocd.cfg
OPENOCDARGS += -f $(OPENOCDCFG)
GDB_PORT ?= 3333
GDB_LOAD_ARGS ?= --batch
GDB_LOAD_CMDS += -ex "set mem inaccessible-by-default off"
GDB_LOAD_CMDS += -ex "set remotetimeout 240"
GDB_LOAD_CMDS += -ex "target extended-remote localhost:$(GDB_PORT)"
GDB_LOAD_CMDS += -ex "monitor reset halt"
GDB_LOAD_CMDS += -ex "monitor flash protect 0 64 last off"
GDB_LOAD_CMDS += -ex "load"
GDB_LOAD_CMDS += -ex "monitor resume"
GDB_LOAD_CMDS += -ex "monitor shutdown"
GDB_LOAD_CMDS += -ex "quit"
.PHONY: load
load:
$(OPENOCD) $(OPENOCDARGS) & \
$(GDB) $(TEST)/$(TEST).hex $(GDB_LOAD_ARGS) $(GDB_LOAD_CMDS)
#############################################################
# Run benchmark
#############################################################
GDB_RUN_ARGS ?= --batch
GDB_RUN_CMDS += -ex "target extended-remote localhost:$(GDB_PORT)"
#GDB_RUN_CMDS += -ex "shell clear"
GDB_RUN_CMDS += -ex "jump _start"
GDB_RUN_CMDS += -ex 'p $$mhpmcounter4'
GDB_RUN_CMDS += -ex "monitor shutdown"
GDB_RUN_CMDS += -ex "quit"
.PHONY: run
run:
$(OPENOCD) $(OPENOCDARGS) & \
$(GDB) $(TEST)/$(TEST).elf $(GDB_RUN_ARGS) $(GDB_RUN_CMDS)