1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 16:25:16 +03:00

Added DEBUG information (thanks again projectkk2glider!)

Conflicts:
	radio/src/opentx.cpp
This commit is contained in:
bsongis 2014-09-05 17:03:01 +02:00
parent 500602e8cc
commit 056d915d37
7 changed files with 89 additions and 50 deletions

View file

@ -47,6 +47,10 @@ class Fifo
{ {
} }
bool empty() {
return (ridx == widx);
}
void push(uint8_t byte) { void push(uint8_t byte) {
uint32_t next = (widx+1) & (N-1); uint32_t next = (widx+1) & (N-1);
if (next != ridx) { if (next != ridx) {
@ -56,7 +60,7 @@ class Fifo
} }
bool pop(uint8_t & byte) { bool pop(uint8_t & byte) {
if (ridx == widx) { if (empty()) {
return false; return false;
} }
else { else {

View file

@ -92,9 +92,20 @@ void menuStatisticsView(uint8_t event)
#if defined(PCBTARANIS) #if defined(PCBTARANIS)
#define MENU_DEBUG_COL1_OFS (11*FW-2) #define MENU_DEBUG_COL1_OFS (11*FW-2)
#define MENU_DEBUG_Y_MIXMAX (2*FH)
#define MENU_DEBUG_Y_LUA (3*FH)
#define MENU_DEBUG_Y_FREE_RAM (4*FH)
#define MENU_DEBUG_Y_STACK (5*FH)
#define MENU_DEBUG_Y_RTOS (6*FH)
#elif defined(PCBSKY9X) #elif defined(PCBSKY9X)
#define MENU_DEBUG_COL1_OFS (11*FW-3) #define MENU_DEBUG_COL1_OFS (11*FW-3)
#define MENU_DEBUG_COL2_OFS (17*FW) #define MENU_DEBUG_COL2_OFS (17*FW)
#define MENU_DEBUG_Y_CURRENT (1*FH)
#define MENU_DEBUG_Y_MAH (2*FH)
#define MENU_DEBUG_Y_CPU_TEMP (3*FH)
#define MENU_DEBUG_Y_COPROC (4*FH)
#define MENU_DEBUG_Y_MIXMAX (5*FH)
#define MENU_DEBUG_Y_RTOS (6*FH)
#else #else
#define MENU_DEBUG_COL1_OFS (14*FW) #define MENU_DEBUG_COL1_OFS (14*FW)
#endif #endif
@ -149,76 +160,85 @@ void menuStatisticsDebug(uint8_t event)
#if defined(PCBSKY9X) && !defined(REVA) #if defined(PCBSKY9X) && !defined(REVA)
// current // current
lcd_putsLeft(1*FH, STR_CPU_CURRENT); lcd_putsLeft(MENU_DEBUG_Y_CURRENT, STR_CPU_CURRENT);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 1*FH, getCurrent(), UNIT_MILLIAMPS, LEFT); putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CURRENT, getCurrent(), UNIT_MILLIAMPS, LEFT);
uint32_t current_scale = 488 + g_eeGeneral.currentCalib; uint32_t current_scale = 488 + g_eeGeneral.currentCalib;
lcd_putc(MENU_DEBUG_COL2_OFS, 1*FH, '>'); lcd_putc(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CURRENT, '>');
putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, 1*FH, Current_max*10*current_scale/8192, UNIT_RAW, LEFT); putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CURRENT, Current_max*10*current_scale/8192, UNIT_RAW, LEFT);
// consumption // consumption
lcd_putsLeft(2*FH, STR_CPU_MAH); lcd_putsLeft(MENU_DEBUG_Y_MAH, STR_CPU_MAH);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 2*FH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1); putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MAH, g_eeGeneral.mAhUsed + Current_used*current_scale/8192/36, UNIT_MAH, LEFT|PREC1);
#endif #endif
#if defined(PCBSKY9X) #if defined(PCBSKY9X)
lcd_putsLeft(3*FH, STR_CPU_TEMP); lcd_putsLeft(MENU_DEBUG_Y_CPU_TEMP, STR_CPU_TEMP);
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 3*FH, getTemperature(), UNIT_TEMPERATURE, LEFT); putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_CPU_TEMP, getTemperature(), UNIT_TEMPERATURE, LEFT);
lcd_putc(MENU_DEBUG_COL2_OFS, 3*FH, '>'); lcd_putc(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_CPU_TEMP, '>');
putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, 3*FH, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT); putsTelemetryValue(MENU_DEBUG_COL2_OFS+FW+1, MENU_DEBUG_Y_CPU_TEMP, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT);
#endif #endif
#if defined(COPROCESSOR) #if defined(COPROCESSOR)
lcd_putsLeft(4*FH, STR_COPROC_TEMP); lcd_putsLeft(MENU_DEBUG_Y_COPROC, STR_COPROC_TEMP);
if (Coproc_read==0) { if (Coproc_read==0) {
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Co Proc NACK"),INVERS); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Co Proc NACK"),INVERS);
} }
else if (Coproc_read==0x81) { else if (Coproc_read==0x81) {
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Inst.TinyApp"),INVERS); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Inst.TinyApp"),INVERS);
} }
else if (Coproc_read<3) { else if (Coproc_read<3) {
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH, PSTR("Upgr.TinyApp"),INVERS); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, PSTR("Upgr.TinyApp"),INVERS);
} }
else { else {
putsTelemetryValue(MENU_DEBUG_COL1_OFS, 4*FH, Coproc_temp, UNIT_TEMPERATURE, LEFT); putsTelemetryValue(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_COPROC, Coproc_temp, UNIT_TEMPERATURE, LEFT);
putsTelemetryValue(MENU_DEBUG_COL2_OFS, 4*FH, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT); putsTelemetryValue(MENU_DEBUG_COL2_OFS, MENU_DEBUG_Y_COPROC, Coproc_maxtemp, UNIT_TEMPERATURE, LEFT);
} }
#endif #endif
#if defined(PCBTARANIS) && !defined(SIMU) #if defined(PCBTARANIS) && !defined(SIMU)
lcd_putsLeft(3*FH, "Free Mem"); lcd_putsLeft(MENU_DEBUG_Y_FREE_RAM, "Free Mem");
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 3*FH, getAvailableMemory(), LEFT); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_FREE_RAM, getAvailableMemory(), LEFT);
#endif #endif
#if defined(LUA) #if defined(LUA)
lcd_putsLeft(4*FH, "Lua scripts"); lcd_putsLeft(MENU_DEBUG_Y_LUA, "Lua scripts");
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 4*FH+1, "[Duration]", SMLSIZE); lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_LUA+1, "[Duration]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaDuration, LEFT); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaDuration, LEFT);
lcd_putsAtt(lcdLastPos+2, 4*FH+1, "[Interval]", SMLSIZE); lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_LUA+1, "[Interval]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 4*FH, 10*maxLuaInterval, LEFT); lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_LUA, 10*maxLuaInterval, LEFT);
#endif #endif
#if defined(CPUARM) #if defined(CPUARM)
lcd_putsLeft(5*FH, STR_TMIXMAXMS); lcd_putsLeft(MENU_DEBUG_Y_MIXMAX, STR_TMIXMAXMS);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 5*FH, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT); lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_MIXMAX, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
lcd_puts(lcdLastPos, 5*FH, "ms"); lcd_puts(lcdLastPos, MENU_DEBUG_Y_MIXMAX, "ms");
lcd_putsLeft(6*FH, STR_FREESTACKMINB);
#if LCD_W >= 212
lcd_putsAtt(MENU_DEBUG_COL1_OFS, 6*FH+1, "[Main]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(0), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Mix]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(1), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, 6*FH+1, "[Audio]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(2), UNSIGN|LEFT);
#else
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, 6*FH, stack_free(0), UNSIGN|LEFT);
lcd_puts(lcdLastPos, 6*FH, "/");
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(1), UNSIGN|LEFT);
lcd_puts(lcdLastPos, 6*FH, "/");
lcd_outdezAtt(lcdLastPos, 6*FH, stack_free(2), UNSIGN|LEFT);
#endif #endif
#else #if defined(PCBTARANIS)
lcd_putsLeft(MENU_DEBUG_Y_STACK, STR_FREESTACKMINB);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_STACK, stack_free(255), UNSIGN|LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_STACK, "b");
#endif
#if defined(PCBTARANIS)
lcd_putsAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS+1, "[Main]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(0), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[Mix]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(1), UNSIGN|LEFT);
lcd_putsAtt(lcdLastPos+2, MENU_DEBUG_Y_RTOS+1, "[Audio]", SMLSIZE);
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(2), UNSIGN|LEFT);
#endif
#if defined(PCBSKY9X)
lcd_putsLeft(MENU_DEBUG_Y_RTOS, STR_FREESTACKMINB);
lcd_outdezAtt(MENU_DEBUG_COL1_OFS, MENU_DEBUG_Y_RTOS, stack_free(0), UNSIGN|LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_RTOS, "/");
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(1), UNSIGN|LEFT);
lcd_puts(lcdLastPos, MENU_DEBUG_Y_RTOS, "/");
lcd_outdezAtt(lcdLastPos, MENU_DEBUG_Y_RTOS, stack_free(2), UNSIGN|LEFT);
#endif
#if !defined(CPUARM)
lcd_putsLeft(1*FH, STR_TMR1LATMAXUS); lcd_putsLeft(1*FH, STR_TMR1LATMAXUS);
lcd_outdez8(MENU_DEBUG_COL1_OFS , 1*FH, g_tmr1Latency_max/2 ); lcd_outdez8(MENU_DEBUG_COL1_OFS , 1*FH, g_tmr1Latency_max/2 );
lcd_putsLeft(2*FH, STR_TMR1LATMINUS); lcd_putsLeft(2*FH, STR_TMR1LATMINUS);

View file

@ -699,7 +699,8 @@ extern uint8_t flightModeTransitionLast;
#if defined(CPUARM) && !defined(SIMU) #if defined(CPUARM) && !defined(SIMU)
extern unsigned char *heap; extern unsigned char *heap;
extern int _end; extern int _end;
extern unsigned char *_estack; extern int _estack;
extern int _main_stack_start;
#define getAvailableMemory() ((unsigned int)((unsigned char *)&_estack - heap)) #define getAvailableMemory() ((unsigned int)((unsigned char *)&_estack - heap))
#endif #endif

View file

@ -46,6 +46,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include "debug.h"
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
* Exported variables * Exported variables
@ -54,9 +55,7 @@
#undef errno #undef errno
extern int errno; extern int errno;
extern int _end; extern int _end;
extern int _estack; extern int _main_stack_start;
#define RAM_END (unsigned char *)&_estack
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
* Exported functions * Exported functions
@ -68,7 +67,7 @@ extern int _getpid ( void ) ;
unsigned char *heap = (unsigned char *)&_end; unsigned char *heap = (unsigned char *)&_end;
extern caddr_t _sbrk(int nbytes) extern caddr_t _sbrk(int nbytes)
{ {
if (heap + nbytes < RAM_END-8192) { if (heap + nbytes < (unsigned char *)&_main_stack_start) {
unsigned char *prev_heap = heap; unsigned char *prev_heap = heap;
heap += nbytes; heap += nbytes;
return (caddr_t) prev_heap; return (caddr_t) prev_heap;
@ -142,7 +141,7 @@ extern int _write( int file, char *ptr, int len )
extern void _exit( int status ) extern void _exit( int status )
{ {
printf( "Exiting with status %d.\n", status ) ; TRACE( "Exiting with status %d.\n", status ) ;
for ( ; ; ) ; for ( ; ; ) ;
} }

View file

@ -98,6 +98,17 @@ LoopFillZerobss:
ldr r3, = _ebss ldr r3, = _ebss
cmp r2, r3 cmp r2, r3
bcc FillZerobss bcc FillZerobss
/*Paint Main Stack */
ldr r2, = _main_stack_start
PaintMainStack:
movs r3, #0x55555555
str r3, [r2], #4
LoopPaintMainStack:
ldr r3, = _estack
cmp r2, r3
bcc PaintMainStack
/* Call the clock system intitialization function.*/ /* Call the clock system intitialization function.*/
bl SystemInit bl SystemInit

View file

@ -34,6 +34,8 @@ ENTRY(Reset_Handler)
/* Highest address of the user mode stack */ /* Highest address of the user mode stack */
_estack = 0x20020000; /* end of 128K SRAM */ _estack = 0x20020000; /* end of 128K SRAM */
_main_stack_size = 0x1000; /*size of main stack*/
_main_stack_start = _estack - _main_stack_size;
/* Generate a link error if heap and stack don't fit into RAM */ /* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0; /* required amount of heap */ _Min_Heap_Size = 0; /* required amount of heap */

View file

@ -21,6 +21,8 @@ ENTRY(Reset_Handler)
/* Highest address of the user mode stack */ /* Highest address of the user mode stack */
_estack = 0x20020000; /* end of 128K SRAM */ _estack = 0x20020000; /* end of 128K SRAM */
_main_stack_size = 0x1000; /*size of main stack*/
_main_stack_start = _estack - _main_stack_size;
/* Generate a link error if heap and stack don't fit into RAM */ /* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0; /* required amount of heap */ _Min_Heap_Size = 0; /* required amount of heap */