From 6a3d978a75a4a34881db241444f3b1f863fe3c1f Mon Sep 17 00:00:00 2001 From: Technobly Date: Wed, 27 Apr 2022 20:32:13 -0500 Subject: [PATCH] [deprecation] PRODUCT_ID macro --- docs/build.md | 12 ++----- hal/inc/deviceid_hal.h | 3 +- .../product_id_and_version/application.cpp | 1 - user/applications/tinker/application.cpp | 1 - .../immediate_updates/immediate_updates.cpp | 1 - wiring/inc/spark_wiring_version.h | 34 +++++++++++++++++-- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/docs/build.md b/docs/build.md index 8b896f9008..af303dbe31 100644 --- a/docs/build.md +++ b/docs/build.md @@ -67,7 +67,6 @@ to indicate Safe Mode when the application firmware isn't run. - `v` - verbose - set to 1 to trigger verbose output - `PLATFORM`/`PLATFORM_ID`: specifies the target platform, either as a name or as an ID. -- `PRODUCT_ID`: specifies the target product ID. - `PRODUCT_FIRMWARE_VERSION`: specifies the firmware version that is sent to the cloud. Value from 0 to 65535. - `GCC_PREFIX`: a prefix added to the ARM toolchain. Allows custom locations to be specified if @@ -206,16 +205,9 @@ make Will build the main firmware, and all the modules the main firmware depends on. -## Product ID +## Product Version -The Product ID and product firmware version -is specified in your application code via the macros: - -``` -PRODUCT_ID(id); -``` - -and +The product firmware version is specified in your application code via the macro: ``` PRODUCT_VERSION(version) diff --git a/hal/inc/deviceid_hal.h b/hal/inc/deviceid_hal.h index 2da292994b..c71b59a04c 100644 --- a/hal/inc/deviceid_hal.h +++ b/hal/inc/deviceid_hal.h @@ -56,8 +56,7 @@ extern "C" { unsigned HAL_device_ID(uint8_t* dest, unsigned destLen); /** - * Retrievse the platform ID of this device. This allows libraries above HAL - * to not be compile-time dependent on the PRODUCT_ID symbol. + * Retrievse the platform ID of this device. */ unsigned HAL_Platform_ID(); diff --git a/user/applications/product_id_and_version/application.cpp b/user/applications/product_id_and_version/application.cpp index 38542ae37a..358976a198 100644 --- a/user/applications/product_id_and_version/application.cpp +++ b/user/applications/product_id_and_version/application.cpp @@ -3,7 +3,6 @@ // To verify product creator macros work correctly. // These values get sent to the cloud on connection and help dashboard.particle.io do the right thing // -PRODUCT_ID(42); PRODUCT_VERSION(3); void setup() { diff --git a/user/applications/tinker/application.cpp b/user/applications/tinker/application.cpp index 1061ef4d1c..157d8cb1f9 100644 --- a/user/applications/tinker/application.cpp +++ b/user/applications/tinker/application.cpp @@ -73,7 +73,6 @@ const PinMapping g_pinmap[] = { const size_t g_pin_count = sizeof(g_pinmap) / sizeof(*g_pinmap); -PRODUCT_ID(PLATFORM_ID); PRODUCT_VERSION(3); /* Function prototypes -------------------------------------------------------*/ diff --git a/user/tests/app/immediate_updates/immediate_updates.cpp b/user/tests/app/immediate_updates/immediate_updates.cpp index 222eddf831..a1234182f1 100644 --- a/user/tests/app/immediate_updates/immediate_updates.cpp +++ b/user/tests/app/immediate_updates/immediate_updates.cpp @@ -1,7 +1,6 @@ #include "Particle.h" #define VERSION 6 -PRODUCT_ID(2448); PRODUCT_VERSION(VERSION); SYSTEM_MODE(SEMI_AUTOMATIC); diff --git a/wiring/inc/spark_wiring_version.h b/wiring/inc/spark_wiring_version.h index 157e222a0c..78f143c70d 100644 --- a/wiring/inc/spark_wiring_version.h +++ b/wiring/inc/spark_wiring_version.h @@ -44,8 +44,38 @@ struct __ApplicationProductVersion { #endif #if PLATFORM_ID!=3 -#define PRODUCT_ID(x) __ApplicationProductID __appProductID(x); __attribute__((externally_visible, section(".modinfo.product_id"))) uint16_t __system_product_id = (x); -#define PRODUCT_VERSION(x) __ApplicationProductVersion __appProductVersion(x); __attribute__((externally_visible, section(".modinfo.product_version"))) uint16_t __system_product_version = (x); +#define PRODUCT_ID(x) _Pragma ("GCC error \"The PRODUCT_ID macro must be removed from your firmware source code. \ +The same compiled firmware binary may be used in multiple products that share the same platform and functionality.\"") +/* + * PRODUCT_ID and PRODUCT_VERSION will be added to the beginning of the suffix by the linker. + * + * The following is an example of where the two 16-bit values live at the end of the binary, + * in the 40 byte suffix. + * + * This is for a Boron PLATFORM_ID 13, and code with version 3. + * product_id (0D,00) and product_version (03,00) + * + * 0D,00,03,00,00,00,66,B6,B7,8F,3E,A4,8E,10,1B,30,FE,2A,C1,29,22,08, + * 5A,8A,43,ED,93,1C,DA,3A,8D,50,13,48,80,D3,7F,74,28,00,4B,C2,BA,F6 + * + * Here's the beautified view: + * + * suffixInfo: { + * productId: 13, + * productVersion: 3, + * fwUniqueId: '66b6b78f3ea48e101b30fe2ac12922085a8a43ed931cda3a8d50134880d37f74', + * reserved: 0, + * suffixSize: 40, + * crcBlock: '4bc2baf6' + * } + * + */ +#define PRODUCT_VERSION(x) \ + __ApplicationProductVersion __appProductVersion(x); \ + __attribute__((externally_visible, section(".modinfo.product_version"))) uint16_t __system_product_version = (x); \ + /* PRODUCT_ID used to do the following with a dynamic ID, but now we hardcode the PLATFORM_ID as the PRODUCT_ID. */ \ + __ApplicationProductID __appProductID(PLATFORM_ID); \ + __attribute__((externally_visible, section(".modinfo.product_id"))) uint16_t __system_product_id = (PLATFORM_ID); #else #define PRODUCT_ID(x) #define PRODUCT_VERSION(x)