forked from lujji/stm8-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (42 loc) · 1.25 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
export PATH := $(PATH):$(HOME)/local/sdcc/bin
MCU = stm8s003f3
ARCH = stm8
#F_CPU ?= 2000000
F_CPU ?= 16000000
TARGET ?= main.ihx
SRCS := $(wildcard *.c)
ASRCS := $(wildcard *.s)
OBJS = $(SRCS:.c=.rel)
OBJS += $(ASRCS:.s=.rel)
CC = sdcc
LD = sdld
AS = sdasstm8
OBJCOPY = sdobjcopy
CFLAGS = -m$(ARCH) -p$(MCU)
CFLAGS += -DF_CPU=$(F_CPU)UL -I.
CFLAGS += --stack-auto --noinduction --use-non-free --noinvariant --opt-code-size
LDFLAGS = -m$(ARCH) -l$(ARCH) --out-fmt-ihx
LDFLAGS += -Wl-bIVT=0x8000 -Wl-bGSINIT=0x8080
all: $(TARGET) size
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@
%.rel: %.s
$(AS) -plosgff $<
%.rel: %.c
$(CC) $(CFLAGS) -c $< -o $@
flash: $(TARGET)
stm8flash -c stlinkv2 -p $(MCU) -w $(TARGET)
clean:
rm -f *.map *.rel *.ihx *.o *.sym *.lk *.lst *.rst *.cdb *.bin *.asm
size:
@$(OBJCOPY) -I ihex --output-target=binary $(TARGET) $(TARGET).bin
@echo "-----\nImage size:"
@stat -L -c %s $(TARGET).bin
opt-dump:
stm8flash -c stlinkv2 -p stm8s003f3 -s opt -r dump_opt.bin
mem-dump:
stm8flash -c stlinkv2 -p stm8s003f3 -s flash -r dump_flash.bin
erase:
tr '\000' '\377' < /dev/zero | dd of=empty.bin bs=8192 count=1
stm8flash -c stlinkv2 -p stm8s003f3 -s flash -w empty.bin
.PHONY: clean all program