Skip to content

Commit b4ec924

Browse files
Just panic() on FreeRTOS fatal error
Blinking the LED doesn't work on all boards (CYW43), but panic() will show on any debugger quite nicely.
1 parent b5cb754 commit b4ec924

File tree

1 file changed

+3
-45
lines changed

1 file changed

+3
-45
lines changed

cores/rp2040/freertos/variantHooks.cpp

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ extern mutex_t __usb_mutex;
229229
static TaskHandle_t __usbTask;
230230
static void __usb(void *param);
231231
extern volatile bool __freeRTOSinitted;
232-
static void lwipThread(void *params);
233232
void startFreeRTOS(void) {
234233

235234
TaskHandle_t c0;
@@ -330,45 +329,14 @@ void vApplicationTickHook(void) {
330329
#endif /* configUSE_TICK_HOOK == 1 */
331330
/*-----------------------------------------------------------*/
332331

333-
#if ( configUSE_MALLOC_FAILED_HOOK == 1 || configCHECK_FOR_STACK_OVERFLOW >= 1 || configDEFAULT_ASSERT == 1 )
334-
335-
/**
336-
Private function to enable board led to use it in application hooks
337-
*/
338-
void prvSetMainLedOn(void) {
339-
#ifdef LED_BUILTIN
340-
gpio_init(LED_BUILTIN);
341-
gpio_set_dir(LED_BUILTIN, true);
342-
gpio_put(LED_BUILTIN, true);
343-
#endif
344-
}
345-
346-
/**
347-
Private function to blink board led to use it in application hooks
348-
*/
349-
void prvBlinkMainLed(void) {
350-
#ifdef LED_BUILTIN
351-
gpio_put(LED_BUILTIN, !gpio_get(LED_BUILTIN));
352-
#endif
353-
}
354-
355-
#endif
356332

357333
/* ---------------------------------------------------------------------------*\
358334
Usage:
359335
called on fatal error (interrupts disabled already)
360336
\*---------------------------------------------------------------------------*/
361337
extern "C"
362338
void rtosFatalError(void) {
363-
prvSetMainLedOn(); // Main LED on.
364-
365-
for (;;) {
366-
// Main LED slow flash
367-
sleep_ms(100);
368-
prvBlinkMainLed();
369-
sleep_ms(2000);
370-
prvBlinkMainLed();
371-
}
339+
panic("Fatal error");
372340
}
373341

374342
#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
@@ -391,12 +359,7 @@ extern "C"
391359
void vApplicationMallocFailedHook(void) __attribute__((weak));
392360

393361
void vApplicationMallocFailedHook(void) {
394-
prvSetMainLedOn(); // Main LED on.
395-
396-
for (;;) {
397-
sleep_ms(50);
398-
prvBlinkMainLed(); // Main LED fast blink.
399-
}
362+
panic("Malloc failed");
400363
}
401364

402365
#endif /* configUSE_MALLOC_FAILED_HOOK == 1 */
@@ -411,12 +374,7 @@ void vApplicationStackOverflowHook(TaskHandle_t xTask,
411374

412375
void vApplicationStackOverflowHook(TaskHandle_t xTask __attribute__((unused)),
413376
char * pcTaskName __attribute__((unused))) {
414-
prvSetMainLedOn(); // Main LED on.
415-
416-
for (;;) {
417-
sleep_ms(2000);
418-
prvBlinkMainLed(); // Main LED slow blink.
419-
}
377+
panic("Stack overflow");
420378
}
421379

422380
#endif /* configCHECK_FOR_STACK_OVERFLOW >= 1 */

0 commit comments

Comments
 (0)