Skip to content

Commit 5b45e9d

Browse files
Only start LWIP thread on FreeRTOS if needed (#3121)
Fixes #3120 LWIP was being unconditionally started under FreeRTOS, even if the app wasn't using any LWIP calls. Now start the LWIP thread on the first call to lwip_init, same as we init the RNG.
1 parent 2329614 commit 5b45e9d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

cores/rp2040/freertos/freertos-main.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ void startFreeRTOS(void) {
155155
xTaskCreate(IdleThisCore, "IdleCore1", 128, 0, configMAX_PRIORITIES - 1, __idleCoreTask + 1);
156156
vTaskCoreAffinitySet(__idleCoreTask[1], 1 << 1);
157157

158-
__startLWIPThread();
159-
160158
// Initialise and run the freeRTOS scheduler. Execution should never return here.
161159
__freeRTOSinitted = true;
162160
vTaskStartScheduler();

cores/rp2040/lwip_wrap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
#include "_xoshiro.h"
3333
#include "lwip_wrap.h"
3434
#include <pico/btstack_run_loop_async_context.h>
35+
#ifdef __FREERTOS
36+
#include "freertos/freertos-lwip.h"
37+
#endif
3538

3639
//auto_init_recursive_mutex(__lwipMutex); // Only for case with no Ethernet or PicoW, but still doing LWIP (PPP?)
3740
recursive_mutex_t __lwipMutex;
@@ -54,6 +57,9 @@ extern "C" {
5457
recursive_mutex_init(&__lwipMutex);
5558
_lwip_rng = new XoshiroCpp::Xoshiro256PlusPlus(micros());
5659
__real_lwip_init();
60+
#ifdef __FREERTOS
61+
__startLWIPThread();
62+
#endif
5763
}
5864
}
5965

0 commit comments

Comments
 (0)