<div dir="ltr">> I suspect the compiler could cause this. 6.2 vs 4.9.3 is a great version<br>> difference (assuming this is the one from your next email). Our<br>> regnual's binary files' sizes are different (either compiler or<br>> different ./configure setting).<br><br>I use that version for the Gnuk 1.2.2-fix branch compile as well indeed. It might very well be a breaking change then.<br><br>> Also, you have not shown in log the configuration phase. Possible other<br>> causes:<br>> - improper chopstx commit (`git submodule update` should be issued after<br>> checkout)<br>> - regnual and gnuk binaries have not been recompiled after checkout and<br>> ./configure command<br>> - vid/pid not set or set to wrong value for ./configuration script<br>> (defaults should be matched by upgrade script AFAIR)<br><br>I don't have my terminal log anymore, but I did a fresh checkout into a new folder including a git submodule update. (Otherwise the chopstx folder would be empty and the compile fails). I did also checked usb_strings.py and gnuk_token.py because earlier versions had the FSIJ ID hardcoded in there, but that is in a seperate file now. Therefore I do know that the device was listed in lsusb, otherwise I woudln't know the Clay Logic ID.<br><br>My configure command for gnuk was (shell history for the win):<br><br> ./configure --target=NITROKEY_START --vidpid="20a0:4211"<br><br>regnual is just a make (no ./configure file there).<br><br>Jan sent me the original nitrokey 1.0.4 firmware in compiled form:<br><br> $ md5sum nitrokey-start-firmware-1.0.4-1a.hex <br> 5507fabe87dcc68e4a931ab014940af6 nitrokey-start-firmware-1.0.4-1a.hex<br> $ sha512sum ../nitrokey-start-firmware-1.0.4-1a.hex <br> f318d5bb375889076f109282237f28da6dc4b3e392aa9e14d4c2dac56763f48656b0e010039a0039928e8ee0087a3e6f2833cffa978fbe4ace72b506fae13260 ../nitrokey-start-firmware-1.0.4-1a.hex<br><br>To downgrade the Nitrokey and try if the update then fails, since I had errors compiling gnuk.<br><br> $ python2 usb_strings.py <br> Device: <br> Vendor: Nitrokey<br> Product: Nitrokey Start<br> Serial: FSIJ-1.2.2-87042430<br> Revision: release/1.0.2-471-g1a76ab5<br> Config: NITROKEY_START:dfu=no:debug=no:pinpad=no:certdo=no<br> Sys: 3.0<br><br><br> $ lsusb -v -s 002:019<br><br> Bus 002 Device 019: ID 20a0:4211 Clay Logic <br> Device Descriptor:<br> bLength 18<br> bDescriptorType 1<br> bcdUSB 1.10<br> bDeviceClass 0 <br> bDeviceSubClass 0 <br> bDeviceProtocol 0 <br> bMaxPacketSize0 64<br> idVendor 0x20a0 Clay Logic<br> idProduct 0x4211 <br> bcdDevice 2.00<br> iManufacturer 1 Nitrokey<br> iProduct 2 Nitrokey Start<br> iSerial 3 FSIJ-1.2.2-87042430<br> bNumConfigurations 1<br> Configuration Descriptor:<br> bLength 9<br> bDescriptorType 2<br> wTotalLength 93<br> bNumInterfaces 1<br> bConfigurationValue 1<br> iConfiguration 0 <br> bmAttributes 0x80<br> (Bus Powered)<br> MaxPower 100mA<br> Interface Descriptor:<br> bLength 9<br> bDescriptorType 4<br> bInterfaceNumber 0<br> bAlternateSetting 0<br> bNumEndpoints 3<br> bInterfaceClass 11 Chip/SmartCard<br> bInterfaceSubClass 0 <br> bInterfaceProtocol 0 <br> iInterface 0 <br> ChipCard Interface Descriptor:<br> bLength 54<br> bDescriptorType 33<br> bcdCCID 1.10 (Warning: Only accurate for version 1.0)<br> nMaxSlotIndex 0<br> bVoltageSupport 1 5.0V <br> dwProtocols 2 T=1<br> dwDefaultClock 4000<br> dwMaxiumumClock 4000<br> bNumClockSupported 0<br> dwDataRate 9600 bps<br> dwMaxDataRate 9600 bps<br> bNumDataRatesSupp. 0<br> dwMaxIFSD 254<br> dwSyncProtocols 00000000 <br> dwMechanical 00000000 <br> dwFeatures 0002047A<br> Auto configuration based on ATR<br> Auto voltage selection<br> Auto clock change<br> Auto baud rate change<br> Auto parameter negotation made by CCID<br> Auto IFSD exchange<br> Short APDU level exchange<br> dwMaxCCIDMsgLen 271<br> bClassGetResponse echo<br> bClassEnvelope FF<br> wlcdLayout none<br> bPINSupport 0 <br> bMaxCCIDBusySlots 1<br> Endpoint Descriptor:<br> bLength 7<br> bDescriptorType 5<br> bEndpointAddress 0x81 EP 1 IN<br> bmAttributes 2<br> Transfer Type Bulk<br> Synch Type None<br> Usage Type Data<br> wMaxPacketSize 0x0040 1x 64 bytes<br> bInterval 0<br> Endpoint Descriptor:<br> bLength 7<br> bDescriptorType 5<br> bEndpointAddress 0x01 EP 1 OUT<br> bmAttributes 2<br> Transfer Type Bulk<br> Synch Type None<br> Usage Type Data<br> wMaxPacketSize 0x0040 1x 64 bytes<br> bInterval 0<br> Endpoint Descriptor:<br> bLength 7<br> bDescriptorType 5<br> bEndpointAddress 0x82 EP 2 IN<br> bmAttributes 3<br> Transfer Type Interrupt<br> Synch Type None<br> Usage Type Data<br> wMaxPacketSize 0x0004 1x 4 bytes<br> bInterval 255<br> can't get debug descriptor: Resource temporarily unavailable<br> Device Status: 0x0000<br> (Bus Powered)<br><br><br>I suspect regnual and the device are confused about the downgrade since it seems to work initially, but not entirely (regnual fix branch):<br><br><br> $ python2 ./upgrade_by_passwd.py -f ../regnual/regnual.bin ../nitrokey-start-firmware-1.0.4-1a.hex <br> ../regnual/regnual.bin: 4372<br> ../nitrokey-start-firmware-1.0.4-1a.hex: 164224<br> CRC32: f3fafa79<br><br> Device: <br> Configuration: 1<br> Interface: 0<br> 20002800:20005000<br> Downloading flash upgrade program...<br> start 20002800<br> end 20003900<br> Run flash upgrade program...<br> Waiting for device to appear:<br> - Wait 1 seconds...<br> Device: <br> 08001000:08020000<br> Downloading the program<br> start 08001000<br> end 08028100<br> Traceback (most recent call last):<br> File "./upgrade_by_passwd.py", line 134, in <module><br> main(wait_e, keyno, passwd, data_regnual, data_upgrade[4096:])<br> File "./upgrade_by_passwd.py", line 87, in main<br> reg.download(mem_info[0], data_upgrade)<br> File "/home/remy/repo/nitrokey-upfix/tool/gnuk_token.py", line 513, in download<br> value = i, index = 0, timeout = 10000)<br> File "/usr/lib/python2.7/site-packages/usb/legacy.py", line 211, in controlMsg<br> timeout = timeout)<br> File "/usr/lib/python2.7/site-packages/usb/core.py", line 1043, in ctrl_transfer<br> self.__get_timeout(timeout))<br> File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 883, in ctrl_transfer<br> timeout))<br> File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 595, in _check<br> raise USBError(_strerror(ret), ret, _libusb_errno[ret])<br> usb.core.USBError: [Errno 32] Pipe error<br><br><br><br> $ python2 usb_strings.py <br> Device: <br> Vendor: Nitrokey<br> Product: Nitrokey Start<br> Serial: FSIJ-0.0<br><br>Did a DFU flash here to Jans binary:<br><br> $ sudo stm32flash -w nitrokey-start-firmware-1.0.4-1a.hex -g 0x0 /dev/ttyUSB0 <br> stm32flash 0.5<br><br> <a href="http://stm32flash.sourceforge.net/">http://stm32flash.sourceforge.net/</a><br><br> Using Parser : Intel HEX<br> Interface serial_posix: 57600 8E1<br> Version : 0x22<br> Option 1 : 0x00<br> Option 2 : 0x00<br> Device ID : 0x0410 (STM32F10xxx Medium-density)<br> - RAM : 20KiB (512b reserved by bootloader)<br> - Flash : 128KiB (size first sector: 4x1024)<br> - Option RAM : 16b<br> - System RAM : 2KiB<br> Write to memory<br> Erasing memory<br> Wrote address 0x0800e400 (100.00%) Done.<br><br> Starting execution at address 0x08000000... done.<br><br><br><br><br> $ python2 usb_strings.py <br> Device: <br> Vendor: Nitrokey<br> Product: Nitrokey Start<br> Serial: FSIJ-1.0.4-52FF7106<br> Revision: release/1.0.4-6-g739e00e<br> Config: NITROKEY_START:dfu=no:debug=no:pinpad=no:certdo=yes:keygen=yes<br> Sys: 1.0<br><br><br> $ gpg --card-status<br> Reader ...........: 20A0:4211:FSIJ-1.0.4-52FF7106:0<br> Application ID ...: D276000124010200FFFE52FF71060000<br> Version ..........: 2.0<br> Manufacturer .....: unmanaged S/N range<br> Serial number ....: 52FF7106<br> Name of cardholder: [not set]<br> Language prefs ...: [not set]<br> Sex ..............: unspecified<br> URL of public key : [not set]<br> Login data .......: [not set]<br> Signature PIN ....: forced<br> Key attributes ...: rsa2048 rsa2048 rsa2048<br> Max. PIN lengths .: 127 127 127<br> PIN retry counter : 3 3 3<br> Signature counter : 0<br> Signature key ....: [none]<br> Encryption key....: [none]<br> Authentication key: [none]<br> General key info..: [none]<br><br><br><br><br>> The blinking on the device<br>> shows it executed regnual's binary and waits for commands. If it is<br>> listed on lsusb maybe just changing/adding vid/pid in mentioned GNUK_<br>> file would suffice since it is parsed by upgrade script (removing<br>> previously the code uploading regnual to the device).<br><br>Yes, Niibe explained this in an earlier conversation I remember. The device, after starting the flash, did not show up in lsusb again, but dmesg gave no errors, it did that before.<br><br>However, after downgrading and trying to flash the 1.0.4 from Jan, it failed again:<br><br> $ python2 ./upgrade_by_passwd.py -f ../regnual/regnual.bin ../nitrokey-start-firmware-1.0.4-1a.hex <br> ../regnual/regnual.bin: 4372<br> ../nitrokey-start-firmware-1.0.4-1a.hex: 164224<br> CRC32: f3fafa79<br><br> Device: <br> Configuration: 1<br> Interface: 0<br> 20001400:20004a00<br> Downloading flash upgrade program...<br> start 20001400<br> end 20002500<br> Run flash upgrade program...<br> Waiting for device to appear:<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> ^CTraceback (most recent call last):<br> File "./upgrade_by_passwd.py", line 134, in <module><br> main(wait_e, keyno, passwd, data_regnual, data_upgrade[4096:])<br> File "./upgrade_by_passwd.py", line 75, in main<br> time.sleep(wait_e)<br> KeyboardInterrupt<br><br>This time with the green LED blinking, and the dmesg errors:<br><br> [Tue Dec 20 17:05:12 2016] usb 1-1-port1: disabled by hub (EMI?), re-enabling...<br> [Tue Dec 20 17:05:12 2016] usb 1-1.1: USB disconnect, device number 4<br> [Tue Dec 20 17:05:12 2016] usb 1-1.1: new low-speed USB device number 5 using ehci-pci<br> [Tue Dec 20 17:05:13 2016] usb 1-1.1: device descriptor read/64, error -32<br> [Tue Dec 20 17:05:13 2016] usb 1-1.1: device descriptor read/64, error -32<br> [Tue Dec 20 17:05:13 2016] usb 1-1.1: new low-speed USB device number 6 using ehci-pci<br> [Tue Dec 20 17:05:13 2016] usb 1-1.1: device descriptor read/64, error -32<br> [Tue Dec 20 17:05:13 2016] usb 1-1.1: device descriptor read/64, error -32<br> [Tue Dec 20 17:05:13 2016] usb 1-1.1: new low-speed USB device number 7 using ehci-pci<br> [Tue Dec 20 17:05:14 2016] usb 1-1.1: device not accepting address 7, error -32<br> [Tue Dec 20 17:05:14 2016] usb 1-1.1: new low-speed USB device number 8 using ehci-pci<br> [Tue Dec 20 17:05:14 2016] usb 1-1.1: device not accepting address 8, error -32<br> [Tue Dec 20 17:05:14 2016] usb 1-1-port1: unable to enumerate USB device<br><br>lsusb doesn't show the device.<br><br><DFU flash again to 1.0.4><br><br>I fired up a VM with Ubuntu 16.10 and installed 'gcc-arm-none-eabi binutils-arm-none-eabi libnewlib-arm-none-eabi build-essential' to compile everything there:<br><br> root@compile:~/nitrokey-upfix/regnual# arm-none-eabi-gcc -v<br> Using built-in specs.<br> COLLECT_GCC=arm-none-eabi-gcc<br> COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-none-eabi/4.9.3/lto-wrapper<br> Target: arm-none-eabi<br> gcc version 4.9.3 20150529 (prerelease) (15:4.9.3+svn231177-1) <br><br>Compile log (make) here: <a href="http://pastebin.com/ztLL9d5Q">http://pastebin.com/ztLL9d5Q</a><br><br> $ sha512sum src/build/gnuk.bin <br> 32770c3b05a9c7972cf249b320e38358ce7c91d9bc65bd3f2ea6d8afba167a9407fbfa94898b3d721336114d6ac253f638a4a783c58fd0956599c3b4177a2397 src/build/gnuk.bin<br> $ sha512sum regnual/regnual.bin <br> 13cf8536d4a524c42ac88dac059f209c6853df1e4cc608d5f4bf07cc6fa1c65cbbb0d10393784c0dd31b7f702ca60bdb24e90d8ebb0cff421712bd30632fc4a9 regnual/regnual.bin<br><br>Trying the upgrade again with a compile from the same gcc as you (4.9) to 1.2.2 fix branch:<br><br> $ python2 usb_strings.py <br> Device: <br> Vendor: Nitrokey<br> Product: Nitrokey Start<br> Serial: FSIJ-1.0.4-52FF7106<br> Revision: release/1.0.4-6-g739e00e<br> Config: NITROKEY_START:dfu=no:debug=no:pinpad=no:certdo=yes:keygen=yes<br> Sys: 1.0<br><br><br> $ python2 ./upgrade_by_passwd.py -f ../regnual/regnual.bin ../src/build/gnuk.bin <br> ../regnual/regnual.bin: 4388<br> ../src/build/gnuk.bin: 110592<br> CRC32: a4811640<br><br> Device: <br> Configuration: 1<br> Interface: 0<br> 20001400:20004a00<br> Downloading flash upgrade program...<br> start 20001400<br> end 20002500<br> Run flash upgrade program...<br> Waiting for device to appear:<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> - Wait 1 seconds...<br> ^CTraceback (most recent call last):<br> File "./upgrade_by_passwd.py", line 134, in <module><br> main(wait_e, keyno, passwd, data_regnual, data_upgrade[4096:])<br> File "./upgrade_by_passwd.py", line 75, in main<br> time.sleep(wait_e)<br> KeyboardInterrupt<br><br><br><br>Then I flashed via DFU the 1.2.2-fix compiled binary, which worked:<br><br> $ sudo stm32flash -w ../src/build/gnuk.bin -g 0x0 /dev/ttyUSB0 <br> stm32flash 0.5<br><br> <a href="http://stm32flash.sourceforge.net/">http://stm32flash.sourceforge.net/</a><br><br> Using Parser : Raw BINARY<br> Interface serial_posix: 57600 8E1<br> Version : 0x22<br> Option 1 : 0x00<br> Option 2 : 0x00<br> Device ID : 0x0410 (STM32F10xxx Medium-density)<br> - RAM : 20KiB (512b reserved by bootloader)<br> - Flash : 128KiB (size first sector: 4x1024)<br> - Option RAM : 16b<br> - System RAM : 2KiB<br> Write to memory<br> Erasing memory<br> Wrote address 0x0801b000 (100.00%) Done.<br><br> Starting execution at address 0x08000000... done.<br><br><br><br> $ python2 usb_strings.py <br> Device: <br> Vendor: Nitrokey<br> Product: Nitrokey Start<br> Serial: FSIJ-1.2.2-87042430<br> Revision: release/1.0.2-471-g1a76ab5-modified<br> Config: NITROKEY_START:dfu=no:debug=no:pinpad=no:certdo=no<br> Sys: 3.0<br><br><br>After which regnual upgrade works again:<br><br> $ python2 ./upgrade_by_passwd.py -f ../regnual/regnual.bin ../src/build/gnuk.bin <br> ../regnual/regnual.bin: 4388<br> ../src/build/gnuk.bin: 110592<br> CRC32: a4811640<br><br> Device: <br> Configuration: 1<br> Interface: 0<br> 20002800:20005000<br> Downloading flash upgrade program...<br> start 20002800<br> end 20003900<br> Run flash upgrade program...<br> Waiting for device to appear:<br> - Wait 1 seconds...<br> Device: <br> 08001000:08020000<br> Downloading the program<br> start 08001000<br> end 0801b000<br> Resetting device<br> Update procedure finished<br><br><br> $ python2 usb_strings.py <br> Device: <br> Vendor: Nitrokey<br> Product: Nitrokey Start<br> Serial: FSIJ-1.2.2-87042430<br> Revision: release/1.0.2-471-g1a76ab5-modified<br> Config: NITROKEY_START:dfu=no:debug=no:pinpad=no:certdo=no<br> Sys: 3.0<br><br><br>So I'm unsure why you're unable to reproduce it and I can reliably reproduce it. Upgrading from 1.0.4 fails with this regnual-fix and upgrading 1.2.2 with regnual works. Downgrading with dfu to 1.0.4 and then upgrading fails, but after dfu-ing to 1.2.2 upgrading to 1.2.2 works. Even compiling with the same version still allows for reproducable error.<br><br>If, after upgrading with regnual to 1.2.2 I try to downgrade, it also fails reproducably:<br><br> $ python2 ./upgrade_by_passwd.py -f ../regnual/regnual.bin ../nitrokey-start-firmware-1.0.4-1a.hex ../regnual/regnual.bin: 4388<br> ../nitrokey-start-firmware-1.0.4-1a.hex: 164224<br> CRC32: a4811640<br><br> Device: <br> Configuration: 1<br> Interface: 0<br> 20002800:20005000<br> Downloading flash upgrade program...<br> start 20002800<br> end 20003900<br> Run flash upgrade program...<br> Waiting for device to appear:<br> - Wait 1 seconds...<br> Device: <br> 08001000:08020000<br> Downloading the program<br> start 08001000<br> end 08028100<br> Traceback (most recent call last):<br> File "./upgrade_by_passwd.py", line 134, in <module><br> main(wait_e, keyno, passwd, data_regnual, data_upgrade[4096:])<br> File "./upgrade_by_passwd.py", line 87, in main<br> reg.download(mem_info[0], data_upgrade)<br> File "/home/remy/repo/nitrokey-upfix/tool/gnuk_token.py", line 513, in download<br> value = i, index = 0, timeout = 10000)<br> File "/usr/lib/python2.7/site-packages/usb/legacy.py", line 211, in controlMsg<br> timeout = timeout)<br> File "/usr/lib/python2.7/site-packages/usb/core.py", line 1043, in ctrl_transfer<br> self.__get_timeout(timeout))<br> File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 883, in ctrl_transfer<br> timeout))<br> File "/usr/lib/python2.7/site-packages/usb/backend/libusb1.py", line 595, in _check<br> raise USBError(_strerror(ret), ret, _libusb_errno[ret])<br> usb.core.USBError: [Errno 32] Pipe error<br><br><br><br>Regarding the 1.0.4 compile on the GCC 4.9, that also fails, long log here: <a href="http://pastebin.com/eMnheCKu">http://pastebin.com/eMnheCKu</a> (that's on the compile VM)<br><br><br>I hope this information helps, if you need any more checking or information please don't hesitate to ask, I'm happy to help :)<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><br><br><a href="https://raymii.org" target="_blank">https://raymii.org</a><br></div></div>
<br><div class="gmail_quote">On Tue, Dec 20, 2016 at 2:35 PM, Szczepan Zalega | Nitrokey <span dir="ltr"><<a href="mailto:szczepan@nitrokey.com" target="_blank">szczepan@nitrokey.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 12/18/2016 12:22 PM, Remy van Elst wrote:<br>
> I was wondering if I could downgrade a Start to gnuk 1.0.4 that came<br>
> with the Nitrokey (from here<br>
> <a href="https://github.com/Nitrokey/nitrokey-start-firmware/commits/master" rel="noreferrer" target="_blank">https://github.com/Nitrokey/<wbr>nitrokey-start-firmware/<wbr>commits/master</a>) but<br>
> the make fails:<br>
><br>
> $ make<br>
<br>
</span>I do not know unfortunately. I make compilation with GCC 4.9.3 on Ubuntu<br>
16.10 (details in attachment). Precompiled firmware's should be<br>
available today in `gnuk1.2-regnual-fix` branch within<br>
`nitrokey-start-firmware` repository [1] (`./prebuilt/` directory).<br>
<br>
<br>
[1]<br>
<a href="https://github.com/Nitrokey/nitrokey-start-firmware/tree/gnuk1.2-regnual-fix" rel="noreferrer" target="_blank">https://github.com/Nitrokey/<wbr>nitrokey-start-firmware/tree/<wbr>gnuk1.2-regnual-fix</a><br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Best regards,<br>
Szczepan<br>
</font></span><br>______________________________<wbr>_________________<br>
gnuk-users mailing list<br>
<a href="mailto:gnuk-users@lists.alioth.debian.org">gnuk-users@lists.alioth.<wbr>debian.org</a><br>
<a href="https://lists.alioth.debian.org/mailman/listinfo/gnuk-users" rel="noreferrer" target="_blank">https://lists.alioth.debian.<wbr>org/mailman/listinfo/gnuk-<wbr>users</a><br>
<br></blockquote></div><br></div>