bindesc: Add support for the build version values

This patch adds bindesc support for the build version values for the
kernel and application - BUILD_VERSION and APP_BUILD_VERSION.

The kernel's BUILD_VERSION can be overridden at build time.

Signed-off-by: Attie Grande <attie.grande@argentum-systems.co.uk>
This commit is contained in:
Attie Grande 2024-01-22 23:19:53 +00:00 committed by Anas Nashif
commit e6dc930322
4 changed files with 37 additions and 0 deletions

View file

@ -51,6 +51,9 @@ extern "C" {
/** The app version number such as 0x10203 */
#define BINDESC_ID_APP_VERSION_NUMBER 0x804
/** The app git reference such as "v3.3.0-18-g2c85d9224fca" */
#define BINDESC_ID_APP_BUILD_VERSION 0x805
/** The kernel version string such as "3.4.0" */
#define BINDESC_ID_KERNEL_VERSION_STRING 0x900
@ -66,6 +69,9 @@ extern "C" {
/** The kernel version number such as 0x30400 */
#define BINDESC_ID_KERNEL_VERSION_NUMBER 0x904
/** The kernel git reference such as "v3.3.0-18-g2c85d9224fca" */
#define BINDESC_ID_KERNEL_BUILD_VERSION 0x905
/** The year the image was compiled in */
#define BINDESC_ID_BUILD_TIME_YEAR 0xa00
@ -308,6 +314,10 @@ extern const struct bindesc_entry BINDESC_NAME(kernel_version_patchlevel);
extern const struct bindesc_entry BINDESC_NAME(kernel_version_number);
#endif /* defined(CONFIG_BINDESC_KERNEL_VERSION_NUMBER) */
#if defined(CONFIG_BINDESC_KERNEL_BUILD_VERSION)
extern const struct bindesc_entry BINDESC_NAME(kernel_build_version);
#endif /* defined(CONFIG_BINDESC_KERNEL_BUILD_VERSION) */
#if defined(CONFIG_BINDESC_APP_VERSION_STRING)
extern const struct bindesc_entry BINDESC_NAME(app_version_string);
#endif /* defined(CONFIG_BINDESC_APP_VERSION_STRING) */
@ -328,6 +338,10 @@ extern const struct bindesc_entry BINDESC_NAME(app_version_patchlevel);
extern const struct bindesc_entry BINDESC_NAME(app_version_number);
#endif /* defined(CONFIG_BINDESC_APP_VERSION_NUMBER) */
#if defined(CONFIG_BINDESC_APP_BUILD_VERSION)
extern const struct bindesc_entry BINDESC_NAME(app_build_version);
#endif /* defined(CONFIG_BINDESC_APP_BUILD_VERSION) */
#if defined(CONFIG_BINDESC_BUILD_TIME_YEAR)
extern const struct bindesc_entry BINDESC_NAME(build_time_year);
#endif /* defined(CONFIG_BINDESC_BUILD_TIME_YEAR) */

View file

@ -75,11 +75,13 @@ class Bindesc(WestCommand):
self.bindesc_gen_tag(self.TYPE_UINT, 0x802): 'APP_VERSION_MINOR',
self.bindesc_gen_tag(self.TYPE_UINT, 0x803): 'APP_VERSION_PATCHLEVEL',
self.bindesc_gen_tag(self.TYPE_UINT, 0x804): 'APP_VERSION_NUMBER',
self.bindesc_gen_tag(self.TYPE_STR, 0x805): 'APP_BUILD_VERSION',
self.bindesc_gen_tag(self.TYPE_STR, 0x900): 'KERNEL_VERSION_STRING',
self.bindesc_gen_tag(self.TYPE_UINT, 0x901): 'KERNEL_VERSION_MAJOR',
self.bindesc_gen_tag(self.TYPE_UINT, 0x902): 'KERNEL_VERSION_MINOR',
self.bindesc_gen_tag(self.TYPE_UINT, 0x903): 'KERNEL_VERSION_PATCHLEVEL',
self.bindesc_gen_tag(self.TYPE_UINT, 0x904): 'KERNEL_VERSION_NUMBER',
self.bindesc_gen_tag(self.TYPE_STR, 0x905): 'KERNEL_BUILD_VERSION',
self.bindesc_gen_tag(self.TYPE_UINT, 0xa00): 'BUILD_TIME_YEAR',
self.bindesc_gen_tag(self.TYPE_UINT, 0xa01): 'BUILD_TIME_MONTH',
self.bindesc_gen_tag(self.TYPE_UINT, 0xa02): 'BUILD_TIME_DAY',

View file

@ -35,6 +35,12 @@ config BINDESC_KERNEL_VERSION_NUMBER
(major << 16 | minor << 8 | patchlevel). For example,
3.4.0 would be represented as 0x30400
config BINDESC_KERNEL_BUILD_VERSION
bool "Kernel git reference"
help
The kernel git reference, such as "v3.3.0-18-g2c85d9224fca",
or overridden at build time - see BUILD_VERSION
config BINDESC_APP_VERSION_STRING
bool "App version string"
help
@ -62,4 +68,9 @@ config BINDESC_APP_VERSION_NUMBER
(major << 16 | minor << 8 | patchlevel). For example,
1.0.0 would be represented as 0x10000
config BINDESC_APP_BUILD_VERSION
bool "App git reference"
help
The application git reference, such as "v3.3.0-18-g2c85d9224fca"
endif # BINDESC_DEFINE_VERSION

View file

@ -33,6 +33,11 @@ BINDESC_UINT_DEFINE(kernel_version_number, BINDESC_ID_KERNEL_VERSION_NUMBER,
KERNEL_VERSION_NUMBER);
#endif /* defined(CONFIG_BINDESC_KERNEL_VERSION_NUMBER) */
#if defined(CONFIG_BINDESC_KERNEL_BUILD_VERSION)
BINDESC_STR_DEFINE(kernel_build_version, BINDESC_ID_KERNEL_BUILD_VERSION,
STRINGIFY(BUILD_VERSION));
#endif /* CONFIG_BINDESC_KERNEL_BUILD_VERSION */
#if defined(HAS_APP_VERSION)
#include <zephyr/app_version.h>
@ -61,4 +66,9 @@ BINDESC_UINT_DEFINE(app_version_number, BINDESC_ID_APP_VERSION_NUMBER,
APP_VERSION_NUMBER);
#endif /* defined(CONFIG_BINDESC_APP_VERSION_NUMBER) */
#if defined(CONFIG_BINDESC_APP_BUILD_VERSION)
BINDESC_STR_DEFINE(app_build_version, BINDESC_ID_APP_BUILD_VERSION,
STRINGIFY(APP_BUILD_VERSION));
#endif /* CONFIG_BINDESC_APP_BUILD_VERSION */
#endif /* defined(HAS_APP_VERSION) */