]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Make the bootrom correctly nack in case of flash write error (e.g. due to lock bits)
authorhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Fri, 1 Jan 2010 14:56:25 +0000 (14:56 +0000)
committerhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Fri, 1 Jan 2010 14:56:25 +0000 (14:56 +0000)
bootrom/bootrom.c
include/proxmark3.h

index f98c1108faba35f5eba8b0a5b04322c415804d7d..83794d9f8c65fb1163f683bf99b24f7c104afc3c 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
index 8cbb98c4c3c368ff1261d3b1426ff3bb3f0f6c06..41cf3f563b299fde89a075a45f99a574dbe53e1f 100644 (file)
@@ -36,6 +36,8 @@
 \r
 #define MC_FLASH_COMMAND_KEY                                   ((0x5a)<<24)\r
 #define MC_FLASH_STATUS_READY                                  (1<<0)\r
+#define MC_FLASH_STATUS_LOCKE                                  (1<<2)\r
+#define MC_FLASH_STATUS_PROGE                                  (1<<3)\r
 #define MC_FLASH_MODE_FLASH_WAIT_STATES(x)             ((x)<<8)\r
 #define MC_FLASH_MODE_MASTER_CLK_IN_MHZ(x)             ((x)<<16)\r
 #define MC_FLASH_COMMAND_PAGEN(x)                              ((x)<<8)\r
Impressum, Datenschutz