diff options
Diffstat (limited to 'apps/systemcmds/eeprom/eeprom.c')
-rw-r--r-- | apps/systemcmds/eeprom/eeprom.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/apps/systemcmds/eeprom/eeprom.c b/apps/systemcmds/eeprom/eeprom.c index 90a8a5b9b..afa7b43b8 100644 --- a/apps/systemcmds/eeprom/eeprom.c +++ b/apps/systemcmds/eeprom/eeprom.c @@ -63,17 +63,17 @@ #ifndef PX4_I2C_BUS_ONBOARD # error PX4_I2C_BUS_ONBOARD not defined, cannot locate onboard EEPROM #endif -#if !defined(CONFIG_MTD_AT24XX) || !CONFIG_MTD_AT24XX -# error CONFIG_MTD_AT24XX not defined, no supported EEPROM available -#endif __EXPORT int eeprom_main(int argc, char *argv[]); static void eeprom_start(void); +static void eeprom_erase(void); static void eeprom_ioctl(unsigned operation); static void eeprom_save(const char *name); static void eeprom_load(const char *name); +static bool started = false; + int eeprom_main(int argc, char *argv[]) { if (argc >= 2) { @@ -86,6 +86,9 @@ int eeprom_main(int argc, char *argv[]) if (!strcmp(argv[1], "load_param")) eeprom_load(argv[2]); + if (!strcmp(argv[1], "erase")) + eeprom_erase(); + if (0) { /* these actually require a file on the filesystem... */ if (!strcmp(argv[1], "reformat")) @@ -103,7 +106,6 @@ int eeprom_main(int argc, char *argv[]) static void eeprom_start(void) { - static bool started = false; int ret; if (started) @@ -135,9 +137,24 @@ eeprom_start(void) if (ret < 0) err(1, "failed to mount EEPROM"); + started = true; + errx(0, "mounted EEPROM at /eeprom"); } +extern int at24c_nuke(void); + +static void +eeprom_erase(void) +{ + if (!started) + errx(1, "must be started first"); + + if (at24c_nuke()) + errx(1, "erase failed"); + errx(0, "erase done, reboot now"); +} + static void eeprom_ioctl(unsigned operation) { |