mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-17 15:15:02 +00:00
feat (bootloader): added rng sampling
Set maximum RNG query frequency to save value known from tests
This commit is contained in:
@@ -18,6 +18,13 @@
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if !defined CONFIG_IDF_TARGET_ESP32S3
|
||||
#define RNG_CPU_WAIT_CYCLE_NUM (80 * 32 * 2) /* extra factor of 2 is precautionary */
|
||||
#else
|
||||
#define RNG_CPU_WAIT_CYCLE_NUM (80 * 23) /* 45 KHz reading frequency is the maximum we have tested so far on S3 */
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) void bootloader_fill_random(void *buffer, size_t length)
|
||||
{
|
||||
uint8_t *buffer_bytes = (uint8_t *)buffer;
|
||||
@@ -40,7 +47,7 @@
|
||||
do {
|
||||
random ^= REG_READ(WDEV_RND_REG);
|
||||
now = cpu_hal_get_cycle_count();
|
||||
} while (now - start < 80 * 32 * 2); /* extra factor of 2 is precautionary */
|
||||
} while (now - start < RNG_CPU_WAIT_CYCLE_NUM);
|
||||
}
|
||||
buffer_bytes[i] = random >> ((i % 4) * 8);
|
||||
}
|
||||
|
Reference in New Issue
Block a user