]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - bootrom/bootrom.c
Corrected erroneous bit masking
[proxmark3-svn] / bootrom / bootrom.c
index e46297f91a426e55db037ab5742c9a3aecb01c84..53e6924d017d6b32aced8ea9a6f40f59c2b5622d 100644 (file)
@@ -1,3 +1,11 @@
+//-----------------------------------------------------------------------------
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Main code for the bootloader
+//-----------------------------------------------------------------------------
+
 #include <proxmark3.h>
 
 struct common_area common_area __attribute__((section(".commonarea")));
 #include <proxmark3.h>
 
 struct common_area common_area __attribute__((section(".commonarea")));
@@ -69,11 +77,11 @@ static void Fatal(void)
     for(;;);
 }
 
     for(;;);
 }
 
-void UsbPacketReceived(BYTE *packet, int len)
+void UsbPacketReceived(uint8_t *packet, int len)
 {
     int i, dont_ack=0;
     UsbCommand *c = (UsbCommand *)packet;
 {
     int i, dont_ack=0;
     UsbCommand *c = (UsbCommand *)packet;
-    volatile DWORD *p;
+    volatile uint32_t *p;
 
     if(len != sizeof(*c)) {
         Fatal();
 
     if(len != sizeof(*c)) {
         Fatal();
@@ -93,14 +101,14 @@ void UsbPacketReceived(BYTE *packet, int len)
             /* The temporary write buffer of the embedded flash controller is mapped to the
              * whole memory region, only the last 8 bits are decoded.
              */
             /* The temporary write buffer of the embedded flash controller is mapped to the
              * whole memory region, only the last 8 bits are decoded.
              */
-            p = (volatile DWORD *)&_flash_start;
+            p = (volatile uint32_t *)&_flash_start;
             for(i = 0; i < 12; i++) {
                 p[i+c->arg[0]] = c->d.asDwords[i];
             }
             break;
 
         case CMD_FINISH_WRITE:
             for(i = 0; i < 12; i++) {
                 p[i+c->arg[0]] = c->d.asDwords[i];
             }
             break;
 
         case CMD_FINISH_WRITE:
-            p = (volatile DWORD *)&_flash_start;
+            p = (volatile uint32_t *)&_flash_start;
             for(i = 0; i < 4; i++) {
                 p[i+60] = c->d.asDwords[i];
             }
             for(i = 0; i < 4; i++) {
                 p[i+60] = c->d.asDwords[i];
             }
@@ -117,12 +125,12 @@ void UsbPacketReceived(BYTE *packet, int len)
                     MC_FLASH_COMMAND_PAGEN((c->arg[0]-(int)&_flash_start)/AT91C_IFLASH_PAGE_SIZE) |
                     AT91C_MC_FCMD_START_PROG;
             }
                     MC_FLASH_COMMAND_PAGEN((c->arg[0]-(int)&_flash_start)/AT91C_IFLASH_PAGE_SIZE) |
                     AT91C_MC_FCMD_START_PROG;
             }
-            
+
             uint32_t sr;
             uint32_t sr;
-            
+
             while(!((sr = AT91C_BASE_EFC0->EFC_FSR) & MC_FLASH_STATUS_READY))
                 ;
             while(!((sr = AT91C_BASE_EFC0->EFC_FSR) & MC_FLASH_STATUS_READY))
                 ;
-            if(sr & (MC_FLASH_STATUS_LOCKE | MC_FLASH_STATUS_PROGE)) { 
+            if(sr & (MC_FLASH_STATUS_LOCKE | MC_FLASH_STATUS_PROGE)) {
                    dont_ack = 1;
                     c->cmd = CMD_NACK;
                     UsbSendPacket(packet, len);
                    dont_ack = 1;
                     c->cmd = CMD_NACK;
                     UsbSendPacket(packet, len);
@@ -249,7 +257,7 @@ void BootROM(void)
     LED_A_OFF();
 
     // if 512K FLASH part - TODO make some defines :)
     LED_A_OFF();
 
     // if 512K FLASH part - TODO make some defines :)
-    if ((AT91C_BASE_DBGU->DBGU_CIDR | 0xf00) == 0xa00) {
+    if ((AT91C_BASE_DBGU->DBGU_CIDR & 0xf00) == 0xa00) {
            AT91C_BASE_EFC0->EFC_FMR =
                MC_FLASH_MODE_FLASH_WAIT_STATES(1) |
                        MC_FLASH_MODE_MASTER_CLK_IN_MHZ(0x48);
            AT91C_BASE_EFC0->EFC_FMR =
                MC_FLASH_MODE_FLASH_WAIT_STATES(1) |
                        MC_FLASH_MODE_MASTER_CLK_IN_MHZ(0x48);
Impressum, Datenschutz