]> git.droids-corp.org - aversive.git/commitdiff
eeprom check is better
authorzer0 <zer0@carbon.local>
Sat, 24 Apr 2010 20:59:51 +0000 (22:59 +0200)
committerzer0 <zer0@carbon.local>
Sat, 24 Apr 2010 20:59:51 +0000 (22:59 +0200)
projects/microb2010/ballboard/main.c
projects/microb2010/cobboard/main.c
projects/microb2010/mainboard/main.c

index 725a89dc8d3432cac0037bee79a33945519fe06a..925109ff072a4bec687030616327958f5e6b8e03 100755 (executable)
@@ -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 */
index 7a3d2408b7f4f8fe8a06d0dcd8913ab7720968f6..215fb5c0ee895d393d35a4ea9c800029992417e7 100755 (executable)
@@ -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 */
index 14a2aad68ef5b18d140a0fb932e27dc6070c952a..8616303a10cf1e55ce53cb3f170a9a75374281e6 100755 (executable)
@@ -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 */