Remove the EFI_NO_CONFIG_WORKING_COPY option (#3630)
* no working copy * oops
This commit is contained in:
parent
f8d59d1031
commit
a37c9bca9e
|
@ -61,8 +61,6 @@
|
||||||
*/
|
*/
|
||||||
#define EFI_TUNER_STUDIO TRUE
|
#define EFI_TUNER_STUDIO TRUE
|
||||||
|
|
||||||
#undef EFI_NO_CONFIG_WORKING_COPY
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bluetooth UART setup support.
|
* Bluetooth UART setup support.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -60,8 +60,6 @@
|
||||||
*/
|
*/
|
||||||
#define EFI_TUNER_STUDIO TRUE
|
#define EFI_TUNER_STUDIO TRUE
|
||||||
|
|
||||||
#define EFI_NO_CONFIG_WORKING_COPY TRUE
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bluetooth UART setup support.
|
* Bluetooth UART setup support.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -89,15 +89,6 @@
|
||||||
#include "rusEfiFunctionalTest.h"
|
#include "rusEfiFunctionalTest.h"
|
||||||
#endif /* EFI_SIMULATOR */
|
#endif /* EFI_SIMULATOR */
|
||||||
|
|
||||||
#if !defined(EFI_NO_CONFIG_WORKING_COPY)
|
|
||||||
/**
|
|
||||||
* this is a local copy of the configuration. Any changes to this copy
|
|
||||||
* have no effect until this copy is explicitly propagated to the main working copy
|
|
||||||
*/
|
|
||||||
persistent_config_s configWorkingCopy;
|
|
||||||
|
|
||||||
#endif /* EFI_NO_CONFIG_WORKING_COPY */
|
|
||||||
|
|
||||||
static void printErrorCounters() {
|
static void printErrorCounters() {
|
||||||
efiPrintf("TunerStudio size=%d / total=%d / errors=%d / H=%d / O=%d / P=%d / B=%d",
|
efiPrintf("TunerStudio size=%d / total=%d / errors=%d / H=%d / O=%d / P=%d / B=%d",
|
||||||
sizeof(tsOutputChannels), tsState.totalCounter, tsState.errorCounter, tsState.queryCommandCounter,
|
sizeof(tsOutputChannels), tsState.totalCounter, tsState.errorCounter, tsState.queryCommandCounter,
|
||||||
|
@ -169,12 +160,8 @@ void tunerStudioDebug(TsChannelBase* tsChannel, const char *msg) {
|
||||||
#endif /* EFI_TUNER_STUDIO_VERBOSE */
|
#endif /* EFI_TUNER_STUDIO_VERBOSE */
|
||||||
}
|
}
|
||||||
|
|
||||||
char *getWorkingPageAddr() {
|
uint8_t* getWorkingPageAddr() {
|
||||||
#ifndef EFI_NO_CONFIG_WORKING_COPY
|
return (uint8_t*)engineConfiguration;
|
||||||
return (char*) &configWorkingCopy.engineConfiguration;
|
|
||||||
#else
|
|
||||||
return (char*) engineConfiguration;
|
|
||||||
#endif /* EFI_NO_CONFIG_WORKING_COPY */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr size_t getTunerStudioPageSize() {
|
static constexpr size_t getTunerStudioPageSize() {
|
||||||
|
@ -199,39 +186,6 @@ static void handlePageSelectCommand(TsChannelBase *tsChannel, ts_response_format
|
||||||
sendOkResponse(tsChannel, mode);
|
sendOkResponse(tsChannel, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy specified amount of bytes from specified offset from communication layer working copy into real configuration
|
|
||||||
*
|
|
||||||
* Some changes like changing VE table or timing table are applied right away, meaning
|
|
||||||
* that the values are copied from communication copy into actual engine control copy right away.
|
|
||||||
* We call these parameters 'soft parameters'
|
|
||||||
*
|
|
||||||
* This is needed to support TS online auto-tune.
|
|
||||||
*
|
|
||||||
* On the contrary, 'hard parameters' are waiting for the Burn button to be clicked and configuration version
|
|
||||||
* would be increased and much more complicated logic would be executed.
|
|
||||||
*/
|
|
||||||
static void onlineApplyWorkingCopyBytes(uint32_t offset, int count) {
|
|
||||||
if (offset >= sizeof(engine_configuration_s)) {
|
|
||||||
int maxSize = sizeof(persistent_config_s) - offset;
|
|
||||||
if (count > maxSize) {
|
|
||||||
warning(CUSTOM_TS_OVERFLOW, "TS overflow %d %d", offset, count);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
efiPrintf("applying soft change from %d length %d", offset, count);
|
|
||||||
#if !defined(EFI_NO_CONFIG_WORKING_COPY)
|
|
||||||
memcpy(((char*)config) + offset, ((char*) &configWorkingCopy) + offset,
|
|
||||||
count);
|
|
||||||
#endif /* EFI_NO_CONFIG_WORKING_COPY */
|
|
||||||
|
|
||||||
}
|
|
||||||
// todo: ECU does not burn while engine is running yet tune CRC
|
|
||||||
// tune CRC is calculated based on the latest online part (FSIO formulas are in online region of the tune)
|
|
||||||
// open question what's the best strategy to balance coding efforts, performance matters and tune crc functionality
|
|
||||||
// open question what is the runtime cost of wiping 2K of bytes on each IO communication, could be that 2K of byte memset
|
|
||||||
// is negligable comparing with the IO costs?
|
|
||||||
}
|
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
|
|
||||||
static const void * getStructAddr(live_data_e structId) {
|
static const void * getStructAddr(live_data_e structId) {
|
||||||
|
@ -326,7 +280,6 @@ void handleWriteChunkCommand(TsChannelBase* tsChannel, ts_response_format_e mode
|
||||||
if (!rebootForPresetPending) {
|
if (!rebootForPresetPending) {
|
||||||
uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset);
|
uint8_t * addr = (uint8_t *) (getWorkingPageAddr() + offset);
|
||||||
memcpy(addr, content, count);
|
memcpy(addr, content, count);
|
||||||
onlineApplyWorkingCopyBytes(offset, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendOkResponse(tsChannel, mode);
|
sendOkResponse(tsChannel, mode);
|
||||||
|
@ -342,7 +295,7 @@ static void handleCrc32Check(TsChannelBase *tsChannel, ts_response_format_e mode
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* start = getWorkingPageAddr() + offset;
|
const uint8_t* start = getWorkingPageAddr() + offset;
|
||||||
|
|
||||||
uint32_t crc = SWAP_UINT32(crc32(start, count));
|
uint32_t crc = SWAP_UINT32(crc32(start, count));
|
||||||
tsChannel->sendResponse(mode, (const uint8_t *) &crc, 4);
|
tsChannel->sendResponse(mode, (const uint8_t *) &crc, 4);
|
||||||
|
@ -373,8 +326,6 @@ static void handleWriteValueCommand(TsChannelBase* tsChannel, ts_response_format
|
||||||
// Skip the write if a preset was just loaded - we don't want to overwrite it
|
// Skip the write if a preset was just loaded - we don't want to overwrite it
|
||||||
if (!rebootForPresetPending) {
|
if (!rebootForPresetPending) {
|
||||||
getWorkingPageAddr()[offset] = value;
|
getWorkingPageAddr()[offset] = value;
|
||||||
|
|
||||||
onlineApplyWorkingCopyBytes(offset, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +345,7 @@ static void handlePageReadCommand(TsChannelBase* tsChannel, ts_response_format_e
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *addr = (const uint8_t *) (getWorkingPageAddr() + offset);
|
const uint8_t* addr = getWorkingPageAddr() + offset;
|
||||||
tsChannel->sendResponse(mode, addr, count);
|
tsChannel->sendResponse(mode, addr, count);
|
||||||
#if EFI_TUNER_STUDIO_VERBOSE
|
#if EFI_TUNER_STUDIO_VERBOSE
|
||||||
// efiPrintf("Sending %d done", count);
|
// efiPrintf("Sending %d done", count);
|
||||||
|
@ -430,10 +381,6 @@ void handleBurnCommand(TsChannelBase* tsChannel, ts_response_format_e mode) {
|
||||||
|
|
||||||
// Skip the burn if a preset was just loaded - we don't want to overwrite it
|
// Skip the burn if a preset was just loaded - we don't want to overwrite it
|
||||||
if (!rebootForPresetPending) {
|
if (!rebootForPresetPending) {
|
||||||
#if !defined(EFI_NO_CONFIG_WORKING_COPY)
|
|
||||||
memcpy(config, &configWorkingCopy, sizeof(persistent_config_s));
|
|
||||||
#endif /* EFI_NO_CONFIG_WORKING_COPY */
|
|
||||||
|
|
||||||
requestBurn();
|
requestBurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,15 +526,6 @@ void TunerstudioThread::ThreadTask() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy real configuration into the communications layer working copy
|
|
||||||
*/
|
|
||||||
void syncTunerStudioCopy(void) {
|
|
||||||
#if !defined(EFI_NO_CONFIG_WORKING_COPY)
|
|
||||||
memcpy(&configWorkingCopy, &persistentState.persistentConfiguration, sizeof(persistent_config_s));
|
|
||||||
#endif /* EFI_NO_CONFIG_WORKING_COPY */
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // EFI_TUNER_STUDIO
|
#endif // EFI_TUNER_STUDIO
|
||||||
|
|
||||||
tunerstudio_counters_s tsState;
|
tunerstudio_counters_s tsState;
|
||||||
|
@ -891,7 +829,6 @@ void startTunerStudioConnectivity(void) {
|
||||||
// char (*__kaboom)[sizeof(persistent_config_s)] = 1;
|
// char (*__kaboom)[sizeof(persistent_config_s)] = 1;
|
||||||
|
|
||||||
memset(&tsState, 0, sizeof(tsState));
|
memset(&tsState, 0, sizeof(tsState));
|
||||||
syncTunerStudioCopy();
|
|
||||||
|
|
||||||
addConsoleAction("tsinfo", printTsStats);
|
addConsoleAction("tsinfo", printTsStats);
|
||||||
addConsoleAction("reset_ts", resetTs);
|
addConsoleAction("reset_ts", resetTs);
|
||||||
|
|
|
@ -29,7 +29,7 @@ extern tunerstudio_counters_s tsState;
|
||||||
void tunerStudioDebug(TsChannelBase* tsChannel, const char *msg);
|
void tunerStudioDebug(TsChannelBase* tsChannel, const char *msg);
|
||||||
void tunerStudioError(TsChannelBase* tsChannel, const char *msg);
|
void tunerStudioError(TsChannelBase* tsChannel, const char *msg);
|
||||||
|
|
||||||
char *getWorkingPageAddr();
|
uint8_t* getWorkingPageAddr();
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
#include "thread_controller.h"
|
#include "thread_controller.h"
|
||||||
|
@ -53,7 +53,6 @@ void printTsStats(void);
|
||||||
void requestBurn(void);
|
void requestBurn(void);
|
||||||
|
|
||||||
void startTunerStudioConnectivity(void);
|
void startTunerStudioConnectivity(void);
|
||||||
void syncTunerStudioCopy(void);
|
|
||||||
|
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
// GCC
|
// GCC
|
||||||
|
|
|
@ -1127,10 +1127,6 @@ void resetConfigurationExt(configuration_callback_t boardCallback, engine_type_e
|
||||||
firmwareError(CUSTOM_UNEXPECTED_ENGINE_TYPE, "Unexpected engine type: %d", engineType);
|
firmwareError(CUSTOM_UNEXPECTED_ENGINE_TYPE, "Unexpected engine type: %d", engineType);
|
||||||
}
|
}
|
||||||
applyNonPersistentConfiguration();
|
applyNonPersistentConfiguration();
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO
|
|
||||||
syncTunerStudioCopy();
|
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void emptyCallbackWithConfiguration(engine_configuration_s * engineConfiguration) {
|
void emptyCallbackWithConfiguration(engine_configuration_s * engineConfiguration) {
|
||||||
|
|
|
@ -22,10 +22,6 @@ bool hasFirmwareErrorFlag = false;
|
||||||
const char *dbg_panic_file;
|
const char *dbg_panic_file;
|
||||||
int dbg_panic_line;
|
int dbg_panic_line;
|
||||||
|
|
||||||
#if EFI_TUNER_STUDIO && !defined(EFI_NO_CONFIG_WORKING_COPY)
|
|
||||||
extern persistent_config_s configWorkingCopy;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char* getFirmwareError(void) {
|
const char* getFirmwareError(void) {
|
||||||
return criticalErrorMessageBuffer;
|
return criticalErrorMessageBuffer;
|
||||||
}
|
}
|
||||||
|
@ -120,11 +116,7 @@ bool warning(obd_code_e code, const char *fmt, ...) {
|
||||||
|
|
||||||
if (engineConfiguration->showHumanReadableWarning) {
|
if (engineConfiguration->showHumanReadableWarning) {
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
#if defined(EFI_NO_CONFIG_WORKING_COPY)
|
|
||||||
memcpy(persistentState.persistentConfiguration.warning_message, warningBuffer, sizeof(warningBuffer));
|
memcpy(persistentState.persistentConfiguration.warning_message, warningBuffer, sizeof(warningBuffer));
|
||||||
#else /* defined(EFI_NO_CONFIG_WORKING_COPY) */
|
|
||||||
memcpy(configWorkingCopy.warning_message, warningBuffer, sizeof(warningBuffer));
|
|
||||||
#endif /* defined(EFI_NO_CONFIG_WORKING_COPY) */
|
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
#endif /* EFI_TUNER_STUDIO */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,12 +351,6 @@ static void getByte(int offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onConfigurationChanged() {
|
static void onConfigurationChanged() {
|
||||||
#if EFI_TUNER_STUDIO
|
|
||||||
// on start-up rusEfi would read from working copy of TS while
|
|
||||||
// we have a lot of console commands which write into real copy of configuration directly
|
|
||||||
// we have a bit of a mess here
|
|
||||||
syncTunerStudioCopy();
|
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
|
||||||
incrementGlobalConfigurationVersion();
|
incrementGlobalConfigurationVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,7 +741,7 @@ void initEngineContoller() {
|
||||||
* UNUSED_SIZE constants.
|
* UNUSED_SIZE constants.
|
||||||
*/
|
*/
|
||||||
#ifndef RAM_UNUSED_SIZE
|
#ifndef RAM_UNUSED_SIZE
|
||||||
#define RAM_UNUSED_SIZE 8000
|
#define RAM_UNUSED_SIZE 26000
|
||||||
#endif
|
#endif
|
||||||
#ifndef CCM_UNUSED_SIZE
|
#ifndef CCM_UNUSED_SIZE
|
||||||
#define CCM_UNUSED_SIZE 16
|
#define CCM_UNUSED_SIZE 16
|
||||||
|
|
|
@ -325,16 +325,6 @@ static void rewriteConfig() {
|
||||||
writeToFlashNow();
|
writeToFlashNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writeConfigCommand() {
|
|
||||||
#if EFI_TUNER_STUDIO
|
|
||||||
// on start-up rusEfi would read from working copy of TS while
|
|
||||||
// we have a lot of console commands which write into real copy of configuration directly
|
|
||||||
// we have a bit of a mess here
|
|
||||||
syncTunerStudioCopy();
|
|
||||||
#endif /* EFI_TUNER_STUDIO */
|
|
||||||
writeToFlashNow();
|
|
||||||
}
|
|
||||||
|
|
||||||
void initFlash() {
|
void initFlash() {
|
||||||
#if EFI_STORAGE_EXT_SNOR == TRUE
|
#if EFI_STORAGE_EXT_SNOR == TRUE
|
||||||
mfs_error_t err;
|
mfs_error_t err;
|
||||||
|
@ -359,7 +349,7 @@ void initFlash() {
|
||||||
/**
|
/**
|
||||||
* This would write NOW (you should not be doing this while connected to real engine)
|
* This would write NOW (you should not be doing this while connected to real engine)
|
||||||
*/
|
*/
|
||||||
addConsoleAction(CMD_WRITECONFIG, writeConfigCommand);
|
addConsoleAction(CMD_WRITECONFIG, writeToFlashNow);
|
||||||
#if EFI_TUNER_STUDIO
|
#if EFI_TUNER_STUDIO
|
||||||
/**
|
/**
|
||||||
* This would schedule write to flash once the engine is stopped
|
* This would schedule write to flash once the engine is stopped
|
||||||
|
|
|
@ -69,7 +69,7 @@ TEST(binary, testWriteCrc) {
|
||||||
|
|
||||||
TEST(TunerstudioCommands, writeChunkEngineConfig) {
|
TEST(TunerstudioCommands, writeChunkEngineConfig) {
|
||||||
EngineTestHelper eth(TEST_ENGINE);
|
EngineTestHelper eth(TEST_ENGINE);
|
||||||
MockTsChannel channel;
|
::testing::NiceMock<MockTsChannel> channel;
|
||||||
|
|
||||||
uint8_t* configBytes = reinterpret_cast<uint8_t*>(config);
|
uint8_t* configBytes = reinterpret_cast<uint8_t*>(config);
|
||||||
|
|
||||||
|
@ -81,29 +81,5 @@ TEST(TunerstudioCommands, writeChunkEngineConfig) {
|
||||||
uint8_t val = 50;
|
uint8_t val = 50;
|
||||||
handleWriteChunkCommand(&channel, TS_CRC, 100, 1, &val);
|
handleWriteChunkCommand(&channel, TS_CRC, 100, 1, &val);
|
||||||
|
|
||||||
// hasn't changed yet
|
|
||||||
EXPECT_EQ(configBytes[100], 0);
|
|
||||||
|
|
||||||
handleBurnCommand(&channel, TS_CRC);
|
|
||||||
|
|
||||||
EXPECT_EQ(configBytes[100], 50);
|
EXPECT_EQ(configBytes[100], 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TunerstudioCommands, writeChunkOutsideEngineConfig) {
|
|
||||||
EngineTestHelper eth(TEST_ENGINE);
|
|
||||||
MockTsChannel channel;
|
|
||||||
|
|
||||||
uint8_t* configBytes = reinterpret_cast<uint8_t*>(config);
|
|
||||||
|
|
||||||
size_t offset = sizeof(engine_configuration_s) + 100;
|
|
||||||
|
|
||||||
// Contains zero before the write
|
|
||||||
configBytes[offset] = 0;
|
|
||||||
EXPECT_EQ(configBytes[offset], 0);
|
|
||||||
|
|
||||||
// one step - writes past engineConfiguration don't need a burn
|
|
||||||
uint8_t val = 50;
|
|
||||||
handleWriteChunkCommand(&channel, TS_CRC, offset, 1, &val);
|
|
||||||
|
|
||||||
EXPECT_EQ(configBytes[offset], 50);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue