static bool isValidCrc(persistent_config_container_s *state) { crc_t result = flashStateCrc(state); int isValidCrc_b = result == state->value; if (!isValidCrc_b) { scheduleMsg(logger, "CRC got %d while %d expected", result, state->value); } return isValidCrc_b; }
static int isValidCrc(FlashState *state) { if (state->version != FLASH_DATA_VERSION) { scheduleMsg(&logger, "Unexpected flash version: %d", state->version); return FALSE; } crc result = flashStateCrc(state); int isValidCrc = result == state->value; if (!isValidCrc) scheduleMsg(&logger, "CRC got %d while %d expected", result, state->value); return isValidCrc; }
static int isValidCrc(persistent_config_container_s *state) { if (state->version != FLASH_DATA_VERSION) { scheduleMsg(&logger, "Unexpected flash version: %d", state->version); return FALSE; } crc_t result = flashStateCrc(state); int isValidCrc_b = result == state->value; if (!isValidCrc_b) { scheduleMsg(&logger, "CRC got %d while %d expected", result, state->value); } return isValidCrc_b; }
void writeToFlash(void) { flashState.version = FLASH_DATA_VERSION; scheduleMsg(&logger, "FLASH_DATA_VERSION=%d", flashState.version); crc result = flashStateCrc(&flashState); flashState.value = result; scheduleMsg(&logger, "Reseting flash=%d", FLASH_USAGE); flashErase(FLASH_ADDR, FLASH_USAGE); scheduleMsg(&logger, "Flashing with CRC=%d", result); time_t now = chTimeNow(); result = flashWrite(FLASH_ADDR, (const char *) &flashState, FLASH_USAGE); scheduleMsg(&logger, "Flash programmed in (ms): %d", chTimeNow() - now); scheduleMsg(&logger, "Flashed: %d", result); }
void writeToFlash(void) { #if EFI_INTERNAL_FLASH persistentState.size = PERSISTENT_SIZE; persistentState.version = FLASH_DATA_VERSION; scheduleMsg(&logger, "flash compatible with %d", persistentState.version); crc_t result = flashStateCrc(&persistentState); persistentState.value = result; scheduleMsg(&logger, "Reseting flash: size=%d", PERSISTENT_SIZE); flashErase(FLASH_ADDR, PERSISTENT_SIZE); scheduleMsg(&logger, "Flashing with CRC=%d", result); efitimems_t nowMs = currentTimeMillis(); result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE); scheduleMsg(&logger, "Flash programmed in (ms): %d", currentTimeMillis() - nowMs); scheduleMsg(&logger, "Flashing result: %d", result); #endif /* EFI_INTERNAL_FLASH */ }
void writeToFlashNow(void) { scheduleMsg(logger, " !!!!!!!!!!!!!!!!!!!! BE SURE NOT WRITE WITH IGNITION ON !!!!!!!!!!!!!!!!!!!!"); persistentState.size = PERSISTENT_SIZE; persistentState.version = FLASH_DATA_VERSION; scheduleMsg(logger, "flash compatible with %d", persistentState.version); crc_t crcResult = flashStateCrc(&persistentState); persistentState.value = crcResult; scheduleMsg(logger, "Reseting flash: size=%d", PERSISTENT_SIZE); flashErase(FLASH_ADDR, PERSISTENT_SIZE); scheduleMsg(logger, "Flashing with CRC=%d", crcResult); efitimems_t nowMs = currentTimeMillis(); int result = flashWrite(FLASH_ADDR, (const char *) &persistentState, PERSISTENT_SIZE); scheduleMsg(logger, "Flash programmed in %dms", currentTimeMillis() - nowMs); bool isSuccess = result == FLASH_RETURN_SUCCESS; if (isSuccess) { scheduleMsg(logger, FLASH_SUCCESS_MSG); } else { scheduleMsg(logger, "Flashing failed"); } maxLockTime = 0; }
static bool isValidCrc(persistent_config_container_s *state) { crc_t result = flashStateCrc(state); int isValidCrc_b = result == state->value; return isValidCrc_b; }