Espressif ESP32-S2 Programming Manual page 1048

Hide thumbs Also See for ESP32-S2:
Table of Contents

Advertisement

Chapter 2. API Reference
This function automatically busy-waits to ensure enough external entropy has been introduced into the hardware
RNG state, before returning a new random number. This delay is very short (always less than 100 CPU cycles).
Return Random value between 0 and UINT32_MAX
void esp_fill_random(void *buf, size_t len)
Fill a buffer with random bytes from hardware RNG.
Note This function is implemented via calls to esp_random(), so the same constraints apply.
Parameters
• buf: Pointer to buffer to fill with random numbers.
• len: Length of buffer in bytes
Header File
components/bootloader_support/include/bootloader_random.h
Functions
void bootloader_random_enable(void)
Enable an entropy source for RNG if RF is disabled.
The exact internal entropy source mechanism depends on the chip in use but all SoCs use the SAR ADC
to continuously mix random bits (an internal noise reading) into the HWRNG. Consult the SoC Technical
Reference Manual for more information.
Can also be used from app code early during operation, if true random numbers are required before RF is
initialised. Consult ESP-IDF Programming Guide "Random Number Generation"section for details.
void bootloader_random_disable(void)
Disable entropy source for RNG.
Disables internal entropy source. Must be called after bootloader_random_enable() and before RF features,
ADC, or I2S (ESP32 only) are initialized.
Consult the ESP-IDF Programming Guide "Random Number Generation"section for details.
void bootloader_fill_random(void *buffer, size_t length)
Fill buffer with 'length'random bytes.
Note If this function is being called from app code only, and never from the bootloader, then it's better to
call esp_fill_random().
Parameters
• buffer: Pointer to buffer
• length: This many bytes of random data will be copied to buffer
getrandom
A compatible version of the Linux getrandom() function is also provided for ease of porting:
#include
<sys/random.h>
ssize_t getrandom(void
This function is implemented by calling
The flags argument is ignored, this function is always non-blocking but the strength of any random numbers is
dependent on the same conditions described above.
Return value is -1 (with errno set to EFAULT) if the buf argument is NULL, and equal to buflen otherwise.
Espressif Systems
*buf,
size_t
buflen,
esp_fill_random()
1037
Submit Document Feedback
unsigned int
flags);
internally.
Release v4.4

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S2 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents

Save PDF