solokeys / solo2-cli

Solo 2 library and CLI in Rust
https://docs.rs/solo2
Apache License 2.0
170 stars 31 forks source link

thread 'main' panicked at 'success: HidApi(IncompleteSendError { sent: 60, all: 36 })' in bootloader mode in Windows 10 #6

Closed oplik0 closed 2 years ago

oplik0 commented 2 years ago

When trying to update on Windows 10, the key appears to be put into (or there are attempts to put it into) bootloader mode, but no commands seem to work on it afterwards - this results in thread 'main' panicked at 'success: HidApi(IncompleteSendError { sent: 60, all: 36 })' error on update and with other bootloader commands (bootloader ls, bootloader reboot). Full logs with SOLO2_LOG=debug and RUST_BACKTRACE=full (redacted some number since I'm not sure if they aren't supposed to be kept private):

 INFO  solo2 > solo2 CLI startup
 INFO  solo2::smartcard > connecting with reader: `SoloKeys CCID/ICCD Interface 0`
 DEBUG solo2::smartcard > >> [redacted]
 DEBUG solo2::smartcard > RECV 2 bytes
 DEBUG solo2::smartcard > << [redacted]
 DEBUG solo2::smartcard > >> [redacted]
 DEBUG solo2::smartcard > RECV 18 bytes
 DEBUG solo2::smartcard > << [redacted]
 INFO  solo2::smartcard > ...connected
 DEBUG solo2::smartcard > Reader has a card.
 INFO  solo2::smartcard > connecting with reader: `Windows Hello for Business 1`
 DEBUG solo2::smartcard > >> [redacted]
 DEBUG solo2::smartcard > RECV 2 bytes
 DEBUG solo2::smartcard > << [redacted]
 INFO  solo2::smartcard > ...connected
 DEBUG solo2::smartcard > Reader has a card.
Downloading latest release from https://github.com/solokeys/solo2/
 DEBUG reqwest::connect > starting new connection: https://api.github.com/
 DEBUG reqwest::async_impl::client > response '200 OK' for https://api.github.com/repos/solokeys/solo2/releases/latest
Downloading firmware v1.0.6...
 INFO  solo2::update               > found solo2 firmare in release
 DEBUG reqwest::connect            > starting new connection: https://github.com/
 DEBUG reqwest::async_impl::client > redirecting 'https://github.com/solokeys/solo2/releases/download/1.0.6/solo2-firmware-1.0.6.sb2' to 'https://objects.githubusercontent.com/github-production-release-asset-2e65be/234604146/5b57af48-017e-4c3f-82df-77de0e78bbcb?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211103T172234Z&X-Amz-Expires=300&X-Amz-Signature=1ad971124eaf1a5a4c491ecc499818c11b1f345893132abbdb0b35d9ce91c4d6&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=234604146&response-content-disposition=attachment%3B%20filename%3Dsolo2-firmware-1.0.6.sb2&response-content-type=application%2Foctet-stream'
 DEBUG reqwest::connect            > starting new connection: https://objects.githubusercontent.com/
 DEBUG reqwest::async_impl::client > response '200 OK' for https://objects.githubusercontent.com/github-production-release-asset-2e65be/234604146/5b57af48-017e-4c3f-82df-77de0e78bbcb?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20211103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211103T172234Z&X-Amz-Expires=300&X-Amz-Signature=1ad971124eaf1a5a4c491ecc499818c11b1f345893132abbdb0b35d9ce91c4d6&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=234604146&response-content-disposition=attachment%3B%20filename%3Dsolo2-firmware-1.0.6.sb2&response-content-type=application%2Foctet-stream
 INFO  solo2::update               > found solo2 firmare hash in release
 DEBUG reqwest::async_impl::client > redirecting 'https://github.com/solokeys/solo2/releases/download/1.0.6/solo2-firmware-1.0.6.sha2' to 'https://objects.githubusercontent.com/github-production-release-asset-2e65be/234604146/aaec22f8-9514-4b5e-b831-5957d12a9aa4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=[redacted]3%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211103T172236Z&X-Amz-Expires=300&X-Amz-Signature=323ad9614e94db42fff1d967548f67d04d6762027a93ac7aece7cd2f75a95863&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=234604146&response-content-disposition=attachment%3B%20filename%3Dsolo2-firmware-1.0.6.sha2&response-content-type=application%2Foctet-stream'
 DEBUG reqwest::async_impl::client > response '200 OK' for https://objects.githubusercontent.com/github-production-release-asset-2e65be/234604146/aaec22f8-9514-4b5e-b831-5957d12a9aa4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=[redacted]%2F20211103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211103T172236Z&X-Amz-Expires=300&X-Amz-Signature=323ad9614e94db42fff1d967548f67d04d6762027a93ac7aece7cd2f75a95863&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=234604146&response-content-disposition=attachment%3B%20filename%3Dsolo2-firmware-1.0.6.sha2&response-content-type=application%2Foctet-stream
Verified hash.
Multiple devices connected.
Enter 0-1 to select:
0 - "SoloKeys CCID/ICCD Interface 0" UUID: [redacted]
Selection (0-9): 0
 INFO  solo2::apps                 > selecting app: A00000084700000001
 DEBUG solo2::smartcard            > >> [redacted]
 DEBUG solo2::smartcard            > RECV 2 bytes
 DEBUG solo2::smartcard            > << 9000
 DEBUG solo2::smartcard            > >> [redacted]
 DEBUG solo2::smartcard            > RECV 6 bytes
 DEBUG solo2::smartcard            > << [redacted]
 INFO  solo2::update               > current device version major: 1
 INFO  solo2::update               > new sb2 firmware version: Version { major: 1, minor: 0, patch: 6 }
Tap button on key...
 DEBUG solo2::smartcard            > >> [redacted]
Waiting for key to enter bootloader mode...
 INFO  solo2::update               > attempt 0
 INFO  solo2::update               > attempt 1
 INFO  solo2::update               > attempt 2
thread 'main' panicked at 'success: HidApi(IncompleteSendError { sent: 60, all: 36 })', C:\Users\oplik0\.cargo\registry\src\github.com-1ecc6299db9ec823\lpc55-0.1.0-alpha.7\src\bootloader\protocol.rs:110:76
stack backtrace:
   0:     0x7ff74339754f - <unknown>
   1:     0x7ff7433aed0a - <unknown>
   2:     0x7ff743391058 - <unknown>
   3:     0x7ff743399cd6 - <unknown>
   4:     0x7ff7433997bc - <unknown>
   5:     0x7ff74339a335 - <unknown>
   6:     0x7ff743399f1b - <unknown>
   7:     0x7ff743397e87 - <unknown>
   8:     0x7ff743399e79 - <unknown>
   9:     0x7ff7433c4bd0 - hid_write
  10:     0x7ff7433c4ce3 - hid_write
  11:     0x7ff7432a0cc8 - <unknown>
  12:     0x7ff74329f61b - <unknown>
  13:     0x7ff74329e18b - <unknown>
  14:     0x7ff74329ef00 - <unknown>
  15:     0x7ff74329d370 - <unknown>
  16:     0x7ff74329d114 - <unknown>
  17:     0x7ff7431158af - <unknown>
  18:     0x7ff7430e050f - <unknown>
  19:     0x7ff7430e5427 - <unknown>
  20:     0x7ff7430e7277 - <unknown>
  21:     0x7ff7430dcb59 - <unknown>
  22:     0x7ff7430dcd75 - <unknown>
  23:     0x7ff7430f55ca - <unknown>
  24:     0x7ff7430dd531 - <unknown>
  25:     0x7ff7430d9be6 - <unknown>
  26:     0x7ff7430f2efc - <unknown>
  27:     0x7ff743396e97 - <unknown>
  28:     0x7ff7430dd6a7 - <unknown>
  29:     0x7ff7433b6db4 - hid_write
  30:     0x7ffbb8757034 - BaseThreadInitThunk
  31:     0x7ffbb9f82651 - RtlUserThreadStart

Subsequent runs produce basically the same output just without the device selection step.

Edit: this appears to be a general bootloader issue in Windows, not just with updates. Putting the key into bootloader mode manually (be it via solo app admin boot-to-bootrom or holding all keys for 5 seconds when inserting) bootloader commands emit the same thread 'main' panicked at 'success: HidApi(IncompleteSendError { sent: 60, all: 36 })' error

olivierfaber commented 2 years ago

I have the same error. (thread 'main' panicked at 'success: HidApi(IncompleteSendError { sent: 60, all: 36 })') If usefull, I can post the RUST backtrace if you tell me how to do that..

nickray commented 2 years ago

It seems as if Window sends some kind of "full packet" vs. what was sent. The protocol is over-nitpicky on purpose about this (the idea was to learn what's different on other platforms). I believe this is an issue in lpc55-host that is fixed in the win-fix branch of both repositories, will test some more and then release a v0.0.7. Thanks for reporting.

oplik0 commented 2 years ago

Thanks, I can confirm that the win-fix branch works for me for updating.

Also, a small thing I noticed in the logs here - firmware is misspelled as firmare in these two lines: https://github.com/solokeys/solo2-cli/blob/e010dc72982da488ccbaba2b70c06b2592531e4b/src/update.rs#L32 https://github.com/solokeys/solo2-cli/blob/e010dc72982da488ccbaba2b70c06b2592531e4b/src/update.rs#L46

Not worth separate report or a PR though, so just mentioning it here :)

patschi commented 2 years ago

Just for completeness: This is also, unsurprisingly, reproducible on Windows 11.

nickray commented 2 years ago

Should be fixed by https://github.com/solokeys/solo2-cli/releases/tag/v0.0.7 (if not, feel free to open a new issue).

patschi commented 2 years ago

Should be fixed by https://github.com/solokeys/solo2-cli/releases/tag/v0.0.7 (if not, feel free to open a new issue).

Yes, can confirm:

C:\Users\pkernstock\Downloads>solo2-v0.0.7-x86_64-pc-windows-msvc.exe update
Downloading latest release from https://github.com/solokeys/solo2/
Bootloader detected. The LED should be off.
Writing new firmware...
Done. Rebooting key.  The LED should turn back on.

Thanks for the quick fix!