Skip to content

Commit 5924e77

Browse files
committed
firmware: Include version number + board name in filename
Something I learned while working on portable embedded projects in the past: Always make sure the filenames clearly identify which target/board they are built for, and which version they were built from. This can help prevent a number of problems further down the road. To make this work, at least one signed 'git tag' is required in the repository. File names then are like no2bootloader-ice1usb-0.1-4-g4634574.bin for something built from the fourth commit after the tag '0.1'. One could further extend this to consider using 'git describe --match' and restrict the match to certain tags in order to differentiate gateware from firmware versions. Signed-off-by: Harald Welte <[email protected]>
1 parent 4634574 commit 5924e77

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

firmware/Makefile

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ OBJCOPY = $(CROSS)objcopy
55
ICEPROG = iceprog
66
DFU_UTIL = dfu-util
77

8+
GITVER = $(shell git describe)
9+
TARGET_BASE=no2bootloader-$(BOARD)
10+
TARGET=$(TARGET_BASE)-$(GITVER)
11+
812
BOARD_DEFINE=BOARD_$(shell echo $(BOARD) | tr a-z\- A-Z_)
913
CFLAGS=-Wall -Os -march=rv32i -mabi=ilp32 -ffreestanding -flto -nostartfiles -fomit-frame-pointer -Wl,--gc-section --specs=nano.specs -D$(BOARD_DEFINE) -I.
1014

@@ -45,10 +49,10 @@ SOURCES_common+= \
4549
console_dummy.c
4650
endif
4751

48-
all: fw_dfu.bin
52+
all: $(TARGET).bin $(TARGET_BASE).bin $(TARGET_BASE).elf
4953

5054

51-
fw_dfu.elf: soc.lds $(HEADERS_dfu) $(SOURCES_dfu) $(HEADERS_common) $(SOURCES_common)
55+
$(TARGET).elf: soc.lds $(HEADERS_dfu) $(SOURCES_dfu) $(HEADERS_common) $(SOURCES_common)
5256
$(CC) $(CFLAGS) -Wl,-Bstatic,-T,soc.lds,--strip-debug -o $@ $(SOURCES_common) $(SOURCES_dfu)
5357

5458

@@ -58,8 +62,13 @@ fw_dfu.elf: soc.lds $(HEADERS_dfu) $(SOURCES_dfu) $(HEADERS_common) $(SOURCES_co
5862
%.bin: %.elf
5963
$(OBJCOPY) -O binary $< $@
6064

65+
$(TARGET_BASE).bin: $(TARGET).bin
66+
ln -sf $< $@
67+
68+
$(TARGET_BASE).elf: $(TARGET).elf
69+
ln -sf $< $@
6170

62-
prog: fw_dfu.bin
71+
prog: $(TARGET).bin
6372
$(ICEPROG) -o 384k $<
6473

6574

0 commit comments

Comments
 (0)