nitrokey-pro-firmware icon indicating copy to clipboard operation
nitrokey-pro-firmware copied to clipboard

[HSM] Add debugging functions

Open FlorianUekermann opened this issue 7 years ago • 3 comments

Adds two simple functions for debugging.

Debugf works exactly like printf. Debug takes an array of bytes and a length. Example code on device:

Debugf("Hello world %d", 123)

Output on host:

$python debug.py
Hello world 123

Debugging is disabled by default. Both functions do nothing unless debugging in is enabled by uncommenting line 8 in debug.h (this should be done via make target at some point)

To try it uncomment line 8 in src/inc/debug.h and run "python debug.py" in the repository root. Then plug in the Nitrokey HSM. You should see this as soon as the device is done with the basic setup:

Entering loop after USB startup

This code should have no side effects and be compatible with the master branch as well. As long as pyusb is installed it should work on every OS ('apt-get install python-usb'). More extensive documentation in debug.py and debug.h.

Don't use floating point math (that means don't print them either).

FlorianUekermann avatar Sep 03 '16 23:09 FlorianUekermann

Hi @MaVo159 ! We should add guards also to interface creation, so it would not be available in release binary even when nothing is printed there. Additional interfaces could make device blocked on VM environments.

szszszsz avatar Sep 12 '16 08:09 szszszsz

That is definitely the plan. I would like to wait with that until I have time to merge the two branches though, since I'll need to do something more elegant for the device descriptor anyway. Unless there are immediate plans to release a new version firmware version of course. I wouldn't expect VM problems, because this is not an HID interface. Or have you encountered VMs that don't forward devices for other reasons.

FlorianUekermann avatar Sep 12 '16 09:09 FlorianUekermann

OK! As for VMs I have not heard about other block causes, just blind guess.

szszszsz avatar Sep 12 '16 09:09 szszszsz