From 07588853e4daee2c0ec8bd79c9081d30e9ec5bd3 Mon Sep 17 00:00:00 2001 From: Krzysiek Egzmont Date: Sun, 26 Nov 2023 21:04:01 +0100 Subject: [PATCH] Versioning modified --- Makefile | 41 +++++++++++++++++++++++++---------------- fw-pack.py | 9 ++++----- ui/helper.c | 8 +++++--- ui/welcome.c | 2 +- version.c | 19 +++++++------------ 5 files changed, 42 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index e9f9fef..8fb5a77 100644 --- a/Makefile +++ b/Makefile @@ -158,6 +158,20 @@ else TOP := $(shell pwd) endif +ifdef OS # windows + RM = del /Q + FixPath = $(subst /,\,$1) + WHERE = where + NULL_OUTPUT = nul +else # unix + ifeq ($(shell uname), Linux) + RM = rm -f + FixPath = $1 + WHERE = which + NULL_OUTPUT = /dev/null + endif +endif + AS = arm-none-eabi-gcc CC = @@ -177,12 +191,17 @@ endif OBJCOPY = arm-none-eabi-objcopy SIZE = arm-none-eabi-size +AUTHOR_STRING := EGZUMER # the user might not have/want git installed # can set own version string here (max 7 chars) -GIT_HASH := $(shell git rev-parse --short HEAD) -#GIT_HASH := 230930b +ifneq (, $(shell $(WHERE) git)) + VERSION_STRING := $(shell git describe --tags --exact-match 2>$(NULL_OUTPUT)) + ifeq (, $(VERSION_STRING)) + VERSION_STRING := $(shell git rev-parse --short HEAD) + endif +endif +#VERSION_STRING := 230930b -$(info GIT_HASH = $(GIT_HASH)) ASFLAGS = -c -mcpu=cortex-m0 ifeq ($(ENABLE_OVERLAY),1) @@ -215,7 +234,7 @@ CFLAGS += -Wextra #CFLAGS += -Wpedantic CFLAGS += -DPRINTF_INCLUDE_CONFIG_H -CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" +CFLAGS += -DAUTHOR_STRING=\"$(AUTHOR_STRING)\" -DVERSION_STRING=\"$(VERSION_STRING)\" ifeq ($(ENABLE_SPECTRUM),1) CFLAGS += -DENABLE_SPECTRUM @@ -360,17 +379,7 @@ LIBS = DEPS = $(OBJS:.o=.d) -ifdef OS - RM = del /Q - FixPath = $(subst /,\,$1) - WHERE = where -else - ifeq ($(shell uname), Linux) - RM = rm -f - FixPath = $1 - WHERE = which - endif -endif + ifneq (, $(shell $(WHERE) python)) MY_PYTHON := python @@ -395,7 +404,7 @@ else ifneq (,$(HAS_CRCMOD)) $(info !!!!!!!! run: pip install crcmod) $(info ) else - -$(MY_PYTHON) fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin + -$(MY_PYTHON) fw-pack.py $<.bin $(AUTHOR_STRING) $(VERSION_STRING) $<.packed.bin endif $(SIZE) $< diff --git a/fw-pack.py b/fw-pack.py index a3e6127..4200248 100644 --- a/fw-pack.py +++ b/fw-pack.py @@ -21,11 +21,10 @@ def obfuscate(fw): return bytes([a^b for a, b in zip(fw, cycle(OBFUSCATION))]) plain = open(sys.argv[1], 'rb').read() -if len(sys.argv[2]) > 10: - print('Version suffix is too big!') - sys.exit(1) -version = b'*OEFW-' + bytes(sys.argv[2], 'ascii') +version = b'*' + bytes(sys.argv[2], 'ascii') + b' ' + bytes(sys.argv[3], 'ascii') +version = version[0:16] + if len(version) < 16: version += b'\x00' * (16 - len(version)) @@ -36,5 +35,5 @@ crc.update(packed) digest = crc.digest() digest = bytes([digest[1], digest[0]]) -open(sys.argv[3], 'wb').write(packed + digest) +open(sys.argv[4], 'wb').write(packed + digest) diff --git a/ui/helper.c b/ui/helper.c index 17a01ba..482c70e 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -88,11 +88,13 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ const size_t Length = strlen(pString); size_t i; - if (End > Start) - Start += (((End - Start) - (Length * 8)) + 1) / 2; - const unsigned int char_width = ARRAY_SIZE(gFontSmall[0]); const unsigned int char_spacing = char_width + 1; + + if (End > Start) + Start += (((End - Start) - (Length * char_spacing)) + 1) / 2; + + uint8_t *pFb = gFrameBuffer[Line] + Start; for (i = 0; i < Length; i++) { diff --git a/ui/welcome.c b/ui/welcome.c index 86a69bd..0752310 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -77,7 +77,7 @@ void UI_DisplayWelcome(void) UI_PrintString(WelcomeString0, 0, 127, 0, 10); UI_PrintString(WelcomeString1, 0, 127, 2, 10); - UI_PrintStringSmall(Version, 0, 0, 6); + UI_PrintStringSmall(Version, 0, 128, 6); ST7565_BlitStatusLine(); // blank status line ST7565_BlitFullScreen(); diff --git a/version.c b/version.c index 3750ba1..7798681 100644 --- a/version.c +++ b/version.c @@ -1,16 +1,11 @@ -#define ONE_OF_ELEVEN_VER - -#ifdef GIT_HASH - #define VER GIT_HASH +#ifdef VERSION_STRING + #define VER " "VERSION_STRING #else - #define VER "231004" + #define VER "" #endif -#ifndef ONE_OF_ELEVEN_VER - const char Version[] = "OEFW-"VER; - const char UART_Version[] = "UV-K5 Firmware, Open Edition, OEFW-"VER"\r\n"; -#else - const char Version[] = "1o11+fagci-"VER; - const char UART_Version[] = "UV-K5 Firmware, Open Edition, 1o11+fagci-"VER"\r\n"; -#endif + +const char Version[] = AUTHOR_STRING VER; +const char UART_Version[] = "UV-K5 Firmware, Open Edition, " AUTHOR_STRING VER "\r\n"; +