Skip to content

Commit f1a1df9

Browse files
committed
Merge branch 'docs/backport_random_to_v5.5' into 'release/v5.5'
docs: Backport random.rst to v5.5 See merge request espressif/esp-idf!42667
2 parents 3f3525e + cd742a3 commit f1a1df9

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed

docs/en/api-reference/system/random.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Every 32-bit value that the system reads from the RNG_DATA_REG register of the r
2020

2121
.. only:: not esp32
2222

23-
- RC_FAST_CLK is an asynchronous clock source and it increases the RNG entropy by introducing circuit metastability. See the :ref:`secondary entropy` section for more details.
23+
- RC_FAST_CLK is an asynchronous clock source, and it increases the RNG entropy by introducing circuit metastability. See the :ref:`secondary entropy` section for more details.
2424

25-
The following digram shows the noise sources for the RNG on the {IDF_TARGET_NAME}:
25+
The following diagram shows the noise sources for the RNG on the {IDF_TARGET_NAME}:
2626

2727
.. only:: SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED
2828

@@ -38,7 +38,7 @@ The hardware RNG produces true random numbers so long as one or more of the foll
3838

3939
.. list::
4040

41-
:SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED: - RF subsystem is enabled. i.e., {IDF_TARGET_RF_NAME} {IDF_TARGET_RF_IS} enabled. When enabled, the RF subsystem internally enables the High Speed ADC that can be used as the entropy source. The High Speed ADC may only be available when the respective RF subsystem is active (e.g., not in sleep mode). See the :ref:`enabling RF subsystem` section for more details.
41+
:SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED: - RF subsystem is enabled, i.e., {IDF_TARGET_RF_NAME} {IDF_TARGET_RF_IS} enabled. When enabled, the RF subsystem internally enables the High Speed ADC that can be used as the entropy source. The High Speed ADC may only be available when the respective RF subsystem is active (e.g., not in sleep mode). See the :ref:`enabling RF subsystem` section for more details.
4242
- The internal entropy source SAR ADC has been enabled by calling :cpp:func:`bootloader_random_enable` and not yet disabled by calling :cpp:func:`bootloader_random_disable`.
4343
- While the ESP-IDF :ref:`second-stage-bootloader` is running. This is because the default ESP-IDF bootloader implementation calls :cpp:func:`bootloader_random_enable` when the bootloader starts, and :cpp:func:`bootloader_random_disable` before executing the application.
4444

@@ -69,13 +69,12 @@ During startup, the ESP-IDF bootloader temporarily enables the non-RF internal e
6969

7070
.. only:: not SOC_WIFI_SUPPORTED and not SOC_IEEE802154_SUPPORTED and not SOC_BT_SUPPORTED
7171

72-
For {IDF_TARGET_NAME}, the High Speed ADC is not available. Hence the non-RF internal entropy source (SAR ADC) is kept enabled by default at the time of application startup.
72+
For {IDF_TARGET_NAME}, the High Speed ADC is not available. Hence, the non-RF internal entropy source (SAR ADC) is kept enabled by default at the time of application startup.
7373

7474
.. only:: SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED
7575

7676
However, after the application starts executing, then normally only pseudo-random numbers are available until {IDF_TARGET_RF_NAME} {IDF_TARGET_RF_IS} initialized or until the internal entropy source has been enabled again.
7777

78-
7978
To re-enable the entropy source temporarily during application startup, or for an application that does not use {IDF_TARGET_RF_NAME}, call the function :cpp:func:`bootloader_random_enable` to re-enable the internal entropy source. The function :cpp:func:`bootloader_random_disable` must be called to disable the entropy source again before using any of the following features:
8079

8180
.. list::

docs/zh_CN/api-reference/system/random.rst

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,80 @@
88

99
{IDF_TARGET_NAME} 中包含一个硬件随机数发生器 (RNG),可以调用 API :cpp:func:`esp_random` 和 :cpp:func:`esp_fill_random` 从中获取随机数值。
1010

11+
系统从随机数生成器的 RNG_DATA_REG 寄存器中读取的每一个 32 位数值都是一个真正的随机数。这些真正的随机数是基于系统中的热噪声和异步时钟失配生成的。
12+
13+
.. only:: SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED
14+
15+
- 热噪声来自高速 ADC、SAR ADC 或两者。当高速 ADC 或 SAR ADC 被启用时,会生成比特流,并作为随机种子通过 XOR 逻辑门输入到随机数生成器中。
16+
17+
.. only:: not SOC_WIFI_SUPPORTED and not SOC_IEEE802154_SUPPORTED and not SOC_BT_SUPPORTED
18+
19+
- 热噪声来自 SAR ADC。当 SAR ADC 被启用时,会生成比特流,并作为随机种子通过 XOR 逻辑门输入到随机数生成器中。
20+
21+
.. only:: not esp32
22+
23+
- RC_FAST_CLK 是一种异步时钟源,它通过引入电路亚稳态来增加 RNG 的熵值。详细信息请参阅 :ref:`secondary entropy` 部分。
24+
25+
下图展示了 {IDF_TARGET_NAME} 上 RNG 的噪声来源:
26+
27+
.. only:: SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED
28+
29+
.. image:: /../_static/esp_rng_noise_source_rf_available.svg
30+
:align: center
31+
32+
.. only:: not SOC_WIFI_SUPPORTED and not SOC_IEEE802154_SUPPORTED and not SOC_BT_SUPPORTED
33+
34+
.. image:: /../_static/esp_rng_noise_source_rf_unavailable.svg
35+
:align: center
36+
1137
满足下列任意一个或多个条件时,硬件 RNG 会产生真随机数:
1238

1339
.. list::
1440

15-
:SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED: - RF 子系统已启用,即 {IDF_TARGET_RF_NAME} {IDF_TARGET_RF_IS}。
41+
:SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED: - RF 子系统,即 {IDF_TARGET_RF_NAME} {IDF_TARGET_RF_IS}。启用后,RF 子系统会在内部启用高速 ADC,该 ADC 可用作熵源。高速 ADC 可能仅在相应的 RF 子系统处于活动状态(例如未处于睡眠模式)时可用。详细信息请参阅 :ref:`enabling RF subsystem` 部分
1642
- 调用 :cpp:func:`bootloader_random_enable` 启用了内部熵源 (SAR ADC),且熵源尚未被 :cpp:func:`bootloader_random_disable` 禁用。
1743
- 在 :ref:`second-stage-bootloader` 运行时。这是因为默认的 ESP-IDF 引导加载程序启动时会调用 :cpp:func:`bootloader_random_enable`,并在执行应用程序前调用 :cpp:func:`bootloader_random_disable`。
1844

1945
当上述任一条件为真时,物理噪声样本会连续混合到内部硬件 RNG 状态中来提供熵。如需了解详情,请参阅 **{IDF_TARGET_NAME} 技术参考手册** > **随机数发生器 (RNG)** [`PDF <{IDF_TARGET_TRM_CN_URL}#rng>`__] 章节。
2046

2147
如果上述条件都不满足,那么 RNG 的输出仅应被看作伪随机数。
2248

49+
.. only:: SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED
50+
51+
.. _enabling RF subsystem:
52+
53+
启用 RF 子系统
54+
---------------
55+
56+
可以通过以下任一 API 来启用 RF 子系统:
57+
58+
.. list::
59+
60+
:SOC_WIFI_SUPPORTED: - Wi-Fi: :cpp:func:`esp_wifi_start`
61+
:SOC_BT_SUPPORTED: - 蓝牙 (NimBLE): :cpp:func:`nimble_port_init()` 会在内部调用 :cpp:func:`esp_bt_controller_enable()`
62+
:SOC_BT_SUPPORTED: - 蓝牙 (Bluedroid): :cpp:func:`esp_bt_controller_enable()`
63+
:SOC_IEEE802154_SUPPORTED: - Thread/Zigbee: :cpp:func:`esp_openthread_init`
64+
2365
启动
2466
-------
2567

2668
在启动过程中,ESP-IDF 引导加载程序暂时会启用一个非 RF 内部熵源(SAR ADC 使用内部参考电压噪声),为首次生成的启动密钥提供熵。
2769

2870
.. only:: not SOC_WIFI_SUPPORTED and not SOC_IEEE802154_SUPPORTED and not SOC_BT_SUPPORTED
2971

30-
但是,当应用程序开始执行后,一直到内部熵源再次被启用前,通常只有伪随机数可用
72+
对于 {IDF_TARGET_NAME},高速 ADC 不可用。因此,在应用启动时,非 RF 内部熵源 (SAR ADC) 默认保持启用状态
3173

3274
.. only:: SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED
3375

3476
但是,当应用程序开始执行后,一直到 {IDF_TARGET_RF_NAME} 初始化完成前或内部熵源再次被启用前,通常只有伪随机数可用。
3577

78+
如需在应用程序启动期间临时重启熵源,或为不使用 {IDF_TARGET_RF_NAME} 的应用程序临时重启熵源,请调用函数 :cpp:func:`bootloader_random_enable` 重启内部熵源。在使用下列任一功能前,必须调用函数 :cpp:func:`bootloader_random_disable` 以禁用熵源。
3679

37-
如需在应用程序启动期间临时重启熵源,或为不使用 {IDF_TARGET_RF_NAME} 的应用程序临时重启熵源,请调用函数 :cpp:func:`bootloader_random_enable` 重启内部熵源。在使用下列任一功能前,必须调用函数 :cpp:func:`bootloader_random_disable` 以禁用熵源。
38-
39-
.. list::
80+
.. list::
4081

41-
- ADC
42-
43-
:esp32: - I2S
44-
45-
:SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED: - {IDF_TARGET_RF_NAME}
82+
- ADC
83+
:esp32: - I2S
84+
:SOC_WIFI_SUPPORTED or SOC_IEEE802154_SUPPORTED or SOC_BT_SUPPORTED: - {IDF_TARGET_RF_NAME}
4685

4786
.. note::
4887

@@ -54,6 +93,8 @@
5493

5594
.. only:: not esp32
5695

96+
.. _secondary entropy:
97+
5798
二级熵源
5899
-----------------
59100

0 commit comments

Comments
 (0)