diff --git a/libraries/AP_HAL_ChibiOS/Scheduler.cpp b/libraries/AP_HAL_ChibiOS/Scheduler.cpp index 71c279db72..5993be2e99 100644 --- a/libraries/AP_HAL_ChibiOS/Scheduler.cpp +++ b/libraries/AP_HAL_ChibiOS/Scheduler.cpp @@ -829,14 +829,18 @@ void Scheduler::check_stack_free(void) if (stack_free(&__main_stack_base__) < min_stack) { // use "line number" of 0xFFFF for ISR stack low +#if AP_INTERNALERROR_ENABLED AP::internalerror().error(AP_InternalError::error_t::stack_overflow, 0xFFFF); +#endif } for (thread_t *tp = chRegFirstThread(); tp; tp = chRegNextThread(tp)) { if (stack_free(tp->wabase) < min_stack) { // use task priority for line number. This allows us to // identify the task fairly reliably +#if AP_INTERNALERROR_ENABLED AP::internalerror().error(AP_InternalError::error_t::stack_overflow, tp->realprio); +#endif } } } diff --git a/libraries/AP_HAL_ChibiOS/hwdef/scripts/defaults_iofirmware.h b/libraries/AP_HAL_ChibiOS/hwdef/scripts/defaults_iofirmware.h index 53d1fa5f2b..7cd350f397 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/scripts/defaults_iofirmware.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/scripts/defaults_iofirmware.h @@ -37,3 +37,7 @@ // allow the IOMCU to have its allowed protocols to be set: #define AP_RCPROTOCOL_ENABLE_SET_RC_PROTOCOLS 1 + +#ifndef AP_INTERNALERROR_ENABLED +#define AP_INTERNALERROR_ENABLED 0 +#endif