From 45b60c1e06cf7b2dd0f633b8fc86ccb42796f9dd Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sun, 8 Dec 2024 18:31:43 +0100 Subject: [PATCH 01/19] Saving --- .github/workflows/release.yml | 4 ++-- HeliosEmbedded/Makefile | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c1f0818a..d5bce2c0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -151,9 +151,9 @@ jobs: uses: ncipollo/release-action@v1 with: tag: ${{ env.new_tag }} - name: Helios Vortex ${{ env.new_version }} + name: Helios Engine ${{ env.new_version }} body: | - Release of Helios Vortex version ${{ env.new_version }} + Release of Helios Engine version ${{ env.new_version }} draft: false prerelease: false env: diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index 1a6ee69e..ee14dbae 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -2,7 +2,7 @@ ### CONFIGURATION ### ##################### -.PHONY: all upload set_fuses set_default_fuses set_16mhz_fuses set_8mhz_fuses set_1mhz_fuses get_fuses extract_hex upload_hex extract_eeprom upload_eeprom clean +.PHONY: all upload set_fuses set_default_fuses set_16mhz_fuses set_8mhz_fuses set_1mhz_fuses get_fuses extract_hex upload_hex extract_eeprom upload_eeprom clean compute_version ifneq ($(OS),Windows_NT) OS = $(shell uname -s) @@ -146,7 +146,7 @@ DFILES = $(SRCS:.cpp=.d) # Target name TARGET = helios -all: $(TARGET).hex +all: compute_version $(TARGET).hex @echo Detected Operating System: $(OS) $(OBJDUMP) --disassemble --source --line-numbers --demangle --section=.text $(TARGET).elf > $(TARGET).lst $(NM) --numeric-sort --line-numbers --demangle --print-size --format=s $(TARGET).elf > $(TARGET).map @@ -270,5 +270,15 @@ extract_hex: helios_firmware.hex clean: rm -f $(OBJS) $(TARGET).elf $(TARGET).hex $(DFILES) $(TARGET).bin $(TARGET).eep $(TARGET).lst $(TARGET).map +compute_version: + $(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1)) + $(eval HELIOS_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1)) + $(eval HELIOS_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2)) + $(eval HELIOS_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD)) + $(eval HELIOS_VERSION_MAJOR := $(if $(HELIOS_VERSION_MAJOR),$(HELIOS_VERSION_MAJOR),0)) + $(eval HELIOS_VERSION_MINOR := $(if $(HELIOS_VERSION_MINOR),$(HELIOS_VERSION_MINOR),1)) + $(eval HELIOS_BUILD_NUMBER := $(if $(HELIOS_BUILD_NUMBER),$(HELIOS_BUILD_NUMBER),0)) + $(eval HELIOS_VERSION_NUMBER := $(HELIOS_VERSION_MAJOR).$(HELIOS_VERSION_MINOR).$(HELIOS_BUILD_NUMBER)) + # include dependency files to ensure partial rebuilds work correctly -include $(DFILES) From 73f8819186d0e52060049296ea4d76f2214a0ca5 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sun, 8 Dec 2024 18:33:53 +0100 Subject: [PATCH 02/19] Added the defines --- HeliosEmbedded/Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index ee14dbae..88369574 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -81,6 +81,15 @@ CPU_SPEED = 8000000L # the port for serial upload SERIAL_PORT = COM11 +# compiler defines +DEFINES=\ + -DHELIOS_VERSION_MAJOR=$(HELIOS_VERSION_MAJOR) \ + -DHELIOS_VERSION_MINOR=$(HELIOS_VERSION_MINOR) \ + -DHELIOS_BUILD_NUMBER=$(HELIOS_BUILD_NUMBER) \ + -DHELIOS_VERSION_NUMBER=$(HELIOS_VERSION_NUMBER) \ + -D__AVR_ATtiny85__ \ + -DF_CPU=$(CPU_SPEED) \ + CFLAGS = -g \ -Os \ -MMD \ @@ -116,6 +125,9 @@ ifeq ($(OS),Windows_NT) # Windows LDFLAGS+=-B $(DEVICE_DIR) endif +ifneq ($(DEFINES),) + CFLAGS+=$(DEFINES) +endif INCLUDES= \ -I $(INCLUDE_DIR) \ -I ../Helios @@ -152,6 +164,7 @@ all: compute_version $(TARGET).hex $(NM) --numeric-sort --line-numbers --demangle --print-size --format=s $(TARGET).elf > $(TARGET).map chmod +x avrsize.sh ./avrsize.sh $(TARGET).elf + @echo "== Success building Helios v$(HELIOS_VERSION_NUMBER) ==" $(TARGET).hex: $(TARGET).elf $(OBJCOPY) -O binary -R .eeprom $(TARGET).elf $(TARGET).bin From f67b32a1a09746dafa88198c3e9a0bf7bdd9a195 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sun, 8 Dec 2024 18:40:22 +0100 Subject: [PATCH 03/19] Adding Helios.cpp and Config changes --- Helios/Helios.cpp | 2 ++ Helios/HeliosConfig.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Helios/Helios.cpp b/Helios/Helios.cpp index a93a7bb0..f01c18b0 100644 --- a/Helios/Helios.cpp +++ b/Helios/Helios.cpp @@ -44,6 +44,8 @@ bool Helios::keepgoing; bool Helios::sleeping; #endif +volatile char helios_version[] = HELIOS_VERSION_STR; + bool Helios::init() { // first initialize all the components of helios diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index e25d6cec..991380f7 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -1,6 +1,23 @@ #ifndef HELIOS_CONFIG_H #define HELIOS_CONFIG_H +// Helper macros to expand out the version into a string +#define _STR(x) #x +#define STR(x) _STR(x) + +// Helios Version Number +// +// It is expected that HELIOS_VERSION will be provided on the command line to the +// compiler as a -DHELIOS_VERSION=a.b.c but if it's not it will default here +#ifndef HELIOS_VERSION +#define HELIOS_VERSION 0.0.1 +#endif + +// Helios Version String +// +// This is the string literal equivalent of HELIOS_VERSION above +#define HELIOS_VERSION_STR STR(HELIOS_VERSION) + // Short Click Threshold // // The length of time in milliseconds for a click to From 8b4750ab5798abb0480cb93a37558a0eb1caa9aa Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Sun, 8 Dec 2024 18:43:56 +0100 Subject: [PATCH 04/19] Working on a extract version command --- HeliosEmbedded/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index 88369574..48cc9719 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -2,7 +2,7 @@ ### CONFIGURATION ### ##################### -.PHONY: all upload set_fuses set_default_fuses set_16mhz_fuses set_8mhz_fuses set_1mhz_fuses get_fuses extract_hex upload_hex extract_eeprom upload_eeprom clean compute_version +.PHONY: all upload set_fuses set_default_fuses set_16mhz_fuses set_8mhz_fuses set_1mhz_fuses get_fuses extract_hex upload_hex extract_eeprom upload_eeprom clean compute_version extract_version ifneq ($(OS),Windows_NT) OS = $(shell uname -s) @@ -293,5 +293,10 @@ compute_version: $(eval HELIOS_BUILD_NUMBER := $(if $(HELIOS_BUILD_NUMBER),$(HELIOS_BUILD_NUMBER),0)) $(eval HELIOS_VERSION_NUMBER := $(HELIOS_VERSION_MAJOR).$(HELIOS_VERSION_MINOR).$(HELIOS_BUILD_NUMBER)) +extract_version: + $(eval HELIOS_VERSION_MAJOR := $(shell echo $(LATEST_TAG) | cut -d. -f1)) + $(eval HELIOS_VERSION_MINOR := $(shell echo $(LATEST_TAG) | cut -d. -f2)) + $(eval HELIOS_BUILD_NUMBER := $(shell echo $(LATEST_TAG) | cut -d. -f3)) + # include dependency files to ensure partial rebuilds work correctly -include $(DFILES) From f955abebfed93fa01bb79e88b52d766165be03ba Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 10:15:43 +0100 Subject: [PATCH 05/19] Fixed compute version --- HeliosEmbedded/Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index 48cc9719..c9dc567e 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -67,9 +67,12 @@ AVRDUDE_FLAGS = -C$(AVRDUDE_CONF) \ -P$(AVRDUDE_PORT) \ -b$(AVRDUDE_BAUDRATE) \ -v \ - -B1 \ - -V \ - -D + -B1 + +# -v -- Verbose output - display detailed progress +# -B1 -- Bit clock period (in microseconds) - sets programming speed +# -V -- Disable automatic verify check when uploading +# -D -- Disable auto erase for flash memory ####################### @@ -89,6 +92,7 @@ DEFINES=\ -DHELIOS_VERSION_NUMBER=$(HELIOS_VERSION_NUMBER) \ -D__AVR_ATtiny85__ \ -DF_CPU=$(CPU_SPEED) \ + -D HELIOS_EMBEDDED CFLAGS = -g \ -Os \ @@ -108,7 +112,6 @@ CFLAGS = -g \ -D__AVR_ATtiny85__ \ -mmcu=$(AVRDUDE_CHIP) \ -DF_CPU=$(CPU_SPEED) \ - -D HELIOS_EMBEDDED LDFLAGS = -g \ -Wall \ @@ -171,8 +174,8 @@ $(TARGET).hex: $(TARGET).elf $(OBJCOPY) -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $(TARGET).elf $(TARGET).eep $(OBJCOPY) -O ihex -R .eeprom $< $@ -$(TARGET).elf: $(OBJS) - $(LD) $(LDFLAGS) $^ -o $@ +$(TARGET).elf: compute_version $(OBJS) + $(LD) $(LDFLAGS) $(OBJS) -o $@ %.o: %.S $(CC) $(ASMFLAGS) -c $< -o $@ From d6ebdb6e9b3ffcbf1a8c7cf4bb2a59afbe79414e Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 10:18:49 +0100 Subject: [PATCH 06/19] Renamed the release.yml name --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5bce2c0..aed70e16 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -151,9 +151,9 @@ jobs: uses: ncipollo/release-action@v1 with: tag: ${{ env.new_tag }} - name: Helios Engine ${{ env.new_version }} + name: Helios ${{ env.new_version }} body: | - Release of Helios Engine version ${{ env.new_version }} + Release of Helios version ${{ env.new_version }} draft: false prerelease: false env: From 157a7c13c1110ecf31b0c834ee9b4389f700b76b Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 10:19:41 +0100 Subject: [PATCH 07/19] Removed the extra stuff from the compute_version --- HeliosEmbedded/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index c9dc567e..48245c76 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -287,7 +287,7 @@ clean: rm -f $(OBJS) $(TARGET).elf $(TARGET).hex $(DFILES) $(TARGET).bin $(TARGET).eep $(TARGET).lst $(TARGET).map compute_version: - $(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list "*$(BRANCH_SUFFIX)" | sort -V | tail -n1)) + $(eval LATEST_TAG ?= $(shell git fetch --depth=1 origin +refs/tags/*:refs/tags/* &> /dev/null && git tag --list | sort -V | tail -n1)) $(eval HELIOS_VERSION_MAJOR ?= $(shell echo $(LATEST_TAG) | cut -d. -f1)) $(eval HELIOS_VERSION_MINOR ?= $(shell echo $(LATEST_TAG) | sed 's/$(BRANCH_SUFFIX)$$//' | cut -d. -f2)) $(eval HELIOS_BUILD_NUMBER ?= $(shell git rev-list --count $(LATEST_TAG)..HEAD)) From e2fec38fb2c8ad89d8baf8a6903ce76d7772b999 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 10:23:30 +0100 Subject: [PATCH 08/19] Removed the D --- HeliosEmbedded/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index 48245c76..f3b7daaf 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -86,10 +86,10 @@ SERIAL_PORT = COM11 # compiler defines DEFINES=\ - -DHELIOS_VERSION_MAJOR=$(HELIOS_VERSION_MAJOR) \ - -DHELIOS_VERSION_MINOR=$(HELIOS_VERSION_MINOR) \ - -DHELIOS_BUILD_NUMBER=$(HELIOS_BUILD_NUMBER) \ - -DHELIOS_VERSION_NUMBER=$(HELIOS_VERSION_NUMBER) \ + -HELIOS_VERSION_MAJOR=$(HELIOS_VERSION_MAJOR) \ + -HELIOS_VERSION_MINOR=$(HELIOS_VERSION_MINOR) \ + -HELIOS_BUILD_NUMBER=$(HELIOS_BUILD_NUMBER) \ + -HELIOS_VERSION_NUMBER=$(HELIOS_VERSION_NUMBER) \ -D__AVR_ATtiny85__ \ -DF_CPU=$(CPU_SPEED) \ -D HELIOS_EMBEDDED From 159cc381a0f700fc069f1b8b44b5b8d709ccbe07 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 10:24:46 +0100 Subject: [PATCH 09/19] Fixed the naming --- Helios/HeliosConfig.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 991380f7..51bddb8a 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -7,16 +7,16 @@ // Helios Version Number // -// It is expected that HELIOS_VERSION will be provided on the command line to the -// compiler as a -DHELIOS_VERSION=a.b.c but if it's not it will default here -#ifndef HELIOS_VERSION -#define HELIOS_VERSION 0.0.1 +// It is expected that HELIOS_VERSION_NUMBER will be provided on the command line to the +// compiler as a -HELIOS_VERSION_NUMBER=a.b.c but if it's not it will default here +#ifndef HELIOS_VERSION_NUMBER +#define HELIOS_VERSION_NUMBER 0.0.1 #endif // Helios Version String // // This is the string literal equivalent of HELIOS_VERSION above -#define HELIOS_VERSION_STR STR(HELIOS_VERSION) +#define HELIOS_VERSION_STR STR(HELIOS_VERSION_NUMBER) // Short Click Threshold // From a98c8c627d12845314db9210be5dffe40c4c30da Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 10:26:34 +0100 Subject: [PATCH 10/19] Put the D Back --- Helios/HeliosConfig.h | 10 +++++----- HeliosEmbedded/Makefile | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 51bddb8a..e6269db8 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -7,16 +7,16 @@ // Helios Version Number // -// It is expected that HELIOS_VERSION_NUMBER will be provided on the command line to the -// compiler as a -HELIOS_VERSION_NUMBER=a.b.c but if it's not it will default here -#ifndef HELIOS_VERSION_NUMBER -#define HELIOS_VERSION_NUMBER 0.0.1 +// It is expected that DHELIOS_VERSION_NUMBER will be provided on the command line to the +// compiler as a -DHELIOS_VERSION_NUMBER=a.b.c but if it's not it will default here +#ifndef DHELIOS_VERSION_NUMBER +#define DHELIOS_VERSION_NUMBER 0.0.1 #endif // Helios Version String // // This is the string literal equivalent of HELIOS_VERSION above -#define HELIOS_VERSION_STR STR(HELIOS_VERSION_NUMBER) +#define HELIOS_VERSION_STR STR(DHELIOS_VERSION_NUMBER) // Short Click Threshold // diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index f3b7daaf..48245c76 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -86,10 +86,10 @@ SERIAL_PORT = COM11 # compiler defines DEFINES=\ - -HELIOS_VERSION_MAJOR=$(HELIOS_VERSION_MAJOR) \ - -HELIOS_VERSION_MINOR=$(HELIOS_VERSION_MINOR) \ - -HELIOS_BUILD_NUMBER=$(HELIOS_BUILD_NUMBER) \ - -HELIOS_VERSION_NUMBER=$(HELIOS_VERSION_NUMBER) \ + -DHELIOS_VERSION_MAJOR=$(HELIOS_VERSION_MAJOR) \ + -DHELIOS_VERSION_MINOR=$(HELIOS_VERSION_MINOR) \ + -DHELIOS_BUILD_NUMBER=$(HELIOS_BUILD_NUMBER) \ + -DHELIOS_VERSION_NUMBER=$(HELIOS_VERSION_NUMBER) \ -D__AVR_ATtiny85__ \ -DF_CPU=$(CPU_SPEED) \ -D HELIOS_EMBEDDED From 34359aa0a565db9ecf7cbd77fb57ec2988cd9a91 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 10:52:22 +0100 Subject: [PATCH 11/19] Fixed the Macros --- Helios/HeliosConfig.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index e6269db8..51bddb8a 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -7,16 +7,16 @@ // Helios Version Number // -// It is expected that DHELIOS_VERSION_NUMBER will be provided on the command line to the -// compiler as a -DHELIOS_VERSION_NUMBER=a.b.c but if it's not it will default here -#ifndef DHELIOS_VERSION_NUMBER -#define DHELIOS_VERSION_NUMBER 0.0.1 +// It is expected that HELIOS_VERSION_NUMBER will be provided on the command line to the +// compiler as a -HELIOS_VERSION_NUMBER=a.b.c but if it's not it will default here +#ifndef HELIOS_VERSION_NUMBER +#define HELIOS_VERSION_NUMBER 0.0.1 #endif // Helios Version String // // This is the string literal equivalent of HELIOS_VERSION above -#define HELIOS_VERSION_STR STR(DHELIOS_VERSION_NUMBER) +#define HELIOS_VERSION_STR STR(HELIOS_VERSION_NUMBER) // Short Click Threshold // From adbc6c8c56d913d7a139e063225c0c03a4326664 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:13:27 +0100 Subject: [PATCH 12/19] Got the extract version working --- Helios/HeliosConfig.h | 34 ++++++++++++++++++--- HeliosEmbedded/Makefile | 8 +++-- HeliosEmbedded/find_version.py | 54 ++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 HeliosEmbedded/find_version.py diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 51bddb8a..4917267f 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -5,14 +5,40 @@ #define _STR(x) #x #define STR(x) _STR(x) -// Helios Version Number +// Version Configurations // -// It is expected that HELIOS_VERSION_NUMBER will be provided on the command line to the -// compiler as a -HELIOS_VERSION_NUMBER=a.b.c but if it's not it will default here +// The engine major version indicates the state of the save file, +// if changes to the save format occur then the major version +// must increment so that the savefiles will not be loaded +#ifndef HELIOS_VERSION_MAJOR +#define HELIOS_VERSION_MAJOR 1 +#endif + +// A minor version simply indicates a bugfix or minor change that +// will not affect the save files produced by the engine. This means +// a savefile produced by 1.1 should be loadable by an engine on 1.2 +// and vice versa, but an engine on 2.0 cannot share savefiles with +// either of the engines on version 1.1 or 1.2 +#ifndef HELIOS_VERSION_MINOR +#define HELIOS_VERSION_MINOR 3 +#endif + +// The build or patch number based on the major.minor version, this is +// set by the build system using the number of commits since last version +#ifndef HELIOS_BUILD_NUMBER +#define HELIOS_BUILD_NUMBER 0 +#endif + +// Produces a number like 1.3.0 #ifndef HELIOS_VERSION_NUMBER -#define HELIOS_VERSION_NUMBER 0.0.1 +#define HELIOS_VERSION_NUMBER HELIOS_VERSION_MAJOR.HELIOS_VERSION_MINOR.HELIOS_BUILD_NUMBER #endif +// Produces a string like "1.3.0" +#define ADD_QUOTES(str) #str +#define EXPAND_AND_QUOTE(str) ADD_QUOTES(str) +#define HELIOS_VERSION EXPAND_AND_QUOTE(HELIOS_VERSION_NUMBER) + // Helios Version String // // This is the string literal equivalent of HELIOS_VERSION above diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index 48245c76..83e6eeb0 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -297,9 +297,11 @@ compute_version: $(eval HELIOS_VERSION_NUMBER := $(HELIOS_VERSION_MAJOR).$(HELIOS_VERSION_MINOR).$(HELIOS_BUILD_NUMBER)) extract_version: - $(eval HELIOS_VERSION_MAJOR := $(shell echo $(LATEST_TAG) | cut -d. -f1)) - $(eval HELIOS_VERSION_MINOR := $(shell echo $(LATEST_TAG) | cut -d. -f2)) - $(eval HELIOS_BUILD_NUMBER := $(shell echo $(LATEST_TAG) | cut -d. -f3)) + @echo "Reading firmware version..." + $(eval TEMP_HEX := $(shell mktemp)) + $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:r:$(TEMP_HEX):i + python ./find_version.py $(TEMP_HEX) + @rm $(TEMP_HEX) # include dependency files to ensure partial rebuilds work correctly -include $(DFILES) diff --git a/HeliosEmbedded/find_version.py b/HeliosEmbedded/find_version.py new file mode 100644 index 00000000..a5df6213 --- /dev/null +++ b/HeliosEmbedded/find_version.py @@ -0,0 +1,54 @@ +import sys + +def find_version(hex_content): + try: + # Convert hex file content to string if it's bytes + if isinstance(hex_content, bytes): + hex_content = hex_content.decode('ascii') + + # Look for the specific hex pattern: 312E332E3238 (1.3.28) + # First convert the entire content to a continuous string of hex values + hex_string = ''.join(line.strip()[9:-2] for line in hex_content.splitlines() if line.startswith(':')) + + # Look for our version pattern + import re + # Pattern for version number in hex (31 2E 33 2E 32 38 = "1.3.28") + version_pattern = r'312E[0-9A-F]{2}2E[0-9A-F]{2,4}' + match = re.search(version_pattern, hex_string) + + if match: + # Convert hex to ASCII + hex_version = match.group(0) + version_bytes = bytes.fromhex(hex_version) + version_str = version_bytes.decode('ascii') + return version_str + + return None + except Exception as e: + print(f"Error processing hex file: {str(e)}") + return None + +if __name__ == "__main__": + try: + # Check if filename is provided as argument + if len(sys.argv) > 1: + filename = sys.argv[1] + with open(filename, 'rb') as f: # Open in binary mode + content = f.read() + # Otherwise read from stdin if input is piped + elif not sys.stdin.isatty(): + content = sys.stdin.buffer.read() # Read binary from stdin + # Finally, try to read default filename + else: + with open('helios_firmware.hex', 'rb') as f: # Open in binary mode + content = f.read() + + version = find_version(content) + if version: + print(f"Found version: {version}") + else: + print("Version signature not found.") + except FileNotFoundError: + print("Error: Hex file not found") + except Exception as e: + print(f"Error: {str(e)}") \ No newline at end of file From 8d2f5f00a1ae27296d1ed661e950b9ade7056694 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:19:59 +0100 Subject: [PATCH 13/19] Removed the output from the fimeware --- HeliosEmbedded/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HeliosEmbedded/Makefile b/HeliosEmbedded/Makefile index 83e6eeb0..989dd4cf 100644 --- a/HeliosEmbedded/Makefile +++ b/HeliosEmbedded/Makefile @@ -299,7 +299,7 @@ compute_version: extract_version: @echo "Reading firmware version..." $(eval TEMP_HEX := $(shell mktemp)) - $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:r:$(TEMP_HEX):i + $(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:r:$(TEMP_HEX):i > /dev/null 2>&1 python ./find_version.py $(TEMP_HEX) @rm $(TEMP_HEX) From 768260b5265c34e6c6f737c1166f79aae761c79e Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:22:45 +0100 Subject: [PATCH 14/19] Prevent it from looking at the last saved version --- HeliosEmbedded/find_version.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/HeliosEmbedded/find_version.py b/HeliosEmbedded/find_version.py index a5df6213..2d549905 100644 --- a/HeliosEmbedded/find_version.py +++ b/HeliosEmbedded/find_version.py @@ -38,10 +38,12 @@ def find_version(hex_content): # Otherwise read from stdin if input is piped elif not sys.stdin.isatty(): content = sys.stdin.buffer.read() # Read binary from stdin - # Finally, try to read default filename + # If no input provided, show usage else: - with open('helios_firmware.hex', 'rb') as f: # Open in binary mode - content = f.read() + print("Error: No input provided") + print("Usage: python find_version.py [filename]") + print(" or: cat file.hex | python find_version.py") + sys.exit(1) version = find_version(content) if version: From 029315de1cb7cb158922a9e629151ba9d2962453 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:35:53 +0100 Subject: [PATCH 15/19] Removed the STR --- Helios/HeliosConfig.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 4917267f..9050b897 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -3,7 +3,6 @@ // Helper macros to expand out the version into a string #define _STR(x) #x -#define STR(x) _STR(x) // Version Configurations // From ce4124b9fcae62d4203635b22ad3c017ae88bc63 Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:40:46 +0100 Subject: [PATCH 16/19] Removed the other STR --- Helios/HeliosConfig.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 9050b897..64d956c1 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -1,9 +1,6 @@ #ifndef HELIOS_CONFIG_H #define HELIOS_CONFIG_H -// Helper macros to expand out the version into a string -#define _STR(x) #x - // Version Configurations // // The engine major version indicates the state of the save file, From f191827f6cf93c627937696f14079404a48a231a Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:43:50 +0100 Subject: [PATCH 17/19] Fixed --- Helios/HeliosConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 64d956c1..14f7e9b6 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -38,7 +38,7 @@ // Helios Version String // // This is the string literal equivalent of HELIOS_VERSION above -#define HELIOS_VERSION_STR STR(HELIOS_VERSION_NUMBER) +#define HELIOS_VERSION_STR HELIOS_VERSION(HELIOS_VERSION_NUMBER) // Short Click Threshold // From ca234bfe924d3c138d7a2bfa671aeef82b53e71d Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:46:44 +0100 Subject: [PATCH 18/19] Made versions 0 --- Helios/HeliosConfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 14f7e9b6..6bbc2ddb 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -7,7 +7,7 @@ // if changes to the save format occur then the major version // must increment so that the savefiles will not be loaded #ifndef HELIOS_VERSION_MAJOR -#define HELIOS_VERSION_MAJOR 1 +#define HELIOS_VERSION_MAJOR 0 #endif // A minor version simply indicates a bugfix or minor change that @@ -16,7 +16,7 @@ // and vice versa, but an engine on 2.0 cannot share savefiles with // either of the engines on version 1.1 or 1.2 #ifndef HELIOS_VERSION_MINOR -#define HELIOS_VERSION_MINOR 3 +#define HELIOS_VERSION_MINOR 0 #endif // The build or patch number based on the major.minor version, this is From b4029e24d7b26685d1b8135df0018ad69f706b3a Mon Sep 17 00:00:00 2001 From: Kurt LaVacque Date: Mon, 9 Dec 2024 11:51:51 +0100 Subject: [PATCH 19/19] Fixed the macros --- Helios/HeliosConfig.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Helios/HeliosConfig.h b/Helios/HeliosConfig.h index 6bbc2ddb..cda27691 100644 --- a/Helios/HeliosConfig.h +++ b/Helios/HeliosConfig.h @@ -30,15 +30,13 @@ #define HELIOS_VERSION_NUMBER HELIOS_VERSION_MAJOR.HELIOS_VERSION_MINOR.HELIOS_BUILD_NUMBER #endif -// Produces a string like "1.3.0" -#define ADD_QUOTES(str) #str -#define EXPAND_AND_QUOTE(str) ADD_QUOTES(str) -#define HELIOS_VERSION EXPAND_AND_QUOTE(HELIOS_VERSION_NUMBER) // Helios Version String // -// This is the string literal equivalent of HELIOS_VERSION above -#define HELIOS_VERSION_STR HELIOS_VERSION(HELIOS_VERSION_NUMBER) +// This is the string literal equivalent of HELIOS_VERSION_NUMBER above +#define ADD_QUOTES(str) #str +#define EXPAND_AND_QUOTE(str) ADD_QUOTES(str) +#define HELIOS_VERSION_STR EXPAND_AND_QUOTE(HELIOS_VERSION_NUMBER) // Short Click Threshold //