From 0c771fb52f864c867d2fcff795e4d3ebd8de1c7c Mon Sep 17 00:00:00 2001
From: xengineering <me@xengineering.eu>
Date: Sat, 22 Mar 2025 21:21:44 +0100
Subject: fw: firmware: Add app build version output

---
 RELEASE.md        |  3 +++
 VERSION.txt       |  5 +++++
 fw/CMakeLists.txt |  1 +
 fw/VERSION        |  1 +
 fw/src/firmware.c | 19 +++++++++++++++++++
 5 files changed, 29 insertions(+)
 create mode 100644 RELEASE.md
 create mode 100644 VERSION.txt
 create mode 120000 fw/VERSION
 create mode 100644 fw/src/firmware.c

diff --git a/RELEASE.md b/RELEASE.md
new file mode 100644
index 0000000..7444a8c
--- /dev/null
+++ b/RELEASE.md
@@ -0,0 +1,3 @@
+# Release checklist
+
+- update values in VERSION.txt
diff --git a/VERSION.txt b/VERSION.txt
new file mode 100644
index 0000000..82edf85
--- /dev/null
+++ b/VERSION.txt
@@ -0,0 +1,5 @@
+VERSION_MAJOR = 0
+VERSION_MINOR = 0
+PATCHLEVEL = 99
+VERSION_TWEAK = 0
+EXTRAVERSION =
diff --git a/fw/CMakeLists.txt b/fw/CMakeLists.txt
index 1b978b7..0541836 100644
--- a/fw/CMakeLists.txt
+++ b/fw/CMakeLists.txt
@@ -43,6 +43,7 @@ target_sources(app
 		"${CMAKE_CURRENT_SOURCE_DIR}/src/http.c"
 		"${CMAKE_CURRENT_SOURCE_DIR}/src/ws.c"
 		"${CMAKE_CURRENT_SOURCE_DIR}/src/heart.c"
+		"${CMAKE_CURRENT_SOURCE_DIR}/src/firmware.c"
 )
 
 zephyr_linker_sources(SECTIONS sections-rom.ld)
diff --git a/fw/VERSION b/fw/VERSION
new file mode 120000
index 0000000..c892f30
--- /dev/null
+++ b/fw/VERSION
@@ -0,0 +1 @@
+../VERSION.txt
\ No newline at end of file
diff --git a/fw/src/firmware.c b/fw/src/firmware.c
new file mode 100644
index 0000000..9c0fa16
--- /dev/null
+++ b/fw/src/firmware.c
@@ -0,0 +1,19 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public License,
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
+ * obtain one at https://mozilla.org/MPL/2.0/.
+ */
+
+#include <zephyr/app_version.h>
+#include <zephyr/init.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_REGISTER(firmware);
+
+int firmware_log_metadata(void)
+{
+	LOG_INF("App build version: %s", STRINGIFY(APP_BUILD_VERSION));
+
+	return 0;
+}
+SYS_INIT(firmware_log_metadata, APPLICATION, 0);
-- 
cgit v1.2.3-70-g09d2