solokeys / solo2-cli

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

Update fails #25

Closed aussetg closed 2 years ago

aussetg commented 2 years ago

Trying to update:

guillaume@thinkpad ~> solo2 update                                                                                                                                                                                                               ~
Downloading latest release from https://github.com/solokeys/solo2/
Fetched firmware version 1:20200101.8
Tap button on key to confirm, or replug to abort...
thread 'main' panicked at 'success: AbortDataPhase', /home/guillaume/.cargo/registry/src/github.com-1ecc6299db9ec823/lpc55-0.1.0-alpha.8/src/bootloader/protocol.rs:110:76
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

after:

guillaume@thinkpad ~ [101]> solo2 ls                                                                                                                                                                                                             ~
LPC 55 9AE924EB79ECC45DA66A0841426A083A

Key is completely unresponsive.

solo2 bootloader reboot

is not working.

EDIT: Running solo2 update once again while the key is unresponsive in bootloader mode then restored it to a functional state.

nickray commented 2 years ago

Acknowledged, although not actionable. If this is reproducible, can you enable that backtrace (export RUST_BACKTRACE=1; solo2 update) and share the output?

nickray commented 2 years ago

Does this issue still occur with v0.1.1 of the CLI?

aussetg commented 2 years ago

It's broken differently on my machine with 0.1.1 :)

guillaume@m1 ~ [101]> RUST_BACKTRACE=1 /home/guillaume/.cargo/bin/solo2 list
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: The operation requires a Smart Card, but no Smart Card is currently in the device', /home/guillaume/.cargo/registry/src/github.com-1ecc6299db9ec823/solo2-0.1.1/src/device/pcsc.rs:98:50
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once
4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
5: solo2::device::pcsc::Session::infos
6: solo2::device::pcsc::Session::devices
7: solo2::device::pcsc::list
8: <solo2::device::Solo2 as lpc55::bootloader::UuidSelectable>::list
9: <solo2::device::Device as lpc55::bootloader::UuidSelectable>::list
10: solo2::try_main
11: solo2::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
guillaume@m1 ~ [101]> RUST_BACKTRACE=full /home/guillaume/.cargo/bin/solo2 list
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: The operation requires a Smart Card, but no Smart Card is currently in the device', /home/guillaume/.cargo/registry/src/github.com-1ecc6299db9ec823/solo2-0.1.1/src/device/pcsc.rs:98:50
stack backtrace:
0:     0x55872d56b32c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3264ad1edb4a78ca
1:     0x55872d58dddc - core::fmt::write::h85b247e856e081ad
2:     0x55872d5643c5 - std::io::Write::write_fmt::he3b80a66fc2ba5d3
3:     0x55872d56cec0 - std::panicking::default_hook::{{closure}}::hf2bcdea8e51c0c13
4:     0x55872d56ca75 - std::panicking::default_hook::h8864cfaaed08e53a
5:     0x55872d56d574 - std::panicking::rust_panic_with_hook::hb272975096b9f3ce
6:     0x55872d56d050 - std::panicking::begin_panic_handler::{{closure}}::hbbd6c4e11858ba52
7:     0x55872d56b7f4 - std::sys_common::backtrace::__rust_end_short_backtrace::hdd56e8729123abc5
8:     0x55872d56cfb9 - rust_begin_unwind
9:     0x55872d2dc7a1 - core::panicking::panic_fmt::h9596d5ee0dabf3a3
10:     0x55872d2dc893 - core::result::unwrap_failed::h7d8122a7d843671d
11:     0x55872d327cd7 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::h85be689a71692755
12:     0x55872d31c733 - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::h91fa3d534dca622e
13:     0x55872d328747 - solo2::device::pcsc::Session::infos::h0914e6662c508391
14:     0x55872d3287dc - solo2::device::pcsc::Session::devices::h0bccb634a710cfa4
15:     0x55872d328456 - solo2::device::pcsc::list::hc9edc94c37a3c1d2
16:     0x55872d30ee1a - <solo2::device::Solo2 as lpc55::bootloader::UuidSelectable>::list::ha130179841227bf3
17:     0x55872d30f914 - <solo2::device::Device as lpc55::bootloader::UuidSelectable>::list::h56eba9dc30007cb5
18:     0x55872d2ee4c2 - solo2::try_main::hbb5b8c074a559374
19:     0x55872d2edef2 - solo2::main::h84775dbf52dcd94d
20:     0x55872d2f6003 - std::sys_common::backtrace::__rust_begin_short_backtrace::hf7030764c5c8a8eb
21:     0x55872d2f4e79 - std::rt::lang_start::{{closure}}::h2b2d71200769460a
22:     0x55872d56b00b - std::rt::lang_start_internal::hcbc5d1079a591413
23:     0x55872d2f4e62 - main
24:     0x7efd5cbf3560 - __libc_start_call_main
25:     0x7efd5cbf360c - __libc_start_main@@GLIBC_2.34
26:     0x55872d2dcf75 - _start
27:                0x0 - <unknown>
guillaume@m1 ~ [101]> lsusb
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 004: ID 072f:223b Advanced Card Systems, Ltd ACR1252 Dual Reader
Bus 005 Device 003: ID 28de:1142 Valve Software Wireless Steam Controller
Bus 005 Device 002: ID 04d9:a292 Holtek Semiconductor, Inc. USB-HID Keyboard
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 8087:0029 Intel Corp. AX200 Bluetooth
Bus 003 Device 003: ID 0b05:18f3 ASUSTek Computer, Inc. AURA LED Controller
Bus 003 Device 002: ID 1209:beee Generic Solo 2 Security Key
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0424:5734 Microchip Technology, Inc. (formerly SMSC) USB5734
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 005: ID 0424:274a Microchip Technology, Inc. (formerly SMSC) Hub Controller
Bus 001 Device 004: ID 03e7:2485 Intel Movidius MyriadX
Bus 001 Device 003: ID 046d:c539 Logitech, Inc. USB Receiver
Bus 001 Device 002: ID 0424:2734 Microchip Technology, Inc. (formerly SMSC) USB2734
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 1209:beee Generic Solo 2 Security Key
Device Descriptor:
bLength                18
bDescriptorType         1
bcdUSB               2.10
bDeviceClass          239 Miscellaneous Device
bDeviceSubClass         2 
bDeviceProtocol         1 Interface Association
bMaxPacketSize0        64
idVendor           0x1209 Generic
idProduct          0xbeee 
bcdDevice            1.00
iManufacturer           1 SoloKeys
iProduct                2 Solo 2 Security Key
iSerial                 3 A48164D5D99CCF569C36E620419237F2
bNumConfigurations      1
Configuration Descriptor:
bLength                 9
bDescriptorType         2
wTotalLength       0x00b8
bNumInterfaces          4
bConfigurationValue     1
iConfiguration          0 
bmAttributes         0x80
(Bus Powered)
MaxPower              100mA
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        0
bAlternateSetting       0
bNumEndpoints           2
bInterfaceClass        11 Chip/SmartCard
bInterfaceSubClass      0 
bInterfaceProtocol      0 
iInterface              4 CCID/ICCD Interface
ChipCard Interface Descriptor:
bLength                54
bDescriptorType        33
bcdCCID              1.10  (Warning: Only accurate for version 1.0)
nMaxSlotIndex           0
bVoltageSupport         1  5.0V 
dwProtocols             2  T=1
dwDefaultClock       3580
dwMaxiumumClock      3580
bNumClockSupported      0
dwDataRate           9600 bps
dwMaxDataRate        9600 bps
bNumDataRatesSupp.      0
dwMaxIFSD             254
dwSyncProtocols  00000000 
dwMechanical     00000000 
dwFeatures       00040840
Auto parameter negotiation made by CCID
Short and extended APDU level exchange
dwMaxCCIDMsgLen      3072
bClassGetResponse    echo
bClassEnvelope       echo
wlcdLayout           none
bPINSupport             0 
bMaxCCIDBusySlots       1
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x81  EP 1 IN
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               0
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x01  EP 1 OUT
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               0
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        1
bAlternateSetting       0
bNumEndpoints           2
bInterfaceClass         3 Human Interface Device
bInterfaceSubClass      0 
bInterfaceProtocol      0 
iInterface              0 
HID Device Descriptor:
bLength                 9
bDescriptorType        33
bcdHID               1.11
bCountryCode            0 Not supported
bNumDescriptors         1
bDescriptorType        34 Report
wDescriptorLength      34
Report Descriptors: 
** UNAVAILABLE **
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x02  EP 2 OUT
bmAttributes            3
Transfer Type            Interrupt
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               5
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x82  EP 2 IN
bmAttributes            3
Transfer Type            Interrupt
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               5
Interface Association:
bLength                 8
bDescriptorType        11
bFirstInterface         2
bInterfaceCount         2
bFunctionClass          2 Communications
bFunctionSubClass       2 Abstract (modem)
bFunctionProtocol       0 
iFunction               0 
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        2
bAlternateSetting       0
bNumEndpoints           1
bInterfaceClass         2 Communications
bInterfaceSubClass      2 Abstract (modem)
bInterfaceProtocol      0 
iInterface              0 
CDC Header:
bcdCDC               1.10
CDC ACM:
bmCapabilities       0x00
CDC Union:
bMasterInterface        2
bSlaveInterface         3 
CDC Call Management:
bmCapabilities       0x00
bDataInterface          3
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x83  EP 3 IN
bmAttributes            3
Transfer Type            Interrupt
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0008  1x 8 bytes
bInterval             255
Interface Descriptor:
bLength                 9
bDescriptorType         4
bInterfaceNumber        3
bAlternateSetting       0
bNumEndpoints           2
bInterfaceClass        10 CDC Data
bInterfaceSubClass      0 
bInterfaceProtocol      0 
iInterface              0 
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x84  EP 4 IN
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               0
Endpoint Descriptor:
bLength                 7
bDescriptorType         5
bEndpointAddress     0x04  EP 4 OUT
bmAttributes            2
Transfer Type            Bulk
Synch Type               None
Usage Type               Data
wMaxPacketSize     0x0040  1x 64 bytes
bInterval               0
Binary Object Store Descriptor:
bLength                 5
bDescriptorType        15
wTotalLength       0x000c
bNumDeviceCaps          1
USB 2.0 Extension Device Capability:
bLength                 7
bDescriptorType        16
bDevCapabilityType      2
bmAttributes   0x00000000
(Missing must-be-set LPM bit!)
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0000
(Bus Powered)
barakplasma commented 2 years ago

solo2 update worked for me on MacOS Big Sur 11.6.2 (20G314)

$ cargo version
cargo 1.60.0-nightly (95bb3c92b 2022-01-18)
$ solo2 update
Downloading latest release from https://github.com/solokeys/solo2/
Fetched firmware version 1:20200101.9
Tap button on key to confirm, or replug to abort...
LPC55 Bootloader detected. The LED should be off.
Writing new firmware...
Done. Rebooting key. The LED should turn back on.
$ solo2 list
Solo 2 84.......57 (CTAP only, firmware 1:20200101.9)
kusma commented 2 years ago

I'm also failing to update, but with a different problem:

kusma@kusma-xps13:~/src/mesa$ solo2 list
Solo 2 466EF844AD83EE5299033F819E683B2D (CTAP only, firmware 1:20200101.7)
kusma@kusma-xps13:~/src/mesa$ solo2 update
Downloading latest release from https://github.com/solokeys/solo2/
Fetched firmware version 1:20200101.9
Tap button on key to confirm, or replug to abort...

After I touch the device, the lights turn off, and the solo2 command just hangs there. I've let it hang for around 45 minutes until I gave up. Disconnecting and reconnecting the device brings it back to life, but repeating the update just gives the same result.

DarkSpir commented 2 years ago

Same issue here. If that helps: It happens on both solo2 keys I got here, so no difference between usb-a and usb-c.

./solo2 list
Solo 2 149D3BE505837D5A9D12FE47426B7261 (CTAP only, firmware 1:20200101.8)
Solo 2 4577BC872B2403518D9EE9CD6864F433 (CTAP only, firmware 1:20200101.7)
./solo2 update
Downloading latest release from https://github.com/solokeys/solo2/
Fetched firmware version 1:20200101.9
✔ Multiple Solo 2 devices available, select one or hit Escape key · Solo 2 149D3BE505837D5A9D12FE47426B7261 (CTAP only, firmware 1:20200101.8)
Tap button on key to confirm, or replug to abort...

Since they are both listed as CTAP only I tried to run update with --ctap parameter, no change. When the solo2's led goes off it's usb device id changes from 0xbeee to 0xb000:

Bus 003 Device 011: ID 1209:beee Generic Solo 2 Security Key
Bus 003 Device 015: ID 1209:b000 Generic USB COMPOSITE DEVICE

Edit: I think I got it. When I plug in the solo2 it will set up a ttyACM device and udev creates it with the ownership root:dialout and permission 660. My user is in the dialout group so everything is fine. But, when the update process starts and solo2 changes its usb device id it also sets up a hidraw device instead of a ttyACM one:

[ 1918.073109] hid-generic 0003:1209:B000.0013: hiddev1,hidraw2: USB HID v1.00 Device [NXP SEMICONDUCTOR INC. USB COMPOSITE DEVICE] on usb-0000:00:14.0-3/input0

And this time udev creates it with ownership root:root and permission 600. So suddenly the solo2 update process can't access the device anymore.

Solution: Put the 70-solo2.rules from the release files to /etc/udev/rules.d/ and load them with:

udevadm control --reload-rules
udevadm trigger

And the update works fine:

./solo2 update
Downloading latest release from https://github.com/solokeys/solo2/
Fetched firmware version 1:20200101.9
✔ Multiple Solo 2 devices available, select one or hit Escape key · Solo 2 149D3BE505837D5A9D12FE47426B7261 (CTAP only, firmware 1:20200101.8)
Tap button on key to confirm, or replug to abort...
LPC55 Bootloader detected. The LED should be off.
Writing new firmware...
Done. Rebooting key. The LED should turn back on.
./solo2 list
Solo 2 149D3BE505837D5A9D12FE47426B7261 (CTAP only, firmware 1:20200101.9)
Solo 2 4577BC872B2403518D9EE9CD6864F433 (CTAP only, firmware 1:20200101.7)
kusma commented 2 years ago

Yeah, I can confirm that this fixed the issue for me. I already did the same thing for my original solo key, and didn't realize the solo2 udev file was different. Oh well, we live and learn :sweat_smile:

chrishopkins53 commented 2 years ago

Thanks @DarkSpir. That worked perfectly