import serial import struct import sys offset = 0x800 tty = 'tty' baud = 115200 chunksize = 128 def write(s, offset, dat): for i in range(0, len(dat), chunksize): chunk = dat[i: i + chunksize] cmd = struct.pack('