mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
b4408a9f85
commit
8c7b996fa2
|
@ -100,22 +100,17 @@ static void doResetConfiguration(void) {
|
|||
resetConfigurationExt(logger, engineConfiguration->engineType PASS_ENGINE_PARAMETER);
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
OK = 0,
|
||||
CRC_FAILED = 1,
|
||||
INCOMPATIBLE_VERSION = 2,
|
||||
RESET_REQUESTED = 3
|
||||
} persisted_configuration_state_e;
|
||||
|
||||
persisted_configuration_state_e flashState;
|
||||
|
||||
void readFromFlash(void) {
|
||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "read f");
|
||||
printMsg(logger, "readFromFlash()");
|
||||
/**
|
||||
* this method could and should be executed before we have any
|
||||
* connectivity so no console output here
|
||||
*/
|
||||
persisted_configuration_state_e readConfiguration(void) {
|
||||
efiAssert(getRemainingStack(chThdSelf()) > 256, "read f", PC_ERROR);
|
||||
flashRead(FLASH_ADDR, (char *) &persistentState, PERSISTENT_SIZE);
|
||||
|
||||
persisted_configuration_state_e result;
|
||||
|
||||
if (!isValidCrc(&persistentState)) {
|
||||
result = CRC_FAILED;
|
||||
resetConfigurationExt(logger, DEFAULT_ENGINE_TYPE PASS_ENGINE_PARAMETER);
|
||||
|
@ -131,6 +126,15 @@ void readFromFlash(void) {
|
|||
}
|
||||
// we can only change the state after the CRC check
|
||||
engineConfiguration->firmwareVersion = getRusEfiVersion();
|
||||
return result;
|
||||
}
|
||||
|
||||
void readFromFlash(void) {
|
||||
printMsg(logger, "readFromFlash()");
|
||||
readConfiguration();
|
||||
|
||||
persisted_configuration_state_e result = readConfiguration();
|
||||
|
||||
|
||||
if (result == CRC_FAILED) {
|
||||
printMsg(logger, "Need to reset flash to default due to CRC");
|
||||
|
|
|
@ -13,6 +13,15 @@
|
|||
|
||||
#define FLASH_DATA_VERSION 9200
|
||||
|
||||
typedef enum {
|
||||
OK = 0,
|
||||
CRC_FAILED = 1,
|
||||
INCOMPATIBLE_VERSION = 2,
|
||||
RESET_REQUESTED = 3,
|
||||
PC_ERROR = 4
|
||||
} persisted_configuration_state_e;
|
||||
|
||||
persisted_configuration_state_e readConfiguration(void);
|
||||
void readFromFlash(void);
|
||||
void initFlash(Logging *sharedLogger);
|
||||
|
||||
|
|
|
@ -166,6 +166,12 @@ void applyNewConfiguration(void) {
|
|||
void runRusEfi(void) {
|
||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 512, "init s");
|
||||
|
||||
/**
|
||||
* First thing is reading configuration from flash memory.
|
||||
* In order to have complete flexibility configuration has to go before anything else.
|
||||
*/
|
||||
readConfiguration();
|
||||
|
||||
msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0);
|
||||
|
||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||
|
|
Loading…
Reference in New Issue