Skip to content

Conversation

@pwpiwi
Copy link
Contributor

@pwpiwi pwpiwi commented Jan 23, 2020

This was initiated by @uzlonewolf's idea of "command queuing" which sended new commands to PM3 before the previous had been acknowledged. This didn't work for Windows (see discussion in #901). It turned out that this was in fact another approach to circumvent the timeouts in uart_receive() which tend to delay uart_send(). The same was already achieved by blocking the communication thread on CMD_ACK during flashing.

This PR enables the block on CMD_ACK in general. Plus it allows variable sized responses similar to @doegox's work on RRG repo (but with less code changes).

Ah yes, and this improves the key checking speed from 219keys/sec to 238 keys/sec.

* move cmd.[ch] and usb_cdc.[ch] to armsrc
* sorting out #includes
* replace byte_t by uint8_t
* some reformatting
* whitespace fixes
* (no functional changes)
* merge cmd.c into usb_cdc.c
* move back usb_cdc.[ch] to common/
* declare low level functions usb_read() and usb_write() and more functions as static
* use cmd_receive() in bootrom.c and appmain.c
* remove unused memory wasting csrTab[100] in usb_cdc.c
* replace more byte_t by uint8_t
* more whitespace fixes
* use different data types for commands and responses
* use variable length responses
* maintain client/flasher compatibility with old format (e.g. when using old bootloader)
* maintain bootloader compatibility with old format (e.g. when using old or RRG flasher.exe)
* fix length of version string in appmain.c
* ensure that CMD_ACK is used exclusively for the very last response of each PM3 operation. All Dbprintf() must be before.
* always switch off field before exiting
* append null packet for USB transfers % 64 bytes
* reformatting and whitespace fixes
* whitespace fixes
* sorting out #includes
* added some LED handling in appmain.c (helped with debugging)
* finally replaced the infamous device unlink by msleep(1000)
* fixed some format strings in comms.c (with -DCOMMS_DEBUG)
* made uart_receive() and uart_send() behave as described in header
* some formating
@pwpiwi
Copy link
Contributor Author

pwpiwi commented Jan 31, 2020

With the latest commit we have uart_posix.c behave like uart_win32.c. and with less blocking. Key checking rate on Kali Linux is now much better but still slightly behind Windows (233 vs 235 key/sec). No idea where the rest is lost...

@pwpiwi
Copy link
Contributor Author

pwpiwi commented Feb 4, 2020

replacing msleep() in WaitForResponseTimeoutW() by some pthread-signalling in GetCommand() brought the Windows implementation back to the 238keys/sec we had seen before and Kali Linux to 237keys/sec. I still have no idea why it is slower on Linux.

@pwpiwi pwpiwi merged commit d6e1d48 into Proxmark:master Feb 6, 2020
@pwpiwi pwpiwi deleted the small_USB_response branch February 6, 2020 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant