mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
224bf325a7
commit
1eec06cb51
|
@ -187,7 +187,7 @@ void setHondaAccordConfigurationThreeWires(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
|
|
||||||
void setHondaAccordConfigurationDip(DECLARE_ENGINE_PARAMETER_F) {
|
void setHondaAccordConfigurationDip(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
engineConfiguration->engineType = HONDA_ACCORD_CD_DIP;
|
engineConfiguration->engineType = HONDA_ACCORD_CD_DIP;
|
||||||
engineConfiguration->trigger.type = TT_HONDA_ACCORD_CD_DIP;
|
engineConfiguration->trigger.type = TT_HONDA_1_4_24;
|
||||||
setHondaAccordConfigurationCommon(PASS_ENGINE_PARAMETER_F);
|
setHondaAccordConfigurationCommon(PASS_ENGINE_PARAMETER_F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,8 +167,8 @@ case TT_DODGE_STRATUS:
|
||||||
return "TT_DODGE_STRATUS";
|
return "TT_DODGE_STRATUS";
|
||||||
case TT_36_2_2_2:
|
case TT_36_2_2_2:
|
||||||
return "TT_36_2_2_2";
|
return "TT_36_2_2_2";
|
||||||
case TT_HONDA_ACCORD_CD_DIP:
|
case TT_HONDA_1_4_24:
|
||||||
return "TT_HONDA_ACCORD_CD_DIP";
|
return "TT_HONDA_1_4_24";
|
||||||
case TT_HONDA_4_24:
|
case TT_HONDA_4_24:
|
||||||
return "TT_HONDA_4_24";
|
return "TT_HONDA_4_24";
|
||||||
case TT_MAZDA_MIATA_NA:
|
case TT_MAZDA_MIATA_NA:
|
||||||
|
|
|
@ -167,7 +167,7 @@ typedef enum {
|
||||||
// this makes sense because mechanical spark distribution does not require synchronization
|
// this makes sense because mechanical spark distribution does not require synchronization
|
||||||
TT_HONDA_4_24 = 12,
|
TT_HONDA_4_24 = 12,
|
||||||
|
|
||||||
TT_HONDA_ACCORD_CD_DIP = 13,
|
TT_HONDA_1_4_24 = 13,
|
||||||
|
|
||||||
// cam-based
|
// cam-based
|
||||||
TT_DODGE_NEON_2003_CAM = 14,
|
TT_DODGE_NEON_2003_CAM = 14,
|
||||||
|
|
|
@ -40,6 +40,14 @@ extern engine_configuration_s *engineConfiguration;
|
||||||
|
|
||||||
#define PERSISTENT_SIZE sizeof(persistent_config_container_s)
|
#define PERSISTENT_SIZE sizeof(persistent_config_container_s)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://sourceforge.net/p/rusefi/tickets/335/
|
||||||
|
*
|
||||||
|
* Address of second cofig copy, rounded to 4K. 4K is the page size is it?
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define FLASH_ADDR_SECOND_COPY (FLASH_ADDR + ((PERSISTENT_SIZE + 4095) & 0xFFFFF000))
|
||||||
|
|
||||||
crc_t flashStateCrc(persistent_config_container_s *state) {
|
crc_t flashStateCrc(persistent_config_container_s *state) {
|
||||||
return calc_crc((const crc_t*) &state->persistentConfiguration, sizeof(persistent_config_s));
|
return calc_crc((const crc_t*) &state->persistentConfiguration, sizeof(persistent_config_s));
|
||||||
}
|
}
|
||||||
|
@ -77,6 +85,7 @@ void writeToFlashNow(void) {
|
||||||
scheduleMsg(logger, "Flashing with CRC=%d", crcResult);
|
scheduleMsg(logger, "Flashing with CRC=%d", crcResult);
|
||||||
efitimems_t nowMs = currentTimeMillis();
|
efitimems_t nowMs = currentTimeMillis();
|
||||||
int result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE);
|
int result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE);
|
||||||
|
flashWrite(FLASH_ADDR_SECOND_COPY, (const char *) &persistentState, PERSISTENT_SIZE);
|
||||||
scheduleMsg(logger, "Flash programmed in %dms", currentTimeMillis() - nowMs);
|
scheduleMsg(logger, "Flash programmed in %dms", currentTimeMillis() - nowMs);
|
||||||
bool isSuccess = result == FLASH_RETURN_SUCCESS;
|
bool isSuccess = result == FLASH_RETURN_SUCCESS;
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
@ -99,27 +108,41 @@ static void doResetConfiguration(void) {
|
||||||
|
|
||||||
persisted_configuration_state_e flashState;
|
persisted_configuration_state_e flashState;
|
||||||
|
|
||||||
|
static persisted_configuration_state_e doReadConfiguration(flashaddr_t address, Logging * logger) {
|
||||||
|
printMsg(logger, "readFromFlash %x", address);
|
||||||
|
flashRead(address, (char *) &persistentState, PERSISTENT_SIZE);
|
||||||
|
|
||||||
|
if (!isValidCrc(&persistentState)) {
|
||||||
|
return CRC_FAILED;
|
||||||
|
} else if (persistentState.version != FLASH_DATA_VERSION || persistentState.size != PERSISTENT_SIZE) {
|
||||||
|
return INCOMPATIBLE_VERSION;
|
||||||
|
} else {
|
||||||
|
return PC_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method could and should be executed before we have any
|
* this method could and should be executed before we have any
|
||||||
* connectivity so no console output here
|
* connectivity so no console output here
|
||||||
*/
|
*/
|
||||||
persisted_configuration_state_e readConfiguration(Logging * logger) {
|
persisted_configuration_state_e readConfiguration(Logging * logger) {
|
||||||
efiAssert(getRemainingStack(chThdSelf()) > 256, "read f", PC_ERROR);
|
efiAssert(getRemainingStack(chThdSelf()) > 256, "read f", PC_ERROR);
|
||||||
flashRead(FLASH_ADDR, (char *) &persistentState, PERSISTENT_SIZE);
|
|
||||||
|
|
||||||
persisted_configuration_state_e result;
|
persisted_configuration_state_e result = doReadConfiguration(FLASH_ADDR, logger);
|
||||||
if (!isValidCrc(&persistentState)) {
|
if (result != PC_OK) {
|
||||||
result = CRC_FAILED;
|
printMsg(logger, "Reading second configuration copy");
|
||||||
|
result = doReadConfiguration(FLASH_ADDR_SECOND_COPY, logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == CRC_FAILED) {
|
||||||
warning(CUSTOM_ERR_FLASH_CRC_FAILED, "flash CRC failed");
|
warning(CUSTOM_ERR_FLASH_CRC_FAILED, "flash CRC failed");
|
||||||
resetConfigurationExt(logger, DEFAULT_ENGINE_TYPE PASS_ENGINE_PARAMETER);
|
resetConfigurationExt(logger, DEFAULT_ENGINE_TYPE PASS_ENGINE_PARAMETER);
|
||||||
} else if (persistentState.version != FLASH_DATA_VERSION || persistentState.size != PERSISTENT_SIZE) {
|
} else if (result == INCOMPATIBLE_VERSION) {
|
||||||
result = INCOMPATIBLE_VERSION;
|
|
||||||
resetConfigurationExt(logger, engineConfiguration->engineType PASS_ENGINE_PARAMETER);
|
resetConfigurationExt(logger, engineConfiguration->engineType PASS_ENGINE_PARAMETER);
|
||||||
} else {
|
} else {
|
||||||
/**
|
/**
|
||||||
* At this point we know that CRC and version number is what we expect. Safe to assume it's a valid configuration.
|
* At this point we know that CRC and version number is what we expect. Safe to assume it's a valid configuration.
|
||||||
*/
|
*/
|
||||||
result = OK;
|
|
||||||
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
|
applyNonPersistentConfiguration(logger PASS_ENGINE_PARAMETER);
|
||||||
}
|
}
|
||||||
// we can only change the state after the CRC check
|
// we can only change the state after the CRC check
|
||||||
|
@ -128,7 +151,6 @@ persisted_configuration_state_e readConfiguration(Logging * logger) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void readFromFlash(void) {
|
void readFromFlash(void) {
|
||||||
printMsg(logger, "readFromFlash()");
|
|
||||||
persisted_configuration_state_e result = readConfiguration(logger);
|
persisted_configuration_state_e result = readConfiguration(logger);
|
||||||
|
|
||||||
if (result == CRC_FAILED) {
|
if (result == CRC_FAILED) {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define FLASH_DATA_VERSION 10000
|
#define FLASH_DATA_VERSION 10000
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OK = 0,
|
PC_OK = 0,
|
||||||
CRC_FAILED = 1,
|
CRC_FAILED = 1,
|
||||||
INCOMPATIBLE_VERSION = 2,
|
INCOMPATIBLE_VERSION = 2,
|
||||||
RESET_REQUESTED = 3,
|
RESET_REQUESTED = 3,
|
||||||
|
|
|
@ -538,7 +538,7 @@ void TriggerShape::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMET
|
||||||
configureHondaAccordShifted(triggerShape PASS_ENGINE_PARAMETER);
|
configureHondaAccordShifted(triggerShape PASS_ENGINE_PARAMETER);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TT_HONDA_ACCORD_CD_DIP:
|
case TT_HONDA_1_4_24:
|
||||||
configureHondaAccordCDDip(triggerShape PASS_ENGINE_PARAMETER);
|
configureHondaAccordCDDip(triggerShape PASS_ENGINE_PARAMETER);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -249,5 +249,5 @@ int getRusEfiVersion(void) {
|
||||||
return 123; // this is here to make the compiler happy about the unused array
|
return 123; // this is here to make the compiler happy about the unused array
|
||||||
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
if (UNUSED_CCM_SIZE[0] * 0 != 0)
|
||||||
return 3211; // this is here to make the compiler happy about the unused array
|
return 3211; // this is here to make the compiler happy about the unused array
|
||||||
return 20170213;
|
return 20170214;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue