How to incorporate build date/time, firmware versions and board type in Zephyr build for access by code

Hi

I want to be able to access some build type variables in my C code in a Zephyr project (using west as the build manager) to be able to show them on a screen or in logs (need to identify the exact firmware build and the options used to be able to support customers...)

I have found how to use the Zephr 'VERSION' file to set my firmware versions and then access these as defines in the code.

I would like to do the same for other elements of the build:

- the board type (eg 'nrf5340dk_nrf5340') used for the build

I tried putting a 'boards' section in a snippet to define 'DTS_EXTRA_CPPFLAGS' but it seems these are only passed to the dts tool, not to general C compilation?

  boards:
    cc1medv1_nrf5340:
      append:
        DTS_EXTRA_CPPFLAGS: -DBOARD=cc2-v1
    nrf5340dk_nrf5340:
      append:
        DTS_EXTRA_CPPFLAGS: -DBOARD=nrf5340DK

- the build date/time

I found the config options related to BINDESC such as 

CONFIG_BINDESC_BUILD_DATE_TIME_STRING=y
but, I don't see how to get the generated string in my code?

- the 'snippets' used on the command line for the build (as these affect the binary created!)

? no idea?

Parents Reply Children
Related