]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - bootrom/bootrom.c
ADD: added a StopTicks functions, to disable the timer used for ticks (TC0, TC1)
[proxmark3-svn] / bootrom / bootrom.c
index 63c04ae5c952ab4ec61aac15f1d61ba4b188e5a4..26231b01541cefdb79d32fd26c60fd2b728ded57 100644 (file)
@@ -49,8 +49,7 @@ static void ConfigClocks(void)
         PMC_MAIN_OSC_STARTUP_DELAY(8);
 
        // wait for main oscillator to stabilize
         PMC_MAIN_OSC_STARTUP_DELAY(8);
 
        // wait for main oscillator to stabilize
-       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS) )
-               ;
+       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS) ) {};
 
     // PLL output clock frequency in range  80 - 160 MHz needs CKGR_PLL = 00
     // PLL output clock frequency in range 150 - 180 MHz needs CKGR_PLL = 10
 
     // PLL output clock frequency in range  80 - 160 MHz needs CKGR_PLL = 00
     // PLL output clock frequency in range 150 - 180 MHz needs CKGR_PLL = 10
@@ -63,8 +62,7 @@ static void ConfigClocks(void)
                PMC_PLL_USB_DIVISOR(1);
 
        // wait for PLL to lock
                PMC_PLL_USB_DIVISOR(1);
 
        // wait for PLL to lock
-       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK) )
-               ;
+       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK) ) {};
 
        // we want a master clock (MCK) to be PLL clock / 2 = 96Mhz / 2 = 48Mhz
        // datasheet recommends that this register is programmed in two operations
 
        // we want a master clock (MCK) to be PLL clock / 2 = 96Mhz / 2 = 48Mhz
        // datasheet recommends that this register is programmed in two operations
@@ -72,15 +70,13 @@ static void ConfigClocks(void)
     AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
 
        // wait for main clock ready signal
     AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
 
        // wait for main clock ready signal
-       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) )
-               ;
+       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) ) {};
 
        // set the source to PLL
     AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2 | AT91C_PMC_CSS_PLL_CLK;
 
        // wait for main clock ready signal
 
        // set the source to PLL
     AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2 | AT91C_PMC_CSS_PLL_CLK;
 
        // wait for main clock ready signal
-       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) )
-               ;
+       while ( !(AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY) ) {};
 }
 
 static void Fatal(void) {
 }
 
 static void Fatal(void) {
@@ -141,10 +137,10 @@ void UsbPacketReceived(uint8_t *packet, int len) {
                                // Wait until flashing of page finishes
                                uint32_t sr;
                                while(!((sr = AT91C_BASE_EFC0->EFC_FSR) & AT91C_MC_FRDY));
                                // Wait until flashing of page finishes
                                uint32_t sr;
                                while(!((sr = AT91C_BASE_EFC0->EFC_FSR) & AT91C_MC_FRDY));
-                                       if(sr & (AT91C_MC_LOCKE | AT91C_MC_PROGE)) {
-                                               dont_ack = 1;
-                                               cmd_send(CMD_NACK,sr,0,0,0,0);
-                                       }
+                               if(sr & (AT91C_MC_LOCKE | AT91C_MC_PROGE)) {
+                                       dont_ack = 1;
+                                       cmd_send(CMD_NACK,sr,0,0,0,0);
+                               }
                        }
                } break;
       
                        }
                } break;
       
@@ -199,8 +195,7 @@ static void flash_mode(int externally_entered)
        size_t rx_len;
 
        usb_enable();
        size_t rx_len;
 
        usb_enable();
-       for (volatile size_t i=0; i<0x100000; i++)
-               ;
+       for (volatile size_t i=0; i<0x100000; i++) {};
 
        for(;;) {
                WDT_HIT();
 
        for(;;) {
                WDT_HIT();
@@ -280,7 +275,11 @@ void BootROM(void)
        AT91C_BASE_EFC0->EFC_FMR =
                AT91C_MC_FWS_1FWS |
                MC_FLASH_MODE_MASTER_CLK_IN_MHZ(48);
        AT91C_BASE_EFC0->EFC_FMR =
                AT91C_MC_FWS_1FWS |
                MC_FLASH_MODE_MASTER_CLK_IN_MHZ(48);
-
+#ifdef HAS_512_FLASH
+       AT91C_BASE_EFC1->EFC_FMR =
+               AT91C_MC_FWS_1FWS |
+               MC_FLASH_MODE_MASTER_CLK_IN_MHZ(48);
+#endif 
     // Initialize all system clocks
     ConfigClocks();
 
     // Initialize all system clocks
     ConfigClocks();
 
Impressum, Datenschutz