]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/flash.c
Add License/Copyright headers/notices. Please add your own copyright notice if you...
[proxmark3-svn] / client / flash.c
index ee66dbe17da1bd5a7e3146fb7bc970aaa3f8403e..45fa63060bce8eafa0f9740ebc6aa9e92c97c3cc 100644 (file)
@@ -1,20 +1,21 @@
-#ifdef WIN32
-#include <windows.h>
-#include <setupapi.h>
-#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
-BOOL UsbConnect(void);
-#endif
-#include <proxusb.h>
+//-----------------------------------------------------------------------------
+// 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.
+//-----------------------------------------------------------------------------
+// Flashing utility functions
+//-----------------------------------------------------------------------------
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include "sleep.h"
+#include "proxusb.h"
 #include "flash.h"
 #include "elf.h"
 
 static uint32_t ExpectedAddr;
 static uint8_t QueuedToSend[256];
-static bool AllWritten;
 #define PHYSICAL_FLASH_START 0x100000
 #define PHYSICAL_FLASH_END   0x200000
 
@@ -63,8 +64,6 @@ void WriteBlock(unsigned int block_start, unsigned int len, unsigned char *buf)
   memcpy(c.d.asBytes, temp_buf+240, 16);
   SendCommand(&c);
   WaitForAck();
-
-  AllWritten = true;
 }
 
 void LoadFlashFromFile(const char *file, int start_addr, int end_addr)
@@ -197,7 +196,7 @@ unsigned int EnterFlashState(void)
   if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
     fprintf(stderr,"Entering flash-mode...\n");
     UsbCommand c;
-    bzero(&c, sizeof(c));
+    memset(&c, 0, sizeof (c));
 
     if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT) && (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT)) {
       /* New style handover: Send CMD_START_FLASH, which will reset the board and
@@ -215,15 +214,10 @@ unsigned int EnterFlashState(void)
       fprintf(stderr,"Waiting for Proxmark to reappear on USB... ");
     }
 
-#ifdef WIN32
-    Sleep(1000);
-    while (!UsbConnect()) { Sleep(1000); }
-#else
     CloseProxmark();
     sleep(1);
 
     while (!OpenProxmark(0)) { sleep(1); }
-#endif
     fprintf(stderr,"Found.\n");
 
     return GetProxmarkState();
Impressum, Datenschutz