memory savings (#3195)

* d

* dead code

* all your ram are belong to me

* turn off gpiochips we don't need

* save

* save by using the same file handle

* smaller stack ok

* these can be on the stack

* this is closer

* what about ccm?

* probing available

* now probe ccm

* ccm

* put stuff in ccm

* fsio

* memory usage

* memory
This commit is contained in:
Matthew Kennedy 2021-08-26 13:05:31 -07:00 committed by GitHub
parent cf5d4cbe1c
commit 52a24ee773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 25 additions and 33 deletions

View File

@ -147,11 +147,11 @@
#define EFI_POTENTIOMETER FALSE #define EFI_POTENTIOMETER FALSE
#ifndef BOARD_TLE6240_COUNT #ifndef BOARD_TLE6240_COUNT
#define BOARD_TLE6240_COUNT 1 #define BOARD_TLE6240_COUNT 0
#endif #endif
#ifndef BOARD_MC33972_COUNT #ifndef BOARD_MC33972_COUNT
#define BOARD_MC33972_COUNT 1 #define BOARD_MC33972_COUNT 0
#endif #endif
#ifndef BOARD_TLE8888_COUNT #ifndef BOARD_TLE8888_COUNT

View File

@ -584,7 +584,7 @@ void handleQueryCommand(TsChannelBase* tsChannel, ts_response_format_e mode) {
*/ */
static void handleTestCommand(TsChannelBase* tsChannel) { static void handleTestCommand(TsChannelBase* tsChannel) {
tsState.testCommandCounter++; tsState.testCommandCounter++;
static char testOutputBuffer[64]; char testOutputBuffer[64];
/** /**
* this is NOT a standard TunerStudio command, this is my own * this is NOT a standard TunerStudio command, this is my own
* extension of the protocol to simplify troubleshooting * extension of the protocol to simplify troubleshooting
@ -611,7 +611,7 @@ static void handleTestCommand(TsChannelBase* tsChannel) {
extern CommandHandler console_line_callback; extern CommandHandler console_line_callback;
static void handleGetVersion(TsChannelBase* tsChannel) { static void handleGetVersion(TsChannelBase* tsChannel) {
static char versionBuffer[32]; char versionBuffer[32];
chsnprintf(versionBuffer, sizeof(versionBuffer), "rusEFI v%d@%s", getRusEfiVersion(), VCS_VERSION); chsnprintf(versionBuffer, sizeof(versionBuffer), "rusEFI v%d@%s", getRusEfiVersion(), VCS_VERSION);
tsChannel->sendResponse(TS_CRC, (const uint8_t *) versionBuffer, strlen(versionBuffer) + 1); tsChannel->sendResponse(TS_CRC, (const uint8_t *) versionBuffer, strlen(versionBuffer) + 1);
} }

View File

@ -30,8 +30,7 @@ typedef struct {
extern tunerstudio_counters_s tsState; extern tunerstudio_counters_s tsState;
// SD protocol file removal is one of the stack consuming use-cases #define CONNECTIVITY_THREAD_STACK (2 * UTILITY_THREAD_STACK_SIZE)
#define CONNECTIVITY_THREAD_STACK (3 * UTILITY_THREAD_STACK_SIZE)
/** /**
* handle non CRC wrapped command * handle non CRC wrapped command

View File

@ -17,9 +17,9 @@
#include "dc_motors.h" #include "dc_motors.h"
#if ! EFI_UNIT_TEST #if ! EFI_UNIT_TEST
#include "stepper.h" #include "stepper.h"
static StepDirectionStepper iacStepperHw; static StepDirectionStepper iacStepperHw CCM_OPTIONAL;
static DualHBridgeStepper iacHbridgeHw; static DualHBridgeStepper iacHbridgeHw CCM_OPTIONAL;
StepperMotor iacMotor; StepperMotor iacMotor CCM_OPTIONAL;
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */
static SimplePwm idleSolenoidOpen("idle open"); static SimplePwm idleSolenoidOpen("idle open");

View File

@ -99,7 +99,7 @@ void VvtController::setOutput(expected<percent_t> outputValue) {
#if EFI_AUX_PID #if EFI_AUX_PID
static VvtController instances[CAM_INPUTS_COUNT]; static VvtController instances[CAM_INPUTS_COUNT] CCM_OPTIONAL;
static void turnAuxPidOn(int index) { static void turnAuxPidOn(int index) {
if (!isBrainPinValid(engineConfiguration->auxPidPins[index])) { if (!isBrainPinValid(engineConfiguration->auxPidPins[index])) {

View File

@ -76,10 +76,10 @@ static LENameOrdinalPair leFuelRate(LE_METHOD_FUEL_FLOW_RATE, "fuel_flow");
#define UD_ELEMENT_POOL_SIZE 64 #define UD_ELEMENT_POOL_SIZE 64
static LEElement sysElements[SYS_ELEMENT_POOL_SIZE] CCM_OPTIONAL; static LEElement sysElements[SYS_ELEMENT_POOL_SIZE] CCM_OPTIONAL;
LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE); CCM_OPTIONAL LEElementPool sysPool(sysElements, SYS_ELEMENT_POOL_SIZE);
static LEElement userElements[UD_ELEMENT_POOL_SIZE] CCM_OPTIONAL; static LEElement userElements[UD_ELEMENT_POOL_SIZE] CCM_OPTIONAL;
LEElementPool userPool(userElements, UD_ELEMENT_POOL_SIZE); CCM_OPTIONAL LEElementPool userPool(userElements, UD_ELEMENT_POOL_SIZE);
class FsioPointers { class FsioPointers {
public: public:
@ -277,7 +277,7 @@ void onConfigurationChangeFsioCallback(engine_configuration_s *previousConfigura
#endif #endif
} }
static LECalculator calc; static LECalculator calc CCM_OPTIONAL;
static SimplePwm fsioPwm[FSIO_COMMAND_COUNT] CCM_OPTIONAL; static SimplePwm fsioPwm[FSIO_COMMAND_COUNT] CCM_OPTIONAL;

View File

@ -769,10 +769,10 @@ void initEngineContoller(DECLARE_ENGINE_PARAMETER_SUFFIX) {
* UNUSED_SIZE constants. * UNUSED_SIZE constants.
*/ */
#ifndef RAM_UNUSED_SIZE #ifndef RAM_UNUSED_SIZE
#define RAM_UNUSED_SIZE 1300 #define RAM_UNUSED_SIZE 10000
#endif #endif
#ifndef CCM_UNUSED_SIZE #ifndef CCM_UNUSED_SIZE
#define CCM_UNUSED_SIZE 300 #define CCM_UNUSED_SIZE 600
#endif #endif
static char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE]; static char UNUSED_RAM_SIZE[RAM_UNUSED_SIZE];
static char UNUSED_CCM_SIZE[CCM_UNUSED_SIZE] CCM_OPTIONAL; static char UNUSED_CCM_SIZE[CCM_UNUSED_SIZE] CCM_OPTIONAL;

View File

@ -103,7 +103,7 @@ private:
} }
}; };
static MILController instance; static MILController instance CCM_OPTIONAL;
#if TEST_MIL_CODE #if TEST_MIL_CODE
static void testMil(void) { static void testMil(void) {

View File

@ -244,7 +244,7 @@ static void printMAPInfo(void) {
#endif // EFI_MAP_AVERAGING #endif // EFI_MAP_AVERAGING
adc_channel_e mapAdc = engineConfiguration->map.sensor.hwChannel; adc_channel_e mapAdc = engineConfiguration->map.sensor.hwChannel;
static char pinNameBuffer[16]; char pinNameBuffer[16];
efiPrintf("MAP %.2fv @%s", getVoltage("mapinfo", mapAdc PASS_ENGINE_PARAMETER_SUFFIX), efiPrintf("MAP %.2fv @%s", getVoltage("mapinfo", mapAdc PASS_ENGINE_PARAMETER_SUFFIX),
getPinNameByAdcChannel("map", mapAdc, pinNameBuffer)); getPinNameByAdcChannel("map", mapAdc, pinNameBuffer));

View File

@ -17,8 +17,8 @@
struct AdcSubscriptionEntry { struct AdcSubscriptionEntry {
FunctionalSensor *Sensor; FunctionalSensor *Sensor;
float VoltsPerAdcVolt; float VoltsPerAdcVolt;
adc_channel_e Channel;
Biquad Filter; Biquad Filter;
adc_channel_e Channel;
bool HasUpdated = false; bool HasUpdated = false;
}; };

View File

@ -41,8 +41,6 @@ static int timerRestartCounter = 0;
static const char * msg; static const char * msg;
static char buff[32];
static int timerFreezeCounter = 0; static int timerFreezeCounter = 0;
static int setHwTimerCounter = 0; static int setHwTimerCounter = 0;
static bool hwStarted = false; static bool hwStarted = false;
@ -110,9 +108,7 @@ class MicrosecondTimerWatchdogController : public PeriodicTimerController {
void PeriodicTask() override { void PeriodicTask() override {
efitick_t nowNt = getTimeNowNt(); efitick_t nowNt = getTimeNowNt();
if (nowNt >= lastSetTimerTimeNt + 2 * CORE_CLOCK) { if (nowNt >= lastSetTimerTimeNt + 2 * CORE_CLOCK) {
strcpy(buff, "no_event"); firmwareError(CUSTOM_ERR_SCHEDULING_ERROR, "no event %d", lastSetTimerTimeNt);
itoa10(&buff[8], lastSetTimerTimeNt);
firmwareError(CUSTOM_ERR_SCHEDULING_ERROR, buff);
return; return;
} }

View File

@ -106,7 +106,6 @@ static void printError(const char *str, FRESULT f_error) {
} }
static FIL FDLogFile NO_CACHE; static FIL FDLogFile NO_CACHE;
static FIL FDCurrFile NO_CACHE;
// 10 because we want at least 4 character name // 10 because we want at least 4 character name
#define MIN_FILE_INDEX 10 #define MIN_FILE_INDEX 10
@ -132,8 +131,8 @@ static void sdStatistics(void) {
} }
static void incLogFileName(void) { static void incLogFileName(void) {
memset(&FDCurrFile, 0, sizeof(FIL)); // clear the memory memset(&FDLogFile, 0, sizeof(FIL)); // clear the memory
FRESULT err = f_open(&FDCurrFile, LOG_INDEX_FILENAME, FA_READ); // This file has the index for next log file name FRESULT err = f_open(&FDLogFile, LOG_INDEX_FILENAME, FA_READ); // This file has the index for next log file name
char data[_MAX_FILLER]; char data[_MAX_FILLER];
UINT result = 0; UINT result = 0;
@ -141,10 +140,10 @@ static void incLogFileName(void) {
logFileIndex = MIN_FILE_INDEX; logFileIndex = MIN_FILE_INDEX;
efiPrintf("%s: not found or error: %d", LOG_INDEX_FILENAME, err); efiPrintf("%s: not found or error: %d", LOG_INDEX_FILENAME, err);
} else { } else {
f_read(&FDCurrFile, (void*)data, sizeof(data), &result); f_read(&FDLogFile, (void*)data, sizeof(data), &result);
efiPrintf("Got content [%s] size %d", data, result); efiPrintf("Got content [%s] size %d", data, result);
f_close(&FDCurrFile); f_close(&FDLogFile);
if (result < 5) { if (result < 5) {
data[result] = 0; data[result] = 0;
logFileIndex = maxI(MIN_FILE_INDEX, atoi(data)); logFileIndex = maxI(MIN_FILE_INDEX, atoi(data));
@ -158,10 +157,10 @@ static void incLogFileName(void) {
} }
} }
err = f_open(&FDCurrFile, LOG_INDEX_FILENAME, FA_OPEN_ALWAYS | FA_WRITE); err = f_open(&FDLogFile, LOG_INDEX_FILENAME, FA_OPEN_ALWAYS | FA_WRITE);
itoa10(data, logFileIndex); itoa10(data, logFileIndex);
f_write(&FDCurrFile, (void*)data, strlen(data), &result); f_write(&FDLogFile, (void*)data, strlen(data), &result);
f_close(&FDCurrFile); f_close(&FDLogFile);
efiPrintf("Done %d", logFileIndex); efiPrintf("Done %d", logFileIndex);
} }
@ -402,8 +401,6 @@ static bool mountMmc() {
bool hasUsb = usbResult == MSG_OK; bool hasUsb = usbResult == MSG_OK;
msdObjectInit(&USBMSD1);
// If we have a device AND USB is connected, mount the card to USB, otherwise // If we have a device AND USB is connected, mount the card to USB, otherwise
// mount the null device and try to mount the filesystem ourselves // mount the null device and try to mount the filesystem ourselves
if (cardBlockDevice && hasUsb) { if (cardBlockDevice && hasUsb) {