Versioning modified

This commit is contained in:
Krzysiek Egzmont 2023-11-26 21:04:01 +01:00
parent 199b1a27f1
commit 07588853e4
5 changed files with 42 additions and 37 deletions

View File

@ -158,6 +158,20 @@ else
TOP := $(shell pwd) TOP := $(shell pwd)
endif 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 AS = arm-none-eabi-gcc
CC = CC =
@ -177,12 +191,17 @@ endif
OBJCOPY = arm-none-eabi-objcopy OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size SIZE = arm-none-eabi-size
AUTHOR_STRING := EGZUMER
# the user might not have/want git installed # the user might not have/want git installed
# can set own version string here (max 7 chars) # can set own version string here (max 7 chars)
GIT_HASH := $(shell git rev-parse --short HEAD) ifneq (, $(shell $(WHERE) git))
#GIT_HASH := 230930b 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 ASFLAGS = -c -mcpu=cortex-m0
ifeq ($(ENABLE_OVERLAY),1) ifeq ($(ENABLE_OVERLAY),1)
@ -215,7 +234,7 @@ CFLAGS += -Wextra
#CFLAGS += -Wpedantic #CFLAGS += -Wpedantic
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\" CFLAGS += -DAUTHOR_STRING=\"$(AUTHOR_STRING)\" -DVERSION_STRING=\"$(VERSION_STRING)\"
ifeq ($(ENABLE_SPECTRUM),1) ifeq ($(ENABLE_SPECTRUM),1)
CFLAGS += -DENABLE_SPECTRUM CFLAGS += -DENABLE_SPECTRUM
@ -360,17 +379,7 @@ LIBS =
DEPS = $(OBJS:.o=.d) 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)) ifneq (, $(shell $(WHERE) python))
MY_PYTHON := python MY_PYTHON := python
@ -395,7 +404,7 @@ else ifneq (,$(HAS_CRCMOD))
$(info !!!!!!!! run: pip install crcmod) $(info !!!!!!!! run: pip install crcmod)
$(info ) $(info )
else else
-$(MY_PYTHON) fw-pack.py $<.bin $(GIT_HASH) $<.packed.bin -$(MY_PYTHON) fw-pack.py $<.bin $(AUTHOR_STRING) $(VERSION_STRING) $<.packed.bin
endif endif
$(SIZE) $< $(SIZE) $<

View File

@ -21,11 +21,10 @@ def obfuscate(fw):
return bytes([a^b for a, b in zip(fw, cycle(OBFUSCATION))]) return bytes([a^b for a, b in zip(fw, cycle(OBFUSCATION))])
plain = open(sys.argv[1], 'rb').read() 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: if len(version) < 16:
version += b'\x00' * (16 - len(version)) version += b'\x00' * (16 - len(version))
@ -36,5 +35,5 @@ crc.update(packed)
digest = crc.digest() digest = crc.digest()
digest = bytes([digest[1], digest[0]]) digest = bytes([digest[1], digest[0]])
open(sys.argv[3], 'wb').write(packed + digest) open(sys.argv[4], 'wb').write(packed + digest)

View File

@ -88,11 +88,13 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_
const size_t Length = strlen(pString); const size_t Length = strlen(pString);
size_t i; 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_width = ARRAY_SIZE(gFontSmall[0]);
const unsigned int char_spacing = char_width + 1; 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; uint8_t *pFb = gFrameBuffer[Line] + Start;
for (i = 0; i < Length; i++) for (i = 0; i < Length; i++)
{ {

View File

@ -77,7 +77,7 @@ void UI_DisplayWelcome(void)
UI_PrintString(WelcomeString0, 0, 127, 0, 10); UI_PrintString(WelcomeString0, 0, 127, 0, 10);
UI_PrintString(WelcomeString1, 0, 127, 2, 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_BlitStatusLine(); // blank status line
ST7565_BlitFullScreen(); ST7565_BlitFullScreen();

View File

@ -1,16 +1,11 @@
#define ONE_OF_ELEVEN_VER #ifdef VERSION_STRING
#define VER " "VERSION_STRING
#ifdef GIT_HASH
#define VER GIT_HASH
#else #else
#define VER "231004" #define VER ""
#endif #endif
#ifndef ONE_OF_ELEVEN_VER
const char Version[] = "OEFW-"VER; const char Version[] = AUTHOR_STRING VER;
const char UART_Version[] = "UV-K5 Firmware, Open Edition, OEFW-"VER"\r\n"; const char UART_Version[] = "UV-K5 Firmware, Open Edition, " AUTHOR_STRING 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