Getting the new interface to work has been a difficult task in a sense. For sure it's not the kind of difficulty you 're dealing with with a software coding project, where you have a lot of resources and usually it's somewhere in the logic of the program that you have made a mistake, but you have to have a deep understanding of the low-level operations that are performed by the firmware.
Yet again, debugging is what you need. In my project and with the problems I'm dealing with right now, I needed a USB protocol analyzer. I'm working on Linux, so a lot of the tools that the USB organization is providing aren't any help for me, but I managed to find a program called Wireshark (https://www.wireshark.org/). Wireshark is a network protocol analyzer and can be used, between others, to monitor your USB activity. Take a look at the following screenshot.
I 've filtered out the packets regarding Nitrokey with the filter at the top. This is, of course, particular to your computer and the address that your device was given during enumeration. This screenshot actually lists a lot of the things I've been talking about in my previous posts. As you can see, the host first requests the device descriptor and the device responds to the GET DESCRIPTOR DEVICE request. Then it request the first bytes of the Configuration Descriptor, the device responds and now the host knows the total length of the Configuration Descriptor. So in a new request it asks for the whole Configuration Descriptor.
This is just an example of usb debugging, which unfortunately in my case took hours before I was able to solve it (mainly because I thought some parts of my code were the problem). You see what I did was that I forgot that the wDescriptorLength (you can see that in the highlighted section) is composed of two bytes, one for the high part and one for the low. I thought it was only one byte, so when the host retrieved the wDescriptorLength, it used the next byte (which was supposed to be the size of the Endpoint Descriptor) as the high part, thinking my descriptor length would be 0x0722 instead of 0x0022. But to be honest, even though these kinds of mistakes annoy you, it's a fun procedure to see the actual packets involved and analysing what mistakes have been made :)
Yet again, debugging is what you need. In my project and with the problems I'm dealing with right now, I needed a USB protocol analyzer. I'm working on Linux, so a lot of the tools that the USB organization is providing aren't any help for me, but I managed to find a program called Wireshark (https://www.wireshark.org/). Wireshark is a network protocol analyzer and can be used, between others, to monitor your USB activity. Take a look at the following screenshot.
I 've filtered out the packets regarding Nitrokey with the filter at the top. This is, of course, particular to your computer and the address that your device was given during enumeration. This screenshot actually lists a lot of the things I've been talking about in my previous posts. As you can see, the host first requests the device descriptor and the device responds to the GET DESCRIPTOR DEVICE request. Then it request the first bytes of the Configuration Descriptor, the device responds and now the host knows the total length of the Configuration Descriptor. So in a new request it asks for the whole Configuration Descriptor.
This is just an example of usb debugging, which unfortunately in my case took hours before I was able to solve it (mainly because I thought some parts of my code were the problem). You see what I did was that I forgot that the wDescriptorLength (you can see that in the highlighted section) is composed of two bytes, one for the high part and one for the low. I thought it was only one byte, so when the host retrieved the wDescriptorLength, it used the next byte (which was supposed to be the size of the Endpoint Descriptor) as the high part, thinking my descriptor length would be 0x0722 instead of 0x0022. But to be honest, even though these kinds of mistakes annoy you, it's a fun procedure to see the actual packets involved and analysing what mistakes have been made :)
