You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow provisioning ESP32 nvs partition when building
Adds the option to provision nvs partition data at build time for the esp32 platform. If the file
`nvs_partition.csv` is found in the AtomVM/src/platforms/esp32 directory when building; the nvs
partition will be created and added to the `idf.py flash` task as well as to the configuration for
the mkimage.sh script in the build directory. An example file is provided and `nvs_partition.csv`
is added to `.gitignore` to prevent accidentally pushing secrets to remote repositories.
Signed-off-by: Winford <[email protected]>
Copy file name to clipboardExpand all lines: doc/src/build-instructions.md
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -300,6 +300,71 @@ the partition table has not been altered.
300
300
301
301
To build a single binary image file see [Building a Release Image](#building-a-release-image), below.
302
302
303
+
#### NVS Partition Provisioning
304
+
305
+
For streamlining deployment of images for an environment developers may pre-provision NVS partition
306
+
data. This is done by creating a file in the AtomVM/src/platforms/esp32 directory named
307
+
`nvs_partition.csv`, an example called `nvs_partition.csv-example` is provided in the same
308
+
directory. If this file exists it will be included by the mkimage.sh script in the build directory.
309
+
The partition is not included in the `idf.py flash` task so that settings made by applications can
310
+
be retained. To update changes or restore to the defaults defined in`nvs_partition.csv` delete the
311
+
generated `build/nvs.bin` file (if present) and execute the command`idf.py nvs-flash`.
312
+
313
+
This is a more detailed example, with explanations of the structure:
314
+
315
+
```{csv}
316
+
key,type,encoding,value
317
+
network,namespace,,
318
+
ssid,data,binary,"NETWORK_NAME"
319
+
psk,data,binary,"PASSWORD"
320
+
settings,namespace,,
321
+
feature0,data,binary,"1"
322
+
extra_feature,data,binary,"0"
323
+
token,file,binary,/path/to/file
324
+
```
325
+
326
+
Let's break this down line by line:
327
+
328
+
```csv
329
+
key,type,encoding,value
330
+
```
331
+
This is the header describing the columns. It is important that there is no whitespace at the end of each line
332
+
and none separating the commas (`,`) throughout this file.
333
+
334
+
```csv
335
+
network,namespace,,
336
+
```
337
+
The first entry should have a "key" name and have type "namespace". The namespaces are the same
338
+
used to look up the keys with
339
+
[esp:nvs_get_binary/2 (or /3)](./apidocs/erlang/eavmlib/esp.md#nvs_get_binary2). Note that the
340
+
`encoding` and `value` are empty.
341
+
342
+
```csv
343
+
ssid,data,binary,"NETWORK_NAME"
344
+
...
345
+
```
346
+
The keys must use encoding type `binary` as this is the only type currently supported by AtomVM.
347
+
348
+
```csv
349
+
settings,namespace,,
350
+
...
351
+
```
352
+
Multiple namespaces may be used for separation, followed by their keys.
353
+
354
+
```csv
355
+
token,file,binary,/path/to/file
356
+
```
357
+
External file contents may be included
358
+
359
+
The initial values flashed to the `nvs` partition may be changed by applications using
360
+
[esp:nvs_put_binary/3](./apidocs/erlang/eavmlib/esp.md#nvs_put_binary3). If you wish to make
361
+
changes to the partition data and re-flash without rebuilding and flashing the entire AtomVM build
362
+
you may delete the generated `build/nvs.bin` file and run `idf.py nvs-flash`, this will regenerate
363
+
and flash the `nvs` partition.
364
+
365
+
For more information about the format of this file see Espressif's
366
+
[documentation for the NVS generator file format](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/storage/nvs_partition_gen.html#csv-file-format).
367
+
303
368
### Running tests for ESP32
304
369
305
370
Tests for ESP32 are run on the desktop (or CI) using qemu.
0 commit comments