From cff2473cf8a0b151e2a4a3cfaed4f474998e00f8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 27 Apr 2018 16:51:08 +0200 Subject: [PATCH] testing. RDV40 Flashmemory upload / download working. --- client/cmdanalyse.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/client/cmdanalyse.c b/client/cmdanalyse.c index 5f6c4e146..f85a0f08b 100644 --- a/client/cmdanalyse.c +++ b/client/cmdanalyse.c @@ -507,10 +507,11 @@ int CmdAnalyseA(const char *Cmd){ clearCommandBuffer(); SendCommand(&c); if ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) { - PrintAndLogEx(NORMAL, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); return 1; } break; + // write flash mem case 1: c = (UsbCommand) {CMD_WRITE_FLASH_MEM, {startindex, len, 0}}; memcpy(c.d.asBytes, data, len); @@ -518,16 +519,49 @@ int CmdAnalyseA(const char *Cmd){ SendCommand(&c); if ( !WaitForResponseTimeout(CMD_ACK, &resp, 2000) ) { - PrintAndLogEx(NORMAL, "timeout while waiting for reply."); + PrintAndLogEx(WARNING, "timeout while waiting for reply."); return 1; } uint8_t isok = resp.arg[0] & 0xFF; if (isok) PrintAndLogEx(SUCCESS, "Flash write ok"); else - PrintAndLogEx(FAILED, "Flash write ok"); + PrintAndLogEx(FAILED, "Flash write fail"); - break; + break; + // downloading mem to client + case 2: { + uint8_t got[0x3FFFF]; + memset(got, 0, sizeof(got)); + PrintAndLogEx(NORMAL, "downloading %u bytes from flashmem", sizeof(got)); + GetFromFlashMen(got, sizeof(got), 0); + WaitForResponse(CMD_ACK, NULL); + + print_hex(got, 8); + + for(uint32_t i=0; i< sizeof(got); i++) { + if ( got[i] < 0xFF) { + printf("I %u (0x%x) | %x \n", i, i, got[i] ); + } + } + break; + } + // wipe + case 3: { + c = (UsbCommand) {CMD_UPLOAD_FLASH_MEM, {0, 0, 0}}; + clearCommandBuffer(); + SendCommand(&c); + if ( !WaitForResponseTimeout(CMD_ACK, &resp, 8000) ) { + PrintAndLogEx(WARNING, "timeout while waiting for reply."); + return 1; + } + uint8_t isok = resp.arg[0] & 0xFF; + if (isok) + PrintAndLogEx(SUCCESS, "Flash WIPE ok"); + else + PrintAndLogEx(FAILED, "Flash WIPE failed"); + break; + } } return 0;