@@ -37,7 +37,7 @@ data secure by applying hardware write protection.
37
37
- [ Appearance field description] ( #appearance-field-description )
38
38
- [ Enabling factory data support] ( #enabling-factory-data-support )
39
39
- [ Generating factory data] ( #generating-factory-data )
40
- - [ Creating the factory data JSON file with the first script] ( #creating-the-factory-data-json-file -with-the-first-script )
40
+ - [ Creating the factory data JSON and HEX files with the first script] ( #creating-the-factory-data-json-and-hex-files -with-the-first-script )
41
41
- [ How to set user data] ( #how-to-set-user-data )
42
42
- [ How to handle user data] ( #how-to-handle-user-data )
43
43
- [ Verifying using the JSON Schema tool] ( #verifying-using-the-json-schema-tool )
@@ -218,14 +218,19 @@ file written in another way. To make sure that the JSON file is correct and the
218
218
device is able to read out parameters,
219
219
[ verify the file using the JSON schema tool] ( #verifying-using-the-json-schema-tool ) .
220
220
221
- ### Creating the factory data JSON file with the first script
221
+ You can also use only the first script to generate both JSON and HEX files, by
222
+ providing optional ` offset ` and ` size ` arguments, which results in invoking the
223
+ script internally. Such option is the recommended one, but invoking two scripts
224
+ one by one is also supported to provide backward compatibility.
225
+
226
+ ### Creating the factory data JSON and HEX files with the first script
222
227
223
228
A Matter device needs a proper factory data partition stored in the flash memory
224
229
to read out all required parameters during startup. To simplify the factory data
225
230
generation, you can use the
226
231
[ generate_nrfconnect_chip_factory_data.py] ( ../../scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py )
227
232
Python script to provide all required parameters and generate a human-readable
228
- JSON file.
233
+ JSON file and save it to a HEX file .
229
234
230
235
To use this script, complete the following steps:
231
236
@@ -245,10 +250,10 @@ To use this script, complete the following steps:
245
250
--sn --vendor_id, --product_id, --vendor_name, --product_name, --date, --hw_ver, --hw_ver_str, --spake2_it, --spake2_salt, --discriminator
246
251
```
247
252
248
- b. Add output file path :
253
+ b. Add output path to store .json file, e.g. my_dir/output :
249
254
250
255
```
251
- -o <path_to_output_json_file >
256
+ -o <path_to_output_file >
252
257
```
253
258
254
259
c. Generate SPAKE2 verifier using one of the following methods:
@@ -341,6 +346,34 @@ To use this script, complete the following steps:
341
346
> `chip-cert` executable. See the note at the end of this section to learn
342
347
> how to get it.
343
348
349
+ k. (optional) Partition offset that is an address in device's NVM memory,
350
+ where factory data will be stored.
351
+
352
+ ```
353
+ --offset <offset>
354
+ ```
355
+
356
+ > **Note:** To generate a HEX file with factory data, you need to provide
357
+ > both `offset` and `size` optional arguments. As a result,
358
+ > `factory_data.hex` and `factory_data.bin` files are created in the
359
+ > `output` directory. The first file contains the required memory offset.
360
+ > For this reason, it can be programmed directly to the device using a
361
+ > programmer (for example, `nrfjprog`).
362
+
363
+ l. (optional) The maximum partition size in device's NVM memory, where
364
+ factory data will be stored.
365
+
366
+ ```
367
+ --size <size>
368
+ ```
369
+
370
+ > **Note:** To generate a HEX file with factory data, you need to provide
371
+ > both `offset` and `size` optional arguments. As a result,
372
+ > `factory_data.hex` and `factory_data.bin` files are created in the
373
+ > `output` directory. The first file contains the required memory offset.
374
+ > For this reason, it can be programmed directly to the device using a
375
+ > programmer (for example, `nrfjprog`).
376
+
344
377
4. Run the script using the prepared list of arguments:
345
378
346
379
```
@@ -370,8 +403,10 @@ $ python scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py \
370
403
--passcode 20202021 \
371
404
--product_finish "matte" \
372
405
--product_color "black" \
373
- --out "build.json" \
374
- --schema "scripts/tools/nrfconnect/nrfconnect_factory_data.schema"
406
+ --out "build" \
407
+ --schema "scripts/tools/nrfconnect/nrfconnect_factory_data.schema" \
408
+ --offset 0xf7000 \
409
+ --size 0x1000
375
410
```
376
411
377
412
As the result of the above example, a unique ID for the rotating device ID is
@@ -570,7 +605,7 @@ To generate a manual pairing code and a QR code, complete the following steps:
570
605
```
571
606
572
607
2. Complete steps 1, 2, and 3 from the
573
- [Creating the factory data JSON file with the first script](#creating-the-factory-data-json-file -with-the-first-script)
608
+ [Creating the factory data JSON and HEX files with the first script](#creating-the-factory-data-json-and-hex-files -with-the-first-script)
574
609
section to prepare the final invocation of the Python script.
575
610
576
611
3. Add the `--generate_onboarding` argument to the Python script final
@@ -686,10 +721,15 @@ The output will look similar to the following one:
686
721
### Creating a factory data partition with the second script
687
722
688
723
To store the factory data set in the device's persistent storage, convert the
689
- data from the JSON file to its binary representation in the CBOR format. To do
690
- this, use the
724
+ data from the JSON file to its binary representation in the CBOR format. This is
725
+ done by the
726
+ [generate_nrfconnect_chip_factory_data.py](../../scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py),
727
+ if you provide optional `offset` and `size` arguments. If you provided these
728
+ arguments, skip the following steps of this section.
729
+
730
+ You can skip these optional arguments and do this, using the
691
731
[nrfconnect_generate_partition.py](../../scripts/tools/nrfconnect/nrfconnect_generate_partition.py)
692
- to generate the factory data partition :
732
+ script, but this is obsolete solution kept only for backward compatibility :
693
733
694
734
1. Navigate to the _connectedhomeip_ root directory
695
735
2. Run the following command pattern:
@@ -924,14 +964,13 @@ $ west flash
924
964
## Using own factory data implementation
925
965
926
966
The [factory data generation process](#generating-factory-data) described above
927
- is only an example valid for the nRF Connect platform. You can also create a HEX
928
- file containing all components from the
929
- [factory data component table](#factory-data-component-table) in any format and
930
- then implement a parser to read out all parameters and pass them to a provider.
931
- Each manufacturer can implement a factory data set on its own by implementing a
932
- parser and a factory data accessor inside the Matter stack. Use the
933
- [nRF Connect Provider](../../src/platform/nrfconnect/FactoryDataProvider.h) and
934
- [FactoryDataParser](../../src/platform/nrfconnect/FactoryDataParser.h) as
967
+ is only an example valid for the nRF Connect platform. You can well create a HEX
968
+ file containing all [factory data components](#factory-data-component-table) in
969
+ any format and then implement a parser to read out all parameters and pass them
970
+ to a provider. Each manufacturer can implement a factory data set on its own by
971
+ implementing a parser and a factory data accessor inside the Matter stack. Use
972
+ the [nRF Connect Provider](../../src/platform/nrfconnect/FactoryDataProvider.h)
973
+ and [FactoryDataParser](../../src/platform/nrfconnect/FactoryDataParser.h) as
935
974
examples.
936
975
937
976
You can read the factory data set from the device's flash memory in different
0 commit comments