diff options
author | Harald Welte <laforge@gnumonks.org> | 2018-07-03 22:31:16 +0200 |
---|---|---|
committer | Kévin Redon <kredon@sysmocom.de> | 2018-08-07 10:00:49 +0000 |
commit | 9547e419eb1df6e75db4af7b9f3ea4061f4d3e1e (patch) | |
tree | d67353eec9eaca8247aea440e5243bdd8184f2c4 | |
parent | 8daba9cc9a6a7575c11cddd393c186615020f867 (diff) |
qmod: Add 'e' command for erasing the EEPROM
Change-Id: Id7cb0db568dd3e9d796829bf0019d63048612998
-rw-r--r-- | firmware/libboard/qmod/source/board_qmod.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/firmware/libboard/qmod/source/board_qmod.c b/firmware/libboard/qmod/source/board_qmod.c index 47a4cb6..acd090f 100644 --- a/firmware/libboard/qmod/source/board_qmod.c +++ b/firmware/libboard/qmod/source/board_qmod.c @@ -102,6 +102,26 @@ static int write_hub_eeprom(void) return 0; } +static int erase_hub_eeprom(void) +{ + int i; + + /* wait */ + mdelay(100); + + TRACE_INFO("Erasing EEPROM...\n\r"); + /* write the EEPROM once */ + for (i = 0; i < 256; i++) { + int rc = eeprom_write_byte(0x50, i, 0xff); + /* if the result was negative, repeat that write */ + if (rc < 0) + i--; + } + + return 0; +} + + static void board_exec_dbg_cmd_st12only(int ch) { uint32_t addr, val; @@ -114,6 +134,9 @@ static void board_exec_dbg_cmd_st12only(int ch) case 'E': write_hub_eeprom(); break; + case 'e': + erase_hub_eeprom(); + break; case 'O': printf("Setting PRTPWR_OVERRIDE\n\r"); PIO_Set(&pin_hubpwr_override); @@ -161,6 +184,7 @@ void board_exec_dbg_cmd(int ch) printf("\tR\treset SAM3\n\r"); if (qmod_sam3_is_12()) { printf("\tE\tprogram EEPROM\n\r"); + printf("\te\tErase EEPROM\n\r"); printf("\tO\tEnable PRTPWR_OVERRIDE\n\r"); printf("\to\tDisable PRTPWR_OVERRIDE\n\r"); printf("\tH\tRelease HUB RESET (high)\n\r"); |