-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (50 loc) · 1.51 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
# Examples (uncomment one)
#EXAMPLE := blinky_delay
#EXAMPLE := blinky_clint
#EXAMPLE := blinky_pwm
#EXAMPLE := blinky_plic
#EXAMPLE := hello_world
#EXAMPLE := panicking
#EXAMPLE := pll
#EXAMPLE := semihosting
#EXAMPLE := stlog
EXAMPLE := rtfm
#EXAMPLE := static_mut
# Board crate (uncomment one)
BOARD := hifive
#BOARD := lofive
# OpenOCD configuration (uncomment one)
OPENOCD_CFG := hifive-openocd.cfg
#OPENOCD_CFG := lofive-openocd.cfg
TARGET := riscv32imac-unknown-none-elf
TARGET_DIR := $(abspath ./target/$(TARGET)/debug)
EXAMPLE_DIR := $(TARGET_DIR)/examples
EXAMPLE_BIN := $(EXAMPLE_DIR)/$(EXAMPLE)
BAUD_RATE := 115200
TTY := /dev/ttyUSB2
build:
cargo build --examples $(ARGS)
test:
xargo test --all $(ARGS)
clean:
xargo clean $(ARGS)
readelf:
llvm-readelf -a -h -s -r -symbols $(EXAMPLE_BIN) $(ARGS)
size:
llvm-size $(EXAMPLE_BIN) $(ARGS)
objdump:
llvm-objdump -d -S $(EXAMPLE_BIN) $(ARGS)
dwarfdump:
llvm-dwarfdump -verify $(EXAMPLE_BIN) $(ARGS) | grep error | wc -l
stcat:
stty -F $(TTY) $(BAUD_RATE) sane -opost -brkint -icrnl -isig -icanon -iexten -echo
cat $(TTY) | stcat -e $(EXAMPLE_BIN)
# .gdbinit adds a upload command to gdb
gdb:
riscv32-unknown-elf-gdb $(EXAMPLE_BIN) $(ARGS)
openocd:
openocd -f $(OPENOCD_CFG) $(ARGS)
upload:
openocd -f $(OPENOCD_CFG) \
-c "flash protect 0 64 last off; program ${EXAMPLE_BIN}; resume 0x20400000; exit"
.PHONY: build test clean readelf size objdump dwarfdump gdb openocd upload