Skip to content

zephyr VERSION unnecessarily overflows quickly #93849

@fs34a

Description

@fs34a

Summary

Now MAJOR, MINOR, PATHLEVEL and TWEAK are all 8bits.
VERSION_MAJOR =
VERSION_MINOR =
PATCHLEVEL =
VERSION_TWEAK =
EXTRAVERSION =
In case we don't have serious change, we only bump the version tweak by Jenkins build. A 8bit integer is so easy to run out, then we have to bump patch level even it should not considered as a path level change.

Describe the solution you'd like

In fact mcuboot image version supports wider range than VERSION does. After imgtool.py sign it, the header
is populated from VERSION where revision is from patch level and build_num is from version tweak.

struct mcuboot_img_sem_ver {
    uint8_t major;
    uint8_t minor;
    uint16_t revision;
    uint32_t build_num;
};

As a workaround, we change the zephyr/cmake/modules/version.cmake
Then we can have sufficient version bits to use and this needs no update from mcuboot.

  # For APP_VERSION, extend patchlevel to 16bits, and version tweak to 32bits. This matches the mcuboot image header definition.
  if(type STREQUAL KERNEL)
    math(EXPR ${type}_VERSION_NUMBER_INT "(${MAJOR} << 16) + (${MINOR} << 8)  + (${PATCH})")
    math(EXPR ${type}VERSION_INT         "(${MAJOR} << 24) + (${MINOR} << 16) + (${PATCH} << 8) + (${TWEAK})")
  else()
    math(EXPR ${type}_VERSION_NUMBER_INT "(${MAJOR} << 48) + (${MINOR} << 40)  + (${PATCH})")
    math(EXPR ${type}VERSION_INT         "(${MAJOR} << 56) + (${MINOR} << 48) + (${PATCH} << 40) + (${TWEAK})")
  endif()

Alternatives

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementChanges/Updates/Additions to existing features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions