auto-sync
This commit is contained in:
parent
b1846be06a
commit
1c996430e7
|
@ -100,22 +100,17 @@ static void doResetConfiguration(void) {
|
||||||
resetConfigurationExt(logger, engineConfiguration->engineType PASS_ENGINE_PARAMETER);
|
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;
|
persisted_configuration_state_e flashState;
|
||||||
|
|
||||||
void readFromFlash(void) {
|
/**
|
||||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 256, "read f");
|
* this method could and should be executed before we have any
|
||||||
printMsg(logger, "readFromFlash()");
|
* 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);
|
flashRead(FLASH_ADDR, (char *) &persistentState, PERSISTENT_SIZE);
|
||||||
|
|
||||||
persisted_configuration_state_e result;
|
persisted_configuration_state_e result;
|
||||||
|
|
||||||
if (!isValidCrc(&persistentState)) {
|
if (!isValidCrc(&persistentState)) {
|
||||||
result = CRC_FAILED;
|
result = CRC_FAILED;
|
||||||
resetConfigurationExt(logger, DEFAULT_ENGINE_TYPE PASS_ENGINE_PARAMETER);
|
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
|
// we can only change the state after the CRC check
|
||||||
engineConfiguration->firmwareVersion = getRusEfiVersion();
|
engineConfiguration->firmwareVersion = getRusEfiVersion();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void readFromFlash(void) {
|
||||||
|
printMsg(logger, "readFromFlash()");
|
||||||
|
readConfiguration();
|
||||||
|
|
||||||
|
persisted_configuration_state_e result = readConfiguration();
|
||||||
|
|
||||||
|
|
||||||
if (result == CRC_FAILED) {
|
if (result == CRC_FAILED) {
|
||||||
printMsg(logger, "Need to reset flash to default due to CRC");
|
printMsg(logger, "Need to reset flash to default due to CRC");
|
||||||
|
|
|
@ -13,6 +13,15 @@
|
||||||
|
|
||||||
#define FLASH_DATA_VERSION 9200
|
#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 readFromFlash(void);
|
||||||
void initFlash(Logging *sharedLogger);
|
void initFlash(Logging *sharedLogger);
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,12 @@ void applyNewConfiguration(void) {
|
||||||
void runRusEfi(void) {
|
void runRusEfi(void) {
|
||||||
efiAssertVoid(getRemainingStack(chThdSelf()) > 512, "init s");
|
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);
|
msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0);
|
||||||
|
|
||||||
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
|
||||||
|
|
Loading…
Reference in New Issue