def write_vmu(handle): bus = maple.MapleProxy() # Quick bus enumeration bus.deviceInfo(maple.ADDRESS_CONTROLLER) bus.deviceInfo(maple.ADDRESS_PERIPH1) bus.getMemInfo(maple.ADDRESS_PERIPH1) print "Writing 256 blocks..." for block_num in range(DUMP_SIZE / BLOCK_SIZE): sys.stdout.write('.') sys.stdout.flush() orig_data = bus.readFlash(maple.ADDRESS_PERIPH1, block_num, 0) target_data = handle.read(BLOCK_SIZE) if orig_data != target_data: for phase_num in range(BLOCK_SIZE / WRITE_SIZE): #print block_num, phase_num data = target_data[phase_num * WRITE_SIZE:(phase_num + 1) * WRITE_SIZE] bus.writeFlash(maple.ADDRESS_PERIPH1, block_num, phase_num, data) new_data = bus.readFlash(maple.ADDRESS_PERIPH1, block_num, 0) if new_data != target_data: print "Problem: data mis-match" print maple.debug_hex(target_data) print maple.debug_hex(new_data) return print # Do a dummy read of one block to turn off the transferring-data icon bus.readFlash(maple.ADDRESS_PERIPH1, 0, 0)
def read_vmu(): bus = maple.MapleProxy() # Quick bus enumeration bus.deviceInfo(maple.ADDRESS_CONTROLLER) bus.deviceInfo(maple.ADDRESS_PERIPH1) bus.getCond(maple.ADDRESS_CONTROLLER, maple.FN_CONTROLLER) bus.getCond(maple.ADDRESS_PERIPH1, maple.FN_CLOCK) bus.getMemInfo(maple.ADDRESS_PERIPH1) print bus.readFlash(maple.ADDRESS_PERIPH1, 0, 0)
def main(): parser = argparse.ArgumentParser() parser.add_argument('-p', '--port', default=maple.PORT) parser.add_argument('filename') args = parser.parse_args() if args.filename == '-': image = maple.load_image(sys.stdin) else: image = maple.load_image(args.filename) bus = maple.MapleProxy(args.port) bus.deviceInfo(maple.ADDRESS_CONTROLLER) bus.deviceInfo(maple.ADDRESS_PERIPH1) bus.writeLCD(maple.ADDRESS_PERIPH1, image)
def read_vmu(handle): bus = maple.MapleProxy() # Quick bus enumeration bus.deviceInfo(maple.ADDRESS_CONTROLLER) bus.deviceInfo(maple.ADDRESS_PERIPH1) bus.getCond(maple.ADDRESS_CONTROLLER, maple.FN_CONTROLLER) bus.getCond(maple.ADDRESS_PERIPH1, maple.FN_CLOCK) bus.getMemInfo(maple.ADDRESS_PERIPH1) for block_num in range(NUM_BLOCKS): sys.stdout.write('.') sys.stdout.flush() data = bus.readFlash(maple.ADDRESS_PERIPH1, 0, 0) handle.write(data)
def read_vmu(port, start_block=0, end_block=LAST_BLOCK): bus = maple.MapleProxy(port) # Quick bus enumeration bus.deviceInfo(maple.ADDRESS_CONTROLLER) bus.deviceInfo(maple.ADDRESS_PERIPH1) bus.getCond(maple.ADDRESS_CONTROLLER, maple.FN_CONTROLLER) bus.getCond(maple.ADDRESS_PERIPH1, maple.FN_CLOCK) bus.getMemInfo(maple.ADDRESS_PERIPH1) for block_num in range(start_block, end_block + 1): sys.stdout.write(chr(13) + chr(27) + '[K' + 'Reading block %d of 255' % (block_num,)) sys.stdout.flush() data = bus.readFlash(maple.ADDRESS_PERIPH1, block_num, 0) yield data