parser.add_argument('--flash', action='store', help='hex file to program') args, unknown = parser.parse_known_args() key_dir = args.key_dir used_key_dir = get_used_key_dir(key_dir) key_db_file = get_key_db_file(key_dir) initialSetup(key_dir, used_key_dir, key_db_file) dbdict = readDB(key_db_file) unused_keys = readKeyFiles(key_dir) try: flasher = flashProgrammer(args.openocd_dir) if flasher.connected is True: print('Connected to openOCD') flasher._sendCmd('reset halt') # Make sure the processor is stopped uid = readUID(flasher) print('Device UID is ' + uid) # Check if key is already present in this device if dcdcCheck(flasher) is False: # Check database to see if we've already flashed this device if uid in dbdict: # Already used
help='key directory') parser.add_argument('--flash', action='store', help='hex file to program') args, unknown = parser.parse_known_args() key_dir = args.key_dir used_key_dir = get_used_key_dir(key_dir) key_db_file = get_key_db_file(key_dir) initialSetup(key_dir, used_key_dir, key_db_file) dbdict = readDB(key_db_file) unused_keys = readKeyFiles(key_dir) try: flasher = flashProgrammer(args.openocd_dir) if flasher.connected is True: print('Connected to openOCD') flasher._sendCmd('reset halt') # Make sure the processor is stopped uid = readUID(flasher) print('Device UID is ' + uid) # Check if key is already present in this device if dcdcCheck(flasher) is False: # Check database to see if we've already flashed this device if uid in dbdict: # Already used
#!/usr/bin/env python # -*- coding: utf-8 -*- from openocd.flashProgrammer import flashProgrammer # # Quick example of reading UID, erasing flash, programming flash, and reading back flash # flasher = flashProgrammer() if flasher.connected is True: flasher._sendCmd('reset halt') # Read device unique ID uid_bytes = flasher.readMem(0x1FFFF7E8, 12) uid = '' for byte in range(len(uid_bytes)): uid += '{:02X}'.format(uid_bytes[byte]) print('uid:') print(uid) flasher.erase(0x800d400, 0x400) flasher.flashFile('/Users/alvaro/Desktop/test.bin', 0x800d400) print flasher.verifyFile('/Users/alvaro/Desktop/test.bin', 0x800d400) print flasher.verifyFile('/Users/alvaro/Desktop/flash.bin', 0x800d400) # flasher.dumpImage('/Users/alvaro/Desktop/flash.bin', 0x800d400, 0x400) flasher.kill()