3 ## This file is part of the sigrok-util project.
5 ## Copyright (C) 2013 Marcus Comstedt <marcus@mc.pp.se>
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 3 of the License, or
10 ## (at your option) any later version.
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
24 def extract_symbol(elf, symname, filename):
25 blob = elf.load_symbol(elf.dynsym[symname])
26 f = open(filename, 'wb')
29 print("saved %d bytes to %s" % (len(blob), filename))
31 def extract_bitstream(elf, lv):
32 extract_symbol(elf, 'gLogic16Lv'+lv+'CompressedBitstream',
33 'saleae-logic16-fpga-'+lv+'.bitstream')
36 print("sigrok-fwextract-saleae-logic16 <programfile>")
44 if len(sys.argv) != 2:
48 filename = sys.argv[1]
49 elf = parseelf.elf(filename)
50 extract_bitstream(elf, '18')
51 extract_bitstream(elf, '33')
52 except Exception as e:
53 print("Error: %s" % str(e))