From f2ffd1fb9935dbc62d97eab1c07fd6bac9e03938 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Wed, 22 Aug 2012 08:25:54 +0200 Subject: [PATCH 1/3] Changed DIAGNOSTICS flag to be individual to each module instead of global. The upshot is the stack usage monitor can be turned on at a lower RAM threshold. --- flight/CopterControl/Makefile | 22 +++++++++++++++++--- flight/Modules/Actuator/actuator.c | 6 +++--- flight/Modules/Stabilization/stabilization.c | 6 +++--- flight/Modules/System/systemmod.c | 8 +++---- flight/PipXtreme/Makefile | 21 ++++++++++++++++--- flight/Revolution/Makefile | 6 +++++- flight/SimPosix/Makefile | 8 ++++++- 7 files changed, 59 insertions(+), 18 deletions(-) diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index f786df65c..3f2a119ad 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -38,9 +38,13 @@ OUTDIR := $(TOP)/build/$(TARGET) DEBUG ?= NO # Include objects that are just nice information to show -DIAGNOSTICS ?= NO +STACK_DIAGNOSTICS ?= NO +MIXERSTATUS_DIAGNOSTICS ?= NO +RATEDESIRED_DIAGNOSTICS ?= NO +I2C_WDG_STATS_DIAGNOSTICS ?= NO DIAG_TASKS ?= NO + # Set to YES to build a FW version that will erase all flash memory ERASE_FLASH ?= NO # Set to YES to use the Servo output pins for debugging via scope or logic analyser @@ -474,8 +478,20 @@ ifeq ($(DEBUG),YES) CFLAGS += -DDEBUG endif -ifeq ($(DIAGNOSTICS),YES) -CFLAGS += -DDIAGNOSTICS +ifeq ($(STACK_DIAGNOSTICS),YES) +CFLAGS += -DSTACK_DIAGNOSTICS +endif + +ifeq ($(MIXERSTATUS_DIAGNOSTICS),YES) +CFLAGS += -DMIXERSTATUS_DIAGNOSTICS +endif + +ifeq ($(RATEDESIRED_DIAGNOSTICS),YES) +CFLAGS += -DRATEDESIRED_DIAGNOSTICS +endif + +ifeq ($(I2C_WDG_STATS_DIAGNOSTICS),YES) +CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS endif ifeq ($(DIAG_TASKS),YES) diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index e59d50957..6bd471666 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -126,7 +126,7 @@ int32_t ActuatorInitialize() // Primary output of this module ActuatorCommandInitialize(); -#if defined(DIAGNOSTICS) +#if defined(MIXERSTATUS_DIAGNOSTICS) // UAVO only used for inspecting the internal status of the mixer during debug MixerStatusInitialize(); #endif @@ -212,7 +212,7 @@ static void actuatorTask(void* parameters) ActuatorDesiredGet(&desired); ActuatorCommandGet(&command); -#if defined(DIAGNOSTICS) +#if defined(MIXERSTATUS_DIAGNOSTICS) MixerStatusGet(&mixerStatus); #endif int nMixers = 0; @@ -362,7 +362,7 @@ static void actuatorTask(void* parameters) // Update in case read only (eg. during servo configuration) ActuatorCommandGet(&command); -#if defined(DIAGNOSTICS) +#if defined(MIXERSTATUS_DIAGNOSTICS) MixerStatusSet(&mixerStatus); #endif diff --git a/flight/Modules/Stabilization/stabilization.c b/flight/Modules/Stabilization/stabilization.c index 43bb9b0d5..a484cc132 100644 --- a/flight/Modules/Stabilization/stabilization.c +++ b/flight/Modules/Stabilization/stabilization.c @@ -127,7 +127,7 @@ int32_t StabilizationInitialize() // Initialize variables StabilizationSettingsInitialize(); ActuatorDesiredInitialize(); -#if defined(DIAGNOSTICS) +#if defined(RATEDESIRED_DIAGNOSTICS) RateDesiredInitialize(); #endif @@ -176,7 +176,7 @@ static void stabilizationTask(void* parameters) AttitudeActualGet(&attitudeActual); GyrosGet(&gyrosData); -#if defined(DIAGNOSTICS) +#if defined(RATEDESIRED_DIAGNOSTICS) RateDesiredGet(&rateDesired); #endif @@ -308,7 +308,7 @@ static void stabilizationTask(void* parameters) } uint8_t shouldUpdate = 1; -#if defined(DIAGNOSTICS) +#if defined(RATEDESIRED_DIAGNOSTICS) RateDesiredSet(&rateDesired); #endif ActuatorDesiredGet(&actuatorDesired); diff --git a/flight/Modules/System/systemmod.c b/flight/Modules/System/systemmod.c index 715c26d72..870273a1e 100644 --- a/flight/Modules/System/systemmod.c +++ b/flight/Modules/System/systemmod.c @@ -82,7 +82,7 @@ static void objectUpdatedCb(UAVObjEvent * ev); static void updateStats(); static void updateSystemAlarms(); static void systemTask(void *parameters); -#if defined(DIAGNOSTICS) +#if defined(I2C_WDG_STATS_DIAGNOSTICS) static void updateI2Cstats(); static void updateWDGstats(); #endif @@ -118,7 +118,7 @@ int32_t SystemModInitialize(void) #if defined(DIAG_TASKS) TaskInfoInitialize(); #endif -#if defined(DIAGNOSTICS) +#if defined(I2C_WDG_STATS_DIAGNOSTICS) I2CStatsInitialize(); WatchdogStatusInitialize(); #endif @@ -168,7 +168,7 @@ static void systemTask(void *parameters) // Update the system alarms updateSystemAlarms(); -#if defined(DIAGNOSTICS) +#if defined(I2C_WDG_STATS_DIAGNOSTICS) updateI2Cstats(); updateWDGstats(); #endif @@ -301,7 +301,7 @@ static void objectUpdatedCb(UAVObjEvent * ev) /** * Called periodically to update the I2C statistics */ -#if defined(DIAGNOSTICS) +#if defined(I2C_WDG_STATS_DIAGNOSTICS) static void updateI2Cstats() { #if defined(PIOS_INCLUDE_I2C) diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 63f2e7907..8538908f0 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -38,7 +38,10 @@ OUTDIR := $(TOP)/build/$(TARGET) DEBUG ?= NO # Include objects that are just nice information to show -DIAGNOSTICS ?= NO +STACK_DIAGNOSTICS ?= NO +MIXERSTATUS_DIAGNOSTICS ?= NO +RATEDESIRED_DIAGNOSTICS ?= NO +I2C_WDG_STATS_DIAGNOSTICS ?= NO # Set to YES to build a FW version that will erase all flash memory ERASE_FLASH ?= NO @@ -378,8 +381,20 @@ ifeq ($(DEBUG),YES) CFLAGS = -DDEBUG endif -ifeq ($(DIAGNOSTICS),YES) -CFLAGS = -DDIAGNOSTICS +ifeq ($(STACK_DIAGNOSTICS),YES) +CFLAGS += -DSTACK_DIAGNOSTICS +endif + +ifeq ($(MIXERSTATUS_DIAGNOSTICS),YES) +CFLAGS += -DMIXERSTATUS_DIAGNOSTICS +endif + +ifeq ($(RATEDESIRED_DIAGNOSTICS),YES) +CFLAGS += -DRATEDESIRED_DIAGNOSTICS +endif + +ifeq ($(I2C_WDG_STATS_DIAGNOSTICS),YES) +CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS endif CFLAGS += -g$(DEBUGF) diff --git a/flight/Revolution/Makefile b/flight/Revolution/Makefile index ce8a45b6d..cc222f744 100644 --- a/flight/Revolution/Makefile +++ b/flight/Revolution/Makefile @@ -255,7 +255,11 @@ endif # common architecture-specific flags from the device-specific library makefile CFLAGS += $(ARCHFLAGS) -CFLAGS += -DDIAGNOSTICS +CFLAGS += -DSTACK_DIAGNOSTICS +CFLAGS += -DMIXERSTATUS_DIAGNOSTICS +CFLAGS += -DRATEDESIRED_DIAGNOSTICS +CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS + CFLAGS += -DDIAG_TASKS # This is not the best place for these. Really should abstract out diff --git a/flight/SimPosix/Makefile b/flight/SimPosix/Makefile index 84a9bb060..616ef5995 100644 --- a/flight/SimPosix/Makefile +++ b/flight/SimPosix/Makefile @@ -250,7 +250,13 @@ endif CFLAGS += $(ARCHFLAGS) CFLAGS += $(UAVOBJDEFINE) -CFLAGS += -DDIAGNOSTICS + +CFLAGS += -DSTACK_DIAGNOSTICS +CFLAGS += -DMIXERSTATUS_DIAGNOSTICS +CFLAGS += -DRATEDESIRED_DIAGNOSTICS +CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS + + CFLAGS += -DDIAG_TASKS # This is not the best place for these. Really should abstract out From 929bf73504a4a9492a57d700afcf6f96d13fb645 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Thu, 23 Aug 2012 07:41:43 +0200 Subject: [PATCH 2/3] Missed adding a diagnostics refactor to the commit. --- flight/PipXtreme/System/inc/FreeRTOSConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/PipXtreme/System/inc/FreeRTOSConfig.h b/flight/PipXtreme/System/inc/FreeRTOSConfig.h index 994956008..0c515b7f7 100755 --- a/flight/PipXtreme/System/inc/FreeRTOSConfig.h +++ b/flight/PipXtreme/System/inc/FreeRTOSConfig.h @@ -76,7 +76,7 @@ NVIC value of 255. */ #endif /* Enable run time stats collection */ -#if defined(DIAGNOSTICS) +#if defined(STACK_DIAGNOSTICS) #define configCHECK_FOR_STACK_OVERFLOW 2 #define configGENERATE_RUN_TIME_STATS 1 From 4923655cd3b50e8d82fc914264265a55ba948c58 Mon Sep 17 00:00:00 2001 From: Laura Sebesta Date: Thu, 27 Sep 2012 18:51:12 +0200 Subject: [PATCH 3/3] Added global flag for enabling all diagnostic tools. --- flight/CopterControl/Makefile | 14 +++++++++----- flight/PipXtreme/Makefile | 16 ++++++++++++---- flight/Revolution/Makefile | 1 - flight/SimPosix/Makefile | 2 -- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 3f2a119ad..c1b5042de 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -44,6 +44,8 @@ RATEDESIRED_DIAGNOSTICS ?= NO I2C_WDG_STATS_DIAGNOSTICS ?= NO DIAG_TASKS ?= NO +#Or just turn on all the above diagnostics. WARNING: This consumes massive amounts of memory. +ALL_DIGNOSTICS ?=NO # Set to YES to build a FW version that will erase all flash memory ERASE_FLASH ?= NO @@ -478,23 +480,25 @@ ifeq ($(DEBUG),YES) CFLAGS += -DDEBUG endif -ifeq ($(STACK_DIAGNOSTICS),YES) +#The following Makefile command, ifneq (, $(filter) $(A), $(B) $(C)) is equivalent +# to the pseudocode `if(A== B || A==C)` +ifneq (,$(filter YES,$(STACK_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DSTACK_DIAGNOSTICS endif -ifeq ($(MIXERSTATUS_DIAGNOSTICS),YES) +ifneq (,$(filter YES,$(MIXERSTATUS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DMIXERSTATUS_DIAGNOSTICS endif -ifeq ($(RATEDESIRED_DIAGNOSTICS),YES) +ifneq (,$(filter YES,$(RATEDESIRED_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DRATEDESIRED_DIAGNOSTICS endif -ifeq ($(I2C_WDG_STATS_DIAGNOSTICS),YES) +ifneq (,$(filter YES,$(I2C_WDG_STATS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS endif -ifeq ($(DIAG_TASKS),YES) +ifneq (,$(filter YES,$(DIAG_TASKS) $(ALL_DIGNOSTICS))) CFLAGS += -DDIAG_TASKS endif diff --git a/flight/PipXtreme/Makefile b/flight/PipXtreme/Makefile index 8538908f0..07c9e05d4 100644 --- a/flight/PipXtreme/Makefile +++ b/flight/PipXtreme/Makefile @@ -42,6 +42,10 @@ STACK_DIAGNOSTICS ?= NO MIXERSTATUS_DIAGNOSTICS ?= NO RATEDESIRED_DIAGNOSTICS ?= NO I2C_WDG_STATS_DIAGNOSTICS ?= NO +DIAG_TASKS ?= YES + +#Or just turn on all the above diagnostics. WARNING: This consumes massive amounts of memory. +ALL_DIGNOSTICS ?=NO # Set to YES to build a FW version that will erase all flash memory ERASE_FLASH ?= NO @@ -381,22 +385,26 @@ ifeq ($(DEBUG),YES) CFLAGS = -DDEBUG endif -ifeq ($(STACK_DIAGNOSTICS),YES) +ifneq (,$(filter YES,$(STACK_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DSTACK_DIAGNOSTICS endif -ifeq ($(MIXERSTATUS_DIAGNOSTICS),YES) +ifneq (,$(filter YES,$(MIXERSTATUS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DMIXERSTATUS_DIAGNOSTICS endif -ifeq ($(RATEDESIRED_DIAGNOSTICS),YES) +ifneq (,$(filter YES,$(RATEDESIRED_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DRATEDESIRED_DIAGNOSTICS endif -ifeq ($(I2C_WDG_STATS_DIAGNOSTICS),YES) +ifneq (,$(filter YES,$(I2C_WDG_STATS_DIAGNOSTICS) $(ALL_DIGNOSTICS))) CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS endif +ifneq (,$(filter YES,$(DIAG_TASKS) $(ALL_DIGNOSTICS))) +CFLAGS += -DDIAG_TASKS +endif + CFLAGS += -g$(DEBUGF) CFLAGS += -O$(OPT) CFLAGS += -mcpu=$(MCU) diff --git a/flight/Revolution/Makefile b/flight/Revolution/Makefile index cc222f744..ff76ddbfa 100644 --- a/flight/Revolution/Makefile +++ b/flight/Revolution/Makefile @@ -259,7 +259,6 @@ CFLAGS += -DSTACK_DIAGNOSTICS CFLAGS += -DMIXERSTATUS_DIAGNOSTICS CFLAGS += -DRATEDESIRED_DIAGNOSTICS CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS - CFLAGS += -DDIAG_TASKS # This is not the best place for these. Really should abstract out diff --git a/flight/SimPosix/Makefile b/flight/SimPosix/Makefile index 616ef5995..3d541b409 100644 --- a/flight/SimPosix/Makefile +++ b/flight/SimPosix/Makefile @@ -255,8 +255,6 @@ CFLAGS += -DSTACK_DIAGNOSTICS CFLAGS += -DMIXERSTATUS_DIAGNOSTICS CFLAGS += -DRATEDESIRED_DIAGNOSTICS CFLAGS += -DI2C_WDG_STATS_DIAGNOSTICS - - CFLAGS += -DDIAG_TASKS # This is not the best place for these. Really should abstract out