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: Documentation/platforms/risc-v/esp32c3/index.rst
+84-77Lines changed: 84 additions & 77 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,8 +97,8 @@ functions required to boot the device are built within NuttX. Simple boot does n
97
97
require any specific configuration (it is selectable by default if no other
98
98
2nd stage bootloader is used).
99
99
100
-
If other features, like `Secure Boot and Flash Encryption`_, are required, an
101
-
externally-built 2nd stage bootloader is needed. The bootloader is built using
100
+
If features like `Flash Encryption`_ are required, an externally-built
101
+
2nd stage bootloader is needed. The MCUBoot bootloader is built using
102
102
the ``make bootloader`` command. This command generates the firmware in the
103
103
``nuttx`` folder. The ``ESPTOOL_BINDIR`` is used in the ``make flash`` command
104
104
to specify the path to the bootloader. For compatibility among other SoCs and
@@ -497,108 +497,115 @@ Finally, the image is loaded but not confirmed.
497
497
To make sure it won't rollback to the previous image, you must confirm with ``mcuboot_confirm`` and reboot the board.
498
498
The OTA is now complete.
499
499
500
-
Secure Boot and Flash Encryption
501
-
--------------------------------
502
-
503
-
Secure Boot
504
-
^^^^^^^^^^^
500
+
Flash Encryption
501
+
----------------
505
502
506
-
Secure Boot protects a device from running any unauthorized (i.e., unsigned) code by checking that
507
-
each piece of software that is being booted is signed. On an ESP32-C3, these pieces of software include
508
-
the second stage bootloader and each application binary. Note that the first stage bootloader does not
509
-
require signing as it is ROM code thus cannot be changed. This is achieved using specific hardware in
510
-
conjunction with MCUboot (read more about MCUboot `here <https://docs.mcuboot.com/>`__).
503
+
Flash encryption is intended for encrypting the contents of the ESP32-C3's off-chip flash memory. Once this feature is enabled,
504
+
firmware is flashed as plaintext, and then the data is encrypted in place on the first boot. As a result, physical readout
505
+
of flash will not be sufficient to recover most flash contents.
511
506
512
-
The Secure Boot process on the ESP32-C3 involves the following steps performed:
507
+
The current state of flash encryption for ESP32-C3 allows the use of Virtual E-Fuses and development mode, which permit users to evaluate and test the firmware before making definitive changes such as burning E-Fuses.
513
508
514
-
1. The first stage bootloader verifies the second stage bootloader's RSA-PSS signature. If the verification is successful,
515
-
the first stage bootloader loads and executes the second stage bootloader.
509
+
Flash encryption supports the following features:
516
510
517
-
2. When the second stage bootloader loads a particular application image, the application's signature (RSA, ECDSA or ED25519) is verified
518
-
by MCUboot.
519
-
If the verification is successful, the application image is executed.
511
+
.. list-table::
512
+
:header-rows: 1
520
513
521
-
.. warning:: Once enabled, Secure Boot will not boot a modified bootloader. The bootloader will only boot an
522
-
application firmware image if it has a verified digital signature. There are implications for reflashing
523
-
updated images once Secure Boot is enabled. You can find more information about the ESP32-C3's Secure boot
- Use flash encryption without burning E-Fuses. Default selection when flash encryption is enabled.
518
+
* - **Flash Encryption in Development mode**
519
+
- Allows reflashing an encrypted device by appending the ``--encrypt`` argument to the ``esptool.py write_flash`` command. This is done automatically if ``ESPRESSIF_SECURE_FLASH_ENC_FLASH_DEVICE_ENCRYPTED`` is set.
520
+
* - **Flash Encryption in Release mode**
521
+
- Does not allow reflashing the device. This is a permanent setting.
522
+
* - **Flash Encryption key**
523
+
- A user-generated key is required by default. Alternatively, a device-generated key is possible, but it will not be recoverable by the user (not recommended). See ``ESPRESSIF_SECURE_FLASH_ENC_USE_HOST_KEY``.
524
+
* - **Encrypted MTD Partition**
525
+
- If SPI Flash is enabled, an empty user MTD partition will be automatically encrypted on first flash.
525
526
526
-
.. note:: As the bootloader image is built on top of the Hardware Abstraction Layer component
527
-
of `ESP-IDF <https://github.com/espressif/esp-idf>`_, the
528
-
`API port by Espressif <https://docs.mcuboot.com/readme-espressif.html>`_ will be used
529
-
by MCUboot rather than the original NuttX port.
527
+
.. note::
530
528
531
-
Flash Encryption
532
-
^^^^^^^^^^^^^^^^
529
+
It is **strongly suggested** to read the following before working on flash encryption:
533
530
534
-
Flash encryption is intended for encrypting the contents of the ESP32-C3's off-chip flash memory. Once this feature is enabled,
535
-
firmware is flashed as plaintext, and then the data is encrypted in place on the first boot. As a result, physical readout
536
-
of flash will not be sufficient to recover most flash contents.
[esp32c3] [INF] Disabling RNG early entropy source...
586
+
[esp32c3] [INF] br_image_off = 0x20000
587
+
[esp32c3] [INF] ih_hdr_size = 0x20
588
+
[esp32c3] [INF] Loading image 0 - slot 0 from flash, area id: 1
589
+
...
590
+
NuttShell (NSH) NuttX-12.8.0
591
+
nsh>
580
592
581
-
Now you can design an update and confirm agent to your application. Check the `MCUboot design guide <https://docs.mcuboot.com/design.html>`_ and the
582
-
`MCUboot Espressif port documentation <https://docs.mcuboot.com/readme-espressif.html>`_ for
583
-
more information on how to apply MCUboot. Also check some `notes about the NuttX MCUboot port <https://github.com/mcu-tools/mcuboot/blob/main/docs/readme-nuttx.md>`_,
584
-
the `MCUboot porting guide <https://github.com/mcu-tools/mcuboot/blob/main/docs/PORTING.md>`_ and some
585
-
`examples of MCUboot applied in NuttX applications <https://github.com/apache/nuttx-apps/tree/master/examples/mcuboot>`_.
593
+
Actual encryption and burning E-Fuses
594
+
'''''''''''''''''''''''''''''''''''''
586
595
587
-
After you developed an application which implements all desired functions, you need to flash it into the primary image slot
588
-
of the device (it will automatically be in the confirmed state, you can learn more about image
To flash to the primary image slot, select ``Application image primary slot`` in
591
-
:menuselection:`System Type --> Application Image Configuration --> Target slot for image flashing`
592
-
and compile it using ``make -j ESPSEC_KEYDIR=~/signing_keys``.
596
+
E-Fuses are burned by esptool and the bootloader on the first boot after flashing with encryption enabled.
597
+
This process is automated on NuttX build system.
593
598
594
-
When creating update images, make sure to change :menuselection:`System Type --> Application Image Configuration --> Target slot for image flashing`
595
-
to ``Application image secondary slot``.
599
+
.. warning:: Burning E-Fuses is NOT a reversible operation and should be done with caution.
596
600
597
-
.. important:: When deploying your application, make sure to disable UART Download Mode by selecting ``Permanently disabled`` in
598
-
:menuselection:`System Type -->Application Image Configuration--> UART ROM download mode`
599
-
and change usage mode to ``Release`` in `System Type --> Application Image Configuration --> Enable usage mode`.
600
-
**After disabling UART Download Mode you will not be able to flash other images through UART.**
601
+
To build a firmware with E-Fuse support and flash encryption enabled, open ``menuconfig`` and:
602
+
1. Enable flash encryption on boot on: :menuselection:`System Type -->Bootloader and Image Configuration`
603
+
2. Disable Virtual E-Fuses :menuselection:`System Type -->Peripheral Support -->E-Fuse support`
604
+
3. Check usage mode is Development (this allows reflashing, while Release mode does not).
601
605
606
+
.. note:: If using development mode of flash encryption (see menuconfig and documentation above), it is still possible to re-flash the device with esptool by
607
+
setting ``ESPRESSIF_SECURE_FLASH_ENC_FLASH_DEVICE_ENCRYPTED`` which adds ``--encrypt`` argument to the ``esptool.py write_flash`` command.
608
+
This will apply the burned encryption key to the image while flashing.
0 commit comments