diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 72d4f508ce..bcc864a1a1 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -116,6 +116,7 @@ * * todo: place this field next to 'engineConfiguration'? */ +static bool hasRememberedConfiguration = false; #if EFI_ACTIVE_CONFIGURATION_IN_FLASH #include "flash_int.h" engine_configuration_s & activeConfiguration = reinterpret_cast(getFlashAddrFirstCopy())->persistentConfiguration.engineConfiguration; @@ -132,6 +133,7 @@ void rememberCurrentConfiguration() { #else isActiveConfigurationVoid = false; #endif /* EFI_ACTIVE_CONFIGURATION_IN_FLASH */ + hasRememberedConfiguration = true; } static void wipeString(char *string, int size) { @@ -164,6 +166,9 @@ __attribute__((weak)) void boardOnConfigurationChange(engine_configuration_s* /* * See preCalculate which is invoked BOTH on start and configuration change */ void incrementGlobalConfigurationVersion() { + if (!hasRememberedConfiguration) { + firmwareError(OBD_PCM_Processor_Fault, "too early to invoke incrementGlobalConfigurationVersion"); + } engine->globalConfigurationVersion++; #if EFI_DEFAILED_LOGGING efiPrintf("set globalConfigurationVersion=%d", globalConfigurationVersion); diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 4049c35c8c..1bc708603e 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -648,7 +648,7 @@ void commonEarlyInit() { #if HW_CHECK_ALWAYS_STIMULATE // we need a special binary for final assembly check. We cannot afford to require too much software or too many steps // to be executed at the place of assembly - enableTriggerStimulator(); + enableTriggerStimulator(/*incGlobalConfiguration*/false); #endif // HW_CHECK_ALWAYS_STIMULATE } diff --git a/firmware/controllers/trigger/trigger_emulator_algo.cpp b/firmware/controllers/trigger/trigger_emulator_algo.cpp index b6096c51f1..fdc5984626 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.cpp +++ b/firmware/controllers/trigger/trigger_emulator_algo.cpp @@ -172,11 +172,13 @@ static void startSimulatedTriggerSignal() { // self-stimulation // see below for trigger output generator -void enableTriggerStimulator() { +void enableTriggerStimulator(bool incGlobalConfiguration) { startSimulatedTriggerSignal(); engine->triggerCentral.directSelfStimulation = true; engine->rpmCalculator.Register(); - incrementGlobalConfigurationVersion(); + if (incGlobalConfiguration) { + incrementGlobalConfigurationVersion(); + } } // start generating trigger signal on physical outputs diff --git a/firmware/controllers/trigger/trigger_emulator_algo.h b/firmware/controllers/trigger/trigger_emulator_algo.h index 2f662e081d..cae6f94650 100644 --- a/firmware/controllers/trigger/trigger_emulator_algo.h +++ b/firmware/controllers/trigger/trigger_emulator_algo.h @@ -17,7 +17,7 @@ void setTriggerEmulatorRPM(int value); void onConfigurationChangeRpmEmulatorCallback(engine_configuration_s *previousConfiguration); // Start & stop trigger emulation -void enableTriggerStimulator(); +void enableTriggerStimulator(bool incGlobalConfiguration = true); void enableExternalTriggerStimulator(); void disableTriggerStimulator();