Beispiel #1
0
    dbg = CCDebugger(tty)
except Exception as e:
    print "ERROR: %s" % str(e)
    sys.exit(1)

print "> using file " + filename

# Get info
print "> Chip information:"
print "                     Chip ID    : 0x%04x" % dbg.chipID
print "                     Flash size : %3i Kb" % dbg.chipInfo['flash']
print "                    SRAM size   : %3i Kb" % dbg.chipInfo['sram']
print ""

# Parse the HEX file
hexFile = CCHEXFile(filename)
hexFile.load()

# Display sections & calculate max memory usage
maxMem = 0

#build flash image
flash_data = bytearray([0xFF] * dbg.flashSize)

print "> Sections in %s:\n" % filename
print "            Addr.    Size"
print "            -------- -------------"
for mb in hexFile.memBlocks:

    # Calculate top position
    memTop = mb.addr + mb.size
Beispiel #2
0
			if not hasLicense:
				binfo['hwver'] = 0x01
		else:
			hwvMessage = "(From command-line)"
			binfo['hwver'] = int(sys.argv[4])

# Print collected license information
print "\nLicense information:"
print " IEEE Address : %s" % serial
print " H/W Version  : %02x" % binfo['hwver'], hwvMessage
print "   BT Address : %s" % binfo['btaddr'], btaMessage
print "      License : %s" % binfo['license'], licMessage
print ""

# Parse the HEX file
hexFile = CCHEXFile( sys.argv[1] )
hexFile.load()

# Display sections & calculate max memory usage
maxMem = 0
print "Sections in %s:\n" % sys.argv[1]
print " Addr.    Size"
print "-------- -------------"
for mb in hexFile.memBlocks:

	# Calculate top position
	memTop = mb.addr + mb.size
	if memTop > maxMem:
		maxMem = memTop

	# Print portion
Beispiel #3
0
from cclib import CCHEXFile, getOptions, openCCDebugger
import sys

# Get serial port either form environment or from arguments
opts = getOptions("Generic CCDebugger Flash Reader Tool", hexOut=True)

# Open debugger
try:
    dbg = openCCDebugger(opts['port'], enterDebug=opts['enter'])
except Exception as e:
    print "ERROR: %s" % str(e)
    sys.exit(1)

# Get serial number
print "\nReading %i KBytes to %s..." % (dbg.chipInfo['flash'], opts['out'])
hexFile = CCHEXFile(opts['out'])

# Read in chunks of 4Kb (for UI-update purposes)
for i in range(0, int(dbg.chipInfo['flash'] / 4)):

    # Read CODE
    chunk = dbg.readCODE(i * 0x1000, 0x1000)

    # Write chunk to file
    hexFile.stack(chunk)

    # Log status
    print "\r    Progress %.0f%%..." % ((
        (i + 1) * 4 * 100) / dbg.chipInfo['flash']),
    sys.stdout.flush()
Beispiel #4
0
from cclib.extensions.bluegiga import BlueGigaCCDebugger
import sys

# Get serial port either form environment or from arguments
opts = getOptions("BlueGiga-Specific CCDebugger Flash Reader Tool", hexOut=True)

# Open debugger
try:
	dbg = openCCDebugger(opts['port'], enterDebug=opts['enter'], driver=BlueGigaCCDebugger)
except Exception as e:
	print("ERROR: %s" % str(e))
	sys.exit(1)

# Get serial number
print("\nReading %i KBytes to %s..." % (dbg.chipInfo['flash'], opts['out']))
hexFile = CCHEXFile(opts['out'])

# Read in chunks of 4Kb (for UI-update purposes)
for i in range(0, int(dbg.chipInfo['flash'] / 4)):

	# Read CODE
	chunk = dbg.readCODE( i * 0x1000, 0x1000 )

	# Write chunk to file
	hexFile.stack(chunk)

	# Log status
	print("\r    Progress %.0f%%..." % ( ( (i+1)*4 * 100) / dbg.chipInfo['flash'] ), end=' ')
	sys.stdout.flush()

# Log completion
Beispiel #5
0
    sys.exit(1)

# Get offset
offset = 0
if opts['offset']:
    if opts['offset'][0:2] == "0x":
        offset = int(opts['offset'], 16)
    else:
        offset = int(opts['offset'])
    print("NOTE: The memory addresses are offset by %i bytes!" % offset)

# Get bluegiga-specific info
serial = dbg.getSerial()

# Parse the HEX file
hexFile = CCHEXFile(opts['in'])
hexFile.load()

# Display sections & calculate max memory usage
maxMem = 0
print("Sections in %s:\n" % opts['in'])
print(" Addr.    Size")
print("-------- -------------")
for mb in hexFile.memBlocks:

    # Calculate top position
    memTop = mb.addr + mb.size
    if memTop > maxMem:
        maxMem = memTop

    # Print portion
Beispiel #6
0
	sys.exit(1)

# Get offset
offset = 0
if opts['offset']:
	if opts['offset'][0:2] == "0x":
		offset = int(opts['offset'], 16)
	else:
		offset = int(opts['offset'])
	print("NOTE: The memory addresses are offset by %i bytes!" % offset)

# Get bluegiga-specific info
serial = dbg.getSerial()

# Parse the HEX file
hexFile = CCHEXFile( opts['in'] )
hexFile.load()

# Display sections & calculate max memory usage
maxMem = 0
print("Sections in %s:\n" % opts['in'])
print(" Addr.    Size")
print("-------- -------------")
for mb in hexFile.memBlocks:

	# Calculate top position
	memTop = mb.addr + mb.size
	if memTop > maxMem:
		maxMem = memTop

	# Print portion
Beispiel #7
0
	print "ERROR: %s" % str(e)
	sys.exit(1)

# Get info
print "\nChip information:"
print "      Chip ID : 0x%04x" % dbg.chipID
print "   Flash size : %i Kb" % dbg.chipInfo['flash']
print "    SRAM size : %i Kb" % dbg.chipInfo['sram']
if dbg.chipInfo['usb']:
	print "          USB : Yes"
else:
	print "          USB : No"

# Get serial number
print "\nReading %i KBytes to %s..." % (dbg.chipInfo['flash'], sys.argv[1])
hexFile = CCHEXFile(sys.argv[1])

#enter debug mode
dbg.enter()

try:
	maxPages = dbg.chipInfo['flash']
	for p in range(maxPages):
		pageAddress = p*dbg.flashPageSize
		
		print "\r> %3d%%: reading page %d of %d..." % ((((100.0*p)/(maxPages-1))), p, maxPages-1),
		sys.stdout.flush()
		
		readPage = dbg.readFlashPage(pageAddress)
		#for x in readPage:
		#	print "%02X" % (x),
Beispiel #8
0
            if not hasLicense:
                binfo['hwver'] = 0x01
        else:
            hwvMessage = "(From command-line)"
            binfo['hwver'] = int(opts['ver'])

# Print collected license information
print "\nLicense information:"
print " IEEE Address : %s" % serial
print " H/W Version  : %02x" % binfo['hwver'], hwvMessage
print "   BT Address : %s" % binfo['btaddr'], btaMessage
print "      License : %s" % binfo['license'], licMessage
print ""

# Parse the HEX file
hexFile = CCHEXFile(opts['in'])
hexFile.load()

# Display sections & calculate max memory usage
maxMem = 0
print "Sections in %s:\n" % opts['in']
print " Addr.    Size"
print "-------- -------------"
for mb in hexFile.memBlocks:

    # Calculate top position
    memTop = mb.addr + mb.size
    if memTop > maxMem:
        maxMem = memTop

    # Print portion
	print "ERROR: %s" % str(e)
	sys.exit(1)

# Get info
print "\nChip information:"
print "      Chip ID : 0x%04x" % dbg.chipID
print "   Flash size : %i Kb" % dbg.chipInfo['flash']
print "    SRAM size : %i Kb" % dbg.chipInfo['sram']
if dbg.chipInfo['usb']:
	print "          USB : Yes"
else:
	print "          USB : No"

# Get serial number
print "\nReading %i KBytes to %s..." % (dbg.chipInfo['flash'], sys.argv[1])
hexFile = CCHEXFile(sys.argv[1])

#enter debug mode
dbg.enter()

try:
	maxPages = dbg.chipInfo['flash']
	for p in range(maxPages):
		pageAddress = p*dbg.flashPageSize
		
		print "\r> %3d%%: reading page %d of %d..." % ((((100.0*p)/(maxPages-1))), p, maxPages-1),
		sys.stdout.flush()
		
		readPage = dbg.readFlashPage(pageAddress)
		for x in readPage:
			print "%02X" % (x),