From: zer0 Date: Sat, 24 Apr 2010 20:59:51 +0000 (+0200) Subject: eeprom check is better X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4f7bc6a1332aa9cd2ac3cf8f34bf990203cb03e7;p=aversive.git eeprom check is better --- diff --git a/projects/microb2010/ballboard/main.c b/projects/microb2010/ballboard/main.c index 725a89d..925109f 100755 --- a/projects/microb2010/ballboard/main.c +++ b/projects/microb2010/ballboard/main.c @@ -170,13 +170,17 @@ int main(void) # error not supported #endif - eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_BALLBOARD); /* check eeprom to avoid to run the bad program */ if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) != EEPROM_MAGIC_BALLBOARD) { + int c; sei(); - printf_P(PSTR("Bad eeprom value\r\n")); - while(1); + printf_P(PSTR("Bad eeprom value ('f' to force)\r\n")); + c = uart_recv(CMDLINE_UART); + if (c == 'f') + eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_BALLBOARD); + wait_ms(100); + bootloader(); } /* LOGS */ diff --git a/projects/microb2010/cobboard/main.c b/projects/microb2010/cobboard/main.c index 7a3d240..215fb5c 100755 --- a/projects/microb2010/cobboard/main.c +++ b/projects/microb2010/cobboard/main.c @@ -173,13 +173,17 @@ int main(void) # error not supported #endif - eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_COBBOARD); /* check eeprom to avoid to run the bad program */ if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) != EEPROM_MAGIC_COBBOARD) { + int c; sei(); - printf_P(PSTR("Bad eeprom value\r\n")); - while(1); + printf_P(PSTR("Bad eeprom value ('f' to force)\r\n")); + c = uart_recv(CMDLINE_UART); + if (c == 'f') + eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_COBBOARD); + wait_ms(100); + bootloader(); } /* LOGS */ diff --git a/projects/microb2010/mainboard/main.c b/projects/microb2010/mainboard/main.c index 14a2aad..8616303 100755 --- a/projects/microb2010/mainboard/main.c +++ b/projects/microb2010/mainboard/main.c @@ -196,13 +196,17 @@ int main(void) fdevopen(uart1_dev_send, uart1_dev_recv); #endif - //eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_MAINBOARD); /* check eeprom to avoid to run the bad program */ if (eeprom_read_byte(EEPROM_MAGIC_ADDRESS) != EEPROM_MAGIC_MAINBOARD) { + int c; sei(); - printf_P(PSTR("Bad eeprom value\r\n")); - while(1); + printf_P(PSTR("Bad eeprom value ('f' to force)\r\n")); + c = uart_recv(CMDLINE_UART); + if (c == 'f') + eeprom_write_byte(EEPROM_MAGIC_ADDRESS, EEPROM_MAGIC_MAINBOARD); + wait_ms(100); + bootloader(); } #endif /* ! HOST_VERSION */