From f2fe4f00a67b8504d9d7f35d4c7de6200b334aff Mon Sep 17 00:00:00 2001 From: Thomas Bourgoin Date: Wed, 18 Sep 2024 18:04:33 +0200 Subject: [PATCH] drivers: stm32_rng: use default PRNG init if RNG is disabled in the DT In case RNG peripheral is not enabled in device tree, fallback to the default RNG initialization implementation. Signed-off-by: Thomas Bourgoin Acked-by: Jens Wiklander Acked-by: Jerome Forissier Reviewed-by: Etienne Carriere --- core/drivers/stm32_rng.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/drivers/stm32_rng.c b/core/drivers/stm32_rng.c index bb9d4aef72a..ab758b36e6e 100644 --- a/core/drivers/stm32_rng.c +++ b/core/drivers/stm32_rng.c @@ -428,11 +428,17 @@ static TEE_Result stm32_rng_read(uint8_t *out, size_t size) } #ifdef CFG_WITH_SOFTWARE_PRNG -/* Override weak plat_rng_init with platform handler to seed PRNG */ +/* Override weak plat_rng_init with platform handler to attempt to seed PRNG */ void plat_rng_init(void) { uint8_t seed[RNG_FIFO_BYTE_DEPTH] = { }; + if (!stm32_rng) { + __plat_rng_init(); + DMSG("PRNG seeded without RNG"); + return; + } + if (stm32_rng_read(seed, sizeof(seed))) panic();