-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
66 lines (48 loc) · 1.28 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
# fiveforths - https://github.com/aw/fiveforths
#
# Makefile for building and testing
PROGNAME = fiveforths
FIRMWARE ?= $(PROGNAME).bin
DEVICE ?= /dev/ttyUSB0
CFLAGS := -g
CROSS ?= /usr/bin/riscv64-unknown-elf-
AS := $(CROSS)as
LD := $(CROSS)ld
OBJCOPY := $(CROSS)objcopy
OBJDUMP := $(CROSS)objdump
READELF := $(CROSS)readelf
# MCU and board specific variables
ARCH ?= rv32imac_zicsr
EMU ?= elf32lriscv
MCU ?= gd32vf103
BOARD ?= longan-nano-lite
.PHONY: clean
build: $(PROGNAME).o $(PROGNAME).elf $(PROGNAME).bin $(PROGNAME).hex $(PROGNAME).dump
%.o: %.s
$(AS) $(CFLAGS) -march=$(ARCH) -I src/boards/$(BOARD) -I src/mcus/$(MCU) -I src -o $@ $<
%.elf: %.o
$(LD) -m $(EMU) -T src/boards/$(BOARD)/linker.ld -o $@ $<
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
%.hex: %.elf
$(OBJCOPY) -O ihex $< $@
%.dump: %.elf
$(OBJDUMP) -D -S $< > $@
readelf: $(PROGNAME).elf
$(READELF) -a $<
serve:
bundle exec jekyll serve
openocd:
/opt/riscv/bin/openocd -f ft232r.cfg -f openocd.cfg
debug:
/opt/riscv/bin/riscv64-unknown-elf-gdb -command=debug.gdb -q fiveforths.elf
flash:
stm32loader -p $(DEVICE) -ewv $(FIRMWARE)
djb2:
gcc -o djb2 djb2.c
longan-nano:
$(MAKE) build BOARD=longan-nano
longan-nano-lite:
$(MAKE) build BOARD=longan-nano-lite
clean:
rm -v *.bin *.elf *.o *.hex *.dump