Skip to content

Commit

Permalink
* Allow overrule of PID/VID/Version at build time (#22787)
Browse files Browse the repository at this point in the history
Used for customer development and simple OTA test image creation
  • Loading branch information
tima-q authored Sep 21, 2022
1 parent d7df118 commit 4ea64dd
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/lighting-app/qpg/include/CHIPProjectConfig.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@
*
* 0xFFF1: Test Vendor.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
*
* 0x8005: example lighting app
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005
#endif // CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
Expand Down
4 changes: 4 additions & 0 deletions examples/lock-app/qpg/include/CHIPProjectConfig.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,18 @@
*
* 0xFFF1: Test vendor.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
*
* 0x8006: example lock-app
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006
#endif // CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
Expand Down
1 change: 1 addition & 0 deletions examples/persistent-storage/qpg/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ qpg_executable("persistent_storage_app") {
output_name = "chip-${qpg_target_ic}-persistent_storage-example.out"

deps = []
defines = []

public_deps = [
":sdk",
Expand Down
4 changes: 4 additions & 0 deletions examples/persistent-storage/qpg/include/CHIPProjectConfig.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@
*
* 0xFFF1: Test vendor.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
*
* 0x8009: example persistent-storage
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8009
#endif // CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
Expand Down
4 changes: 4 additions & 0 deletions examples/shell/qpg/include/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@
*
* 0xFFF1: Test vendor.
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID
#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1
#endif // CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
*
* 0x8009: example shell
*/
#ifndef CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID
#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8012
#endif // CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID

/**
* CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION
Expand Down
42 changes: 42 additions & 0 deletions third_party/qpg_sdk/qpg_executable.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ import("${build_root}/toolchain/flashable_executable.gni")
import("${chip_root}/src/platform/device.gni")
import("qpg_sdk.gni")

declare_args() {
matter_device_vid = ""
matter_device_pid = ""
matter_device_software_version_string = ""
matter_device_software_version = ""
}

# Run the generator script that takes a .HEX file and adds the OTA header to it.
#
# This requires a Python script, given by ota_header_generator,
Expand Down Expand Up @@ -66,6 +73,25 @@ template("qpg_executable") {
objcopy_image_format = "ihex"
objcopy = "arm-none-eabi-objcopy"

defines = []
if (defined(invoker.defines)) {
defines += invoker.defines
}

# Overrule CHIPProjectConfig.h settings
if (matter_device_vid != "") {
defines += [ "CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${matter_device_vid}" ]
}
if (matter_device_pid != "") {
defines += [ "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${matter_device_pid}" ]
}
if (matter_device_software_version_string != "") {
defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${matter_device_software_version_string}\"" ]
}
if (matter_device_software_version != "") {
defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION=${matter_device_software_version}" ]
}

# Copy flashing dependencies to the output directory so that the output
# is collectively self-contained; this allows flashing to work reliably
# even if the build and flashing steps take place on different machines
Expand Down Expand Up @@ -124,6 +150,22 @@ template("qpg_executable") {
"--pem_password=test1234",
"--sign",
]

# Use build-time overrules in OTA header creation
# Normally taken from CHIPProjectConfig.h by scripting
if (matter_device_vid != "") {
ota_header_options += [ "-vid=${matter_device_vid}" ]
}
if (matter_device_pid != "") {
ota_header_options += [ "-pid=${matter_device_pid}" ]
}
if (matter_device_software_version != "") {
ota_header_options += [ "-vn=${matter_device_software_version}" ]
}
if (matter_device_software_version_string != "") {
ota_header_options +=
[ "-vs=\"${matter_device_software_version_string}\"" ]
}
deps = [ ":$executable_target_name" ]
}
}
Expand Down

0 comments on commit 4ea64dd

Please sign in to comment.