From: Jan Luebbe Date: Tue, 11 Jul 2017 19:20:47 +0000 (+0200) Subject: sigrok-fwextract-saleae-logic16: Add extraction of Logic Pro firmware X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c91650aeee9b219c08954dcaffa2d22bbc63da64;p=sigrok-util.git sigrok-fwextract-saleae-logic16: Add extraction of Logic Pro firmware This was tested with vendor software version 1.2.10. --- diff --git a/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 b/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 index 40c92ba..460bfb1 100755 --- a/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 +++ b/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 @@ -307,6 +307,31 @@ def extract_fx2_firmware_single(elf, symname, filename): print("saved %d bytes to %s" % (len(blob), filename)) return True +def extract_fx3_firmware(elf, symname, filename): + index = 0 + blobs = [] + while True: + sym = elf.dynsym.get(symname + '_' + str(index)) + if not sym: + break + index += 1 + hex = bytes.decode(elf.load_symbol(sym)) + if hex[-1] == '\0': + hex = hex[:-1] + for part in hex.split(';'): + if not part: + continue + if part[0] != ':': + raise Exception('ihex line does not start with ":"') + blobs.append(bytes.fromhex(part[1:])) + if not blobs: + return + with open(filename, 'wb') as f: + for blob in blobs: + f.write(blob) + print("saved %d bytes from %d blobs to %s" % (sum(map(len, blobs)), + len(blobs), filename)) + def extract_symbol(elf, symname, filename): blob = elf.load_symbol(elf.dynsym[symname]) f = open(filename, 'wb') @@ -314,6 +339,11 @@ def extract_symbol(elf, symname, filename): f.close() print("saved %d bytes to %s" % (len(blob), filename)) +def try_extract_symbol(elf, symname, filename): + if not symname in elf.dynsym: + return + extract_symbol(elf, symname, filename) + def extract_bitstream(elf, lv): extract_symbol(elf, 'gLogic16Lv' + lv + 'CompressedBitstream', 'saleae-logic16-fpga-' + lv + '.bitstream') @@ -339,5 +369,9 @@ try: extract_fx2_firmware(elf, 'gLogic16HexFileLines', 'saleae-logic16-fx2.fw') extract_bitstream(elf, '18') extract_bitstream(elf, '33') + extract_fx3_firmware(elf, 'LogicPro16FirmwareStrings', 'saleae-logicpro16-fx3.fw') + extract_fx3_firmware(elf, 'LogicPro8FirmwareStrings', 'saleae-logicpro8-fx3.fw') + try_extract_symbol(elf, 'gLogicPro16CompressedBitstream', 'saleae-logicpro16-fpga.bitstream') + try_extract_symbol(elf, 'gLogicProCompressedBitstream', 'saleae-logicpro8-fpga.bitstream') except Exception as e: print("Error: %s" % str(e))