-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (38 loc) · 1.04 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
MCU = stm8s003f3
ARCH = stm8
F_CPU ?= 16000000
TARGET ?= firmware.ihx
SRCS := $(wildcard *.c)
ASRCS := $(wildcard *.s)
OBJS = $(SRCS:.c=.rel)
OBJS += $(ASRCS:.s=.rel)
CC = sdcc
LD = sdld
AS = sdasstm8
OBJCOPY = sdobjcopy
ASFLAGS = -plosgff
CFLAGS = -m$(ARCH) -p$(MCU) --std-sdcc11 --opt-code-size
CFLAGS += -DF_CPU=$(F_CPU)UL -Iinclude
CFLAGS += --stack-auto --noinduction --use-non-free
LDFLAGS = -m$(ARCH) -l$(ARCH) --out-fmt-ihx
all: $(TARGET) size
$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@
%.rel: %.c
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
%.rel: %.s
$(AS) $(ASFLAGS) $<
size:
@$(OBJCOPY) -I ihex --output-target=binary $(TARGET) $(TARGET).bin
@echo "----------"
@echo "Image size:"
@stat -L -c %s $(TARGET).bin
flash: $(TARGET)
stm8flash -c stlinkv2 -p $(MCU) -w $(TARGET)
opt:
stm8flash -c stlinkv2 -p $(MCU) -s opt -w opt.dat
serial: $(TARGET)
stm8gal -p /dev/ttyUSB0 -w $(TARGET)
clean:
rm -f *.map *.asm *.rel *.ihx *.o *.sym *.lk *.lst *.rst *.cdb *.bin
.PHONY: clean all flash opt