[Gnuk-users] Regnual firmware update in Gnuk-1.0.x

NIIBE Yutaka gniibe at fsij.org
Fri Aug 28 02:05:51 UTC 2015


On 08/28/2015 08:45 AM, Mateusz Zalega wrote:
> Run flash upgrade program...
> Wait 3 seconds...
> Traceback (most recent call last):
>   File "./upgrade_by_passwd.py", line 112, in <module>
>     main(passwd, data_regnual, data_upgrade[4096:])
>   File "./upgrade_by_passwd.py", line 82, in main
>     mem_info = reg.mem_info()
> AttributeError: 'NoneType' object has no attribute 'mem_info

At Debconf15, we encountered same problem on dkg's computer.

The upgrade process is:

   On host PC,

   (1) Register public key for firmware upgrade authentication
       (by PIN authentication)

   (2) Invoke firmware upgrade by public key authentication

   (3) Send reGNUal (flash upgrade program) to FST-01
       (reGNUal is the helper program which does receive new firmware
        and flash it on the memory of MCU)

   (4) Send new firmware

On some hosts, the error occurs between (3) and (4).

The device side of FST-01 shutdowns USB communication as Gnuk Token,
and restarts as new USB device.  It expects host does re-enumeration
(scan the USB plug-and-play process) again to detect the device
change.  It takes some time for host PC.  I guessed that three seconds
were enough for all situations.


I think that following may help your situation.

diff --git a/tool/upgrade_by_passwd.py b/tool/upgrade_by_passwd.py
index 49e13b3..d7b5319 100755
--- a/tool/upgrade_by_passwd.py
+++ b/tool/upgrade_by_passwd.py
@@ -67,8 +67,8 @@ def main(keyno, passwd, data_regnual, data_upgrade):
     del gnuk
     gnuk = None
     #
-    print("Wait 3 seconds...")
-    time.sleep(3)
+    print("Wait 10 seconds...")
+    time.sleep(10)
     # Then, send upgrade program...
     reg = None
     for dev in gnuk_devices_by_vidpid():


Since the script is written using old API of libusb, we just wait
here.  Obviously, retries on failure or better error handling is
expected here.

When it will be migrated to new API of libusb, we can take advantage
of its event-based API.
-- 



More information about the gnuk-users mailing list