]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - bootrom/bootrom.c
oops. in the spirit of cleaner code, don't do stuff twice!
[proxmark3-svn] / bootrom / bootrom.c
index f98c1108faba35f5eba8b0a5b04322c415804d7d..c0522dfad66bd89023a4256ca3cfe4a100df659a 100644 (file)
@@ -117,8 +117,16 @@ void UsbPacketReceived(BYTE *packet, int len)
                     MC_FLASH_COMMAND_PAGEN((c->arg[0]-(int)&_flash_start)/AT91C_IFLASH_PAGE_SIZE) |\r
                     AT91C_MC_FCMD_START_PROG;\r
             }\r
-            while(!(AT91C_BASE_EFC0->EFC_FSR & MC_FLASH_STATUS_READY))\r
+            \r
+            uint32_t sr;\r
+            \r
+            while(!((sr = AT91C_BASE_EFC0->EFC_FSR) & MC_FLASH_STATUS_READY))\r
                 ;\r
+            if(sr & (MC_FLASH_STATUS_LOCKE | MC_FLASH_STATUS_PROGE)) { \r
+                   dont_ack = 1;\r
+                    c->cmd = CMD_NACK;\r
+                    UsbSendPacket(packet, len);\r
+            }\r
             break;\r
 \r
         case CMD_HARDWARE_RESET:\r
@@ -289,6 +297,8 @@ void BootROM(void)
            flash_mode(1);\r
     } else if(BUTTON_PRESS()) {\r
            flash_mode(0);\r
+    } else if(*(uint32_t*)&_osimage_entry == 0xffffffffU) {\r
+           flash_mode(1);\r
     } else {\r
            // jump to Flash address of the osimage entry point (LSBit set for thumb mode)\r
            asm("bx %0\n" : : "r" ( ((int)&_osimage_entry) | 0x1 ) );\r
Impressum, Datenschutz