Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to debug OpenSK on nRF52840DK #714

Open
gnmarco opened this issue Feb 6, 2025 · 2 comments
Open

Unable to debug OpenSK on nRF52840DK #714

gnmarco opened this issue Feb 6, 2025 · 2 comments
Assignees

Comments

@gnmarco
Copy link

gnmarco commented Feb 6, 2025

I tried many times to enable debugging on OpenSK deployed on the nRF52840DK board without success. However, I managed to get the board up and running without debugging.

Actual behavior

  1. Execute JLinkExe -device nrf52 -if swd -speed 1000 -autoconnect 1 in a terminal
  2. Execute JLinkRTTClient in another
  3. Connect board JTAG port to the computer
  4. Run ./deploy.py --board=nrf52840dk_opensk --opensk --debug
  5. The configuration of the device fails (as expected), but I can see debug output:
Initialization complete. Entering main loop
NRF52 HW INFO: Variant: Unspecified, Part: N52840, Package: QI, Ram: K256, Flash: K1024
Hello world from OpenSK!
Entering main ctap loop
tock$ ...................................................
  1. Connect micro USB cable to the USB port of the device (by keeping the JTAG connected)
  2. Press "RESET" (debug output stops), this is needed in order for the board to be recognized by the computer.
  3. Run
./tools/configure.py \
    --certificate=crypto_data/opensk_cert.pem \
    --private-key=crypto_data/opensk.key
  1. The command hangs and the board has LED1 blinking with non-regular intervals.

Expected behavior

In point 7. the output should not stop and point 9. should not happen.

Additional information

Even without the debugger enabled (i.e. without executing steps 1 and 2, it still does not work and I get the same results).
Am I doing something wrong? Is this a known bug? I tried having a look at #561 but I cannot get it to work.

UPDATE

I managed to configure the develop branch of the firmware, but I am still not able to debug using the aforementioned steps. If I change steps (1) and (2) and put them in place of steps (3) and (4) the board complains that it is locked and must be unprotected (by wiping the internal memory, of course, rendering deploy.py useless).

Thanks.

@kaczmarczyck kaczmarczyck self-assigned this Feb 6, 2025
@kaczmarczyck
Copy link
Collaborator

I tried to reproduce, and what I agree that the blinking patterns in debug mode are irregular. Could be because the timings are off when OpenSK is slowed down by printing debug output.

In my case, I don't have to press "RESET". But if I do, the debug output also doesn't stop, as long as I keep both cables plugged it. Can you explain why rebooting the chip helps the host OS recognize the board?

Step (8) works without problems for me. I do have to touch at some point, when the terminal says

Please touch the device to confirm...

I'm not sure why your device behaves differently than mine. If you don't mind losing all previously stored data, you can also try if resetting the storage helps:

./deploy.py --board=nrf52840dk_opensk --erase_storage

@gnmarco
Copy link
Author

gnmarco commented Feb 6, 2025

Hi @kaczmarczyck , thanks for your reply.

I tried to reproduce, and what I agree that the blinking patterns in debug mode are irregular. Could be because the timings are off when OpenSK is slowed down by printing debug output.

With the 2.1 branch I can load OpenSK (in debug mode) onto the board, but when I try to configure it (tools/configure.py), LED1 keeps blinking irregularly and the script hangs and times out.

In my case, I don't have to press "RESET". But if I do, the debug output also doesn't stop, as long as I keep both cables plugged it. Can you explain why rebooting the chip helps the host OS recognize the board?

I have absolutely no idea. If I don't press RESET the board is not detected by my host after deployment. I saw that this behavior is documented in OpenSK: "Note: Due to current limitations of our implementation and Tock, you may have to press the BOOT/RESET button, located next to the device USB port on the board in order to see your OpenSK device on your system."

Step (8) works without problems for me. I do have to touch at some point, when the terminal says

Please touch the device to confirm...

With the deploy branch, step 8 works fine. However, I still don't get debug.

I'm not sure why your device behaves differently than mine. If you don't mind losing all previously stored data, you can also try if resetting the storage helps:

./deploy.py --board=nrf52840dk_opensk --erase_storage

Done. And then I followed the steps I outlined before, in this issue. Using the deploy branch I can load ctap2 in debug mode. The device cannot be configured as it appears the system cannot detect it (see above). When I press "Reset", the debug output stops. This is what I see in the debug output:

Initialization complete. Entering main loop
NRF52 HW INFO: Variant: Unspecified, Part: N52840, Package: QI, Ram: K256, Flash: K1024
Hello world from OpenSK!
Entering main ctap loop
tock$ ...........................................................................................................................................................................................................................................................................................................

Then I also tried to leave the debug console opened during the --erase_storage and I correctly saw debug output.
The problem is pressing "Reset", that seems to "protect" again the board and thus, I believe, it does not allow debugging anymore. If I am right, that's why it stops debug output.

BTW, @kaczmarczyck which board version do you have? On mine there is written PCA10056 3.0.2 2024.33.

PS: sorry for accidentally closing the issue. I don't even know how I did it.

@gnmarco gnmarco closed this as completed Feb 6, 2025
@gnmarco gnmarco reopened this Feb 6, 2025
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

No branches or pull requests

2 participants