Unverified Commit 3068cd0a authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Use SW random generator for all LWIP (#1892)

parent fa390f48
...@@ -70,26 +70,17 @@ public: ...@@ -70,26 +70,17 @@ public:
extern "C" { extern "C" {
static XoshiroCpp::Xoshiro256PlusPlus *_lwip_rng = nullptr; static XoshiroCpp::Xoshiro256PlusPlus *_lwip_rng = nullptr;
// Random number generator for LWIP. Bare metal, use the HW. FreeRTOS, use xoshiro generator to avoid needing to freeze the other core // Random number generator for LWIP
unsigned long __lwip_rand() { unsigned long __lwip_rand() {
if (__isFreeRTOS) { return (unsigned long)(*_lwip_rng)();
return (unsigned long)(*_lwip_rng)();
} else {
return get_rand_32();
}
} }
// Avoid calling lwip_init multiple times // Avoid calling lwip_init multiple times
extern void __real_lwip_init(); extern void __real_lwip_init();
void __wrap_lwip_init() { void __wrap_lwip_init() {
static bool initted = false; if (!_lwip_rng) {
if (!initted) { _lwip_rng = new XoshiroCpp::Xoshiro256PlusPlus(get_rand_64());
if (__isFreeRTOS) {
_lwip_rng = new XoshiroCpp::Xoshiro256PlusPlus(rp2040.getCycleCount());
}
__real_lwip_init(); __real_lwip_init();
initted = true;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment