google / OpenSK

OpenSK is an open-source implementation for security keys written in Rust that supports both FIDO U2F and FIDO2 standards.
Apache License 2.0
3k stars 289 forks source link

Debug output sometimes freezes the OpenSK application #58

Closed gendx closed 4 years ago

gendx commented 4 years ago

Expected Behavior

When deploying the OpenSK app with --debug enabled, the key works and debug output is visible in the console. The debug output starts with the following:

Initialization complete. Entering main loop
NRF52 HW INFO: Variant: AAD0, Part: N52840, Package: QI, Ram: K256, Flash: K1024
usbc::start() - State=PoweredOn
Your chip is NRF52840 revision 3. Although this USB implementation should be compatible, your chip hasn't been tested.
usbc::start() - subscribing to interrupts.
enable_out_endpoint_(0) - State=Started
enable_in_out_endpoint_(1) - State=Started
attach() - State=Started
enable_pullup() - State=Started
Enabling USB pullups
New state is Attached
usbc::ready not implemented
usbc::suspend not implemented
usbc::resume not implemented
Bus reset
Cancelling USB receive due to timeout
Cancelling USB receive due to timeout
Set Address = 21
Cancelling USB receive due to timeout
Cancelling USB receive due to timeout
...

Actual Behavior

Sometimes, the log output stops after the following. In that case, the control flow seems blocked: the key doesn't process any USB request, no LED blinks.

Initialization complete. Entering main loop
NRF52 HW INFO: Variant: AAD0, Part: N52840, Package: QI, Ram: K256, Flash: K1024
usbc::start() - State=PoweredOn
Your chip is NRF52840 revision 3. Although this USB implementation should be compatible, your chip hasn't been tested.
usbc::start() - subscribing to interrupts.
enable_out_endpoint_(0) - State=Started
enable_in_out_endpoint_(1) - State=Started
attach() - State=Started
enable_pullup() - State=Started
Enabling USB pullups
New state is Attached
usbc::ready not implemented

Note: without --debug, the log output sometimes also stops after usbc::ready not implemented. But in that case the application is still functional afterwards.

Steps to Reproduce the Problem

On an nRF52840-DK.

  1. Deploy OpenSK with $ ./deploy.py os --board nrf52840_dk and $ ./deploy.py app --debug --panic-console --opensk.
  2. Run $ JLinkExe -device nrf52 -if swd -speed 1000 -autoconnect 1 and $ JLinkRTTClient on a separate terminal.
  3. Press the reset button multiple times and observe the console output each time.

Specifications

gendx commented 4 years ago

Filed an issue on upstream Tock as it could be a kernel bug.

gendx commented 4 years ago

This is an upstream issue: see https://github.com/tock/tock/issues/1629 and the fix in https://github.com/tock/tock/pull/1636.

Keeping this issue open to monitor the situation and update the Tock submodule once the fix is merged.