forked from warpBytes/multizone-secure-iot-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
97 lines (73 loc) · 2.54 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
# 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
#############################################################
IPADDR ?= 192.168.0.2
NETMASK ?= 255.255.255.0
BOARD ?= X300
ifeq ($(BOARD),X300)
RISCV_ARCH := rv32imac
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:
"$(MAKE)" -C zone1
"$(MAKE)" -C zone2 IPADDR="$(IPADDR)" NETMASK="$(NETMASK)"
"$(MAKE)" -C zone3
"$(MAKE)" -C zone4
java -jar ext/multizone/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:rv32"
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)