sigrok-fwextract-saleae-logic16: Support vendor software version 1.1.34
authorMarcus Comstedt <marcus@mc.pp.se>
Tue, 14 Apr 2015 07:50:43 +0000 (09:50 +0200)
committerUwe Hermann <uwe@hermann-uwe.de>
Wed, 6 May 2015 15:33:14 +0000 (17:33 +0200)
This fixes bug #398.

firmware/saleae-logic16/sigrok-fwextract-saleae-logic16

index a1213c8674c9e4676f740b1f50ca2e30f1c0ab2c..40c92bac6751dbfb509fc77437ed095563c3fc80 100755 (executable)
@@ -294,6 +294,19 @@ def extract_fx2_firmware(elf, symname, filename):
     f.close()
     print("saved %d bytes to %s" % (len(blob), filename))
 
+def extract_fx2_firmware_single(elf, symname, filename):
+    if not symname in elf.dynsym:
+        return False
+    hex = bytes.decode(elf.load_symbol(elf.dynsym[symname]))
+    if hex[-1] == '\0':
+        hex = hex[:-1]
+    blob = ihex_to_binary(hex.split(';'))
+    f = open(filename, 'wb')
+    f.write(blob)
+    f.close()
+    print("saved %d bytes to %s" % (len(blob), filename))
+    return True
+
 def extract_symbol(elf, symname, filename):
     blob = elf.load_symbol(elf.dynsym[symname])
     f = open(filename, 'wb')
@@ -322,7 +335,8 @@ try:
     elf = parseelf.elf(filename)
     if elf.ehdr['e_machine'] != 3 and elf.ehdr['e_machine'] != 62:
         raise Exception('Unsupported e_machine')
-    extract_fx2_firmware(elf, 'gLogic16HexFileLines', 'saleae-logic16-fx2.fw')
+    if not extract_fx2_firmware_single(elf, 'Logic16FirmwareStrings', 'saleae-logic16-fx2.fw'):
+        extract_fx2_firmware(elf, 'gLogic16HexFileLines', 'saleae-logic16-fx2.fw')
     extract_bitstream(elf, '18')
     extract_bitstream(elf, '33')
 except Exception as e: