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
Copy file name to clipboardExpand all lines: examples/storage/nvs_bootloader/README.md
+116-1Lines changed: 116 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@
3
3
4
4
# NVS Bootloader
5
5
6
-
The purpose of this example is to show how to use the simplified, read-only API of NVS flash that can be used as a part of bootloader
6
+
The purpose of this example is to show how to use the simplified, read-only API of NVS flash that can be used as a part of bootloader.
7
+
8
+
A very practical application of being able to access the NVS in the bootloader build would be faster device restoration, where-in the application stores the device's current state/configurations and post a reset it would read the NVS to restore the device's last state, without waiting for application to boot-up.
7
9
8
10
## Usage of this example:
9
11
@@ -123,3 +125,116 @@ Below is a short explanation of files in the project folder.
123
125
The example creates request/response array `read_list[]`, populates it with identifiers of the data to be read.
124
126
Function `nvs_bootloader_read()` tries to find respective data in the partition (here `"nvs"`) and if the data is found, it populates the request/response array with data. For nvs entries either not found or not matching are indicated in response array as well.
125
127
Function `log_nvs_bootloader_read_list()`is used before and after reading from nvs to show request/response data to the console.
128
+
129
+
# Encrypted NVS Bootloader
130
+
131
+
This example is extended to support reading encrypted NVS partition when NVS encryption is enabled.
132
+
133
+
## Usage of this example:
134
+
135
+
Enable NVS encryption using your preferred scheme. Please find more details regarding the `flash encryption based NVS encryption scheme` and the `HMAC based NVS encryption scheme` in the [NVS encryption documentation](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/storage/nvs_encryption.html).
136
+
137
+
(Note: In case you select the `HMAC based NVS encryption scheme`, make sure that you burn the below mentioned [HMAC key](./main/nvs_enc_hmac_key.bin) in the efuses.)
138
+
139
+
For generating the encrypted NVS partitions, we shall use [NVS partition generator](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/storage/nvs_partition_gen.html#nvs-partition-generator-utility).
140
+
We shall use the [nvs_partition_gen.py](../../../components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py) script for the operations.
141
+
142
+
Along with the above mentioned file structure, the project folder also contains pre-generated encrypted partitions and the partition corresponding to the selected NVS encryption scheme is flashed along with the build artefacts using the `main/CMakeLists.txt`.
143
+
144
+
In case the data in `nvs_data.csv` is modified, these encrypted NVS partitions can be re-generated using the following commands:
145
+
146
+
1. NVS Encryption using the flash encryption scheme
Build the application using configurations corresponding to the NVS encryption scheme that you have selected:
159
+
160
+
```
161
+
idf.py set-target <target>
162
+
163
+
# For NVS encryption using flash encryption scheme
164
+
cat sdkconfig.ci.nvs_enc_flash_enc >> sdkconfig
165
+
166
+
OR
167
+
168
+
# For NVS encryption using the HMAC scheme
169
+
cat sdkconfig.ci.nvs_enc_hmac >> sdkconfig
170
+
171
+
idf.py build
172
+
```
173
+
174
+
Then flash it and open the monitor with the following command:
175
+
```
176
+
idf.py flash monitor
177
+
```
178
+
179
+
If everything went well, the console output should contain the same three blocks of log messages that are mentioned above.
180
+
181
+
### Running the example using QEMU
182
+
183
+
You could quickly try out this example using QEMU. Refer this [link](https://github.com/espressif/esp-toolchain-docs/blob/main/qemu/README.md#choose-your-target) to know which targets are currently supported in QEMU.
184
+
185
+
#### Using the NVS encryption's flash encryption scheme
186
+
187
+
1. Configure the application with the corresponding configurations
188
+
189
+
```
190
+
idf.py set-target <qemu-supported-targets>
191
+
192
+
cat sdkconfig.ci.nvs_enc_flash_enc >> sdkconfig
193
+
194
+
# Disable the below config as it was enabled as a CI related configuration, thus enabling flash encryption during boot-up in QEMU
0 commit comments