firmware: Build firmware files with auto-generated version numbers

This resembles what we do for other firmware targets, such as simtrace2,
osmo-ccid-firmware, etc.

As we have multiple different firmware, hardware, gateware projects in
this repository, and they each may have separate tags, we now require
that there are project specific tags.  So for example, tags with a
prefix of icE1usb-fw for the firmware versions.

symlinks for easy use by scripts etc. are generated, always pointing to
the last-built versioned filename.

Change-Id: Ia308587e36a79c27fdb285e369a9c921ee65995f
This commit is contained in:
Harald Welte 2020-12-17 13:15:12 +01:00
parent ae2c89e19e
commit 3255b74187
2 changed files with 29 additions and 8 deletions

View File

@ -9,6 +9,10 @@ OBJCOPY = $(CROSS)objcopy
ICEPROG = iceprog
DFU_UTIL = dfu-util
TAG_PREFIX = e1_tracer-fw
GITVER = $(shell git describe --match '$(TAG_PREFIX)*')
TARGET = $(GITVER)
BOARD_DEFINE=BOARD_$(shell echo $(BOARD) | tr a-z\- A-Z_)
CFLAGS=-Wall -Wextra -Wno-unused -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section --specs=nano.specs -D$(BOARD_DEFINE) -I. -I../common
@ -56,10 +60,10 @@ SOURCES_app=\
$(NULL)
all: e1_tracer-fw.bin
all: $(GITVER).bin $(TAG_PREFIX).bin $(TAG_PREFIX).elf
e1_tracer-fw.elf: $(LNK) $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
$(GITVER).elf: $(LNK) $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
$(CC) $(CFLAGS) -Wl,-Bstatic,-T,$(LNK),--strip-debug -o $@ $(SOURCES_common) $(SOURCES_app)
@ -69,10 +73,17 @@ e1_tracer-fw.elf: $(LNK) $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURC
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
prog: e1_tracer-fw.bin
$(TAG_PREFIX).bin: $(GITVER).bin
ln -sf $< $@
$(TAG_PREFIX).elf: $(GITVER).elf
ln -sf $< $@
prog: $(GITVER).bin
$(ICEPROG) -o 640k $<
dfuprog: e1_tracer-fw.bin
dfuprog: $(GITVER).bin
$(DFU_UTIL) -R -a 1 -D $<

View File

@ -9,6 +9,10 @@ OBJCOPY = $(CROSS)objcopy
ICEPROG = iceprog
DFU_UTIL = dfu-util
TAG_PREFIX = icE1usb-fw
GITVER = $(shell git describe --match '$(TAG_PREFIX)*')
TARGET = $(GITVER)
BOARD_DEFINE=BOARD_$(shell echo $(BOARD) | tr a-z\- A-Z_)
CFLAGS=-Wall -Wextra -Wno-unused -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section --specs=nano.specs -D$(BOARD_DEFINE) -I. -I../common
@ -56,10 +60,10 @@ SOURCES_app=\
$(NULL)
all: icE1usb-fw.bin
all: $(GITVER).bin $(TAG_PREFIX).bin $(TAG_PREFIX).elf
icE1usb-fw.elf: $(LNK) $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
$(GITVER).elf: $(LNK) $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES_common)
$(CC) $(CFLAGS) -Wl,-Bstatic,-T,$(LNK),--strip-debug -o $@ $(SOURCES_common) $(SOURCES_app)
@ -69,10 +73,16 @@ icE1usb-fw.elf: $(LNK) $(HEADERS_app) $(SOURCES_app) $(HEADERS_common) $(SOURCES
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
prog: icE1usb-fw.bin
$(TAG_PREFIX).bin: $(GITVER).bin
ln -sf $< $@
$(TAG_PREFIX).elf: $(GITVER).elf
ln -sf $< $@
prog: $(GITVER).bin
$(ICEPROG) -o 640k $<
dfuprog: icE1usb-fw.bin
dfuprog: $(GITVER).bin
$(DFU_UTIL) -R -a 1 -D $<