X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-util.git;a=blobdiff_plain;f=firmware%2Fsaleae-logic16%2Fsigrok-fwextract-saleae-logic16;fp=firmware%2Fsaleae-logic16%2Fsigrok-fwextract-saleae-logic16;h=40c92bac6751dbfb509fc77437ed095563c3fc80;hp=a1213c8674c9e4676f740b1f50ca2e30f1c0ab2c;hb=2c45c57a7213bb3350d81c7ea6ed99f8a74fdd0b;hpb=6e39ae141c82a394f31b990b98d25633ab0e82ee diff --git a/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 b/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 index a1213c8..40c92ba 100755 --- a/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 +++ b/firmware/saleae-logic16/sigrok-fwextract-saleae-logic16 @@ -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: