forked from hex-five/multizone-linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (92 loc) · 2.87 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
112
113
114
115
# Copyright(C) 2018 Hex Five Security, Inc. - All Rights Reserved
#############################################################
# 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 ?= E31
ifeq ($(BOARD),E21)
ARCH := rv32
RISCV_ARCH := $(ARCH)imac
RISCV_ABI := ilp32
else ifeq ($(BOARD),E31)
ARCH := rv32
RISCV_ARCH := $(ARCH)imac
RISCV_ABI := ilp32
else ifeq ($(BOARD),E51)
ARCH := rv64
RISCV_ARCH := $(ARCH)imac
RISCV_ABI := lp64
else ifeq ($(BOARD),S51)
ARCH := rv64
RISCV_ARCH := $(ARCH)imac
RISCV_ABI := lp64
else ifeq ($(BOARD),U540)
ARCH := rv64
RISCV_ARCH := $(ARCH)imac
RISCV_ABI := lp64
else ifeq ($(BOARD),X300)
ARCH := rv32
RISCV_ARCH := $(ARCH)imac
RISCV_ABI := ilp32
else
$(error Unsupported board $(BOARD))
endif
#############################################################
# Arguments/variables available to all submakes
#############################################################
export BOARD
export RISCV_ARCH
export RISCV_ABI
#############################################################
# Rules for building multizone
#############################################################
.PHONY: all
all: clean
$(MAKE) -C zone1
$(MAKE) -C zone2
$(MAKE) -C zone3
$(MAKE) -C zone4
java -jar multizone.jar -c bsp/$(BOARD)/multizone.cfg zone1/zone1.hex zone2/zone2.hex zone3/zone3.hex zone4/zone4.hex --arch=$(BOARD)
.PHONY: clean
clean:
$(MAKE) -C zone1 clean
$(MAKE) -C zone2 clean
$(MAKE) -C zone3 clean
$(MAKE) -C zone4 clean
rm -f multizone.hex
#############################################################
# Load and debug variables and rules
#############################################################
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 "set arch riscv:$(ARCH)"
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) multizone.hex $(GDB_LOAD_ARGS) $(GDB_LOAD_CMDS)