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
2.98k stars 289 forks source link

LED flashing light blue after flashing, cannot enter DFU mode #544

Closed Tiebe closed 1 year ago

Tiebe commented 2 years ago

Expected Behavior

Being able to use OpenSK after flashing

Actual Behavior

Led flashing light blue rapidly, cannot enter DFU mode by pressing the button while plugging in.

lsusb output:

Bus 003 Device 053: ID 1915:521f Nordic Semiconductor ASA OpenSK

dmesg output:

[ 4676.899717] usb 3-1: new full-speed USB device number 53 using xhci_hcd
[ 4677.081222] usb 3-1: New USB device found, idVendor=1915, idProduct=521f, bcdDevice= 0.01
[ 4677.081233] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 4677.081238] usb 3-1: Product: OpenSK
[ 4677.081242] usb 3-1: Manufacturer: Nordic Semiconductor ASA
[ 4677.081245] usb 3-1: SerialNumber: v1.0
[ 4677.085530] hid-generic 0003:1915:521F.0031: hiddev96,hidraw6: USB HID v1.10 Device [Nordic Semiconductor ASA OpenSK] on usb-0000:00:14.0-1/input0

Steps to Reproduce the Problem

  1. git clone https://github.com/google/OpenSK.git
  2. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh
  3. source $HOME/ .cargo/env
  4. cd OpenSK
  5. ./setup.sh
  6. ./deploy.py --board=nrf52840_mdk_dfu --opensk --programmer=none
  7. python3 uf2conv.py -c -f 0xada52840 -o target/opensk.uf2 target/nrf52840_mdk_dfu_merged.hex
  8. Copy opensk.uf2 to usb dongle

Specifications

kaczmarczyck commented 2 years ago

Works for me on a fresh MDK. Maybe you need to erase the persistent storage, and the blinking is a panic. In that case, follow the instructions above again, but instead of flashing OpenSK, you install the example app that erases all storage. WARNING: Erases all existing credentials, in case you have any important ones.

./deploy.py --board=nrf52840_mdk_dfu --programmer=none --erase_storage
python3 uf2conv.py -c -f 0xada52840 -o target/opensk.uf2 target/nrf52840_mdk_dfu_merged.hex

Then copy and replug. Give it a few seconds to complete erasing the storage. Then try again with --opensk instead of --erase_storage:

./deploy.py --board=nrf52840_mdk_dfu --programmer=none --opensk
python3 uf2conv.py -c -f 0xada52840 -o target/opensk.uf2 target/nrf52840_mdk_dfu_merged.hex

Replug and please report back if that changes anything.

Tiebe commented 1 year ago

Would love to try this, but I can't even enter dfu mode, so I can't flash anything

kaczmarczyck commented 1 year ago

Ah right, understood. Is this problem OpenSK related, because you can't enter DFU mode since you flashed an OpenSK, and it worked before?

Tiebe commented 1 year ago

That's correct

kaczmarczyck commented 1 year ago

In that case, I'll have to understand how to reproduce. Please let me know if you have any pointers etc. about that.

chimpnz commented 1 year ago

I had the same problem. Flashing LED and unresponsive bootloader.

If you have a Raspberry Pi you can use OpenOCD to re-flash the UF2 bootloader.

I followed the instructions here https://www.rototron.info/circuitpython-nrf52840-dongle-openocd-pi-tutorial/

It is for the PCA10059 dongle but the process is the same. The only difference is the location of the SWDCLK and SWDIO pins. The pinout can be found here https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/#pinout-diagram

Heed the warnings about resetting the voltage regulator.

The latest 0.7.0 UF2 bootloader for the MDK is here: https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/download/0.7.0/mdk_nrf52840_dongle_bootloader-0.7.0_s140_6.1.1.hex

Only flash the bootloader and skip installing CircuitPython at the end.

OpenSK ran fine with the fresh bootloader.

kaczmarczyck commented 1 year ago

Thanks for helping! Do you know if the unresponsive bootloader was caused by OpenSK? @chimpnz

chimpnz commented 1 year ago

Thanks for helping! Do you know if the unresponsive bootloader was caused by OpenSK? @chimpnz

Not really sure. I tried to reproduce it and can not. The MDK dongle that had the issue had CircuitPython and LOGItacker installed previously. I tried again loading both via UF2 and then OpenSK and the bootloader remains functional.

I tried another MDK dongle with the original bootloader (UF2 Bootloader 0.2.13-42-g82464f9-dirty) with CircuitPython/LOGItacker/OpenSK and bootloader works fine.

One odd thing is that CircuitPython will no longer run on either dongle. I can copy the UF2 file but it does not run after reset. Tried several versions. LOGItacker and OpenSK run fine.

jmichelp commented 1 year ago

Can you confirm which branch you're using? stable or develop? The original issue is against stable.

Considering the dongle has been used before, this is what may have happened:

In develop branch we removed that part of the code to avoid such issue and we also have a patch to protect these 2 bootloader values.

But the develop branch is not always tested with the MDK dongle so it might not work out of the box if we haven't properly kept the board configuration.

If you're using the stable branch, we can try backporting the patch to see if this solves the issue.

chimpnz commented 1 year ago

I am using the stable branch.

chimpnz commented 1 year ago

I erased and flashed the UF2 bootloader. CircuitPython will load an run. After loading OpenSK, CircuitPython will no longer run.