Skip to content

Commit 3068cd0

Browse files
Use SW random generator for all LWIP (#1892)
1 parent fa390f4 commit 3068cd0

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

cores/rp2040/lwip_wrap.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,17 @@ class LWIPMutex {
7070
extern "C" {
7171

7272
static XoshiroCpp::Xoshiro256PlusPlus *_lwip_rng = nullptr;
73-
// Random number generator for LWIP. Bare metal, use the HW. FreeRTOS, use xoshiro generator to avoid needing to freeze the other core
73+
// Random number generator for LWIP
7474
unsigned long __lwip_rand() {
75-
if (__isFreeRTOS) {
76-
return (unsigned long)(*_lwip_rng)();
77-
} else {
78-
return get_rand_32();
79-
}
75+
return (unsigned long)(*_lwip_rng)();
8076
}
8177

82-
8378
// Avoid calling lwip_init multiple times
8479
extern void __real_lwip_init();
8580
void __wrap_lwip_init() {
86-
static bool initted = false;
87-
if (!initted) {
88-
if (__isFreeRTOS) {
89-
_lwip_rng = new XoshiroCpp::Xoshiro256PlusPlus(rp2040.getCycleCount());
90-
}
81+
if (!_lwip_rng) {
82+
_lwip_rng = new XoshiroCpp::Xoshiro256PlusPlus(get_rand_64());
9183
__real_lwip_init();
92-
initted = true;
9384
}
9485
}
9586

0 commit comments

Comments
 (0)