From b03de3095ec3e6a2bee29676f12f18a385b0f921 Mon Sep 17 00:00:00 2001 From: Doug Weibel Date: Mon, 28 Nov 2011 19:42:27 -0700 Subject: [PATCH] Add DataFlash.Init before doing a forced log erase on eeprom reset. Add progress indication during log erase --- ArduCopter/Log.pde | 1 + ArduCopter/system.pde | 6 ++++++ ArduPlane/Log.pde | 1 + ArduPlane/system.pde | 35 +++++++++++++++-------------------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/ArduCopter/Log.pde b/ArduCopter/Log.pde index b88c1da507..c9adce420f 100644 --- a/ArduCopter/Log.pde +++ b/ArduCopter/Log.pde @@ -136,6 +136,7 @@ erase_logs(uint8_t argc, const Menu::arg *argv) for(int j = 1; j <= DF_LAST_PAGE; j++) { DataFlash.PageErase(j); DataFlash.StartWrite(j); // We need this step to clean FileNumbers + if(j%128 == 0) Serial.printf_P(PSTR("+")); } g.log_last_filenumber.set_and_save(0); diff --git a/ArduCopter/system.pde b/ArduCopter/system.pde index de883542e3..9618148c66 100644 --- a/ArduCopter/system.pde +++ b/ArduCopter/system.pde @@ -163,6 +163,12 @@ static void init_ardupilot() Serial.printf_P(PSTR("Firmware change: erasing EEPROM...\n")); delay(100); // wait for serial send AP_Var::erase_all(); + + // erase DataFlash on format version change + #if LOGGING_ENABLED == ENABLED + DataFlash.Init(); + erase_logs(NULL, NULL); + #endif // clear logs - createing infinate lockup //erase_logs(NULL, NULL); diff --git a/ArduPlane/Log.pde b/ArduPlane/Log.pde index f5d2aa57e2..b6b8d22a4b 100644 --- a/ArduPlane/Log.pde +++ b/ArduPlane/Log.pde @@ -140,6 +140,7 @@ erase_logs(uint8_t argc, const Menu::arg *argv) for(int j = 1; j <= DF_LAST_PAGE; j++) { DataFlash.PageErase(j); DataFlash.StartWrite(j); // We need this step to clean FileNumbers + if(j%128 == 0) Serial.printf_P(PSTR("+")); } g.log_last_filenumber.set_and_save(0); diff --git a/ArduPlane/system.pde b/ArduPlane/system.pde index e01c4f105a..a571914f6f 100644 --- a/ArduPlane/system.pde +++ b/ArduPlane/system.pde @@ -116,31 +116,26 @@ static void init_ardupilot() // // Check the EEPROM format version before loading any parameters from EEPROM. // - if (!g.format_version.load()) { - - Serial.println_P(PSTR("\nEEPROM blank - resetting all parameters to defaults...\n")); - delay(100); // wait for serial msg to flush - - AP_Var::erase_all(); - - // save the current format version - g.format_version.set_and_save(Parameters::k_format_version); - - } else if (g.format_version != Parameters::k_format_version) { - - Serial.printf_P(PSTR("\n\nEEPROM format version %d not compatible with this firmware (requires %d)" - "\n\nForcing complete parameter reset..."), - g.format_version.get(), Parameters::k_format_version); - delay(100); // wait for serial msg to flush + + if (!g.format_version.load() || + g.format_version != Parameters::k_format_version) { // erase all parameters + Serial.printf_P(PSTR("Firmware change: erasing EEPROM...\n")); + delay(100); // wait for serial send AP_Var::erase_all(); - - // save the new format version + + // erase DataFlash on format version change + #if LOGGING_ENABLED == ENABLED + DataFlash.Init(); + erase_logs(NULL, NULL); + #endif + + // save the current format version g.format_version.set_and_save(Parameters::k_format_version); - Serial.println_P(PSTR("done.")); - } else { + + } else { unsigned long before = micros(); // Load all auto-loaded EEPROM variables AP_Var::load_all();