Skip to content

Commit

Permalink
Allow configurable build time versioning of efr32 (#25732)
Browse files Browse the repository at this point in the history
* update build script and gn file

print software version along with software version string in base app

remove extra #defines

fix getHardwareVersionString typo

fix header

* remove debug statement

* Restyled by whitespace

* Restyled by clang-format

* Restyled by gn

* add else condition for version str

* code review comments

* update descriptions

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jan 4, 2024
1 parent ded19a1 commit 1847305
Show file tree
Hide file tree
Showing 17 changed files with 62 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8004

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
20 changes: 0 additions & 20 deletions examples/light-switch-app/silabs/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8004

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
20 changes: 0 additions & 20 deletions examples/lighting-app/silabs/SiWx917/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
20 changes: 0 additions & 20 deletions examples/lighting-app/silabs/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
20 changes: 0 additions & 20 deletions examples/lock-app/silabs/SiWx917/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
20 changes: 0 additions & 20 deletions examples/lock-app/silabs/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/silabs/SiWx917/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)
appError(APP_ERROR_CREATE_TIMER_FAILED);
}

SILABS_LOG("Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);

#ifdef ENABLE_WSTK_LEDS
sStatusLED.Init(APP_STATE_LED);
Expand Down
12 changes: 6 additions & 6 deletions examples/platform/silabs/SiWx917/SiWx917DeviceDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ CHIP_ERROR SIWx917DeviceDataProvider::GetHardwareVersionString(char * buf, size_
size_t hardwareVersionStringLen = 0; // without counting null-terminator
CHIP_ERROR err =
SilabsConfig::ReadConfigValueStr(SilabsConfig::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen);
#if defined(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)
#if defined(CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING)
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(bufSize));
memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING, sizeof(bufSize));
err = CHIP_NO_ERROR;
}
#endif // CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#endif // CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING
return err;
}

Expand All @@ -371,13 +371,13 @@ CHIP_ERROR SIWx917DeviceDataProvider::GetHardwareVersion(uint16_t & hardwareVers
uint32_t hardwareVersion32;

err = SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_HardwareVersion, hardwareVersion32);
#if defined(CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION)
#if defined(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION)
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
hardwareVersion32 = CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION;
hardwareVersion32 = CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION;
err = CHIP_NO_ERROR;
}
#endif // defined(CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION)
#endif // defined(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION)

hardwareVersion = static_cast<uint16_t>(hardwareVersion32);
return err;
Expand Down
3 changes: 2 additions & 1 deletion examples/platform/silabs/efr32/BaseApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj)
appError(APP_ERROR_CREATE_TIMER_FAILED);
}

SILABS_LOG("Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);

#if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT)
LEDWidget::InitGpio();
Expand Down
12 changes: 6 additions & 6 deletions examples/platform/silabs/efr32/EFR32DeviceDataProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,13 @@ CHIP_ERROR EFR32DeviceDataProvider::GetHardwareVersionString(char * buf, size_t
size_t hardwareVersionStringLen = 0; // without counting null-terminator
CHIP_ERROR err =
SilabsConfig::ReadConfigValueStr(SilabsConfig::kConfigKey_HardwareVersionString, buf, bufSize, hardwareVersionStringLen);
#if defined(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING)
#if defined(CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING)
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, sizeof(bufSize));
memcpy(buf, CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING, sizeof(bufSize));
err = CHIP_NO_ERROR;
}
#endif // CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING
#endif // CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION_STRING
return err;
}

Expand All @@ -240,13 +240,13 @@ CHIP_ERROR EFR32DeviceDataProvider::GetHardwareVersion(uint16_t & hardwareVersio
uint32_t hardwareVersion32;

err = SilabsConfig::ReadConfigValue(SilabsConfig::kConfigKey_HardwareVersion, hardwareVersion32);
#if defined(CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION)
#if defined(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION)
if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
{
hardwareVersion32 = CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION;
hardwareVersion32 = CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION;
err = CHIP_NO_ERROR;
}
#endif // defined(CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION)
#endif // defined(CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION)

hardwareVersion = static_cast<uint16_t>(hardwareVersion32);
return err;
Expand Down
20 changes: 0 additions & 20 deletions examples/thermostat/silabs/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x800E

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
20 changes: 0 additions & 20 deletions examples/window-app/silabs/SiWx917/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8010

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
20 changes: 0 additions & 20 deletions examples/window-app/silabs/efr32/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,6 @@
*/
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8010

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
*
* The hardware version number assigned to device or product by the device vendor. This
* number is scoped to the device product id, and typically corresponds to a revision of the
* physical device, a change to its packaging, and/or a change to its marketing presentation.
* This value is generally *not* incremented for device software versions.
*/
#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1

/**
* CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
*
* A uint32_t identifying the software version running on the device.
*/
/* The SoftwareVersion attribute of the Basic cluster. */
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001
#endif

/**
* CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
*
Expand Down
25 changes: 14 additions & 11 deletions scripts/examples/gn_efr32_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ if [ "$#" == "0" ]; then
enable_sleepy_device
Enable Sleepy end device. (Default false)
Must also set chip_openthread_ftd=false
sl_matter_version_str
Set a Matter sotfware version string for the Silabs examples
Used and formatted by default in this script.
To skip that formatting or use your own version string use --no-version
use_rs9116
Build wifi example with extension board rs9116. (Default false)
use_SiWx917
Expand All @@ -99,6 +95,13 @@ if [ "$#" == "0" ]; then
Periodic query timeout variable for OTA in seconds
rs91x_wpa3_only
Support for WPA3 only mode on RS91x
sl_matter_version
Use provided software version at build time
sl_matter_version_str
Set a Matter sotfware version string for the Silabs examples
Used and formatted by default in this script.
sl_hardware_version
Use provided hardware version at build time
siwx917_commissionable_data
Build with the commissionable data given in DeviceConfig.h (only for SiWx917)
Presets
Expand All @@ -116,9 +119,6 @@ if [ "$#" == "0" ]; then
use the silabs openthread library
--use_chip_lwip_lib
use the chip lwip library
--no-version
Skip the silabs formating for the Matter software version string
Currently : v1.0-<branchName>-<ShortCommitSha>
--release
Remove all logs and debugs features (including the LCD). Yield the smallest image size possible
--docker
Expand Down Expand Up @@ -194,10 +194,6 @@ else
# optArgs+="openthread_root=\"//third_party/connectedhomeip/third_party/openthread/ot-efr32/openthread\" openthread_efr32_root=\"//third_party/connectedhomeip/third_party/openthread/ot-efr32/src/src\""
# shift
# ;;
--no-version)
USE_GIT_SHA_FOR_VERSION=false
shift
;;
--release)
optArgs+="is_debug=false disable_lcd=true chip_build_libshell=false enable_openthread_cli=false use_external_flash=false chip_logging=false silabs_log_enabled=false "
shift
Expand All @@ -207,6 +203,13 @@ else
USE_DOCKER=true
shift
;;

*"sl_matter_version_str="*)
optArgs+="$1 "
USE_GIT_SHA_FOR_VERSION=false
shift
;;

*)
if [ "$1" =~ *"use_rs9116=true"* ] || [ "$1" =~ *"use_SiWx917=true"* ] || [ "$1" =~ *"use_wf200=true"* ]; then
USE_WIFI=true
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
* A monothonic number identifying the software version running on the device.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 1
#endif

/**
Expand Down
Loading

0 comments on commit 1847305

Please sign in to comment.