-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (40 loc) · 1.1 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
# Makefile for building and testing
PROGNAME = test1
FIRMWARE ?= $(PROGNAME).bin
DEVICE ?= /dev/ttyACM0
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 ?= rv32ec_zicsr
EMU ?= elf32lriscv
.PHONY: clean
build: $(PROGNAME).o $(PROGNAME).elf $(PROGNAME).bin $(PROGNAME).hex $(PROGNAME).dump
%.o: ./$(PROGNAME)/%.s
$(AS) $(CFLAGS) -march=$(ARCH) -I $(PROGNAME) -o $@ $<
%.elf: %.o
$(LD) -m $(EMU) -T linker.ld -o $@ $<
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
%.hex: %.elf
$(OBJCOPY) -O ihex $< $@
%.dump: %.elf
$(OBJDUMP) -D -S $< > $@
readelf: $(PROGNAME).elf
$(READELF) -a $<
flash:
../../installs/ch32v003fun/minichlink/minichlink -w $(FIRMWARE) 0x08000000
dumpram:
../../installs/ch32v003fun/minichlink/minichlink -r dumpram.b 0x20000000 2048
ghex dumpram.b
dumpprg:
../../installs/ch32v003fun/minichlink/minichlink -r dumpprg.b 0x08000000 0x3fff
ghex dumpprg.b
cleandump:
rm -v *.b
clean:
rm -v *.bin *.elf *.o *.hex *.dump