diff --git a/targets/stm32l432/build/application.mk b/targets/stm32l432/build/application.mk index acc3e48..8dd59b1 100644 --- a/targets/stm32l432/build/application.mk +++ b/targets/stm32l432/build/application.mk @@ -1,7 +1,4 @@ -CC=$(PREFIX)arm-none-eabi-gcc -CP=$(PREFIX)arm-none-eabi-objcopy -SZ=$(PREFIX)arm-none-eabi-size -AR=$(PREFIX)arm-none-eabi-ar +include build/common.mk # ST related SRC = src/main.c src/init.c src/redirect.c src/flash.c src/rng.c src/led.c src/device.c @@ -46,7 +43,7 @@ endif DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"app.h\" $(EXTRA_DEFINES) # DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1 -CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g +CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -u _printf_float -lnosys LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic -ltinycbor diff --git a/targets/stm32l432/build/bootloader.mk b/targets/stm32l432/build/bootloader.mk index 3931dde..0849086 100644 --- a/targets/stm32l432/build/bootloader.mk +++ b/targets/stm32l432/build/bootloader.mk @@ -1,7 +1,4 @@ -CC=$(PREFIX)arm-none-eabi-gcc -CP=$(PREFIX)arm-none-eabi-objcopy -SZ=$(PREFIX)arm-none-eabi-size -AR=$(PREFIX)arm-none-eabi-ar +include build/common.mk # ST related SRC = bootloader/main.c bootloader/bootloader.c @@ -44,9 +41,9 @@ endif DEFINES = -DDEBUG_LEVEL=$(DEBUG) -D$(CHIP) -DAES256=1 -DUSE_FULL_LL_DRIVER -DAPP_CONFIG=\"bootloader.h\" $(EXTRA_DEFINES) # DEFINES += -DTEST_SOLO_STM32 -DTEST -DTEST_FIFO=1 -CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g +CFLAGS=$(INC) -c $(DEFINES) -Wall -fdata-sections -ffunction-sections $(HW) -g $(VERSION_FLAGS) LDFLAGS_LIB=$(HW) $(SEARCH) -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -lnosys -LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic +LDFLAGS=$(HW) $(LDFLAGS_LIB) -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref -Wl,-Bstatic .PRECIOUS: %.o diff --git a/targets/stm32l432/build/common.mk b/targets/stm32l432/build/common.mk new file mode 100644 index 0000000..86469b3 --- /dev/null +++ b/targets/stm32l432/build/common.mk @@ -0,0 +1,19 @@ +CC=$(PREFIX)arm-none-eabi-gcc +CP=$(PREFIX)arm-none-eabi-objcopy +SZ=$(PREFIX)arm-none-eabi-size +AR=$(PREFIX)arm-none-eabi-ar + +VERSION=$(shell git describe --abbrev=0 ) +VERSION_FULL=$(shell git describe) +VERSION_MAJ=$(shell python -c 'print("$(VERSION)".split(".")[0])') +VERSION_MIN=$(shell python -c 'print("$(VERSION)".split(".")[1])') +VERSION_PAT=$(shell python -c 'print("$(VERSION)".split(".")[2])') + +VERSION_FLAGS= -DSOLO_VERSION_MAJ=$(VERSION_MAJ) -DSOLO_VERSION_MIN=$(VERSION_MIN) \ + -DSOLO_VERSION_PATCH=$(VERSION_PAT) -DVERSION=\"$(VERSION_FULL)\" + +_all: + echo $(VERSION_FULL) + echo $(VERSION_MAJ) + echo $(VERSION_MIN) + echo $(VERSION_PAT) diff --git a/targets/stm32l432/src/version.h b/targets/stm32l432/src/version.h index e9f2e7c..ea97314 100644 --- a/targets/stm32l432/src/version.h +++ b/targets/stm32l432/src/version.h @@ -13,7 +13,9 @@ #define __STR_HELPER(x) #x #define __STR(x) __STR_HELPER(x) +#ifndef VERSION #define VERSION __STR(SOLO_VERSION_MAJ) "." __STR(SOLO_VERSION_MIN) "." __STR(SOLO_VERSION_PATCH) +#endif #endif