EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1048 background imageLoading...
Page #1048 background image
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 Generationsection 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 Generationsection for details.
void bootloader_fill_random(void *buffer, size_t length)
Fill buffer with lengthrandom bytes.
Note If this function is being called from app code only, and never from the bootloader, then its 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 *buf, size_t buflen, unsigned int flags);
This function is implemented by calling esp_fill_random() internally.
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 1037
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish