# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # from cclib import CCDebugger, hexdump import sys # Open debugger try: dbg = CCDebugger("/dev/ttyACM0") except Exception as e: 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" print "" dbg.enter() dbg.setPC(0x0000) dbg.resume() # Done print ""
sys.exit(4) else: #fine, store this byte flash_data[dest] = data print "> flash usage: %3.1f%% (%d bytes of %d)" % ( (maxMem * 100.0 / dbg.flashSize), maxMem, dbg.flashSize) # Check for oversize data if maxMem > (dbg.flashSize): print "ERROR: Data too bit to fit in chip's memory!" sys.exit(4) try: print "> enter debug:" dbg.enter() if (full_erase): print "> %3d%%: erasing chip..." % (100 * (1.0 / 17)), dbg.chipErase() time.sleep(1) print "done" maxPages = dbg.flashSize / dbg.flashPageSize emptyPage = bytearray([0xFF] * dbg.flashPageSize) for p in range(maxPages): print "> flashing page: %d" % p pageAddress = p * dbg.flashPageSize #data to write
#fine, store this byte flash_data[dest] = data print "> flash usage: %3.1f%% (%d bytes of %d)" % ((maxMem*100.0/dbg.flashSize),maxMem, dbg.flashSize) # Check for oversize data if maxMem > (dbg.flashSize): print "ERROR: Data too bit to fit in chip's memory!" sys.exit(4) print "> flashing:" try: #enter debug mode dbg.enter(); if (full_erase): "> %3d%%: erasing chip..." % (100*(1.0/17)), dbg.chipErase() time.sleep(1) print "done" maxPages = dbg.flashSize/dbg.flashPageSize emptyPage = bytearray([0xFF] * dbg.flashPageSize) for p in range(maxPages): pageAddress = p*dbg.flashPageSize #data to write