def read_replay2(dev, cont): # Generated from packet 367/368 cmd_57s(dev, "\x8D\x89", "\x00\x00") # Atomic # Generated from packet 371/372 cmd_50(dev, "\xDD\x05") # Generated from packet 373/374 buff = bulk2(dev, i87c51_fw.p373, target=0x02) validate_read("\x8F\x00", buff, "packet W: 373/374, R: 375/376") # Generated from packet 377/378 cmd_02(dev, "\x90\x00\x70\x63\x09\x00", "packet W: 377/378, R: 379/380") fw_in = fw_read(dev) print('Readback ok') # Generated from packet 401/402 cmd_57s(dev, '\x8C', "\x00\x00") # Atomic # Generated from packet 405/406 cmd_50(dev, "\x0D\x00") # Generated from packet 407/408 buff = bulk2(dev, "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00", target=0x02) validate_read("\x90\x00", buff, "packet W: 407/408, R: 409/410") # Generated from packet 411/412 cmd_02(dev, "\x91\x00\x80\x63\x09\x00", "packet W: 411/412, R: 413/414") # Atomic # Generated from packet 415/416 cmd_57_50(dev, "\x90", "\x1A\x00") # Generated from packet 417/418 buff = bulk2(dev, "\x66\xB9\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00\x66\xB9\x00" \ "\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x91\x00", buff, "packet W: 417/418, R: 419/420") cmd_02(dev, "\x92\x00\xA0\x63\x09\x00", "packet W: 421/422, R: 423/424") cmd_57s(dev, "\x91", "\x00\x00", "packet W: 425/426, R: 427/428") led_mask_30(dev, 'pass') sm_info1(dev) sm_insert(dev) sm_info10(dev) return fw_in
def boot_warm(dev): # Generated from packet 70/71 buff = cmd.bulk2( dev, "\x43\x19\x00\x00\x00\x3B\x7E\x25\x00\x00\xFE\xFF\x3B\x7C\x25\x00" "\x00\xFE\xFF\x00", target=2) validate_read("\xA4\x06", buff, "packet 72/73")
def fw_read(dev, target=4096): print('Verifying firmware readback') # Generated from packet 381/382 # WARNING: unexpected suffix: 0x01 #buff = bulk2(dev, "\x08\x00\x57\x8F\x00", target=len(fw)) buff = bulk2(dev, "\x08\x00\x57\x8F\x00", target=target) return buff
def boot_cold(dev): bulkRead, bulkWrite, controlRead, _controlWrite = usb_wraps(dev) buff = cmd.bulk2( dev, "\x43\x19\x00\x00\x00\x3B\x66\x1B\x00\x00\xFE\xFF\x3B\x64\x1B\x00" "\x00\xFE\xFF\x00", target=2) validate_read("\xA4\x06", buff, "packet 72/73") # Atomic #cmd.cmd_01 state: 0x80 => 0x81 bulkWrite(0x02, cmd.cmd_43_mk("\x00") + cmd.cmd_11_mk()) bulkWrite(0x02, fw.hash2bin["0232b379"]) bulkWrite(0x02, fw.hash2bin["a7292c41"]) bulkWrite(0x02, fw.hash2bin["ce6f13bd"]) bulkWrite(0x02, fw.hash2bin["4398af9b"]) bulkWrite(0x02, fw.hash2bin["250c94c4"]) buff = cmd.bulk2(dev, "\x5A", target=1) validate_read("\x80", buff, "packet 92/93") # Atomic #cmd.cmd_01 state: 0x81 => 0x82 bulkWrite(0x02, "\x11\x10\x00") bulkWrite( 0x02, "\xEA\xCC\x64\x01\x00\x08\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x3F") buff = cmd.bulk2(dev, "\xA6", target=1) validate_read("\x81", buff, "packet 100/101") # Atomic #cmd.cmd_01 state: 0x82 => 0x83 bulkWrite(0x02, "\x11\x4E\x00") bulkWrite( 0x02, "\xE8\x00\x00\x00\x00\xFA\x5A\x83\xEA\x05\x81\xEA\x00\x00\x01\x00" "\x81\xFA\x00\x00\x01\x00\x74\x1F\xBB\x00\x00\x00\x00\xB9\x00\x00" "\x01\x00\x66\x8B\x02\x66\x89\x83\x00\x00\x01\x00\x83\xC2\x02\x83" "\xC3\x02\x83\xE9\x02\x75\xEB\x8C\xC8\x50\xB8\xF0\xFF\x01\x00\x50" "\x0F\x20\xC0\x0D\x00\x00\x00\x60\x0F\x22\xC0\x0F\x09\xC3") buff = cmd.bulk2(dev, "\xDB", target=1) validate_read("\x82", buff, "packet 108/109") #cmd.cmd_01 state: 0x83 => 0x80. Length 129 => 133 # Generated from packet 110/111 buff = cmd.bulk2(dev, "\x82", target=1) validate_read("\x16", buff, "packet 112/113")
def cleanup_adc(dev): _bulkRead, bulkWrite, _controlRead, _controlWrite = usb_wraps(dev) # Generated from packet 1220/1221 bulkWrite(0x02, "\x50\x1A\x00\x00\x00") # Generated from packet 1222/1223 buff = bulk2( dev, "\x66\xB9\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00\x66\xB9\x00" "\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00", target=2) validate_read("\x83\x00", buff, "packet 1224/1225") # Generated from packet 1226/1227 buff = bulk2(dev, "\x02", target=6) validate_read("\x84\x00\x50\x01\x09\x00", buff, "packet 1228/1229") # Generated from packet 1230/1231 buff = bulk2(dev, "\x57\x83\x00", target=2) validate_read("\x00\x00", buff, "packet 1232/1233")
def fw_w(dev, fw, verbose=False): pos = 0 print('FW load: begin') tstart = time.time() while pos < len(fw): remain = len(fw) - pos chunk = fw[pos:pos + min(remain, 0xCC)] if len(chunk) == remain: prefix = 0x08 reply = "\x00" else: prefix = 0x18 reply = "\x0B" if verbose: print((' pos 0X%04X, len 0x%02X, prefix 0x%02X' % (pos, len(chunk), prefix))) buff = bulk2(dev, chr(len(chunk)) + '\x00' + chunk, target=0x01, prefix=prefix) validate_read(reply, buff, "packet W: 429/430, R: 431/432") pos += len(chunk) tend = time.time() print(('FW load : end. Took %0.1f sec' % (tend - tstart, )))
def init_dev(dev, verbose=False): bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev) # bp1410 init signature #validate_read("\x08\x16\x01\x00", devsig, "packet 57/58") buff = controlRead(0xC0, 0xB0, 0x0000, 0x0000, 4096) validate_read("\x00\x00\x00", buff, "packet 62/63") buff = bulkRead(0x86, 0x0200) validate_read("\x08\x16\x01\x00", buff, "packet 64/65") buff = bytearray(cmd.cmd_01(dev)) # Seems to be okay if we always do this although its only sometimes needed glitch_154 = True # All of these are the same except for the state byte # maybe varies depending if SM installed if len(buff) == 129: if verbose: print('Boot: cold') state = buff[0x13] if state != 0x80 and verbose: print((' WARNING: state: 0x%02X. Interrupted load?' % state)) # 70-117 boot_cold(dev) elif len(buff) == 133: if verbose: print('Boot: warm') # 70-76 boot_warm(dev) # elif buff == r01_glitch_154: # print 'Warm boot (glitch)' # glitch_154 = True # # 70-76 # boot_warm(dev) else: raise Exception("Bad warm/cold response") # Packets going forward are from cold boot since its more canonical / clean # warm -40 packet (ie 120 cold => 80 warm) buff = cmd.bulk2( dev, "\x14\x38\x25\x00\x00\x04\x00\x90\x32\x90\x00\xA7\x02\x1F\x00\x14" "\x40\x25\x00\x00\x01\x00\x3C\x36\x0E\x01", target=0x20) validate_read( "\x14\x00\x54\x41\x38\x34\x56\x4C\x56\x5F\x46\x58\x34\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E" "\x2C", buff, "packet 124/125") bulkWrite(0x02, "\x43\x19\x00\x00\x00") bulkWrite(0x02, "\x20\x01\x00\x0C\x04") bulkWrite(0x02, "\x41\x00\x00") # Generated from packet 148/149 #cmd.cmd_01[0x17]: 0x00 => 0x09 # warm: als state 0x83 => 0x80, 0x15: 0x30 => 0x00, 016: 0x01 => 0x00 buff = cmd.bulk2(dev, "\x10\x80\x02", target=6) validate_read("\x80\x00\x00\x00\x09\x00", buff, "packet 150/151") buff = cmd.bulk2(dev, "\x45\x01\x00\x00\x31\x00\x06", target=0x64) validate_read( "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" "\xFF\xFF\xFF\xFF\xFF", buff, "packet 154/155") cmd.cmd_49(dev) bulkWrite( 0x02, "\x3B\x0C\x22\x00\xC0\x30\x00\x3B\x0E\x22\x00\xC0\x00\x00\x3B\x1A" "\x22\x00\xC0\x18\x00") buff = cmd.bulk2(dev, "\x4A\x03\x00\x00\x00", target=2) validate_read("\x03\x00", buff, "packet 176/177") # Atomic # Generated from packet 178/179 bulkWrite(0x02, "\x4C\x00\x02") # Generated from packet 180/181 # None (0xB2) controlWrite(0x40, 0xB2, 0x0000, 0x0000, "") # Atomic cmd.cmd_50(dev, "\x45\x00") # FIXME: size field unexpected buff = cmd.bulk2( dev, "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x01\x10" "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x01\x80" "\xE9\x02\x00\x00\x00\x90\x00\xE9\x04\x00\x00\x00\x00\x00\x00\x00" "\xE9\x03\x00\x00\x00\x90\x00\x00\x66\xB9\x00\x00\xB2\x00\xFB\xFF" "\x25\x44\x11\x00\x00", target=2) validate_read("\x80\x00", buff, "packet 186/187") #cmd.cmd_01[0x15]: 0x00 => 0x50 cmd.cmd_02(dev, "\x81\x00\x50\x00\x09\x00", "packet 190/191") # Atomic #cmd.cmd_01 state: 0x81 => 0x82 cmd.cmd_50(dev, "\xC0\x00") buff = cmd.bulk2( dev, "\x66\xB8\x01\x2D\x81\xE3\xFF\xFF\x00\x00\x66\xBB\x18\x00\x66\xC7" "\x05\x30\x40\x00\xC0\xF0\xFF\x89\xD9\xC1\xE1\x02\x66\xC7\x81\x02" "\x00\x00\x00\xF0\xFF\x66\x03\x05\xE4\x46\x00\x00\x66\x89\x05\x90" "\x40\x00\xC0\x89\xDA\x81\xCA\x00\x80\x00\x00\x66\x89\x15\x50\x40" "\x00\xC0\xC6\x05\x14\x22\x00\xC0\x7B\x81\xCA\x00\x40\x00\x00\x66" "\x89\x15\x50\x40\x00\xC0\x89\xD9\x66\xC1\xE1\x02\x66\x89\x81\x00" "\x00\x00\x00\x66\x2B\x05\xE4\x46\x00\x00\xC6\x05\x14\x22\x00\xC0" "\xBB\x81\xCB\x00\x80\x00\x00\x66\x89\x1D\x50\x40\x00\xC0\x89\xC2" "\x81\xE2\x07\x00\x00\x00\x03\xD2\x81\xCA\x01\x00\x00\x00\x89\xD9" "\x81\xE1\x03\x00\x00\x00\xD3\xE2\xD3\xE2\xD3\xE2\xD3\xE2\xD3\xE2" "\xC1\xE2\x0A\x89\xD9\x81\xE1\xFC\x03\x00\x00\x09\xCA\x88\x82\x00" "\x00\x00\x40\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00", target=2) validate_read("\x81\x00", buff, "packet 196/197") #cmd.cmd_01: 0x15: 0x50 => 0x01. 0x16: 0x00 => 0x01 # Generated from packet 198/199 cmd.cmd_02(dev, "\x82\x00\x10\x01\x09\x00", "packet 200/201") if glitch_154: buff = cmd.bulk2( dev, "\x08\x20\x09\x20\x0A\x20\x0B\x20\x57\x81\x00\x0C\x04\x30", target=2) validate_read("\x04\x00", buff, "packet 204/205") else: # Think this clears the red light # Generated from packet 202/203 buff = cmd.bulk2( dev, "\x04\x72\x05\x73\x06\x2E\x07\x70\x08\x75\x09\x73\x0A\x68\x0B\x28" "\x57\x81\x00\x0C\x04\x30", target=2) validate_read("\x04\x00", buff, "packet 204/205") buff = cmd.bulk2( dev, "\x3B\x0C\x22\x00\xC0\x30\x00\x3B\x0E\x22\x00\xC0\x00\x00\x3B\x1A" "\x22\x00\xC0\x18\x00\x0E\x01", target=0x20) validate_read( "\x14\x00\x54\x41\x38\x34\x56\x4C\x56\x5F\x46\x58\x34\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E" "\x2C", buff, "packet 208/209") # Atomic #cmd.cmd_01 state: 0x82 => 0x83 bulkWrite(0x02, "\x48\x00\x20\x00\x00\x50\x12\x00\x00\x00") buff = cmd.bulk2( dev, "\x00\x00\x00\x00\x04\x00\x08\x00\x0C\x00\x10\x00\x14\x00\x18\x00" "\x1C\x00", target=2) validate_read("\x82\x00", buff, "packet 226/227") cmd.cmd_02(dev, "\x83\x00\x30\x01\x09\x00", "packet 230/231") #cmd.cmd_01: 0x15: 0x10 => 0x30 buff = cmd.bulk2( dev, "\x1D\x10\x01\x09\x00\x00\x00\x15\x60\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x1C\x00\x00\x48\x00\x12\xAA", target=1) validate_read("\xAB", buff, "packet 234/235")
def dev_read(dev, cont=False, verbose=False): bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev) config = {} # Generated from packet 1273/1274 # Unexpected SM read buff = cmd.bulk2b(dev, "\x22\x02\x25\x00\x25\x00\x06") validate_read("\x00\x00", buff, "packet W: 1273/1274, R 1 to 1275/1276") # Generated from packet 1643/1644 # NOTE:: req max 4096 but got 3 buff = controlRead(0xC0, 0xB0, 0x0000, 0x0000, 4096) # Req: 4096, got: 3 validate_read("\x00\x00\x00", buff, "packet 1643/1644") # Generated from packet 1645/1646 _prefix, buff, _size = cmd.bulk86_next_read(dev) validate_read("\x16", buff, "packet 1645/1646") # NOTE:: req max 512 but got 4 # Generated from packet 1647/1648 #cmd.cmd_01(dev) # NOTE:: req max 512 but got 136 # Generated from packet 1651/1652 # reliability issues #buff = cmd.bulk2b(dev, buff = cmd.bulk2(dev, target=2, cmd=\ "\x43\x19\x08\x00\x00\x3B\x7E\x25\x00\x00\xFE\xFF\x3B\x7C\x25\x00" \ "\x00\xFE\xFF\x00" ) validate_read("\xA4\x06", buff, "packet W: 1651/1652, R 1 to 1653/1654") # NOTE:: req max 512 but got 136 # Generated from packet 1691/1692 bulkWrite(0x02, "\x43\x19\x08\x00\x00") # Generated from packet 1693/1694 bulkWrite(0x02, "\x20\x01\x00\x0C\x04") # Generated from packet 1695/1696 cmd.cmd_41(dev) # Generated from packet 1697/1698 cmd.cmd_10(dev) # NOTE:: req max 512 but got 35 # Generated from packet 1709/1710 cmd.cmd_45(dev) # NOTE:: req max 512 but got 103 # Generated from packet 1713/1714 cmd.cmd_49(dev) # NOTE:: req max 512 but got 35 # Generated from packet 1737/1738 cmd.cmd_49(dev) # NOTE:: req max 512 but got 11 # Generated from packet 1753/1754 cmd.cmd_3B(dev) # Generated from packet 1755/1756 cmd.cmd_4A(dev) # NOTE:: req max 512 but got 5 # Generated from packet 1759/1760 cmd.cmd_4C(dev) # Generated from packet 1761/1762 buff = controlWrite(0x40, 0xB2, 0x0000, 0x0000, "") # Generated from packet 1763/1764 cmd.cmd_50(dev, "\x4D\x00") # Generated from packet 1765/1766 buff = cmd.bulk2b(dev, "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x01\x10" \ "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x01\x80" \ "\xE9\x02\x00\x00\x00\x90\x00\xE9\x04\x00\x00\x00\x00\x00\x00\x00" \ "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x00\x00" \ "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x80\x00", buff, "packet W: 1765/1766, R 1 to 1767/1768") # Generated from packet 1769/1770 cmd.cmd_02(dev, "\x81\x00\x50\x00\x09\x00") # Generated from packet 1773/1774 cmd.cmd_50(dev, "\xC0\x00") # Generated from packet 1775/1776 buff = cmd.bulk2b(dev, "\x66\xB8\x01\x2D\x81\xE3\xFF\xFF\x00\x00\x66\xBB\x18\x00\x66\xC7" \ "\x05\x30\x40\x00\xC0\xF0\xFF\x89\xD9\xC1\xE1\x02\x66\xC7\x81\x02" \ "\x00\x00\x00\xF0\xFF\x66\x03\x05\xE4\x46\x00\x00\x66\x89\x05\x90" \ "\x40\x00\xC0\x89\xDA\x81\xCA\x00\x80\x00\x00\x66\x89\x15\x50\x40" \ "\x00\xC0\xC6\x05\x14\x22\x00\xC0\x7B\x81\xCA\x00\x40\x00\x00\x66" \ "\x89\x15\x50\x40\x00\xC0\x89\xD9\x66\xC1\xE1\x02\x66\x89\x81\x00" \ "\x00\x00\x00\x66\x2B\x05\xE4\x46\x00\x00\xC6\x05\x14\x22\x00\xC0" \ "\xBB\x81\xCB\x00\x80\x00\x00\x66\x89\x1D\x50\x40\x00\xC0\x89\xC2" \ "\x81\xE2\x07\x00\x00\x00\x03\xD2\x81\xCA\x01\x00\x00\x00\x89\xD9" \ "\x81\xE1\x03\x00\x00\x00\xD3\xE2\xD3\xE2\xD3\xE2\xD3\xE2\xD3\xE2" \ "\xC1\xE2\x0A\x89\xD9\x81\xE1\xFC\x03\x00\x00\x09\xCA\x88\x82\x00" \ "\x00\x00\x40\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x81\x00", buff, "packet W: 1775/1776, R 1 to 1777/1778") # Generated from packet 1779/1780 cmd.cmd_02(dev, "\x82\x00\x10\x01\x09\x00") # Generated from packet 1783/1784 bulkWrite(0x02, "\x04\x20\x05\x3D\x06\x20\x07\x64\x08\x6F\x09\x63\x0A\x75\x0B\x6D" \ "\x57\x81\x00" ) # Generated from packet 1785/1786 cmd.cmd_02(dev, "\x82\x00\x10\x01\x09\x00") # Generated from packet 1789/1790 cmd.led_mask(dev, "active") # Generated from packet 1793/1794 cmd.cmd_50(dev, "\x18\x00") # Generated from packet 1795/1796 buff = cmd.bulk2b(dev, "\x66\xB8\x01\x32\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x82\x00", buff, "packet W: 1795/1796, R 1 to 1797/1798") # Generated from packet 1799/1800 cmd.cmd_02(dev, "\x83\x00\x30\x01\x09\x00") # Generated from packet 1803/1804 buff = cmd.bulk2b(dev, "\x57\x82\x00\x20\x01\x00\x2B\x3B\x0C\x22\x00\xC0\x40\x00\x3B\x0E" \ "\x22\x00\xC0\x00\x00\x3B\x1A\x22\x00\xC0\x18\x00\x0E\x01" ) validate_read( "\x14\x00\x54\x41\x38\x34\x56\x4C\x56\x5F\x46\x58\x34\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x2C" , buff, "packet W: 1803/1804, R 1 to 1805/1806") # Generated from packet 1827/1828 buff = cmd.bulk2b(dev, "\x48\x00\x10\x82\x02") validate_read("\x82\x00\x10\x01\x09\x00", buff, "packet W: 1827/1828, R 1 to 1829/1830") # Generated from packet 1831/1832 bulkWrite(0x02, "\x20\x01\x00\x50\x7D\x02\x00\x00") # Generated from packet 1833/1834 buff = cmd.bulk2b(dev, pic16f84_fw.p651) validate_read("\x82\x00", buff, "packet W: 1833/1834, R 1 to 1835/1836") # Generated from packet 1837/1838 cmd.cmd_02(dev, "\x83\x00\x90\x03\x09\x00") # Generated from packet 1841/1842 bulkWrite(0x02, "\x57\x82\x00\x50\x1D\x00\x00\x00") # Generated from packet 1843/1844 buff = cmd.bulk2b(dev, "\xC7\x05\x74\x46\x00\x00\x0B\x00\x00\x00\xFF\x15\x38\x11\x00\x00" \ "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x83\x00", buff, "packet W: 1843/1844, R 1 to 1845/1846") # Generated from packet 1847/1848 cmd.cmd_02(dev, "\x84\x00\xB0\x03\x09\x00") # Generated from packet 1851/1852 bulkWrite(0x02, "\x57\x83\x00\x50\x18\x3A\x00\x00") # Generated from packet 1853/1854 buff = cmd.bulk2b(dev, pic16f84_fw.p533) validate_read("\x84\x00", buff, "packet W: 1853/1854, R 1 to 1855/1856") # Generated from packet 1857/1858 cmd.cmd_02(dev, "\x85\x00\xD0\x3D\x09\x00") # Generated from packet 1861/1862 bulkWrite(0x02, "\x57\x84\x00\xF0\xFF\x01\x00\x00\x80\xFF\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\xFE\xFF\xFF\x7F\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" \ "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" ) # Generated from packet 1863/1864 cmd.cmd_50(dev, "\xDE\x03") # Generated from packet 1865/1866 buff = cmd.bulk2b(dev, pic16f84_fw.p555) validate_read("\x85\x00", buff, "packet W: 1865/1866, R 1 to 1867/1868") # Generated from packet 1869/1870 cmd.cmd_02(dev, "\x86\x00\xB0\x41\x09\x00") # Generated from packet 1873/1874 # Times out if chip not inserted #cmd.cmd_57s(dev, "\x85", "\x01") if cont: removed_ref = \ "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" cmd.check_cont(dev, verbose=verbose, removed_ref=removed_ref) # Generated from packet 1877/1878 cmd.cmd_50(dev, "\x71\x1B") # Generated from packet 1879/1880 buff = cmd.bulk2b(dev, pic16f84_fw.p591) validate_read("\x86\x00", buff, "packet W: 1879/1880, R 1 to 1881/1882") # Generated from packet 1883/1884 cmd.cmd_02(dev, "\x87\x00\x30\x5D\x09\x00") # Generated from packet 1887/1888 buff = cmd.bulk2b(dev, "\x57\x86\x00\x2C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x06" \ "\x07\x08\x09\x28\x29\x2A\x2B\x2D\x2E\x2F\x30\x00\x00" ) # Observed while shining high power laser on chip if buff == '\x00': raise cmd.Overcurrent('packet W: 1887/1888, R 1 to 1889/1890') validate_read("\x01", buff, "packet W: 1887/1888, R 1 to 1889/1890") # Generated from packet 1891/1892 bulkWrite(0x02, "\x20\x01\x00\x50\x36\x00\x00\x00") # Generated from packet 1893/1894 buff = cmd.bulk2b(dev, "\x00\x00\x3C\x00\x38\x00\x34\x00\x30\x00\x00\x00\x39\x00\x35\x00" \ "\x31\x00\x3E\x00\x2E\x00\x21\x00\x25\x00\x29\x00\x1C\x00\x20\x00" \ "\x24\x00\x28\x00\x2C\x00\x00\x00\x04\x00\x08\x00\x0C\x00\x10\x00" \ "\x14\x00\x18\x00\x1C\x00" ) validate_read("\x87\x00", buff, "packet W: 1893/1894, R 1 to 1895/1896") # Generated from packet 1897/1898 cmd.cmd_02(dev, "\x88\x00\x70\x5D\x09\x00") # Generated from packet 1901/1902 bulkWrite(0x02, "\x1D\x30\x5D\x09\x00\x12\x00\x15\x60\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x10\x00\x00\x00\x00\x1C\x30\x00\x10\x00\x00\x00\x00\x00\x48" \ "\x00\x50\x71\x09\x00\x00" ) # Generated from packet 1903/1904 buff = cmd.bulk2b(dev, pic16f84_fw.p615) validate_read("\x88\x00", buff, "packet W: 1903/1904, R 1 to 1905/1906") # Generated from packet 1907/1908 cmd.cmd_02(dev, "\x89\x00\xF0\x66\x09\x00") # Generated from packet 1911/1912 cmd.cmd_57s(dev, "\x88", "\x00\x00") # Generated from packet 1915/1916 cmd.cmd_50(dev, "\x17\x00") # Generated from packet 1917/1918 buff = cmd.bulk2b(dev, "\xC7\x05\x2C\x00\x09\x00\x24\x00\x00\x00\x66\xB9\x00\x00\xB2\x00" \ "\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x89\x00", buff, "packet W: 1917/1918, R 1 to 1919/1920") # Generated from packet 1921/1922 cmd.cmd_02(dev, "\x8A\x00\x10\x67\x09\x00") # Generated from packet 1925/1926 bulkWrite(0x02, "\x57\x89\x00\x50\x18\x00\x00\x00") # Generated from packet 1927/1928 buff = cmd.bulk2b(dev, "\x66\xB8\x01\x32\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x8A\x00", buff, "packet W: 1927/1928, R 1 to 1929/1930") # Generated from packet 1931/1932 cmd.cmd_02(dev, "\x8B\x00\x30\x67\x09\x00") # Generated from packet 1935/1936 bulkWrite(0x02, "\x57\x8A\x00\x50\xD1\x06\x00\x00") # Generated from packet 1937/1938 buff = cmd.bulk2b(dev, pic16f84_fw.p891) validate_read("\x8B\x00", buff, "packet W: 1937/1938, R 1 to 1939/1940") # Generated from packet 1941/1942 cmd.cmd_02(dev, "\x8C\x00\x10\x6E\x09\x00") # Generated from packet 1945/1946 cmd.cmd_57s(dev, "\x8B", "\x00\x00") # Generated from packet 1949/1950 cmd.cmd_50(dev, "\xF2\x02") # Generated from packet 1951/1952 buff = cmd.bulk2b(dev, pic16f84_fw.p663) validate_read("\x8C\x00", buff, "packet W: 1951/1952, R 1 to 1953/1954") # Generated from packet 1955/1956 cmd.cmd_02(dev, "\x8D\x00\x10\x71\x09\x00") # XXX # unprotected: \x00\x00 # protected: \x01\x00 # Generated from packet 1959/1960 buff = cmd.bulk2b(dev, "\x08\x01\x57\x8C\x00") #validate_read("\x00\x00", buff, "packet W: 1959/1960, R 1 to 1961/1962") #util.hexdump(buff, label='packet 1959/1960', indent=' ') #print binascii.hexlify(buff) config['secure'] = buff != '\x00\x00' # Generated from packet 1963/1964 cmd.cmd_50(dev, "\xCE\x03") # Generated from packet 1965/1966 buff = cmd.bulk2b(dev, pic16f84_fw.p919) validate_read("\x8D\x00", buff, "packet W: 1965/1966, R 1 to 1967/1968") # Generated from packet 1969/1970 cmd.cmd_02(dev, "\x8E\x00\xE0\x74\x09\x00") # Generated from packet 1973/1974 cmd.cmd_57s(dev, "\x8D", "\x00\x00") # Generated from packet 1977/1978 buff = cmd.bulk2b(dev, "\x57\x8A\x00\x57\x8B\x00") validate_read("\x00\x00", buff, "packet W: 1977/1978, R 1 to 1979/1980") # Generated from packet 1981/1982 cmd.cmd_50(dev, "\x45\x03") # Generated from packet 1983/1984 buff = cmd.bulk2b(dev, pic16f84_fw.p697) validate_read("\x8E\x00", buff, "packet W: 1983/1984, R 1 to 1985/1986") # Generated from packet 1987/1988 cmd.cmd_02(dev, "\x8F\x00\x30\x78\x09\x00") # Generated from packet 1991/1992 buff = cmd.bulk2b(dev, "\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x04\x0A\x00\x0B\x00" \ "\x57\x8E\x00" ) code = buff #validate_read(pic16f84_fw.p2001, buff, "packet W: 1991/1992, R 5 to 2001/2002") # Generated from packet 2003/2004 cmd.cmd_50(dev, "\x5E\x00") # Generated from packet 2005/2006 buff = cmd.bulk2b(dev, "\x66\xC7\x05\x1C\x24\x00\x00\x00\x00\x66\x8B\x1D\x1C\x24\x00\x00" \ "\x81\xE3\xFF\xFF\x00\x00\xC1\xE3\x01\x53\x5B\x66\xC7\x83\x38\x24" \ "\x00\x00\xAD\x0B\x66\xFF\x05\x1C\x24\x00\x00\x66\x8B\x05\x1C\x24" \ "\x00\x00\x81\xE0\xFF\xFF\x00\x00\xFF\xF0\xB8\x07\x00\x00\x00\x59" \ "\x39\xC8\x77\xC5\x66\xB9\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00" \ "\x00\x66\xB9\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x8F\x00", buff, "packet W: 2005/2006, R 1 to 2007/2008") # Generated from packet 2009/2010 cmd.cmd_02(dev, "\x90\x00\x90\x78\x09\x00") # Generated from packet 2013/2014 cmd.cmd_57s(dev, "\x8F", "\x00\x00") # Generated from packet 2017/2018 cmd.cmd_50(dev, "\x58\x06") # Generated from packet 2019/2020 buff = cmd.bulk2b(dev, pic16f84_fw.p759) validate_read("\x90\x00", buff, "packet W: 2019/2020, R 1 to 2021/2022") # Generated from packet 2023/2024 cmd.cmd_02(dev, "\x91\x00\xF0\x7E\x09\x00") # Generated from packet 2027/2028 cmd.cmd_57s(dev, "\x90", "\x00\x00") # Generated from packet 2031/2032 cmd.cmd_50(dev, "\x92\x00") # Generated from packet 2033/2034 buff = cmd.bulk2b(dev, "\xE9\x03\x00\x00\x00\x90\x00\x00\x66\xC7\x05\xF6\x7E\x09\x00\x00" \ "\x00\x66\x8B\x05\xF6\x7E\x09\x00\x81\xE0\xFF\xFF\x00\x00\xFF\xF0" \ "\xB8\x07\x00\x00\x00\x59\x39\xC8\x0F\x86\x57\x00\x00\x00\x66\x8B" \ "\x1D\xF6\x7E\x09\x00\x81\xE3\xFF\xFF\x00\x00\xC1\xE3\x01\x66\x50" \ "\x66\x8B\x83\x38\x24\x00\x00\xFB\x66\x50\x66\x53\x66\x51\x8A\xC8" \ "\xFF\x15\x3C\x11\x00\x00\x66\x59\x66\x5B\xFA\x66\x58\x66\xC1\xE8" \ "\x08\xFB\x66\x53\x66\x51\x8A\xC8\xFF\x15\x3C\x11\x00\x00\x66\x59" \ "\x66\x5B\xFA\x66\x58\x66\x8B\x05\xF6\x7E\x09\x00\x66\xFF\x05\xF6" \ "\x7E\x09\x00\xEB\x8C\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11" \ "\x00\x00" ) validate_read("\x91\x00", buff, "packet W: 2033/2034, R 1 to 2035/2036") # Generated from packet 2037/2038 cmd.cmd_02(dev, "\x92\x00\x90\x7F\x09\x00") # FIXME: which is this? # Names from minipro #fuses = {'conf_word': None} # 4 ID words? # Generated from packet 2041/2042 # "\xFF\x3F \xFF\x3F \xFF\x3F \xFF\x3F \x03\x00 \x01\x00 \x01\x00" buff = cmd.cmd_57s(dev, "\x91", None) def fuse_unpack(buff, i): return struct.unpack('<H', str(buff[2 * i:2 * i + 2]))[0] for i in range(0, 4): config['user_id%d' % i] = fuse_unpack(buff, i) # FIXME: confirm # Think this is actually incorrect config['conf_word'] = fuse_unpack(buff, 4) #print binascii.hexlify(buff) # Generated from packet 2045/2046 cmd.cmd_50(dev, "\x89\x00") # Generated from packet 2047/2048 buff = cmd.bulk2b(dev, "\x66\xC7\x05\x28\x24\x00\x00\x00\x00\x66\x8B\x05\x28\x24\x00\x00" \ "\x81\xE0\xFF\xFF\x00\x00\xFF\xF0\xB8\x06\x00\x00\x00\x59\x39\xC8" \ "\x0F\x87\x15\x00\x00\x00\xE9\x51\x00\x00\x00\x66\x8B\x05\x28\x24" \ "\x00\x00\x66\xFF\x05\x28\x24\x00\x00\xEB\xCE\xE9\x04\x00\x00\x00" \ "\x00\x00\x00\x00\x66\xC7\x05\xD0\x7F\x09\x00\x06\x00\x66\x8B\x0D" \ "\x28\x24\x00\x00\x66\xD3\x2D\xD0\x7F\x09\x00\x66\x8B\x05\xD0\x7F" \ "\x09\x00\x81\xE0\xFF\xFF\x00\x00\x88\x05\x28\x80\x00\x80\x88\x05" \ "\x24\x80\x06\x40\x88\x05\x24\x80\x04\x40\xEB\xAF\x66\xB9\x00\x00" \ "\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x92\x00", buff, "packet W: 2047/2048, R 1 to 2049/2050") # Generated from packet 2051/2052 cmd.cmd_02(dev, "\x93\x00\x20\x80\x09\x00") # Generated from packet 2055/2056 bulkWrite(0x02, pic16f84_fw.p795) # Generated from packet 2057/2058 buff = cmd.bulk2b(dev, pic16f84_fw.p797) validate_read("\x93\x00", buff, "packet W: 2057/2058, R 1 to 2059/2060") # Generated from packet 2061/2062 cmd.cmd_02(dev, "\x94\x00\xA0\x81\x09\x00") # Generated from packet 2065/2066 bulkWrite(0x02, "\x57\x93\x00\x50\x07\x01\x00\x00") # Generated from packet 2067/2068 buff = cmd.bulk2b(dev, pic16f84_fw.p807) validate_read("\x94\x00", buff, "packet W: 2067/2068, R 1 to 2069/2070") # Generated from packet 2071/2072 cmd.cmd_02(dev, "\x95\x00\xB0\x82\x09\x00") eeprom = read_eeprom(dev) # Generated from packet 2335/2336 cmd.cmd_50(dev, "\x0D\x00") # Generated from packet 2337/2338 buff = cmd.bulk2b(dev, "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00") validate_read("\x95\x00", buff, "packet W: 2337/2338, R 1 to 2339/2340") # Generated from packet 2341/2342 cmd.cmd_02(dev, "\x96\x00\xC0\x82\x09\x00") # Generated from packet 2345/2346 bulkWrite(0x02, "\x57\x95\x00\x50\x1A\x00\x00\x00") # Generated from packet 2347/2348 buff = cmd.bulk2b(dev, "\x66\xB9\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00\x66\xB9\x00" \ "\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00" ) validate_read("\x96\x00", buff, "packet W: 2347/2348, R 1 to 2349/2350") # Generated from packet 2351/2352 cmd.cmd_02(dev, "\x97\x00\xE0\x82\x09\x00") # Generated from packet 2355/2356 cmd.cmd_57s(dev, "\x96", "\x00\x00") # Generated from packet 2359/2360 cmd.led_mask(dev, "pass") # Generated from packet 2383/2384 cmd.cmd_49(dev) return {'code': code, 'data': eeprom, 'config': config}
def dev_write(dev, devcfg, cont=True, verbose=False, blank=True): bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev) fw = devcfg['code'] # Generated by uvusbreplay 0.1 # uvusbreplay copyright 2011 John McMaster <*****@*****.**> # cmd: /home/mcmaster/bin/usbrply --packet-numbers --no-setup --comment --fx2 --packet-numbers -j cap/2015-10-11/i87c51_13_write_cont_id_blank_v2_ff.cap # FIXME: size? read_replay1(dev, cont) # Generated from packet 363/364 cmd_57s(dev, '\x8C', "\x00\x00") # Generated from packet 367/368 cmd_50(dev, "\x18\x00") # Generated from packet 369/370 buff = bulk2(dev, "\x66\xB8\x01\x2D\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x8F\x00", buff, "packet W: 369/370, R: 371/372") # Generated from packet 373/374 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x90\x00\xB0\x5D\x09\x00", buff, "packet W: 373/374, R: 375/376") # Generated from packet 377/378 buff = bulk2(dev, "\x57\x8F\x00\x57\x89\x00", target=0x02) validate_read("\x00\x00", buff, "packet W: 377/378, R: 379/380") # Generated from packet 381/382 cmd_50(dev, "\x0A\x06") # Generated from packet 383/384 buff = bulk2(dev, i87c51_fw.p383, target=0x02) validate_read("\x90\x00", buff, "packet W: 383/384, R: 385/386") # Generated from packet 387/388 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x91\x00\xC0\x63\x09\x00", buff, "packet W: 387/388, R: 389/390") # Generated from packet 391/392 if blank: print('Blank checking') tstart = time.time() buff = bulk2(dev, "\x08\x00\x57\x90\x00", target=0x02) tend = time.time() print(('Blank test took %0.3f sec' % (tend - tstart, ))) if buff == "\x00\x00": print('Blank: pass') elif buff == "\x01\x00": raise NotBlank('Blank: fail') else: hexdump(buff) raise Exception("Unknown blank status") # Generated from packet 395/396 cmd_57s(dev, '\x8C', "\x00\x00") # Generated from packet 399/400 cmd_50(dev, "\x18\x00") # Generated from packet 401/402 buff = bulk2(dev, "\x66\xB8\x01\x32\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x91\x00", buff, "packet W: 401/402, R: 403/404") # Generated from packet 405/406 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x92\x00\xE0\x63\x09\x00", buff, "packet W: 405/406, R: 407/408") # Generated from packet 409/410 buff = bulk2(dev, "\x57\x91\x00\x57\x89\x00", target=0x02) validate_read("\x00\x00", buff, "packet W: 409/410, R: 411/412") # Generated from packet 413/414 cmd_50(dev, "\x9F\x09") # Generated from packet 415/416 buff = bulk2(dev, i87c51_fw.p415, target=0x02) validate_read("\x92\x00", buff, "packet W: 415/416, R: 417/418") # Generated from packet 419/420 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x93\x00\x80\x6D\x09\x00", buff, "packet W: 419/420, R: 421/422") # Generated from packet 423/424 buff = bulk2(dev, "\x57\x92\x00", target=0x01) validate_read("\x62", buff, "packet W: 423/424, R: 425/426") # Generated from packet 427/428 # NOTE: prefix 0x18 buff = bulk86(dev, target=0x01, prefix=0x18) validate_read("\x0B", buff, "packet 427/428") # Generated from packet 429/430 fw_w(dev, fw, verbose=True) # Generated from packet 513/514 cmd_57s(dev, '\x8C', "\x00\x00") # Generated from packet 517/518 cmd_50(dev, "\x18\x00") # Generated from packet 519/520 buff = bulk2(dev, "\x66\xB8\x01\x2D\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x93\x00", buff, "packet W: 519/520, R: 521/522") # Generated from packet 523/524 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x94\x00\xA0\x6D\x09\x00", buff, "packet W: 523/524, R: 525/526") # Generated from packet 527/528 buff = bulk2(dev, "\x57\x93\x00\x57\x89\x00", target=0x02) validate_read("\x00\x00", buff, "packet W: 527/528, R: 529/530") # Generated from packet 531/532 cmd_50(dev, "\xE0\x08") # Generated from packet 533/534 buff = bulk2(dev, i87c51_fw.p533, target=0x02) validate_read("\x94\x00", buff, "packet W: 533/534, R: 535/536") # Generated from packet 537/538 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x95\x00\x80\x76\x09\x00", buff, "packet W: 537/538, R: 539/540") # Generated from packet 541/542 cmd.cmd_57_94(dev) # Generated from packet 547/548 fw_w(dev, fw) # Generated from packet 631/632 cmd_57s(dev, '\x8C', "\x00\x00") # Generated from packet 635/636 cmd_50(dev, "\x18\x00") # Generated from packet 637/638 buff = bulk2(dev, "\x66\xB8\x01\x37\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x95\x00", buff, "packet W: 637/638, R: 639/640") # Generated from packet 641/642 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x96\x00\xA0\x76\x09\x00", buff, "packet W: 641/642, R: 643/644") # Generated from packet 645/646 buff = bulk2(dev, "\x57\x95\x00\x57\x89\x00", target=0x02) validate_read("\x00\x00", buff, "packet W: 645/646, R: 647/648") # Generated from packet 649/650 cmd.cmd_57_94(dev) # Generated from packet 655/656 fw_w(dev, fw) # Generated from packet 739/740 cmd_57s(dev, '\x8C', "\x00\x00") # Generated from packet 743/744 cmd_50(dev, "\x0D\x00") # Generated from packet 745/746 buff = bulk2(dev, "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00", target=0x02) validate_read("\x96\x00", buff, "packet W: 745/746, R: 747/748") # Generated from packet 749/750 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x97\x00\xB0\x76\x09\x00", buff, "packet W: 749/750, R: 751/752") # Generated from packet 753/754 cmd_57_50(dev, "\x96", "\x1A\x00") # Generated from packet 755/756 buff = bulk2(dev, "\x66\xB9\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00\x66\xB9\x00" \ "\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x97\x00", buff, "packet W: 755/756, R: 757/758") # Generated from packet 759/760 buff = bulk2(dev, "\x02", target=0x06) validate_read("\x98\x00\xD0\x76\x09\x00", buff, "packet W: 759/760, R: 761/762") # Generated from packet 763/764 buff = bulk2(dev, "\x57\x97\x00", target=0x02) validate_read("\x00\x00", buff, "packet W: 763/764, R: 765/766") # Generated from packet 767/768 led_mask_30(dev, "pass") # Generated from packet 771/772 cmd.gpio_readi(dev) # Generated from packet 775/776 cmd.gpio_readi(dev) # Generated from packet 779/780 #cmd.sm_info22(dev) # Generated from packet 783/784 #cmd.sm_info24(dev) # Generated from packet 787/788 #sm_info3(dev) # Generated from packet 791/792 cmd_49(dev) # Generated from packet 795/796 #sm_info3(dev) # Generated from packet 799/800 sm_insert(dev) # Generated from packet 803/804 sm_info10(dev)
def read_replay1(dev, cont=True): _bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev) cmd.readB0(dev) # Generated from packet 15/16 cmd_01(dev) # NOTE:: req max 512 but got 136 # Generated from packet 19/20 buff = cmd.bulk2(dev, "\x43\x19\x10\x00\x00\x3B\x7E\x25\x00\x00\xFE\xFF\x3B\x7C\x25\x00" \ "\x00\xFE\xFF\x00", target=0x02) validate_read("\xA4\x06", buff, "packet W: 19/20, R: 21/22") # Generated from packet 23/24 cmd_01(dev) # Generated from packet 27/28 sn_read(dev) # Generated from packet 31/32 cmd.cmd_1438(dev) sm_info1(dev) # Generated from packet 55/56 cmd_01(dev) # NOTE:: req max 512 but got 136 # Generated from packet 59/60 cmd_43(dev, "\x10") # Generated from packet 61/62 bulkWrite(0x02, cmd_20_mk() + cmd_0C_mk()) # Generated from packet 63/64 cmd_41(dev) # Generated from packet 65/66 cmd_10(dev) sm_info3(dev) ''' validate_read( "\x11\x00\x53\x4D\x34\x38\x44\x00\x00\x00\x00\x00\x00\x00\x5D\xF4" \ "\x39\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x62\x6C" , buff, "packet W: 69/70, R: 71/72") ''' sm_insert(dev) # Generated from packet 77/78 cmd_45(dev) # Generated from packet 81/82 cmd_49(dev) sm_info1(dev) sm_insert(dev) # Generated from packet 117/118 sm_info10(dev) # Generated from packet 121/122 cmd_3B(dev) cmd_4A(dev) # NOTE:: req max 512 but got 5 # Generated from packet 127/128 cmd_4C(dev) # Generated from packet 129/130 # None (0xB2) buff = controlWrite(0x40, 0xB2, 0x0000, 0x0000, "") # Atomic # Generated from packet 131/132 cmd_50(dev, "\x5D\x00") # Generated from packet 133/134 buff = bulk2(dev, "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x01\x10" \ "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x01\x80" \ "\xE9\x02\x00\x00\x00\x90\x00\xE9\x04\x00\x00\x00\x00\x00\x00\x00" \ "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x00\x00" \ "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x03\x00\x00\x00\x90\x00\x00" \ "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x80\x00", buff, "packet W: 133/134, R: 135/136") # Generated from packet 137/138 cmd_02(dev, "\x81\x00\x60\x00\x09\x00", "packet W: 137/138, R: 139/140") # Atomic # Generated from packet 141/142 cmd_50(dev, "\xC0\x00") # Generated from packet 143/144 buff = bulk2(dev, "\x66\xB8\x01\x2D\x81\xE3\xFF\xFF\x00\x00\x66\xBB\x18\x00\x66\xC7" \ "\x05\x30\x40\x00\xC0\xF0\xFF\x89\xD9\xC1\xE1\x02\x66\xC7\x81\x02" \ "\x00\x00\x00\xF0\xFF\x66\x03\x05\xE4\x46\x00\x00\x66\x89\x05\x90" \ "\x40\x00\xC0\x89\xDA\x81\xCA\x00\x80\x00\x00\x66\x89\x15\x50\x40" \ "\x00\xC0\xC6\x05\x14\x22\x00\xC0\x7B\x81\xCA\x00\x40\x00\x00\x66" \ "\x89\x15\x50\x40\x00\xC0\x89\xD9\x66\xC1\xE1\x02\x66\x89\x81\x00" \ "\x00\x00\x00\x66\x2B\x05\xE4\x46\x00\x00\xC6\x05\x14\x22\x00\xC0" \ "\xBB\x81\xCB\x00\x80\x00\x00\x66\x89\x1D\x50\x40\x00\xC0\x89\xC2" \ "\x81\xE2\x07\x00\x00\x00\x03\xD2\x81\xCA\x01\x00\x00\x00\x89\xD9" \ "\x81\xE1\x03\x00\x00\x00\xD3\xE2\xD3\xE2\xD3\xE2\xD3\xE2\xD3\xE2" \ "\xC1\xE2\x0A\x89\xD9\x81\xE1\xFC\x03\x00\x00\x09\xCA\x88\x82\x00" \ "\x00\x00\x40\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x81\x00", buff, "packet W: 143/144, R: 145/146") # Generated from packet 147/148 cmd_02(dev, "\x82\x00\x20\x01\x09\x00", "packet W: 147/148, R: 149/150") # Generated from packet 151/152 cmd_09(dev) # Generated from packet 153/154 cmd_02(dev, "\x82\x00\x20\x01\x09\x00", "packet W: 153/154, R: 155/156") # added sm_insert(dev) print('Going active') led_mask_30(dev, 'active') # Atomic # Generated from packet 161/162 cmd_50(dev, "\x18\x00") # Generated from packet 163/164 buff = bulk2(dev, "\x66\xB8\x01\x32\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x82\x00", buff, "packet W: 163/164, R: 165/166") # Generated from packet 167/168 cmd_02(dev, "\x83\x00\x40\x01\x09\x00", "packet W: 167/168, R: 169/170") # Generated from packet 171/172 buff = bulk2(dev, "\x57\x82\x00\x20\x01\x00\x2B\x3B\x0C\x22\x00\xC0\x40\x00\x3B\x0E" \ "\x22\x00\xC0\x00\x00\x3B\x1A\x22\x00\xC0\x18\x00\x0E\x01" , target=0x20) validate_read( "\x14\x00\x54\x41\x38\x34\x56\x4C\x56\x5F\x46\x58\x34\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3E\x2C" , buff, "packet W: 171/172, R: 173/174") sm_info0(dev) # Generated from packet 195/196 buff = bulk2(dev, "\x48\x00\x10\x82\x02", target=0x06) validate_read("\x82\x00\x20\x01\x09\x00", buff, "packet W: 195/196, R: 197/198") # Generated from packet 199/200 bulkWrite(0x02, cmd_20_mk() + cmd_50_mk("\x7D\x02")) # Generated from packet 201/202 buff = bulk2(dev, i87c51_fw.p201, target=0x02) validate_read("\x82\x00", buff, "packet W: 201/202, R: 203/204") # Generated from packet 205/206 cmd_02(dev, "\x83\x00\xA0\x03\x09\x00", "packet W: 205/206, R: 207/208") # Atomic # Generated from packet 209/210 cmd_57_50(dev, "\x82", "\x1D\x00") # Generated from packet 211/212 buff = bulk2(dev, "\xC7\x05\x74\x46\x00\x00\x0B\x00\x00\x00\xFF\x15\x38\x11\x00\x00" \ "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x83\x00", buff, "packet W: 211/212, R: 213/214") # Generated from packet 215/216 cmd_02(dev, "\x84\x00\xC0\x03\x09\x00", "packet W: 215/216, R: 217/218") # Atomic ''' Seems these must be done together Increments socket insertion count ''' # Generated from packet 219/220 cmd_57_50(dev, "\x83", "\x18\x3A") # p221.bin: DOS executable (COM) # Generated from packet 221/222 buff = bulk2(dev, i87c51_fw.p221, target=0x02) validate_read("\x84\x00", buff, "packet W: 221/222, R: 223/224") # Generated from packet 225/226 cmd_02(dev, "\x85\x00\xE0\x3D\x09\x00", "packet W: 225/226, R: 227/228") # Generated from packet 229/230 bulkWrite(0x02, "\x57\x84\x00\xF0\xFF\xFF\x0F\xF0\xFF\xFF\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\xF0\x0F\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" \ "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" ) # Atomic # Generated from packet 231/232 cmd_50(dev, "\xDE\x03") # Generated from packet 233/234 buff = bulk2(dev, i87c51_fw.p233, target=0x02) validate_read("\x85\x00", buff, "packet W: 233/234, R: 235/236") # Generated from packet 237/238 cmd_02(dev, "\x86\x00\xC0\x41\x09\x00", "packet W: 237/238, R: 239/240") # The actual continuity check if cont: # Generated from packet 241/242 # Takes about 0.05 sec on pass but 0.52 sec on fail tstart = time.time() buff = cmd_57s(dev, "\x85", None, "cmd_57") tend = time.time() print(('Continuity test took %0.3f sec' % (tend - tstart, ))) hexdump(buff, label='Continuity', indent=' ') # Chip inserted if buff == "\x01": print('Continuity OK') # Chip removed elif buff == ("\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"): raise cmd.ContFail( 'Continuity complete failure (part not inserted?)') # Inserting chip while running # I'm guessing its telling me which pins failed # Lets bend a pin and verify else: raise cmd.ContFail( 'Continuity partial failure (dirty contacts? Inserted wrong?)' ) # Atomic with following operation # Generated from packet 245/246 cmd_50(dev, "\x62\x00") # Generated from packet 247/248 buff = bulk2(dev, "\x00\x00\x3C\x00\x38\x00\x34\x00\x30\x00\x3D\x00\x39\x00\x35\x00" \ "\x31\x00\x3E\x00\x3A\x00\x36\x00\x32\x00\x3F\x00\x3B\x00\x37\x00" \ "\x33\x00\x1E\x00\x1A\x00\x16\x00\x00\x00\x02\x00\x06\x00\x0A\x00" \ "\x0E\x00\x23\x00\x27\x00\x2B\x00\x2F\x00\x22\x00\x26\x00\x2A\x00" \ "\x2E\x00\x21\x00\x25\x00\x29\x00\x2D\x00\x20\x00\x24\x00\x28\x00" \ "\x1C\x00\x00\x00\x04\x00\x08\x00\x0C\x00\x10\x00\x14\x00\x18\x00" \ "\x1C\x00" , target=0x02) validate_read("\x86\x00", buff, "packet W: 247/248, R: 249/250") # Generated from packet 251/252 cmd_02(dev, "\x87\x00\x30\x42\x09\x00", "packet W: 251/252, R: 253/254") # Atomic with next # Generated from packet 255/256 bulkWrite(0x02, "\x1D\xC0\x41\x09\x00\x28\x00\x15\x60\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x01\x00\x00\x00\x1C\x30\x00\x00\x00\x08\x00\x00\x00\x48" \ "\x00\x50\x71\x09\x00\x00") # Generated from packet 257/258 buff = bulk2(dev, i87c51_fw.p257, target=0x02) validate_read("\x87\x00", buff, "packet W: 257/258, R: 259/260") # Generated from packet 261/262 cmd_02(dev, "\x88\x00\xB0\x4B\x09\x00", "packet W: 261/262, R: 263/264") # Generated from packet 265/266 cmd_57s(dev, "\x87", "\x00\x00", "cmd_57") # Atomic # Generated from packet 269/270 cmd_50(dev, "\x17\x00") # Generated from packet 271/272 buff = bulk2(dev, "\xC7\x05\x2C\x00\x09\x00\x24\x04\x00\x00\x66\xB9\x00\x00\xB2\x00" \ "\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x88\x00", buff, "packet W: 271/272, R: 273/274") # Generated from packet 275/276 cmd_02(dev, "\x89\x00\xD0\x4B\x09\x00", "packet W: 275/276, R: 277/278") # Atomic # Generated from packet 279/280 cmd_57_50(dev, "\x88", "\x32\x07") # Generated from packet 281/282 buff = bulk2(dev, i87c51_fw.p281, target=0x02) validate_read("\x89\x00", buff, "packet W: 281/282, R: 283/284") # Generated from packet 285/286 cmd_02(dev, "\x8A\x00\x10\x53\x09\x00", "packet W: 285/286, R: 287/288") # Generated from packet 289/290 cmd_57s(dev, '\x89', "\x00\x00") # Atomic # Generated from packet 293/294 cmd_50(dev, "\x3D\x03") # Generated from packet 295/296 buff = bulk2(dev, i87c51_fw.p295, target=0x02) validate_read("\x8A\x00", buff, "packet W: 295/296, R: 297/298") # Generated from packet 299/300 cmd_02(dev, "\x8B\x00\x50\x56\x09\x00", "packet W: 299/300, R: 301/302") # Generated from packet 303/304 cmd_57s(dev, "\x8A", "\x89\x00") # Atomic # Generated from packet 307/308 cmd_50(dev, "\x1D\x00") # Generated from packet 309/310 buff = bulk2(dev, "\x66\x8B\x0D\x1A\x24\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00" \ "\x66\xB9\x00\x00\xB2\x02\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x8B\x00", buff, "packet W: 309/310, R: 311/312") # Generated from packet 313/314 cmd_02(dev, "\x8C\x00\x70\x56\x09\x00", "packet W: 313/314, R: 315/316") # Generated from packet 317/318 # Bad part returns \x59\x00 but otherwise can be read # (with partially corrupt bit pattern) if cont: buff = cmd_57s(dev, "\x8B", None) if buff == "\x59\x00": raise Exception("Failed 0x8B health check") else: validate_read("\x58\x00", buff, "") # Atomic # Generated from packet 321/322 cmd_50(dev, "\xF8\x04") # Generated from packet 323/324 buff = bulk2(dev, i87c51_fw.p323, target=0x02) validate_read("\x8C\x00", buff, "packet W: 323/324, R: 325/326") # Generated from packet 327/328 cmd_02(dev, "\x8D\x00\x70\x5B\x09\x00", "packet W: 327/328, R: 329/330") # Generated from packet 331/332 cmd_57s(dev, '\x8C', "\x00\x00") # Atomic # Generated from packet 335/336 cmd_50(dev, "\x18\x00") # Generated from packet 337/338 buff = bulk2(dev, "\x66\xB8\x01\x32\x66\x89\x05\x06\x00\x09\x00\x66\xB9\x00\x00\xB2" \ "\x00\xFB\xFF\x25\x44\x11\x00\x00" , target=0x02) validate_read("\x8D\x00", buff, "packet W: 337/338, R: 339/340") # Generated from packet 341/342 cmd_02(dev, "\x8E\x00\x90\x5B\x09\x00", "packet W: 341/342, R: 343/344") # Generated from packet 345/346 cmd_57s(dev, "\x8D\x89", "\x00\x00") # Atomic # Generated from packet 349/350 cmd_50(dev, "\xFA\x01") # Generated from packet 351/352 buff = bulk2(dev, i87c51_fw.p351, target=0x02) validate_read("\x8E\x00", buff, "packet W: 351/352, R: 353/354") # Generated from packet 355/356 cmd_02(dev, "\x8F\x00\x90\x5D\x09\x00", "packet W: 355/356, R: 357/358") # Generated from packet 323/324 cmd_08(dev, "\x8E") # Generated from packet 363/364 cmd_57s(dev, '\x8C', "\x00\x00")