]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
fix lf sim fpga download overwrites sim buffer (#391)
authormarshmellow42 <marshmellow42@users.noreply.github.com>
Mon, 11 Sep 2017 17:18:32 +0000 (13:18 -0400)
committerpwpiwi <pwpiwi@users.noreply.github.com>
Mon, 11 Sep 2017 17:18:32 +0000 (19:18 +0200)
* adjust LFSim to download lf fpga prior to setting emulation buffer to prevent buffer overwrite condition if you are coming from HF fpga.
* fix lf sim big buff overwrite with fpga download. Move fix to the buffer download cmd.

armsrc/appmain.c
armsrc/lfops.c
client/cmdhflegic.c
client/cmdlf.c

index 4411a0c54915778a9a29bd1dc3e2245079773c83..25285396a396ce5943cf087ae799a7a2b27f5dff 100644 (file)
@@ -1294,6 +1294,15 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        break;
 
                case CMD_DOWNLOADED_SIM_SAMPLES_125K: {
+                       // iceman; since changing fpga_bitstreams clears bigbuff, Its better to call it before.
+                       // to be able to use this one for uploading data to device 
+                       // arg1 = 0 upload for LF usage 
+                       //        1 upload for HF usage
+                       if (c->arg[1] == 0)
+                               FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
+                       else
+                               FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
+
                        uint8_t *b = BigBuf_get_addr();
                        memcpy(b+c->arg[0], c->d.asBytes, USB_CMD_DATA_SIZE);
                        cmd_send(CMD_ACK,0,0,0,0,0);
@@ -1304,7 +1313,7 @@ void UsbPacketReceived(uint8_t *packet, int len)
                        break;
 
                case CMD_SET_LF_DIVISOR:
-                       FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
+                       FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
                        FpgaSendCommand(FPGA_CMD_SET_DIVISOR, c->arg[0]);
                        break;
 
index 95965f56f54e5800cc4943c07b1757628b6ba102..641c02e876edf278f611138fd1ec7d3043729e89 100644 (file)
@@ -387,8 +387,8 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
        int i;
        uint8_t *tab = BigBuf_get_addr();
 
-       //note this may destroy the bigbuf so be sure this is called before now...
-       FpgaDownloadAndGo(FPGA_BITSTREAM_LF);  
+       //note FpgaDownloadAndGo destroys the bigbuf so be sure this is called before now...
+       //FpgaDownloadAndGo(FPGA_BITSTREAM_LF);  
        FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT);
 
        AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT | GPIO_SSC_CLK;
index 493256a90b77673dc61b53263a1c1be5c276edde..c9f3485e10c16aa192218518b5618c680689f758 100644 (file)
@@ -251,7 +251,7 @@ int CmdLegicLoad(const char *Cmd)
           fclose(f);
           return -1;
         }
-        UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {offset, 0, 0}};
+        UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {offset, 1, 0}};
         int j; for(j = 0; j < 8; j++) {
             c.d.asBytes[j] = data[j];
         }
@@ -351,7 +351,7 @@ int CmdLegicRfFill(const char *Cmd)
     }
 
     int i;
-    UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {0, 0, 0}};
+    UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {0, 1, 0}};
     for(i = 0; i < 48; i++) {
       c.d.asBytes[i] = cmd.arg[2];
     }
index 6a5a2fbe927e5a74dbaae87c9a74f5fea7c770fd..eb664a111391f9b03c13106e83aadc371b78fcad 100644 (file)
@@ -410,14 +410,13 @@ int CmdLFSim(const char *Cmd)
 
        sscanf(Cmd, "%i", &gap);
 
-       // convert to bitstream if necessary 
-
+       // convert to bitstream if necessary
        ChkBitstream(Cmd);
 
        //can send only 512 bits at a time (1 byte sent per bit...)
        printf("Sending [%d bytes]", GraphTraceLen);
        for (i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) {
-               UsbCommand c={CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}};
+               UsbCommand c = {CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}};
 
                for (j = 0; j < USB_CMD_DATA_SIZE; j++) {
                        c.d.asBytes[j] = GraphBuffer[i+j];
Impressum, Datenschutz