Skip to content

Commit 946494e

Browse files
authored
Update Security Feature guide to cover ESP-IDF latest version changes. (#71)
* Update the UseSecurityFeatures.md for new versions of esp-idf
1 parent c2ce3a5 commit 946494e

File tree

3 files changed

+65
-44
lines changed

3 files changed

+65
-44
lines changed

GettingStartedGuide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,4 +829,4 @@ For more information, `.\devicetester_win_x86-64.exe help` will show all availab
829829
When IDT is run, it generates the `results/uuid` directory that contains the
830830
logs and other information associated with your test run. See
831831
[Understanding results and logs](https://docs.aws.amazon.com/freertos/latest/userguide/lts-results-logs.html)
832-
for more details.
832+
for more details.

UseSecurityFeatures.md

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,36 @@
22

33
## 1 Pre-requisites
44

5-
In the [Getting Started Guide](GettingStartedGuide.md), one would have setup the ESP32-C3 device, installed the required software, setup AWS IoT, configured the demo project with the AWS IoT endpoint, thing name, private key and certificates, and built and run the demo.
5+
In the [Getting Started Guide](GettingStartedGuide.md), one would have setup
6+
the ESP32-C3 device, installed the required software, setup AWS IoT, configured
7+
the demo project with the AWS IoT endpoint, thing name, private key and
8+
certificates, and built and run the demo.
69

710
## 2 Enable the DS peripheral
811

912
1. Run `idf.py menuconfig`
10-
2. Select `Featured FreeRTOS IoT Integration`.
11-
3. Select `Use DS Peripheral`.
12-
4. Go back to the main menu.
13+
1. Select `Component config`.
14+
1. Select `ESP-TLS`.
15+
1. Enable `Use Digital Signature (DS) Peripheral with ESP-TLS`.
16+
It should have `*` marked with the entry when enabled.
17+
1. Go back to `Component config` menu.
18+
1. Select `ESP Secure Cert Manager`.
19+
1. Enable `Enable DS peripheral support`.
20+
It should have `*` marked with the entry when enabled.
21+
1. Go back to main menu.
1322

1423
## 3 Enable flash encryption
1524

16-
5. Select `Security features`.
17-
6. Set `Enable flash encryption on boot (READ DOCS FIRST)` to true.
18-
7. Select `Enable usage mode`.
19-
8. Set `Development (NOT SECURE)` to true.
20-
9. Go back to `Security features`.
21-
10. Go back to main menu, Save and Exit.
25+
1. Select `Security features`.
26+
1. Set `Enable flash encryption on boot (READ DOCS FIRST)` to true.
27+
1. Select `Enable usage mode`.
28+
1. Enable `Development (NOT SECURE)`. It should have `X` marked with the entry
29+
when enabled.
30+
1. Go back to `Security features`.
31+
1. Go back to main menu, Save and Exit.
2232

23-
**NOTE**: This enables Flash Encryption in **Development Mode**. For production devices,
24-
refer to Espressif's documentation on
33+
**NOTE**: This enables Flash Encryption in **Development Mode**. For production
34+
devices, refer to Espressif's documentation on
2535
[**Release Mode** for Flash Encryption](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/security/flash-encryption.html#release-mode)
2636

2737
## 4 Provision the ESP32-C3 with the private key, device certificate and CA certificate in Development Mode
@@ -31,23 +41,25 @@ connection will be encrypted and stored in a special flash partition.
3141
1. Download the necessary components by running `idf.py reconfigure`
3242
1. Create the `esp_secure_crt` partition binary. If this is the first time
3343
running this command, an eFuse block in the ESP32-C3 will be burnt with a
34-
generated key and this **CANNOT** be reversed:
44+
generated key and this **CANNOT** be reversed.
45+
46+
- Replace the following:
47+
- **PORT** with the serial port to which the ESP32-C3 board is connected.
48+
- **CA_CERT_FILEPATH** with the file path to the **PEM-encoded root CA certificate**.
49+
- **DEVICE_CERT_FILEPATH** with the file path to the **PEM-encoded device certificate**.
50+
- **PRIVATE_KEY_FILEPATH** with the file path to the **PEM-encoded private key**.
51+
- **CHIP_TYPE** with chip type of the target (eg. esp32c3).
52+
- **PRIVATE_KEY_ALGORITHM** with the algorithm used on the private key.
53+
- **NOTE:** If using the
54+
[AWS IoT Generated Credentials](https://docs.aws.amazon.com/iot/latest/developerguide/device-certs-create.html)
55+
this value will be `RSA 2048`
56+
57+
```sh
58+
python managed_components/espressif__esp_secure_cert_mgr/tools/configure_esp_secure_cert.py -p PORT --configure_ds --keep_ds_data_on_host --ca-cert CA_CERT_FILEPATH --device-cert DEVICE_CERT_FILEPATH --private-key PRIVATE_KEY_FILEPATH --target_chip CHIP_TYPE --secure_cert_type cust_flash --priv_key_algo PRIVATE_KEY_ALGORITHM
3559
```
36-
python managed_components/espressif__esp_secure_cert_mgr/tools/configure_esp_secure_cert.py -p PORT --configure_ds --keep_ds_data_on_host --ca-cert CA_CERT_FILEPATH --device-cert DEVICE_CERT_FILEPATH --private-key PRIVATE_KEY_FILEPATH --target_chip esp32c3 --secure_cert_type cust_flash
37-
```
38-
Replace:
39-
**PORT** with the serial port to which the ESP32-C3 board is connected.
40-
**CA_CERT_FILEPATH** with the file path to the **PEM-encoded root CA certificate**.
41-
**DEVICE_CERT_FILEPATH** with the file path to the **PEM-encoded device certificate**.
42-
**PRIVATE_KEY_FILEPATH** with the file path to the **PEM-encoded private key**.
60+
- Type in **BURN** when prompted to.
4361

44-
Type in BURN when prompted to.
4562

46-
2. Write the `esp_secure_crt` partition binary (stored in `esp_secure_cert_data/esp_secure_crt.bin`) to the ESP32-C3's flash by running the following command:
47-
```
48-
esptool.py --no-stub --port PORT write_flash 0xD000 esp_secure_cert_data/esp_secure_cert.bin
49-
```
50-
Replace **PORT** with the serial port to which the ESP32-C3 board is connected.
5163

5264
## 5 Configure Secure Boot
5365

@@ -57,7 +69,7 @@ to the Secure Boot section in the
5769
[Featured FreeRTOS IoT Integration page for the ESP32-C3](https://www.freertos.org/featured-freertos-iot-integration-targeting-an-espressif-esp32-c3-risc-v-mcu/)
5870
on FreeRTOS.org for further details. The private key can be generated with the
5971
following command:
60-
```
72+
```sh
6173
openssl genrsa -out secure_boot_signing_key.pem 3072
6274
```
6375
This will output `secure_boot_signing_key.pem`, which can be renamed as you see
@@ -71,7 +83,8 @@ terminal/command prompt.
7183
3. Select `Security features`.
7284
4. Set `Enable hardware Secure Boot in bootloader (READ DOCS FIRST)` to true.
7385
5. Set `Sign binaries during build` to true.
74-
6. Set `Secure boot private signing key` to the path to the RSA 3072 private key you generated in step 1.
86+
6. Set `Secure boot private signing key` to the path to the RSA 3072 private
87+
key you generated in step 1.
7588
7. Go back to main menu, Save and Exit.
7689

7790
**NOTE**: This covers setting up Secure Boot with a single private key, but
@@ -94,11 +107,12 @@ Secure boot enabled, so bootloader not flashed automatically.
94107
==============================================================================
95108
```
96109
2. Flash the bootloader by copying and pasting the command under "Secure boot
97-
enabled, so bootloader not flashed automatically," (the second block of text)
110+
enabled, so bootloader not flashed automatically," (the second block of text),
98111
replacing:
99-
**PORT** with the serial port to which the ESP32-C3 is connected. (Do not include
100-
the opening and closing braces around PORT in the command)
101-
**BAUD** with 460800.
112+
- **(PORT)** with the serial port to which the ESP32-C3 is connected.
113+
(Do not includethe opening and closing braces around PORT in the command)
114+
- **(BAUD)** with 460800.
115+
102116

103117
## 6 Build and flash the demo project
104118

@@ -117,7 +131,8 @@ Run the following command to build and flash the demo project:
117131
```
118132
idf.py -p PORT flash monitor
119133
```
120-
Replace **PORT** with the serial port to which the ESP32-C3 is connected.
134+
Replace:
135+
- **PORT** with the serial port to which the ESP32-C3 is connected.
121136

122137
**NOTE**: If Flash Encryption was enabled, instead of `flash`, you must use
123138
`encrypted-flash` to flash the board AFTER this step i.e. with subsequent flashes.
@@ -198,8 +213,7 @@ Create a binary with a higher version number.
198213
```
199214
idf.py build
200215
```
201-
If successful, there will be a new binary under the 'build' directory - build/
202-
GoldenReferenceIntegration.bin. Copy this binary to another location, else it will
216+
If successful, there will be a new binary under the 'build' directory - build/FeaturedFreeRTOSIoTIntegration.bin. Copy this binary to another location, else it will
203217
be overwritten in the next step.
204218

205219
### 8.2 Build and flash the device with a binary with a lower version number
@@ -212,8 +226,8 @@ idf.py -p PORT encrypted-flash monitor
212226
`flash`, we use `encrypted-flash` to flash the board for this step.
213227

214228
### 8.3 Upload the binary with the higher version number (created in step 8.1) and create an OTA Update Job
215-
1. In the navigation pane of the AWS IoT console, choose 'Manage', and then choose 'Jobs'.
216-
Choose 'Create a job'.
229+
1. In the navigation pane of the AWS IoT console, choose 'Remote actions',
230+
and then choose 'Jobs'. Choose 'Create a job'.
217231
2. Next to 'Create a FreeRTOS Over-the-Air (OTA) update job', choose
218232
'Create FreeRTOS OTA update job'. Provide a name for the job and click on 'Next'.
219233
3. You can deploy an OTA update to a single device or a group of devices.
@@ -227,16 +241,18 @@ with your devices.
227241
created earlier.
228242
7. Under 'File', choose 'Upload a new file' then click 'Choose file'. A file
229243
browser pops up. Select the signed binary image with the higher version number.
230-
8. Under 'File upload location in S3', click 'Browse S3', then select the S3 bucket
231-
that you had earlier created for this job. Click 'Choose'
244+
8. Under 'File upload location in S3', click 'Browse S3', then select the S3
245+
bucket that you had earlier created for this job. Click 'Choose'
232246
9. Under 'Path name of file on device', type 'NA'
233247
10. Under 'IAM role for OTA update job', choose the role that you created
234248
earlier for the OTA update from the drop down list.
235-
11. Click 'Next', then click on 'Create job'. Confirm if the job was created successfully.
249+
11. Click 'Next', then click on 'Create job'. Confirm if the job was created
250+
successfully.
236251

237252
### 8.4 Monitor OTA
238253

239-
Once the job is created successfully, the demo should start downloading the firmware in chunks. For eg.
254+
Once the job is created successfully, the demo should start downloading the
255+
firmware in chunks. For eg.
240256
```
241257
I (196573) ota_over_mqtt_demo: OTA Event processing completed. Freeing the event buffer to pool.
242258
I (196583) AWS_OTA: Current State=[WaitingForFileBlock], Event=[ReceivedFileBlock], New state=[WaitingForFileBlock]
@@ -253,8 +269,12 @@ I (197603) ota_over_mqtt_demo: Received: 160 Queued: 160 Processed: 160 D
253269
I (198603) ota_over_mqtt_demo: Received: 160 Queued: 160 Processed: 160 Dropped: 0
254270
```
255271

256-
Once all the firmware image chunks are downloaded and the signature is validated, the device reboots with the new image, during which the Secure Boot sequence is executed. See the OTA section in the [Featured FreeRTOS IoT Integration page for the ESP32-C3](https://www.freertos.org/featured-freertos-iot-integration-targeting-an-espressif-esp32-c3-risc-v-mcu/) on FreeRTOS.org for more details.
257-
You can see the new version number of the demo binary. Look for the string "Application version"
272+
Once all the firmware image chunks are downloaded and the signature is validated,
273+
the device reboots with the new image, during which the Secure Boot sequence is
274+
executed. See the OTA section in the
275+
[Featured FreeRTOS IoT Integration page for the ESP32-C3](https://www.freertos.org/featured-freertos-iot-integration-targeting-an-espressif-esp32-c3-risc-v-mcu/)
276+
on FreeRTOS.org for more details. You can see the new version number of the
277+
demo binary. Look for the string "Application version"
258278

259279
```
260280
I (793824) AWS_OTA: Number of blocks remaining: 1

sdkconfig.defaults

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CONFIG_MBEDTLS_THREADING_ALT=n
1616
CONFIG_MBEDTLS_THREADING_PTHREAD=y
1717
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
1818
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
19+
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
1920
CONFIG_OTA_DATA_OVER_HTTP=n
2021
CONFIG_OTA_DATA_OVER_MQTT=y
2122
CONFIG_OTA_DATA_OVER_MQTT_PRIMARY=y

0 commit comments

Comments
 (0)