Skip to content

Commit

Permalink
bindesc: Add support for the build version values
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
attie-argentum authored and nashif committed Sep 4, 2024
1 parent aa6319d commit e6dc930
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/zephyr/bindesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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) */
Expand All @@ -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) */
Expand Down
2 changes: 2 additions & 0 deletions scripts/west_commands/bindesc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ def __init__(self):
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',
Expand Down
11 changes: 11 additions & 0 deletions subsys/bindesc/Kconfig.version
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions subsys/bindesc/bindesc_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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) */

0 comments on commit e6dc930

Please sign in to comment.