From 8c925aa7abd79ac05ef7d94b98bfacd4e37441fd Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Thu, 14 May 2020 16:58:02 +0200 Subject: [PATCH] #546 Moved some memory blocks to CCM. Freed around 40k RAM. --- src/deck/core/deck_info.c | 3 ++- src/deck/drivers/src/lpsTwrTag.c | 3 ++- src/hal/src/sensors_bmi088_bmp388.c | 2 +- src/hal/src/sensors_bmi088_spi_bmp388.c | 2 +- src/hal/src/sensors_mpu9250_lps25h.c | 2 +- src/hal/src/syslink.c | 2 +- src/modules/src/crtp.c | 4 ++-- src/modules/src/estimator_kalman.c | 6 ++---- src/modules/src/lighthouse/lighthouse_core.c | 3 ++- src/modules/src/log.c | 4 ++-- src/modules/src/param.c | 2 +- src/modules/src/tdoaEngineInstance.c | 3 ++- 12 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/deck/core/deck_info.c b/src/deck/core/deck_info.c index 53796b853f..6465717119 100644 --- a/src/deck/core/deck_info.c +++ b/src/deck/core/deck_info.c @@ -35,6 +35,7 @@ #include "ow.h" #include "crc.h" #include "debug.h" +#include "static_mem.h" #ifdef DEBUG #define DECK_INFO_DBG_PRINT(fmt, ...) DEBUG_PRINT(fmt, ## __VA_ARGS__) @@ -43,7 +44,7 @@ #endif static int count = 0; -static DeckInfo deckInfos[DECK_MAX_COUNT]; +NO_DMA_CCM_SAFE_ZERO_INIT static DeckInfo deckInfos[DECK_MAX_COUNT]; static void enumerateDecks(void); static void checkPeriphAndGpioConflicts(void); diff --git a/src/deck/drivers/src/lpsTwrTag.c b/src/deck/drivers/src/lpsTwrTag.c index 040c7d28bb..e8fb6e32ae 100644 --- a/src/deck/drivers/src/lpsTwrTag.c +++ b/src/deck/drivers/src/lpsTwrTag.c @@ -44,6 +44,7 @@ #include "physicalConstants.h" #include "configblock.h" #include "lpsTdma.h" +#include "static_mem.h" #define ANTENNA_OFFSET 154.6 // In meter @@ -100,7 +101,7 @@ static lpsTwrAlgoOptions_t* options = &defaultOptions; // Outlier rejection #define RANGING_HISTORY_LENGTH 32 #define OUTLIER_TH 4 -static struct { +NO_DMA_CCM_SAFE_ZERO_INIT static struct { float32_t history[RANGING_HISTORY_LENGTH]; size_t ptr; } rangingStats[LOCODECK_NR_OF_TWR_ANCHORS]; diff --git a/src/hal/src/sensors_bmi088_bmp388.c b/src/hal/src/sensors_bmi088_bmp388.c index 26de400c4f..6e1cd11e5b 100644 --- a/src/hal/src/sensors_bmi088_bmp388.c +++ b/src/hal/src/sensors_bmi088_bmp388.c @@ -121,7 +121,7 @@ static volatile uint64_t imuIntTimestamp; static Axis3i16 gyroRaw; static Axis3i16 accelRaw; -static BiasObj gyroBiasRunning; +NO_DMA_CCM_SAFE_ZERO_INIT static BiasObj gyroBiasRunning; static Axis3f gyroBias; #if defined(SENSORS_GYRO_BIAS_CALCULATE_STDDEV) && defined (GYRO_BIAS_LIGHT_WEIGHT) static Axis3f gyroBiasStdDev; diff --git a/src/hal/src/sensors_bmi088_spi_bmp388.c b/src/hal/src/sensors_bmi088_spi_bmp388.c index b56923330e..4c4c9eccc7 100644 --- a/src/hal/src/sensors_bmi088_spi_bmp388.c +++ b/src/hal/src/sensors_bmi088_spi_bmp388.c @@ -176,7 +176,7 @@ static volatile uint64_t imuIntTimestamp; static Axis3i16 gyroRaw; static Axis3i16 accelRaw; -static BiasObj gyroBiasRunning; +NO_DMA_CCM_SAFE_ZERO_INIT static BiasObj gyroBiasRunning; static Axis3f gyroBias; #if defined(SENSORS_GYRO_BIAS_CALCULATE_STDDEV) && defined (GYRO_BIAS_LIGHT_WEIGHT) static Axis3f gyroBiasStdDev; diff --git a/src/hal/src/sensors_mpu9250_lps25h.c b/src/hal/src/sensors_mpu9250_lps25h.c index fd8aa6d579..66812250e2 100644 --- a/src/hal/src/sensors_mpu9250_lps25h.c +++ b/src/hal/src/sensors_mpu9250_lps25h.c @@ -124,7 +124,7 @@ static volatile uint64_t imuIntTimestamp; static Axis3i16 gyroRaw; static Axis3i16 accelRaw; -static BiasObj gyroBiasRunning; +NO_DMA_CCM_SAFE_ZERO_INIT static BiasObj gyroBiasRunning; static Axis3f gyroBias; #if defined(SENSORS_GYRO_BIAS_CALCULATE_STDDEV) && defined (GYRO_BIAS_LIGHT_WEIGHT) static Axis3f gyroBiasStdDev; diff --git a/src/hal/src/syslink.c b/src/hal/src/syslink.c index 4e7bf8f523..1bd4926081 100644 --- a/src/hal/src/syslink.c +++ b/src/hal/src/syslink.c @@ -55,7 +55,7 @@ static void syslinkRouteIncommingPacket(SyslinkPacket *slp); static xSemaphoreHandle syslinkAccess; -STATIC_MEM_TASK_ALLOC(syslinkTask, SYSLINK_TASK_STACKSIZE); +STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(syslinkTask, SYSLINK_TASK_STACKSIZE); /* Syslink task, handles communication between nrf and stm and dispatch messages */ diff --git a/src/modules/src/crtp.c b/src/modules/src/crtp.c index 1d607c44cb..9172a60798 100644 --- a/src/modules/src/crtp.c +++ b/src/modules/src/crtp.c @@ -80,8 +80,8 @@ static xQueueHandle queues[CRTP_NBR_OF_PORTS]; static volatile CrtpCallback callbacks[CRTP_NBR_OF_PORTS]; static void updateStats(); -STATIC_MEM_TASK_ALLOC(crtpTxTask, CRTP_TX_TASK_STACKSIZE); -STATIC_MEM_TASK_ALLOC(crtpRxTask, CRTP_RX_TASK_STACKSIZE); +STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(crtpTxTask, CRTP_TX_TASK_STACKSIZE); +STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(crtpRxTask, CRTP_RX_TASK_STACKSIZE); void crtpInit(void) { diff --git a/src/modules/src/estimator_kalman.c b/src/modules/src/estimator_kalman.c index 9b127d016a..56296f1a90 100644 --- a/src/modules/src/estimator_kalman.c +++ b/src/modules/src/estimator_kalman.c @@ -60,8 +60,6 @@ #include "estimator_kalman.h" #include "kalman_supervisor.h" -#include "stm32f4xx.h" - #include "FreeRTOS.h" #include "queue.h" #include "task.h" @@ -213,7 +211,7 @@ static StaticSemaphore_t dataMutexBuffer; * For more information, refer to the paper */ -static kalmanCoreData_t coreData; +NO_DMA_CCM_SAFE_ZERO_INIT static kalmanCoreData_t coreData; /** * Internal variables. Note that static declaration results in default initialization (to 0) @@ -270,7 +268,7 @@ static void kalmanTask(void* parameters); static bool predictStateForward(uint32_t osTick, float dt); static bool updateQueuedMeasurments(const Axis3f *gyro, const uint32_t tick); -STATIC_MEM_TASK_ALLOC(kalmanTask, 3 * configMINIMAL_STACK_SIZE); +STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(kalmanTask, 3 * configMINIMAL_STACK_SIZE); // -------------------------------------------------- diff --git a/src/modules/src/lighthouse/lighthouse_core.c b/src/modules/src/lighthouse/lighthouse_core.c index 5750f01423..84783424fd 100644 --- a/src/modules/src/lighthouse/lighthouse_core.c +++ b/src/modules/src/lighthouse/lighthouse_core.c @@ -47,6 +47,7 @@ #include "lighthouse_core.h" #include "test_support.h" +#include "static_mem.h" static pulseProcessorResult_t angles; @@ -67,7 +68,7 @@ static STATS_CNT_RATE_DEFINE(bs1Rate, HALF_SECOND); static statsCntRateLogger_t* bsRates[PULSE_PROCESSOR_N_BASE_STATIONS] = {&bs0Rate, &bs1Rate}; static uint16_t pulseWidth[PULSE_PROCESSOR_N_SENSORS]; -static pulseProcessor_t ppState = {}; +NO_DMA_CCM_SAFE_ZERO_INIT static pulseProcessor_t ppState = {}; pulseProcessorProcessPulse_t pulseProcessorProcessPulse = (void*)0; diff --git a/src/modules/src/log.c b/src/modules/src/log.c index 9401483b5f..00c38c51d3 100644 --- a/src/modules/src/log.c +++ b/src/modules/src/log.c @@ -99,7 +99,7 @@ struct log_block { }; static struct log_ops logOps[LOG_MAX_OPS]; -static struct log_block logBlocks[LOG_MAX_BLOCKS]; +NO_DMA_CCM_SAFE_ZERO_INIT static struct log_block logBlocks[LOG_MAX_BLOCKS]; static xSemaphoreHandle logLock; static StaticSemaphore_t logLockBuffer; @@ -167,7 +167,7 @@ static int logStopBlock(int id); static void logReset(); static acquisitionType_t acquisitionTypeFromLogType(uint8_t logType); -STATIC_MEM_TASK_ALLOC(logTask, LOG_TASK_STACKSIZE); +STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(logTask, LOG_TASK_STACKSIZE); void logInit(void) { diff --git a/src/modules/src/param.c b/src/modules/src/param.c index ad81cc849c..1f32c84ec4 100644 --- a/src/modules/src/param.c +++ b/src/modules/src/param.c @@ -100,7 +100,7 @@ static CRTPPacket p; static bool isInit = false; -STATIC_MEM_TASK_ALLOC(paramTask, PARAM_TASK_STACKSIZE); +STATIC_MEM_TASK_ALLOC_STACK_NO_DMA_CCM_SAFE(paramTask, PARAM_TASK_STACKSIZE); void paramInit(void) { diff --git a/src/modules/src/tdoaEngineInstance.c b/src/modules/src/tdoaEngineInstance.c index a31e21829b..23056f6195 100644 --- a/src/modules/src/tdoaEngineInstance.c +++ b/src/modules/src/tdoaEngineInstance.c @@ -28,8 +28,9 @@ #include "tdoaEngineInstance.h" #include "log.h" #include "param.h" +#include "static_mem.h" -tdoaEngineState_t tdoaEngineState; +NO_DMA_CCM_SAFE_ZERO_INIT tdoaEngineState_t tdoaEngineState; LOG_GROUP_START(tdoaEngine) STATS_CNT_RATE_LOG_ADD(stRx, &tdoaEngineState.stats.packetsReceived)