-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
110 lines (88 loc) · 2.77 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
# Copyright(C) 2018 Hex Five Security, Inc. - All Rights Reserved
#############################################################
# Platform definitions
#############################################################
BOARD ?= X300
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
#############################################################
# 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
export SIZE := $(CROSS_COMPILE)size
#############################################################
# Rules for building multizone
#############################################################
.PHONY: all
all: clean
$(MAKE) -C zone1
$(MAKE) -C zone2
$(MAKE) -C zone3
$(MAKE) -C zone3.1
$(MAKE) -C zone4
$(MAKE) -C zone4.1
$(MAKE) -C zone4.2
$(MAKE) -C bsp/$(BOARD)/boot
java -jar ./ext/multizone/multizone.jar \
--arch $(BOARD) \
--config bsp/$(BOARD)/multizone.cfg \
--boot bsp/$(BOARD)/boot/boot.hex \
zone1/zone1.hex \
zone2/zone2.hex \
zone3/zone3.hex \
zone4/zone4.hex
.PHONY: clean
clean:
$(MAKE) -C zone1 clean
$(MAKE) -C zone2 clean
$(MAKE) -C zone3 clean
$(MAKE) -C zone3.1 clean
$(MAKE) -C zone4 clean
$(MAKE) -C zone4.1 clean
$(MAKE) -C zone4.2 clean
$(MAKE) -C bsp/$(BOARD)/boot clean
rm -f multizone.hex multizone.bin
#############################################################
# Load to flash
#############################################################
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 init"
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)