Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[deprecation] PRODUCT_ID macro #2446

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions hal/inc/deviceid_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 0 additions & 1 deletion user/applications/product_id_and_version/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion user/applications/tinker/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------------------------------------------------*/
Expand Down
1 change: 0 additions & 1 deletion user/tests/app/immediate_updates/immediate_updates.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "Particle.h"

#define VERSION 6
PRODUCT_ID(2448);
PRODUCT_VERSION(VERSION);
SYSTEM_MODE(SEMI_AUTOMATIC);

Expand Down
34 changes: 32 additions & 2 deletions wiring/inc/spark_wiring_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down