forked from castor-software/openmz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (58 loc) · 1.5 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
#
# Copyright 2020, Saab AB
#
# This software may be distributed and modified according to
# the terms of the MIT License.
# Note that NO WARRANTY is provided.
# See "LICENSE.MIT" for details.
#
PROGRAMS = openmz zone1 zone2
BOARD ?= fe310
BSP_DIR = $(abspath bsp/$(BOARD))
include $(BSP_DIR)/settings.mk
HEXFIVE_DIR = $(abspath libhexfive)
ELF_DIR = $(abspath elf)
HEX_DIR = $(abspath hex)
export CC=riscv64-unknown-elf-gcc
export SIZE=riscv64-unknown-elf-size
export OBJCOPY=riscv64-unknown-elf-objcopy
export OBJDUMP=riscv64-unknown-elf-objdump
.PHONY: all
all: compile
.PHONY: compile
.PHONY: clean
.PHONY: upload
.PHONY: format
ifeq ($(PROGRAM),)
compile:
for file in $(PROGRAMS) ; do \
$(MAKE) -C . compile PROGRAM=$$file ; \
done
clean:
for file in $(PROGRAMS) ; do \
$(MAKE) -C . clean PROGRAM=$$file ; \
done
upload:
for file in $(PROGRAMS) ; do \
$(MAKE) -C . upload PROGRAM=$$file ; \
done
else
PROGRAM_ELF = $(ELF_DIR)/$(PROGRAM).elf
PROGRAM_HEX = $(HEX_DIR)/$(PROGRAM).hex
compile: $(PROGRAM_ELF) $(PROGRAM_HEX)
.PHONY: $(PROGRAM_ELF)
$(PROGRAM_ELF):
mkdir -p $(ELF_DIR)
$(MAKE) -C src/$(PROGRAM) compile \
PROGRAM_ELF=$(PROGRAM_ELF) \
BSP_DIR=$(BSP_DIR) \
HEXFIVE_DIR=$(HEXFIVE_DIR)
$(PROGRAM_HEX): $(PROGRAM_ELF)
mkdir -p $(HEX_DIR)
$(OBJCOPY) -O ihex $(PROGRAM_ELF) $(PROGRAM_HEX)
upload: $(PROGRAM_HEX)
echo "loadfile $(PROGRAM_HEX)\nexit" \
| JLinkExe -device fe310 -if JTAG -speed 4000 -jtagconf -1,-1 -autoconnect 1
clean:
rm -f $(PROGRAM_ELF)
endif