forked from espressif/esp-idf
Add symbol needed for OpenOCD to detect FreeRTOS, add feature to break execution when the scheduler is initially started.
This commit is contained in:
Submodule components/esp32/lib updated: 40dc7af7f3...7bb0a736e4
@@ -121,5 +121,12 @@ config FREERTOS_DEBUG_OCDAWARE
|
|||||||
The FreeRTOS panic and unhandled exception handers can detect a JTAG OCD debugger and
|
The FreeRTOS panic and unhandled exception handers can detect a JTAG OCD debugger and
|
||||||
instead of panicking, have the debugger stop on the offending instruction.
|
instead of panicking, have the debugger stop on the offending instruction.
|
||||||
|
|
||||||
|
config FREERTOS_BREAK_ON_SCHEDULER_START_JTAG
|
||||||
|
bool "Stop program on scheduler start when JTAG/OCD is detected"
|
||||||
|
depends on FREERTOS_DEBUG_OCDAWARE
|
||||||
|
default y
|
||||||
|
help
|
||||||
|
If JTAG/OCD is connected, stop execution when the scheduler is started and the first
|
||||||
|
task is executed.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
# Component Makefile
|
# Component Makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
|
COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME) -Wl,--undefined=uxTopUsedPriority
|
||||||
COMPONENT_ADD_INCLUDEDIRS := include
|
COMPONENT_ADD_INCLUDEDIRS := include
|
||||||
COMPONENT_PRIV_INCLUDEDIRS := include/freertos
|
COMPONENT_PRIV_INCLUDEDIRS := include/freertos
|
||||||
|
|
||||||
|
@@ -128,6 +128,8 @@
|
|||||||
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
|
||||||
*----------------------------------------------------------*/
|
*----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define configUSE_PREEMPTION 1
|
#define configUSE_PREEMPTION 1
|
||||||
#define configUSE_IDLE_HOOK 0
|
#define configUSE_IDLE_HOOK 0
|
||||||
|
|
||||||
|
@@ -118,8 +118,11 @@ typedef unsigned portBASE_TYPE UBaseType_t;
|
|||||||
// portbenchmark
|
// portbenchmark
|
||||||
#include "portbenchmark.h"
|
#include "portbenchmark.h"
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
#define portMUX_DEBUG
|
#define portMUX_DEBUG
|
||||||
|
#define portFIRST_TASK_HOOK CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
volatile uint32_t mux;
|
volatile uint32_t mux;
|
||||||
|
@@ -142,6 +142,17 @@ void panicHandler(XtExcFrame *frame) {
|
|||||||
commonErrorHandler(frame);
|
commonErrorHandler(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setFirstBreakpoint(uint32_t pc) {
|
||||||
|
asm(
|
||||||
|
"wsr.ibreaka0 %0\n" \
|
||||||
|
"rsr.ibreakenable a3\n" \
|
||||||
|
"movi a4,1\n" \
|
||||||
|
"or a4, a4, a3\n" \
|
||||||
|
"wsr.ibreakenable a4\n" \
|
||||||
|
::"r"(pc):"a3","a4");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
void xt_unhandled_exception(XtExcFrame *frame) {
|
void xt_unhandled_exception(XtExcFrame *frame) {
|
||||||
int *regs=(int*)frame;
|
int *regs=(int*)frame;
|
||||||
int x;
|
int x;
|
||||||
@@ -158,14 +169,7 @@ void xt_unhandled_exception(XtExcFrame *frame) {
|
|||||||
panicPutStr(". Setting bp and returning..\r\n");
|
panicPutStr(". Setting bp and returning..\r\n");
|
||||||
//Stick a hardware breakpoint on the address the handler returns to. This way, the OCD debugger
|
//Stick a hardware breakpoint on the address the handler returns to. This way, the OCD debugger
|
||||||
//will kick in exactly at the context the error happened.
|
//will kick in exactly at the context the error happened.
|
||||||
asm(
|
setFirstBreakpoint(regs[1]);
|
||||||
"wsr.ibreaka0 %0\n" \
|
|
||||||
"rsr.ibreakenable a3\n" \
|
|
||||||
"movi a4,1\n" \
|
|
||||||
"or a4, a4, a3\n" \
|
|
||||||
"wsr.ibreakenable a4\n" \
|
|
||||||
::"r"(regs[1]):"a3","a4");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
panicPutStr(". Exception was unhandled.\r\n");
|
panicPutStr(". Exception was unhandled.\r\n");
|
||||||
commonErrorHandler(frame);
|
commonErrorHandler(frame);
|
||||||
@@ -209,3 +213,9 @@ void commonErrorHandler(XtExcFrame *frame) {
|
|||||||
while(1);
|
while(1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setBreakpointIfJtag(void *fn) {
|
||||||
|
if (!inOCDMode()) return;
|
||||||
|
setFirstBreakpoint((uint32_t)fn);
|
||||||
|
}
|
||||||
|
@@ -101,6 +101,8 @@
|
|||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
|
#include "panic.h"
|
||||||
|
|
||||||
/* Defined in portasm.h */
|
/* Defined in portasm.h */
|
||||||
extern void _frxt_tick_timer_init(void);
|
extern void _frxt_tick_timer_init(void);
|
||||||
|
|
||||||
@@ -385,6 +387,10 @@ portBASE_TYPE vPortCPUReleaseMutex(portMUX_TYPE *mux) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG
|
||||||
|
void vPortFirstTaskHook(TaskFunction_t function) {
|
||||||
|
setBreakpointIfJtag(function);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@@ -445,6 +445,11 @@ to its original value when it is released. */
|
|||||||
extern void vApplicationTickHook( void );
|
extern void vApplicationTickHook( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if portFIRST_TASK_HOOK
|
||||||
|
extern void vPortFirstTaskHook(TaskFunction_t taskfn);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* File private functions. --------------------------------*/
|
/* File private functions. --------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -707,6 +712,12 @@ BaseType_t i;
|
|||||||
/* Schedule if nothing is scheduled yet, or overwrite a task of lower prio. */
|
/* Schedule if nothing is scheduled yet, or overwrite a task of lower prio. */
|
||||||
if ( pxCurrentTCB[i] == NULL || pxCurrentTCB[i]->uxPriority <= uxPriority )
|
if ( pxCurrentTCB[i] == NULL || pxCurrentTCB[i]->uxPriority <= uxPriority )
|
||||||
{
|
{
|
||||||
|
#if portFIRST_TASK_HOOK
|
||||||
|
if ( i == 0) {
|
||||||
|
vPortFirstTaskHook(pxTaskCode);
|
||||||
|
}
|
||||||
|
#endif /* configFIRST_TASK_HOOK */
|
||||||
|
|
||||||
pxCurrentTCB[i] = pxNewTCB;
|
pxCurrentTCB[i] = pxNewTCB;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user