From 6427765f23575adff1226b60aaeea64d286a65c7 Mon Sep 17 00:00:00 2001 From: pennam Date: Tue, 2 Dec 2025 11:37:29 +0100 Subject: [PATCH] TRNG: keep track of initialization status --- cores/arduino/WMath.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cores/arduino/WMath.cpp b/cores/arduino/WMath.cpp index 83184d139..02e544f0f 100644 --- a/cores/arduino/WMath.cpp +++ b/cores/arduino/WMath.cpp @@ -48,8 +48,14 @@ extern "C" { static long trng() { uint32_t value[4]; - if (HW_SCE_McuSpecificInit() != FSP_SUCCESS) - return -1; + static bool SCE_inited = false; + if (!SCE_inited) { + if (HW_SCE_McuSpecificInit() != FSP_SUCCESS) { + return -1; + } + SCE_inited = true; + } + HW_SCE_RNG_Read(value); return (long)value[0] >= 0 ? value[0] : -value[0]; }