From 015293ee43d4af1effd314844ce7ddf6f4b076e0 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 5 Jul 2020 11:16:07 -0400 Subject: [PATCH] wipe strings in configuration images --- firmware/console/binary/tunerstudio.cpp | 3 ++- .../controllers/algo/engine_configuration.cpp | 19 +++++++++++++++++++ .../controllers/algo/engine_configuration.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/firmware/console/binary/tunerstudio.cpp b/firmware/console/binary/tunerstudio.cpp index 96291d3320..730d8391dd 100644 --- a/firmware/console/binary/tunerstudio.cpp +++ b/firmware/console/binary/tunerstudio.cpp @@ -437,10 +437,11 @@ static void handlePageReadCommand(ts_channel_s *tsChannel, ts_response_format_e } void requestBurn(void) { + onBurnRequest(PASS_ENGINE_PARAMETER_SIGNATURE); + #if EFI_INTERNAL_FLASH setNeedToWriteConfiguration(); #endif - incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); } static void sendResponseCode(ts_response_format_e mode, ts_channel_s *tsChannel, const uint8_t responseCode) { diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 4e557da49d..6a4a2e78e6 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -166,6 +166,25 @@ void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { extern LoggingWithStorage sharedLogger; +static void wipeString(char *string, int size) { + // we have to reset bytes after \0 symbol in order to calculate correct tune CRC from MSQ file + for (int i = strlen(string) + 1; i < size; i++) { + string[i] = 0; + } +} + +void onBurnRequest(DECLARE_ENGINE_PARAMETER_SIGNATURE) { + wipeString(engineConfiguration->engineMake, sizeof(vehicle_info_t)); + wipeString(engineConfiguration->engineCode, sizeof(vehicle_info_t)); + wipeString(engineConfiguration->vehicleName, sizeof(vehicle_info_t)); + + for (int i = 0; i < FSIO_COMMAND_COUNT; i++) { + wipeString(config->fsioFormulas[i], sizeof(le_formula_t)); + } + + incrementGlobalConfigurationVersion(PASS_ENGINE_PARAMETER_SIGNATURE); +} + /** * this is the top-level method which should be called in case of any changes to engine configuration * online tuning of most values in the maps does not count as configuration change, but 'Burn' command does diff --git a/firmware/controllers/algo/engine_configuration.h b/firmware/controllers/algo/engine_configuration.h index 7e9ceb194b..c9c3173124 100644 --- a/firmware/controllers/algo/engine_configuration.h +++ b/firmware/controllers/algo/engine_configuration.h @@ -46,6 +46,7 @@ void setDefaultBasePins(DECLARE_CONFIG_PARAMETER_SIGNATURE); void setDefaultSdCardParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE); +void onBurnRequest(DECLARE_ENGINE_PARAMETER_SIGNATURE); void rememberCurrentConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE); void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE);