diff --git a/client/cmdflashmem.c b/client/cmdflashmem.c index fd8cf0554..cbf336773 100644 --- a/client/cmdflashmem.c +++ b/client/cmdflashmem.c @@ -280,11 +280,13 @@ static int CmdFlashMemLoad(const char *Cmd) { //Send to device uint32_t bytes_sent = 0; uint32_t bytes_remaining = datalen; - while (bytes_remaining > 0) { uint32_t bytes_in_packet = MIN(FLASH_MEM_BLOCK_SIZE, bytes_remaining); clearCommandBuffer(); + if (bytes_remaining > bytes_in_packet) + // fast push mode + conn.block_after_ACK = true; SendCommandOLD(CMD_FLASHMEM_WRITE, start_index + bytes_sent, bytes_in_packet, 0, data + bytes_sent, bytes_in_packet); bytes_remaining -= bytes_in_packet; @@ -293,9 +295,11 @@ static int CmdFlashMemLoad(const char *Cmd) { PacketResponseNG resp; if (!WaitForResponseTimeout(CMD_ACK, &resp, 2000)) { PrintAndLogEx(WARNING, "timeout while waiting for reply."); + conn.block_after_ACK = false; free(data); return PM3_ETIMEOUT; } + conn.block_after_ACK = false; uint8_t isok = resp.oldarg[0] & 0xFF; if (!isok) { diff --git a/client/comms.c b/client/comms.c index 4501326c1..4ae05fc82 100644 --- a/client/comms.c +++ b/client/comms.c @@ -24,7 +24,7 @@ bool send_with_crc_on_fpc = true; // "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART bool send_via_fpc = false; -static communication_arg_t conn; +communication_arg_t conn; static pthread_t USB_communication_thread; //static pthread_t FPC_communication_thread; @@ -476,7 +476,7 @@ __attribute__((force_align_arg_pointer)) if (connection->block_after_ACK) { // if we just received an ACK, wait here until a new command is to be transmitted - // This is only working on OLD frames, and only used by flasher + // This is only working on OLD frames, and only used by flasher and flashmem if (ACK_received) { while (!txBuffer_pending) { pthread_cond_wait(&txBufferSig, &txBufferMutex); diff --git a/client/comms.h b/client/comms.h index c70a67c51..b3be16b1a 100644 --- a/client/comms.h +++ b/client/comms.h @@ -49,6 +49,7 @@ extern bool send_with_crc_on_usb; extern bool send_with_crc_on_fpc; // "Session" flag, to tell via which interface next msgs are sent: USB or FPC USART extern bool send_via_fpc; +extern communication_arg_t conn; void SetOffline(bool value); bool IsOffline(void);