Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve build system. #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions firmware/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
SDCC=sdcc
SDLD=sdld
OBJECT=halo.ihx
SOURCEDIR = src
BUILDDIR = build
INCLUDEDIR = include

LDCC := sdcc
CFLAGS := -lstm8 -mstm8

FIRMWARE_IMAGE = $(BUILDDIR)/halo-fw.ihx

DEBUG_FW_IMAGE = $(patsubst $(BUILDDIR)/%.ihx,$(BUILDDIR)/%.elf,$(FIRMWARE_IMAGE))
SOURCES = $(wildcard $(SOURCEDIR)/*.c)
OBJECTS = $(patsubst $(SOURCEDIR)/%.c,$(BUILDDIR)/%.rel,$(SOURCES))

.PHONY: all clean flash

all: $(OBJECT)
all: $(FIRMWARE_IMAGE)

clean:
rm -f $(OBJECT) *.cdb *.adb *.asm *.li *.lst *.map *.rel *.rst *.sym *.lk
@echo "Cleaning up '$(BUILDDIR)' directory"
rm -r $(BUILDDIR)

flash: $(OBJECT)
ifeq (,$(command -v STVP_CmdLine.exe))
STVP_CmdLine.exe -Device=STM8L15xG4 -FileProg=$(OBJECT) -verif -no_loop -no_log
else ifeq (,$(command -v stm8flash))
stm8flash -cstlink -pstm8l151 -w $(OBJECT)
flash: $(FIRMWARE_IMAGE)
ifneq (, $(shell command -v STVP_CmdLine.exe;))
STVP_CmdLine.exe -Device=STM8L15xG4 -FileProg=$(FIRMWARE_IMAGE) -verif -no_loop -no_log
else ifneq (, $(shell command -v stm8flash;))
stm8flash -cstlinkv2 -p"stm8l151?4" -w $(FIRMWARE_IMAGE)
else
@echo "STVP_CmdLine or stm8flash not found"
endif



%.ihx: %.c
$(SDCC) -lstm8 -mstm8 --out-fmt-ihx --debug $(CFLAGS) $(LDFLAGS) $<
debug: CFLAGS += --debug
debug: $(DEBUG_FW_IMAGE)

$(BUILDDIR):
@mkdir -p build

$(OBJECTS): $(BUILDDIR)/%.rel : $(SOURCEDIR)/%.c | $(BUILDDIR)
$(LDCC) $(CFLAGS) -I$(INCLUDEDIR) $(LDFLAGS) -c $< -o $@

$(FIRMWARE_IMAGE): $(OBJECTS) | $(BUILDDIR)
$(LDCC) $(CFLAGS) --out-fmt-ihx $^ -o $@

$(DEBUG_FW_IMAGE): $(OBJECTS) | $(BUILDDIR)
$(LDCC) $(CFLAGS) --out-fmt-elf $^ -o $@
72 changes: 0 additions & 72 deletions firmware/halo.ihx

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion firmware/halo.c → firmware/src/halo.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,4 @@ void ledLow(uint8_t led) {
CPX_PORT[col]->ODR.byte &= ~CPX_PIN[col];
CPX_PORT[col]->DDR.byte &= ~CPX_PIN[col];
CPX_PORT[col]->CR1.byte &= ~CPX_PIN[col];
}
}