mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 04:15:26 +03:00
Tasks switching log added (use -DDEBUG_TASKS=YES to enable and CLI command "print tsl" to see it, only works on Horus)
This commit is contained in:
parent
9673df83a7
commit
a8aa6148e5
7 changed files with 122 additions and 1 deletions
|
@ -486,6 +486,7 @@ if(ARCH STREQUAL ARM)
|
||||||
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" OFF)
|
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" OFF)
|
||||||
option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY
|
option(SUPPORT_D16_EU_ONLY "XJT module only supports D16-EU and LR12-EU" OFF) # TODO rename to XJT_EU_ONLY
|
||||||
option(DEBUG_INTERRUPTS "Count interrupts" OFF)
|
option(DEBUG_INTERRUPTS "Count interrupts" OFF)
|
||||||
|
option(DEBUG_TASKS "Task switching statistics" OFF)
|
||||||
|
|
||||||
if(TIMERS EQUAL 3)
|
if(TIMERS EQUAL 3)
|
||||||
add_definitions(-DTIMERS=3)
|
add_definitions(-DTIMERS=3)
|
||||||
|
@ -517,6 +518,10 @@ if(ARCH STREQUAL ARM)
|
||||||
add_definitions(-DDEBUG_INTERRUPTS)
|
add_definitions(-DDEBUG_INTERRUPTS)
|
||||||
set(DEBUG ON)
|
set(DEBUG ON)
|
||||||
endif()
|
endif()
|
||||||
|
if(DEBUG_TASKS)
|
||||||
|
add_definitions(-DDEBUG_TASKS)
|
||||||
|
set(DEBUG ON)
|
||||||
|
endif()
|
||||||
if(CLI)
|
if(CLI)
|
||||||
add_definitions(-DCLI)
|
add_definitions(-DCLI)
|
||||||
set(FIRMWARE_SRC ${FIRMWARE_SRC} cli.cpp)
|
set(FIRMWARE_SRC ${FIRMWARE_SRC} cli.cpp)
|
||||||
|
|
|
@ -373,6 +373,60 @@ void printInterrupts()
|
||||||
}
|
}
|
||||||
#endif //#if defined(DEBUG_INTERRUPTS)
|
#endif //#if defined(DEBUG_INTERRUPTS)
|
||||||
|
|
||||||
|
#if defined(DEBUG_TASKS)
|
||||||
|
|
||||||
|
void printTaskSwitchLog()
|
||||||
|
{
|
||||||
|
serialPrint("Tasks legend [<task_id>, <task name>]:");
|
||||||
|
for(int n = 0; n <= CFG_MAX_USER_TASKS+1; n++) {
|
||||||
|
if (0 == n) {
|
||||||
|
serialPrint("%d: Idle", n);
|
||||||
|
}
|
||||||
|
if (cliTaskId == n) {
|
||||||
|
serialPrint("%d: CLI", n);
|
||||||
|
}
|
||||||
|
else if (menusTaskId == n) {
|
||||||
|
serialPrint("%d: menus", n);
|
||||||
|
}
|
||||||
|
else if (mixerTaskId == n) {
|
||||||
|
serialPrint("%d: mixer", n);
|
||||||
|
}
|
||||||
|
else if (audioTaskId == n) {
|
||||||
|
serialPrint("%d: audio", n);
|
||||||
|
}
|
||||||
|
#if defined(BLUETOOTH)
|
||||||
|
else if (btTaskId == n) {
|
||||||
|
serialPrint("%d: BT", n);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
serialCrlf();
|
||||||
|
|
||||||
|
serialPrint("Tasks switch log at %u [<time>, <task_id>]:", get_tmr10ms());
|
||||||
|
uint32_t lastSwitchTime = 0;
|
||||||
|
uint32_t * tsl = new uint32_t[DEBUG_TASKS_LOG_SIZE];
|
||||||
|
memcpy(tsl, taskSwitchLog, sizeof(taskSwitchLog));
|
||||||
|
uint32_t * p = tsl + taskSwitchLogPos;
|
||||||
|
uint32_t * end = tsl + DEBUG_TASKS_LOG_SIZE;
|
||||||
|
for(int n = 0; n < DEBUG_TASKS_LOG_SIZE; n++) {
|
||||||
|
uint32_t taskId = *p >> 24;
|
||||||
|
uint32_t switchTime = *p & 0xFFFFFF;
|
||||||
|
if (lastSwitchTime != switchTime) {
|
||||||
|
serialPrintf("\r\n%06x: ", switchTime);
|
||||||
|
lastSwitchTime = switchTime;
|
||||||
|
}
|
||||||
|
serialPrintf("%u ", taskId);
|
||||||
|
if ( ++p >= end ) {
|
||||||
|
p = tsl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete[] tsl;
|
||||||
|
serialCrlf();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // #if defined(DEBUG_TASKS)
|
||||||
|
|
||||||
int cliDisplay(const char ** argv)
|
int cliDisplay(const char ** argv)
|
||||||
{
|
{
|
||||||
long long int address = 0;
|
long long int address = 0;
|
||||||
|
@ -505,6 +559,11 @@ int cliDisplay(const char ** argv)
|
||||||
printInterrupts();
|
printInterrupts();
|
||||||
}
|
}
|
||||||
#endif //#if defined(DEBUG_INTERRUPTS)
|
#endif //#if defined(DEBUG_INTERRUPTS)
|
||||||
|
#if defined(DEBUG_TASKS)
|
||||||
|
else if (!strcmp(argv[1], "tsl")) {
|
||||||
|
printTaskSwitchLog();
|
||||||
|
}
|
||||||
|
#endif //#if defined(DEBUG_TASKS)
|
||||||
else if (toLongLongInt(argv, 1, &address) > 0) {
|
else if (toLongLongInt(argv, 1, &address) > 0) {
|
||||||
int size = 256;
|
int size = 256;
|
||||||
if (toInt(argv, 2, &size) >= 0) {
|
if (toInt(argv, 2, &size) >= 0) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ extern uint8_t cliTracesEnabled;
|
||||||
extern Fifo<uint8_t, 256> cliRxFifo;
|
extern Fifo<uint8_t, 256> cliRxFifo;
|
||||||
#include "tasks_arm.h"
|
#include "tasks_arm.h"
|
||||||
#define CLI_STACK_SIZE 1000
|
#define CLI_STACK_SIZE 1000
|
||||||
|
extern OS_TID cliTaskId;
|
||||||
extern TaskStack<CLI_STACK_SIZE> cliStack;
|
extern TaskStack<CLI_STACK_SIZE> cliStack;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -139,3 +139,29 @@ void dumpTraceBuffer()
|
||||||
|
|
||||||
struct InterruptCounters interruptCounters;
|
struct InterruptCounters interruptCounters;
|
||||||
#endif //#if defined(DEBUG_INTERRUPTS)
|
#endif //#if defined(DEBUG_INTERRUPTS)
|
||||||
|
|
||||||
|
#if defined(DEBUG_TASKS)
|
||||||
|
|
||||||
|
uint32_t taskSwitchLog[DEBUG_TASKS_LOG_SIZE] __SDRAM;
|
||||||
|
uint16_t taskSwitchLogPos;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @brief Hook for task switch logging
|
||||||
|
* @param[in] taskID Task which is now in RUNNING state
|
||||||
|
* @retval None
|
||||||
|
*
|
||||||
|
* @par Description
|
||||||
|
* @details This function logs the time when a task entered the RUNNING state.
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
void CoTaskSwitchHook(uint8_t taskID)
|
||||||
|
{
|
||||||
|
/* Log task switch here */
|
||||||
|
taskSwitchLog[taskSwitchLogPos] = (taskID << 24) + ((uint32_t)CoGetOSTime() & 0xFFFFFF);
|
||||||
|
if(++taskSwitchLogPos >= DEBUG_TASKS_LOG_SIZE) {
|
||||||
|
taskSwitchLogPos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(DEBUG_TASKS)
|
||||||
|
|
|
@ -236,6 +236,25 @@ extern struct InterruptCounters interruptCounters;
|
||||||
#define DEBUG_INTERRUPT(int)
|
#define DEBUG_INTERRUPT(int)
|
||||||
#endif //#if defined(DEBUG_INTERRUPTS)
|
#endif //#if defined(DEBUG_INTERRUPTS)
|
||||||
|
|
||||||
|
#if defined(DEBUG_TASKS)
|
||||||
|
|
||||||
|
#define DEBUG_TASKS_LOG_SIZE 512
|
||||||
|
|
||||||
|
// each 32bit is used as:
|
||||||
|
// top 8 bits: task id
|
||||||
|
// botom 24 bits: system tick counter
|
||||||
|
extern uint32_t taskSwitchLog[DEBUG_TASKS_LOG_SIZE];
|
||||||
|
extern uint16_t taskSwitchLogPos;
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
extern void CoTaskSwitchHook(uint8_t taskID);
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // #if defined(DEBUG_TASKS)
|
||||||
|
|
||||||
#endif // _DEBUG_H_
|
#endif // _DEBUG_H_
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,11 @@ extern TaskStack<MIXER_STACK_SIZE> mixerStack;
|
||||||
extern OS_TID audioTaskId;
|
extern OS_TID audioTaskId;
|
||||||
extern TaskStack<AUDIO_STACK_SIZE> audioStack;
|
extern TaskStack<AUDIO_STACK_SIZE> audioStack;
|
||||||
|
|
||||||
|
#if defined(BLUETOOTH)
|
||||||
|
extern OS_TID btTaskId;
|
||||||
|
extern TaskStack<BLUETOOTH_STACK_SIZE> bluetoothStack;
|
||||||
|
#endif
|
||||||
|
|
||||||
void tasksStart();
|
void tasksStart();
|
||||||
|
|
||||||
#endif // _TASKS_ARM_H_
|
#endif // _TASKS_ARM_H_
|
||||||
|
|
6
radio/src/thirdparty/CoOS/kernel/task.c
vendored
6
radio/src/thirdparty/CoOS/kernel/task.c
vendored
|
@ -39,6 +39,7 @@
|
||||||
|
|
||||||
/*---------------------------- Include ---------------------------------------*/
|
/*---------------------------- Include ---------------------------------------*/
|
||||||
#include <coocox.h>
|
#include <coocox.h>
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
/*---------------------------- Variable Define -------------------------------*/
|
/*---------------------------- Variable Define -------------------------------*/
|
||||||
|
|
||||||
|
@ -791,6 +792,11 @@ void Schedule(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(DEBUG_TASKS)
|
||||||
|
CoTaskSwitchHook(pRdyTcb->taskID);
|
||||||
|
#endif
|
||||||
|
|
||||||
SwitchContext(); /* Call task context switch */
|
SwitchContext(); /* Call task context switch */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue