Exemple #1
0
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
Exemple #2
0
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")
Exemple #3
0
def boot_cold(dev):
    bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev)

    # NOTE:: req max 512 but got 4
    # Generated from packet 655/656
    # bulk2 aggregate: packet W: 655/656, 1 to R 657/658
    # NOTE:: req max 512 but got 100
    # Generated from packet 659/660
    # bulk2 aggregate: packet W: 659/660, 1 to R 661/662
    buff = cmd.bulk2b(dev, "\x43\x19\x00\x00\x00\x00")
    validate_read("\x40\x06", buff, "packet W: 659/660, R 1 to 661/662")
    # NOTE:: req max 512 but got 5
    # Generated from packet 663/664
    # bulk2 aggregate: packet W: 663/664, 1 to R 665/666
    # NOTE:: req max 512 but got 100
    # Generated from packet 667/668
    bulkWrite(0x02, "\x43\x19\x00\x00\x00\x11\xF0\xFF")
    bulkWrite(0x02, fw.hash2bin["0232b379"])
    bulkWrite(0x02, fw.hash2bin["68a3a4fc"])
    bulkWrite(0x02, fw.hash2bin["22040fee"])
    bulkWrite(0x02, fw.hash2bin["40b13ba4"])
    bulkWrite(0x02, fw.hash2bin["5712c0fb"])
    # FIXME: fails boot warm
    # Generated from packet 679/680
    # bulk2 aggregate: packet W: 679/680, 1 to R 681/682
    buff = cmd.bulk2b(dev, "\x5A")
    validate_read("\x80", buff, "packet W: 679/680, R 1 to 681/682")

    # NOTE:: req max 512 but got 4
    # Generated from packet 683/684
    bulkWrite(0x02, "\x11\x10\x00")
    # Generated from packet 685/686
    bulkWrite(
        0x02,
        "\xEA\xCC\x64\x01\x00\x08\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x3F")
    # Generated from packet 687/688
    # bulk2 aggregate: packet W: 687/688, 1 to R 689/690
    buff = cmd.bulk2b(dev, "\xA6")
    validate_read("\x81", buff, "packet W: 687/688, R 1 to 689/690")
    # NOTE:: req max 512 but got 4
    # Generated from packet 691/692
    bulkWrite(0x02, "\x11\x4E\x00")
    # Generated from packet 693/694
    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"
        )
    # Generated from packet 695/696
    # bulk2 aggregate: packet W: 695/696, 1 to R 697/698
    buff = cmd.bulk2b(dev, "\xDB")
    validate_read("\x82", buff, "packet W: 695/696, R 1 to 697/698")
    # NOTE:: req max 512 but got 4
    # Generated from packet 699/700
    # bulk2 aggregate: packet W: 699/700, 1 to R 701/702
    buff = cmd.bulk2b(dev, "\x82")
    validate_read("\x16", buff, "packet W: 699/700, R 1 to 701/702")
    # NOTE:: req max 512 but got 4
    # Generated from packet 703/704
    # bulk2 aggregate: packet W: 703/704, 1 to R 705/706
    # NOTE:: req max 512 but got 136
    # Generated from packet 707/708
    # bulk2 aggregate: packet W: 707/708, 1 to R 709/710
    # NOTE:: req max 512 but got 35
    # Generated from packet 711/712
    # bulk2 aggregate: packet W: 711/712, 1 to R 713/714
    # tech adapter read
    if 0:
        buff = cmd.bulk2b(dev,
            "\x14\x38\x25\x00\x00\x04\x00\xB2\x32\x96\x00\xC0\x03\x20\x00\x14" \
            "\x40\x25\x00\x00\x01\x00\x1A\x41\x0E\x01"
            )
        validate_read(
            "\x11\x00\x54\x41\x32\x34\x30\x56\x4C\x56\x5F\x46\x58\x00\x00\x00" \
            "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x21"
            , buff, "packet W: 711/712, R 1 to 713/714")
    # NOTE:: req max 512 but got 35
    # Generated from packet 715/716
    # bulk2 aggregate: packet W: 715/716, 1 to R 717/718
    # NOTE:: req max 512 but got 5
    # Generated from packet 719/720
    # bulk2 aggregate: packet W: 719/720, 1 to R 721/722
    # NOTE:: req max 512 but got 5
    # Generated from packet 723/724
    # bulk2 aggregate: packet W: 723/724, 1 to R 725/726
    # NOTE:: req max 512 but got 35
    # Generated from packet 727/728
    # bulk2 aggregate: packet W: 727/728, 1 to R 729/730
    # NOTE:: req max 512 but got 136
    # Generated from packet 731/732
    bulkWrite(0x02, "\x43\x19\x00\x00\x00")
    # Generated from packet 733/734
    bulkWrite(0x02, "\x20\x01\x00\x0C\x04")
    # Generated from packet 735/736
    cmd.cmd_41(dev)
    # Generated from packet 737/738
    # bulk2 aggregate: packet W: 737/738, 1 to R 739/740
    cmd.cmd_10(dev)
    # NOTE:: req max 512 but got 9
    # Generated from packet 741/742
    # bulk2 aggregate: packet W: 741/742, 1 to R 743/744
    cmd.cmd_45(dev)
    # NOTE:: req max 512 but got 103
    # Generated from packet 745/746
    # bulk2 aggregate: packet W: 745/746, 1 to R 747/748
    cmd.cmd_49(dev)
    # NOTE:: req max 512 but got 5
    # Generated from packet 749/750
    # bulk2 aggregate: packet W: 749/750, 1 to R 751/752
    # NOTE:: req max 512 but got 5
    # Generated from packet 753/754
    # bulk2 aggregate: packet W: 753/754, 1 to R 755/756
    # NOTE:: req max 512 but got 5
    # Generated from packet 757/758
    # bulk2 aggregate: packet W: 757/758, 1 to R 759/760
    # NOTE:: req max 512 but got 35
    # Generated from packet 761/762
    bulkWrite(0x02,
        "\x3B\x0C\x22\x00\xC0\x00\x00\x3B\x0E\x22\x00\xC0\x00\x00\x3B\x1A" \
        "\x22\x00\xC0\x18\x00\x40"
        )
    # Generated from packet 763/764
    # bulk2 aggregate: packet W: 763/764, 1 to R 765/766
    cmd.cmd_4A(dev)
    # NOTE:: req max 512 but got 5
    # Generated from packet 767/768
    cmd.cmd_4C(dev)
    # Generated from packet 769/770
    # None (0xB2)
    buff = controlWrite(0x40, 0xB2, 0x0000, 0x0000, "")
    # Generated from packet 771/772
    cmd.cmd_50(dev, "\x45\x00")
    # Generated from packet 773/774
    # bulk2 aggregate: packet W: 773/774, 1 to R 775/776
    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\x66\xB9\x00\x00\xB2\x00\xFB\xFF" \
        "\x25\x44\x11\x00\x00"
        )
    validate_read("\x80\x00", buff, "packet W: 773/774, R 1 to 775/776")
    # Generated from packet 777/778
    # bulk2 aggregate: packet W: 777/778, 1 to R 779/780
    cmd.cmd_02(dev, "\x81\x00\x50\x00\x09\x00")
    # Generated from packet 781/782
    cmd.cmd_50(dev, "\xC9\x00")
    # Generated from packet 783/784
    # bulk2 aggregate: packet W: 783/784, 1 to R 785/786
    buff = cmd.bulk2b(dev,
        "\x66\xC7\x05\x1E\x22\x00\xC0\x00\x20\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: 783/784, R 1 to 785/786")
    # Generated from packet 787/788
    # bulk2 aggregate: packet W: 787/788, 1 to R 789/790
    cmd.cmd_02(dev, "\x82\x00\x20\x01\x09\x00")
    # Generated from packet 791/792
    # bulk2 aggregate: packet W: 791/792, 1 to R 793/794
    buff = cmd.bulk2b(dev,
        "\x04\x65\x05\x27\x06\x20\x07\x63\x08\x6F\x09\x6E\x0A\x74\x0B\x65" \
        "\x57\x81\x00\x0C\x04\x30"
        )
    validate_read("\x04\x00", buff, "packet W: 791/792, R 1 to 793/794")
    if 0:
        # TA read
        # Generated from packet 795/796
        # bulk2 aggregate: packet W: 795/796, 1 to R 797/798
        buff = cmd.bulk2b(dev,
            "\x3B\x0C\x22\x00\xC0\x00\x00\x3B\x0E\x22\x00\xC0\x00\x00\x3B\x1A" \
            "\x22\x00\xC0\x18\x00\x40\x0E\x01"
            )
        validate_read(
            "\x11\x00\x54\x41\x32\x34\x30\x56\x4C\x56\x5F\x46\x58\x00\x00\x00" \
            "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x21"
            , buff, "packet W: 795/796, R 1 to 797/798")
    # Generated from packet 799/800
    # bulk2 aggregate: packet W: 799/800, 1 to R 801/802
    # Generated from packet 803/804
    # bulk2 aggregate: packet W: 803/804, 1 to R 805/806
    # Generated from packet 807/808
    # bulk2 aggregate: packet W: 807/808, 1 to R 809/810
    # Generated from packet 811/812
    bulkWrite(0x02, "\x48\x00\x20\x00\x00\x50\x12\x00\x00\x00")
    # Generated from packet 813/814
    # bulk2 aggregate: packet W: 813/814, 1 to R 815/816
    buff = cmd.bulk2b(dev,
        "\x00\x00\x00\x00\x04\x00\x08\x00\x0C\x00\x10\x00\x14\x00\x18\x00" \
        "\x1C\x00"
        )
    validate_read("\x82\x00", buff, "packet W: 813/814, R 1 to 815/816")
    # Generated from packet 817/818
    # bulk2 aggregate: packet W: 817/818, 1 to R 819/820
    cmd.cmd_02(dev, "\x83\x00\x40\x01\x09\x00")
    # Generated from packet 821/822
    # bulk2 aggregate: packet W: 821/822, 1 to R 823/824
    buff = cmd.bulk2b(dev,
        "\x1D\x20\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"
        )
    validate_read("\xAB", buff, "packet W: 821/822, R 1 to 823/824")
Exemple #4
0
def boot_warm(dev):
    bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev)

    # Generated from packet 387/388
    # bulk2 aggregate: packet W: 387/388, 1 to R 389/390
    buff = cmd.bulk2b(dev,
        "\x43\x19\x00\x00\x00\x3B\x7E\x25\x00\x00\xFE\xFF\x3B\x7C\x25\x00" \
        "\x00\xFE\xFF\x00"
        )
    validate_read("\x40\x06", buff, "packet W: 387/388, R 1 to 389/390")
    if 0:
        # tech adapter read
        # Generated from packet 399/400
        # bulk2 aggregate: packet W: 399/400, 1 to R 401/402
        buff = cmd.bulk2b(dev,
            "\x14\x38\x25\x00\x00\x04\x00\xB2\x32\x96\x00\xC0\x03\x20\x00\x14" \
            "\x40\x25\x00\x00\x01\x00\x1A\x41\x0E\x01"
            )
        validate_read(
            "\x11\x00\x54\x41\x32\x34\x30\x56\x4C\x56\x5F\x46\x58\x00\x00\x00" \
            "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x21"
            , buff, "packet W: 399/400, R 1 to 401/402")
    # Generated from packet 419/420
    bulkWrite(0x02, "\x43\x19\x00\x00\x00")
    # Generated from packet 421/422
    bulkWrite(0x02, "\x20\x01\x00\x0C\x04")
    # Generated from packet 423/424
    cmd.cmd_41(dev)
    # Generated from packet 425/426
    # bulk2 aggregate: packet W: 425/426, 1 to R 427/428
    cmd.cmd_10(dev)
    # Generated from packet 429/430
    # bulk2 aggregate: packet W: 429/430, 1 to R 431/432
    cmd.cmd_45(dev)
    # Generated from packet 433/434
    # bulk2 aggregate: packet W: 433/434, 1 to R 435/436
    cmd.cmd_49(dev)
    # Generated from packet 449/450
    bulkWrite(0x02,
        "\x3B\x0C\x22\x00\xC0\x00\x00\x3B\x0E\x22\x00\xC0\x00\x00\x3B\x1A" \
        "\x22\x00\xC0\x18\x00\x40"
        )
    # Generated from packet 451/452
    # bulk2 aggregate: packet W: 451/452, 1 to R 453/454
    cmd.cmd_4A(dev)
    # Generated from packet 455/456
    cmd.cmd_4C(dev)
    # Generated from packet 457/458
    # None (0xB2)
    buff = controlWrite(0x40, 0xB2, 0x0000, 0x0000, "")
    # Generated from packet 459/460
    cmd.cmd_50(dev, "\x45\x00")
    # Generated from packet 461/462
    # bulk2 aggregate: packet W: 461/462, 1 to R 463/464
    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\x66\xB9\x00\x00\xB2\x00\xFB\xFF" \
        "\x25\x44\x11\x00\x00"
        )
    validate_read("\x80\x00", buff, "packet W: 461/462, R 1 to 463/464")
    # Generated from packet 465/466
    # bulk2 aggregate: packet W: 465/466, 1 to R 467/468
    cmd.cmd_02(dev, "\x81\x00\x50\x00\x09\x00")
    # Generated from packet 469/470
    cmd.cmd_50(dev, "\xC9\x00")
    # Generated from packet 471/472
    # bulk2 aggregate: packet W: 471/472, 1 to R 473/474
    buff = cmd.bulk2b(dev,
        "\x66\xC7\x05\x1E\x22\x00\xC0\x00\x20\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: 471/472, R 1 to 473/474")
    # Generated from packet 475/476
    # bulk2 aggregate: packet W: 475/476, 1 to R 477/478
    cmd.cmd_02(dev, "\x82\x00\x20\x01\x09\x00")
    # Generated from packet 479/480
    # bulk2 aggregate: packet W: 479/480, 1 to R 481/482
    buff = cmd.bulk2b(dev,
        "\x04\x09\x05\x02\x06\x2E\x08\x01\x09\x01\x0B\xC0\x57\x81\x00\x0C" \
        "\x04\x30"
        )
    validate_read("\x04\x00", buff, "packet W: 479/480, R 1 to 481/482")
    # tech adapter read
    if 0:
        # Generated from packet 483/484
        # bulk2 aggregate: packet W: 483/484, 1 to R 485/486
        buff = cmd.bulk2b(dev,
            "\x3B\x0C\x22\x00\xC0\x00\x00\x3B\x0E\x22\x00\xC0\x00\x00\x3B\x1A" \
            "\x22\x00\xC0\x18\x00\x40\x0E\x01"
            )
        validate_read(
            "\x11\x00\x54\x41\x32\x34\x30\x56\x4C\x56\x5F\x46\x58\x00\x00\x00" \
            "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x21"
            , buff, "packet W: 483/484, R 1 to 485/486")
    # Generated from packet 499/500
    bulkWrite(0x02, "\x48\x00\x20\x00\x00\x50\x12\x00\x00\x00")
    # Generated from packet 501/502
    # bulk2 aggregate: packet W: 501/502, 1 to R 503/504
    buff = cmd.bulk2b(dev,
        "\x00\x00\x00\x00\x04\x00\x08\x00\x0C\x00\x10\x00\x14\x00\x18\x00" \
        "\x1C\x00"
        )
    validate_read("\x82\x00", buff, "packet W: 501/502, R 1 to 503/504")
    # Generated from packet 505/506
    # bulk2 aggregate: packet W: 505/506, 1 to R 507/508
    cmd.cmd_02(dev, "\x83\x00\x40\x01\x09\x00")
    # Generated from packet 509/510
    # bulk2 aggregate: packet W: 509/510, 1 to R 511/512
    buff = cmd.bulk2b(dev,
        "\x1D\x20\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"
        )
    validate_read("\xAB", buff, "packet W: 509/510, R 1 to 511/512")
Exemple #5
0
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}
Exemple #6
0
def dev_read(dev, cont=False, verbose=False):
    bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev)
    config = {}

    # Generated by uvusbreplay 0.1
    # uvusbreplay copyright 2011 John McMaster <*****@*****.**>
    # cmd: /usr/local/bin/usbrply --fx2 --device 9 -j pic16c554.cap
    # Generated from packet 301/302
    # 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 301/302")
    # Generated from packet 303/304
    _prefix, buff, _size = cmd.bulk86_next_read(dev)
    validate_read("\x16", buff, "packet 303/304")
    # NOTE:: req max 512 but got 136
    # Generated from packet 309/310
    # bulk2 aggregate: packet W: 309/310, 1 to R 311/312
    buff = cmd.bulk2b(dev,
        "\x43\x19\x04\x00\x00\x3B\x7E\x25\x00\x00\xFE\xFF\x3B\x7C\x25\x00" \
        "\x00\xFE\xFF\x00"
        )
    validate_read("\xA4\x06", buff, "packet W: 309/310, R 1 to 311/312")

    # tech adapter read
    if 0:
        # NOTE:: req max 512 but got 35
        # Generated from packet 321/322
        # bulk2 aggregate: packet W: 321/322, 1 to R 323/324
        buff = cmd.bulk2b(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"
            )
        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: 321/322, R 1 to 323/324")

    # NOTE:: req max 512 but got 136
    # Generated from packet 349/350
    bulkWrite(0x02, "\x43\x19\x04\x00\x00")
    # Generated from packet 351/352
    bulkWrite(0x02, "\x20\x01\x00\x0C\x04")
    # Generated from packet 353/354
    cmd.cmd_41(dev)
    # Generated from packet 355/356
    # bulk2 aggregate: packet W: 355/356, 1 to R 357/358
    cmd.cmd_10(dev)
    # NOTE:: req max 512 but got 35
    # Generated from packet 367/368
    # bulk2 aggregate: packet W: 367/368, 1 to R 369/370
    cmd.cmd_45(dev)
    # NOTE:: req max 512 but got 103
    # Generated from packet 371/372
    # bulk2 aggregate: packet W: 371/372, 1 to R 373/374
    cmd.cmd_49(dev)
    # NOTE:: req max 512 but got 9
    # Generated from packet 397/398
    # bulk2 aggregate: packet W: 397/398, 1 to R 399/400
    cmd.cmd_49(dev)
    # NOTE:: req max 512 but got 11
    # Generated from packet 413/414
    cmd.cmd_3B(dev)
    # Generated from packet 415/416
    # bulk2 aggregate: packet W: 415/416, 1 to R 417/418
    cmd.cmd_4A(dev)
    # NOTE:: req max 512 but got 5
    # Generated from packet 419/420
    cmd.cmd_4C(dev)
    # Generated from packet 421/422
    buff = controlWrite(0x40, 0xB2, 0x0000, 0x0000, "")
    # Generated from packet 423/424
    cmd.cmd_50(dev, "\x5C\x00")
    # Generated from packet 425/426
    # bulk2 aggregate: packet W: 425/426, 1 to R 427/428
    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" \
        "\xE9\x03\x00\x00\x00\x90\x00\x00\xE9\x02\x00\x00\x00\x90\x00\x66" \
        "\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00"
        )
    validate_read("\x80\x00", buff, "packet W: 425/426, R 1 to 427/428")
    # Generated from packet 429/430
    # bulk2 aggregate: packet W: 429/430, 1 to R 431/432
    cmd.cmd_02(dev, "\x81\x00\x60\x00\x09\x00")
    # Generated from packet 433/434
    cmd.cmd_50(dev, "\xC0\x00")
    # Generated from packet 435/436
    # bulk2 aggregate: packet W: 435/436, 1 to R 437/438
    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: 435/436, R 1 to 437/438")
    # Generated from packet 439/440
    # bulk2 aggregate: packet W: 439/440, 1 to R 441/442
    cmd.cmd_02(dev, "\x82\x00\x20\x01\x09\x00")
    # Generated from packet 443/444
    bulkWrite(0x02, "\x57\x81\x00")
    # Generated from packet 445/446
    # bulk2 aggregate: packet W: 445/446, 1 to R 447/448
    cmd.cmd_02(dev, "\x82\x00\x20\x01\x09\x00")
    # Generated from packet 449/450
    # bulk2 aggregate: packet W: 449/450, 1 to R 451/452
    cmd.led_mask(dev, "active")
    # Generated from packet 453/454
    cmd.cmd_50(dev, "\x18\x00")
    # Generated from packet 455/456
    # bulk2 aggregate: packet W: 455/456, 1 to R 457/458
    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: 455/456, R 1 to 457/458")
    # Generated from packet 459/460
    # bulk2 aggregate: packet W: 459/460, 1 to R 461/462
    cmd.cmd_02(dev, "\x83\x00\x40\x01\x09\x00")
    # Generated from packet 463/464
    # bulk2 aggregate: packet W: 463/464, 1 to R 465/466
    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: 463/464, R 1 to 465/466")
    # Generated from packet 487/488
    # bulk2 aggregate: packet W: 487/488, 1 to R 489/490
    buff = cmd.bulk2b(dev, "\x48\x00\x10\x82\x02")
    validate_read("\x82\x00\x20\x01\x09\x00", buff,
                  "packet W: 487/488, R 1 to 489/490")
    # Generated from packet 491/492
    bulkWrite(0x02, "\x20\x01\x00\x50\x7D\x02\x00\x00")
    # Generated from packet 493/494
    # bulk2 aggregate: packet W: 493/494, 1 to R 495/496
    buff = cmd.bulk2b(dev, bpmicro.pic.pic16f84_fw.p651)
    validate_read("\x82\x00", buff, "packet W: 493/494, R 1 to 495/496")
    # Generated from packet 497/498
    # bulk2 aggregate: packet W: 497/498, 1 to R 499/500
    cmd.cmd_02(dev, "\x83\x00\xA0\x03\x09\x00")
    # Generated from packet 501/502
    bulkWrite(0x02, "\x57\x82\x00\x50\x1D\x00\x00\x00")
    # Generated from packet 503/504
    # bulk2 aggregate: packet W: 503/504, 1 to R 505/506
    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: 503/504, R 1 to 505/506")
    # Generated from packet 507/508
    # bulk2 aggregate: packet W: 507/508, 1 to R 509/510
    cmd.cmd_02(dev, "\x84\x00\xC0\x03\x09\x00")
    # Generated from packet 511/512
    bulkWrite(0x02, "\x57\x83\x00\x50\x18\x3A\x00\x00")
    # Generated from packet 513/514
    # bulk2 aggregate: packet W: 513/514, 1 to R 515/516
    buff = cmd.bulk2b(dev, my_fw.p513)
    validate_read("\x84\x00", buff, "packet W: 513/514, R 1 to 515/516")
    # Generated from packet 517/518
    # bulk2 aggregate: packet W: 517/518, 1 to R 519/520
    cmd.cmd_02(dev, "\x85\x00\xE0\x3D\x09\x00")
    # Generated from packet 521/522
    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 523/524
    cmd.cmd_50(dev, "\xDE\x03")
    # Generated from packet 525/526
    # bulk2 aggregate: packet W: 525/526, 1 to R 527/528
    buff = cmd.bulk2b(dev, my_fw.p525)
    validate_read("\x85\x00", buff, "packet W: 525/526, R 1 to 527/528")
    # Generated from packet 529/530
    # bulk2 aggregate: packet W: 529/530, 1 to R 531/532
    cmd.cmd_02(dev, "\x86\x00\xC0\x41\x09\x00")
    # Generated from packet 533/534
    # bulk2 aggregate: packet W: 533/534, 1 to R 535/536
    cmd.check_cont(dev)
    # Generated from packet 537/538
    cmd.cmd_50(dev, "\x71\x1B")
    # Generated from packet 539/540
    # bulk2 aggregate: packet W: 539/540, 1 to R 541/542
    buff = cmd.bulk2b(dev, my_fw.p539)
    validate_read("\x86\x00", buff, "packet W: 539/540, R 1 to 541/542")
    # Generated from packet 543/544
    # bulk2 aggregate: packet W: 543/544, 1 to R 545/546
    cmd.cmd_02(dev, "\x87\x00\x40\x5D\x09\x00")
    # Generated from packet 547/548
    # bulk2 aggregate: packet W: 547/548, 1 to R 549/550
    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"
        )
    validate_read("\x01", buff, "packet W: 547/548, R 1 to 549/550")
    # Generated from packet 551/552
    bulkWrite(0x02, "\x20\x01\x00\x50\x36\x00\x00\x00")
    # Generated from packet 553/554
    # bulk2 aggregate: packet W: 553/554, 1 to R 555/556
    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: 553/554, R 1 to 555/556")
    # Generated from packet 557/558
    # bulk2 aggregate: packet W: 557/558, 1 to R 559/560
    cmd.cmd_02(dev, "\x88\x00\x80\x5D\x09\x00")
    # Generated from packet 561/562
    bulkWrite(0x02,
        "\x1D\x40\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 563/564
    # bulk2 aggregate: packet W: 563/564, 1 to R 565/566
    buff = cmd.bulk2b(dev, my_fw.p563)
    validate_read("\x88\x00", buff, "packet W: 563/564, R 1 to 565/566")
    # Generated from packet 567/568
    # bulk2 aggregate: packet W: 567/568, 1 to R 569/570
    cmd.cmd_02(dev, "\x89\x00\x00\x67\x09\x00")
    # Generated from packet 571/572
    # bulk2 aggregate: packet W: 571/572, 1 to R 573/574
    cmd.cmd_57s(dev, "\x88", "\x00\x00")
    # Generated from packet 575/576
    cmd.cmd_50(dev, "\x17\x00")
    # Generated from packet 577/578
    # bulk2 aggregate: packet W: 577/578, 1 to R 579/580
    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: 577/578, R 1 to 579/580")
    # Generated from packet 581/582
    # bulk2 aggregate: packet W: 581/582, 1 to R 583/584
    cmd.cmd_02(dev, "\x8A\x00\x20\x67\x09\x00")
    # Generated from packet 585/586
    bulkWrite(0x02, "\x57\x89\x00\x50\x18\x00\x00\x00")
    # Generated from packet 587/588
    # bulk2 aggregate: packet W: 587/588, 1 to R 589/590
    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: 587/588, R 1 to 589/590")
    # Generated from packet 591/592
    # bulk2 aggregate: packet W: 591/592, 1 to R 593/594
    cmd.cmd_02(dev, "\x8B\x00\x40\x67\x09\x00")
    # Generated from packet 595/596
    bulkWrite(0x02, "\x57\x8A\x00\x50\x3D\x09\x00\x00")
    # Generated from packet 597/598
    # bulk2 aggregate: packet W: 597/598, 1 to R 599/600
    buff = cmd.bulk2b(dev, my_fw.p597)
    validate_read("\x8B\x00", buff, "packet W: 597/598, R 1 to 599/600")
    # Generated from packet 601/602
    # bulk2 aggregate: packet W: 601/602, 1 to R 603/604
    cmd.cmd_02(dev, "\x8C\x00\x80\x70\x09\x00")
    # Generated from packet 605/606
    # bulk2 aggregate: packet W: 605/606, 1 to R 607/608
    cmd.cmd_57s(dev, "\x8B", "\x00\x00")
    # Generated from packet 609/610
    cmd.cmd_50(dev, "\x37\x06")
    # Generated from packet 611/612
    # bulk2 aggregate: packet W: 611/612, 1 to R 613/614
    buff = cmd.bulk2b(dev, my_fw.p611)
    validate_read("\x8C\x00", buff, "packet W: 611/612, R 1 to 613/614")
    # Generated from packet 615/616
    # bulk2 aggregate: packet W: 615/616, 1 to R 617/618
    cmd.cmd_02(dev, "\x8D\x00\xC0\x76\x09\x00")

    # Generated from packet 619/620
    # bulk2 aggregate: packet W: 619/620, 1 to R 621/622
    buff = cmd.bulk2b(dev, "\x08\x01\x57\x8C\x00")
    #validate_read("\x01\x00", buff, "packet W: 619/620, R 1 to 621/622")
    config['secure'] = buff != '\x00\x00'

    # Generated from packet 623/624
    cmd.cmd_50(dev, "\xCE\x03")
    # Generated from packet 625/626
    # bulk2 aggregate: packet W: 625/626, 1 to R 627/628
    buff = cmd.bulk2b(dev, my_fw.p625)
    validate_read("\x8D\x00", buff, "packet W: 625/626, R 1 to 627/628")
    # Generated from packet 629/630
    # bulk2 aggregate: packet W: 629/630, 1 to R 631/632
    cmd.cmd_02(dev, "\x8E\x00\x90\x7A\x09\x00")
    # Generated from packet 633/634
    # bulk2 aggregate: packet W: 633/634, 1 to R 635/636
    cmd.cmd_57s(dev, "\x8D", "\x00\x00")
    # Generated from packet 763/764
    # bulk2 aggregate: packet W: 763/764, 1 to R 765/766
    cmd.cmd_57s(dev, "\x8D", "\x00\x00")
    # Generated from packet 767/768
    # bulk2 aggregate: packet W: 767/768, 1 to R 769/770
    cmd.cmd_57s(dev, "\x8A\x8B", "\x00\x00")
    # Generated from packet 771/772
    cmd.cmd_50(dev, "\x66\x26")
    # Generated from packet 773/774
    # bulk2 aggregate: packet W: 773/774, 1 to R 775/776
    buff = cmd.bulk2b(dev, my_fw.p773)
    validate_read("\x8E\x00", buff, "packet W: 773/774, R 1 to 775/776")
    # Generated from packet 777/778
    # bulk2 aggregate: packet W: 777/778, 1 to R 779/780
    cmd.cmd_02(dev, "\x8F\x00\x00\xA1\x09\x00")

    # Generated from packet 781/782
    # bulk2 aggregate: packet W: 781/782, 3 to R 817/818
    buff = cmd.bulk2b(dev, "\x08\x00\x09\x02\x57\x8E\x00")
    #validate_read(my_fw.p817, buff, "packet W: 781/782, R 3 to 817/818")
    code = buff

    # Generated from packet 819/820
    cmd.cmd_50(dev, "\x5E\x00")
    # Generated from packet 821/822
    # bulk2 aggregate: packet W: 821/822, 1 to R 825/826
    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: 821/822, R 1 to 825/826")
    # Generated from packet 827/828
    # bulk2 aggregate: packet W: 827/828, 1 to R 829/830
    cmd.cmd_02(dev, "\x90\x00\x60\xA1\x09\x00")
    # Generated from packet 831/832
    # bulk2 aggregate: packet W: 831/832, 1 to R 833/834
    cmd.cmd_57s(dev, "\x8F", "\x00\x00")
    # Generated from packet 841/842
    cmd.cmd_50(dev, "\x46\x0C")
    # Generated from packet 843/844
    # bulk2 aggregate: packet W: 843/844, 1 to R 845/846
    buff = cmd.bulk2b(dev, my_fw.p843)
    validate_read("\x90\x00", buff, "packet W: 843/844, R 1 to 845/846")
    # Generated from packet 847/848
    # bulk2 aggregate: packet W: 847/848, 1 to R 849/850
    cmd.cmd_02(dev, "\x91\x00\xB0\xAD\x09\x00")
    # Generated from packet 853/854
    # bulk2 aggregate: packet W: 853/854, 1 to R 855/858
    cmd.cmd_57s(dev, "\x90", "\x00\x00")
    # Generated from packet 859/860
    cmd.cmd_50(dev, "\x92\x00")
    # Generated from packet 861/862
    # bulk2 aggregate: packet W: 861/862, 1 to R 865/866
    buff = cmd.bulk2b(dev,
        "\xE9\x03\x00\x00\x00\x90\x00\x00\x66\xC7\x05\xB6\xAD\x09\x00\x00" \
        "\x00\x66\x8B\x05\xB6\xAD\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\xB6\xAD\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\xB6\xAD\x09\x00\x66\xFF\x05\xB6" \
        "\xAD\x09\x00\xEB\x8C\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11" \
        "\x00\x00"
        )
    validate_read("\x91\x00", buff, "packet W: 861/862, R 1 to 865/866")
    # Generated from packet 867/868
    # bulk2 aggregate: packet W: 867/868, 1 to R 869/870
    cmd.cmd_02(dev, "\x92\x00\x50\xAE\x09\x00")

    # Generated from packet 871/872
    # bulk2 aggregate: packet W: 871/872, 1 to R 873/874
    #cmd.cmd_57s(dev, "\x91", "\x00\x04\x02\x04\x04\x04\x06\x04\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)
    config['misc'] = binascii.hexlify(buff[8:])

    # Generated from packet 875/876
    # bulk2 aggregate: packet W: 875/876, 1 to R 879/890
    cmd.cmd_57s(dev, "\x8D", "\x00\x00")
    # Generated from packet 891/892
    cmd.cmd_50(dev, "\x0D\x00")
    # Generated from packet 893/894
    # bulk2 aggregate: packet W: 893/894, 1 to R 897/898
    buff = cmd.bulk2b(dev,
                      "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00")
    validate_read("\x92\x00", buff, "packet W: 893/894, R 1 to 897/898")
    # Generated from packet 899/900
    # bulk2 aggregate: packet W: 899/900, 1 to R 901/902
    cmd.cmd_02(dev, "\x93\x00\x60\xAE\x09\x00")
    # Generated from packet 903/904
    bulkWrite(0x02, "\x57\x92\x00\x50\x1A\x00\x00\x00")
    # Generated from packet 905/906
    # bulk2 aggregate: packet W: 905/906, 1 to R 907/908
    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("\x93\x00", buff, "packet W: 905/906, R 1 to 907/908")
    # Generated from packet 909/910
    # bulk2 aggregate: packet W: 909/910, 1 to R 913/914
    cmd.cmd_02(dev, "\x94\x00\x80\xAE\x09\x00")
    # Generated from packet 915/916
    # bulk2 aggregate: packet W: 915/916, 1 to R 917/918
    cmd.cmd_57s(dev, "\x93", "\x00\x00")
    # Generated from packet 921/922
    # bulk2 aggregate: packet W: 921/922, 1 to R 923/924
    cmd.led_mask(dev, "pass")
    # Generated from packet 963/964
    # bulk2 aggregate: packet W: 963/964, 1 to R 965/966
    cmd.cmd_49(dev)

    return {'code': code, 'config': config}
Exemple #7
0
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")
Exemple #8
0
def dev_read(dev, cont=False, verbose=False):
    bulkRead, bulkWrite, controlRead, controlWrite = usb_wraps(dev)
    config = {}

    # Generated from packet 2237/2238
    # 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 2237/2238")
    # Generated from packet 2239/2240
    _prefix, buff, _size = cmd.bulk86_next_read(dev)
    validate_read("\x16", buff, "packet 2239/2240")
    # NOTE:: req max 512 but got 136
    # Generated from packet 2245/2246
    # bulk2 aggregate: packet W: 2245/2246, 1 to R 2247/2248
    buff = cmd.bulk2b(dev,
        "\x43\x19\x20\x00\x00\x3B\x7E\x25\x00\x00\xFE\xFF\x3B\x7C\x25\x00" \
        "\x00\xFE\xFF\x00"
        )
    validate_read("\xA4\x06", buff, "packet W: 2245/2246, R 1 to 2247/2248")
    # NOTE:: req max 512 but got 35
    # Generated from packet 2257/2258
    # bulk2 aggregate: packet W: 2257/2258, 1 to R 2259/2260
    buff = cmd.bulk2b(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"
        )
    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: 2257/2258, R 1 to 2259/2260")
    # NOTE:: req max 512 but got 107
    # Generated from packet 2287/2288
    bulkWrite(0x02, "\x43\x19\x20\x00\x00")
    # Generated from packet 2289/2290
    bulkWrite(0x02, "\x20\x01\x00\x0C\x04")
    # Generated from packet 2291/2292
    cmd.cmd_41(dev)
    # Generated from packet 2293/2294
    # bulk2 aggregate: packet W: 2293/2294, 1 to R 2295/2296
    cmd.cmd_10(dev)
    # NOTE:: req max 512 but got 35
    # Generated from packet 2305/2306
    # bulk2 aggregate: packet W: 2305/2306, 1 to R 2307/2308
    cmd.cmd_45(dev)
    # NOTE:: req max 512 but got 103
    # Generated from packet 2309/2310
    # bulk2 aggregate: packet W: 2309/2310, 1 to R 2311/2312
    cmd.cmd_49(dev)
    # NOTE:: req max 512 but got 35
    # Generated from packet 2333/2334
    # bulk2 aggregate: packet W: 2333/2334, 1 to R 2335/2336
    cmd.cmd_49(dev)
    # NOTE:: req max 512 but got 11
    # Generated from packet 2351/2352
    cmd.cmd_3B(dev)
    # Generated from packet 2353/2354
    # bulk2 aggregate: packet W: 2353/2354, 1 to R 2355/2356
    cmd.cmd_4A(dev)
    # NOTE:: req max 512 but got 5
    # Generated from packet 2357/2358
    cmd.cmd_4C(dev)
    # Generated from packet 2359/2360
    buff = controlWrite(0x40, 0xB2, 0x0000, 0x0000, "")
    # Generated from packet 2363/2364
    cmd.cmd_50(dev, "\x45\x00")
    # Generated from packet 2365/2366
    # bulk2 aggregate: packet W: 2365/2366, 1 to R 2367/2368
    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\x66\xB9\x00\x00\xB2\x00\xFB\xFF" \
        "\x25\x44\x11\x00\x00"
        )
    validate_read("\x80\x00", buff, "packet W: 2365/2366, R 1 to 2367/2368")
    # Generated from packet 2371/2372
    # bulk2 aggregate: packet W: 2371/2372, 1 to R 2373/2374
    cmd.cmd_02(dev, "\x81\x00\x50\x00\x09\x00")
    # Generated from packet 2375/2376
    cmd.cmd_50(dev, "\xC0\x00")
    # Generated from packet 2377/2378
    # bulk2 aggregate: packet W: 2377/2378, 1 to R 2381/2382
    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: 2377/2378, R 1 to 2381/2382")
    # Generated from packet 2383/2384
    # bulk2 aggregate: packet W: 2383/2384, 1 to R 2385/2386
    cmd.cmd_02(dev, "\x82\x00\x10\x01\x09\x00")
    # Generated from packet 2387/2388
    bulkWrite(0x02,
        "\x04\x20\x05\x3D\x06\x20\x07\x64\x08\x6F\x09\x63\x0A\x75\x0B\x6D" \
        "\x57\x81\x00"
        )
    # Generated from packet 2393/2394
    # bulk2 aggregate: packet W: 2393/2394, 1 to R 2395/2396
    cmd.cmd_02(dev, "\x82\x00\x10\x01\x09\x00")
    # Generated from packet 2397/2398
    # bulk2 aggregate: packet W: 2397/2398, 1 to R 2399/2402
    cmd.led_mask(dev, "active")
    # Generated from packet 2403/2404
    cmd.cmd_50(dev, "\x18\x00")
    # Generated from packet 2405/2406
    # bulk2 aggregate: packet W: 2405/2406, 1 to R 2407/2408
    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: 2405/2406, R 1 to 2407/2408")
    # Generated from packet 2411/2412
    # bulk2 aggregate: packet W: 2411/2412, 1 to R 2413/2414
    cmd.cmd_02(dev, "\x83\x00\x30\x01\x09\x00")
    # Generated from packet 2415/2416
    # bulk2 aggregate: packet W: 2415/2416, 1 to R 2417/2428
    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: 2415/2416, R 1 to 2417/2428")
    # Generated from packet 2455/2456
    # bulk2 aggregate: packet W: 2455/2456, 1 to R 2457/2458
    buff = cmd.bulk2b(dev, "\x48\x00\x10\x82\x02")
    validate_read("\x82\x00\x10\x01\x09\x00", buff,
                  "packet W: 2455/2456, R 1 to 2457/2458")
    # Generated from packet 2461/2462
    bulkWrite(0x02, "\x20\x01\x00\x50\x7D\x02\x00\x00")
    # Generated from packet 2463/2464
    # bulk2 aggregate: packet W: 2463/2464, 1 to R 2465/2466
    buff = cmd.bulk2b(dev, bpmicro.pic.pic16f84_fw.p651)
    validate_read("\x82\x00", buff, "packet W: 2463/2464, R 1 to 2465/2466")
    # Generated from packet 2467/2468
    # bulk2 aggregate: packet W: 2467/2468, 1 to R 2469/2470
    cmd.cmd_02(dev, "\x83\x00\x90\x03\x09\x00")
    # Generated from packet 2471/2472
    bulkWrite(0x02, "\x57\x82\x00\x50\x1D\x00\x00\x00")
    # Generated from packet 2473/2474
    # bulk2 aggregate: packet W: 2473/2474, 1 to R 2475/2476
    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: 2473/2474, R 1 to 2475/2476")
    # Generated from packet 2477/2478
    # bulk2 aggregate: packet W: 2477/2478, 1 to R 2479/2480
    cmd.cmd_02(dev, "\x84\x00\xB0\x03\x09\x00")
    # Generated from packet 2481/2482
    bulkWrite(0x02, "\x57\x83\x00\x50\x18\x3A\x00\x00")
    # Generated from packet 2483/2484
    # bulk2 aggregate: packet W: 2483/2484, 1 to R 2485/2486
    buff = cmd.bulk2b(dev, bpmicro.pic.pic16f84_fw.p533)
    validate_read("\x84\x00", buff, "packet W: 2483/2484, R 1 to 2485/2486")
    # Generated from packet 2487/2488
    # bulk2 aggregate: packet W: 2487/2488, 1 to R 2489/2490
    cmd.cmd_02(dev, "\x85\x00\xD0\x3D\x09\x00")
    # Generated from packet 2491/2492
    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"
        )
    # Generated from packet 2493/2494
    cmd.cmd_50(dev, "\xDE\x03")
    # Generated from packet 2495/2496
    # bulk2 aggregate: packet W: 2495/2496, 1 to R 2497/2498
    buff = cmd.bulk2b(dev, bpmicro.pic.pic16f84_fw.p555)
    validate_read("\x85\x00", buff, "packet W: 2495/2496, R 1 to 2497/2498")
    # Generated from packet 2499/2500
    # bulk2 aggregate: packet W: 2499/2500, 1 to R 2501/2502
    cmd.cmd_02(dev, "\x86\x00\xB0\x41\x09\x00")

    if cont:
        # Generated from packet 2503/2504
        # bulk2 aggregate: packet W: 2503/2504, 1 to R 2505/2506
        cmd.check_cont(dev)

    # Generated from packet 2507/2508
    cmd.cmd_50(dev, "\x62\x00")
    # Generated from packet 2509/2510
    # bulk2 aggregate: packet W: 2509/2510, 1 to R 2511/2512
    buff = cmd.bulk2b(dev,
        "\x00\x00\x1C\x00\x38\x00\x34\x00\x30\x00\x3D\x00\x39\x00\x35\x00" \
        "\x31\x00\x3E\x00\x00\x00\x36\x00\x32\x00\x3F\x00\x3B\x00\x37\x00" \
        "\x33\x00\x1E\x00\x1A\x00\x16\x00\x12\x00\x02\x00\x06\x00\x0A\x00" \
        "\x0E\x00\x23\x00\x27\x00\x2B\x00\x2F\x00\x22\x00\x26\x00\x00\x00" \
        "\x2E\x00\x21\x00\x25\x00\x29\x00\x2D\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("\x86\x00", buff, "packet W: 2509/2510, R 1 to 2511/2512")
    # Generated from packet 2513/2514
    # bulk2 aggregate: packet W: 2513/2514, 1 to R 2515/2516
    cmd.cmd_02(dev, "\x87\x00\x20\x42\x09\x00")
    # Generated from packet 2517/2518
    bulkWrite(0x02,
        "\x1D\xB0\x41\x09\x00\x28\x00\x15\x60\x00\x02\x00\x00\x00\x00\x00" \
        "\x01\x00\x00\x00\x00\x00\x1C\x30\x00\x00\x02\x00\x00\x40\x00\x48" \
        "\x00\x50\x71\x09\x00\x00"
        )
    # Generated from packet 2519/2520
    # bulk2 aggregate: packet W: 2519/2520, 1 to R 2521/2522
    buff = cmd.bulk2b(dev, bpmicro.pic.pic17c43_fw.p2519)
    validate_read("\x87\x00", buff, "packet W: 2519/2520, R 1 to 2521/2522")
    # Generated from packet 2523/2524
    # bulk2 aggregate: packet W: 2523/2524, 1 to R 2525/2526
    cmd.cmd_02(dev, "\x88\x00\xA0\x4B\x09\x00")
    # Generated from packet 2527/2528
    # bulk2 aggregate: packet W: 2527/2528, 1 to R 2529/2530
    cmd.cmd_57s(dev, "\x87", "\x00\x00")
    # Generated from packet 2531/2532
    cmd.cmd_50(dev, "\x17\x00")
    # Generated from packet 2533/2534
    # bulk2 aggregate: packet W: 2533/2534, 1 to R 2535/2536
    buff = cmd.bulk2b(dev,
        "\xC7\x05\x2C\x00\x09\x00\x24\x04\x00\x00\x66\xB9\x00\x00\xB2\x00" \
        "\xFB\xFF\x25\x44\x11\x00\x00"
        )
    validate_read("\x88\x00", buff, "packet W: 2533/2534, R 1 to 2535/2536")
    # Generated from packet 2537/2538
    # bulk2 aggregate: packet W: 2537/2538, 1 to R 2539/2540
    cmd.cmd_02(dev, "\x89\x00\xC0\x4B\x09\x00")
    # Generated from packet 2543/2544
    bulkWrite(0x02, "\x57\x88\x00\x50\x18\x00\x00\x00")
    # Generated from packet 2545/2546
    # bulk2 aggregate: packet W: 2545/2546, 1 to R 2547/2548
    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("\x89\x00", buff, "packet W: 2545/2546, R 1 to 2547/2548")
    # Generated from packet 2549/2550
    # bulk2 aggregate: packet W: 2549/2550, 1 to R 2551/2552
    cmd.cmd_02(dev, "\x8A\x00\xE0\x4B\x09\x00")
    # Generated from packet 2553/2554
    bulkWrite(0x02, "\x57\x89\x00\x50\x04\x0A\x00\x00")
    # Generated from packet 2555/2556
    # bulk2 aggregate: packet W: 2555/2556, 1 to R 2557/2558
    buff = cmd.bulk2b(dev, bpmicro.pic.pic17c43_fw.p2555)
    validate_read("\x8A\x00", buff, "packet W: 2555/2556, R 1 to 2557/2558")
    # Generated from packet 2559/2560
    # bulk2 aggregate: packet W: 2559/2560, 1 to R 2561/2562
    cmd.cmd_02(dev, "\x8B\x00\xF0\x55\x09\x00")
    # Generated from packet 2563/2564
    # bulk2 aggregate: packet W: 2563/2564, 1 to R 2565/2566
    cmd.cmd_57s(dev, "\x8A", "\x00\x00")
    # Generated from packet 2567/2568
    cmd.cmd_50(dev, "\xBE\x03")
    # Generated from packet 2569/2570
    # bulk2 aggregate: packet W: 2569/2570, 1 to R 2571/2572
    buff = cmd.bulk2b(dev, bpmicro.pic.pic17c43_fw.p2569)
    validate_read("\x8B\x00", buff, "packet W: 2569/2570, R 1 to 2571/2572")
    # Generated from packet 2573/2574
    # bulk2 aggregate: packet W: 2573/2574, 1 to R 2575/2576
    cmd.cmd_02(dev, "\x8C\x00\xB0\x59\x09\x00")

    # Generated from packet 2577/2578
    # bulk2 aggregate: packet W: 2577/2578, 1 to R 2581/2582
    buff = cmd.bulk2b(dev, "\x08\x01\x57\x8B\x00")
    #validate_read("\x00\x00", buff, "packet W: 2577/2578, R 1 to 2581/2582")
    config['secure'] = buff != '\x00\x00'

    # Generated from packet 2583/2584
    cmd.cmd_50(dev, "\x1B\x04")
    # Generated from packet 2585/2586
    # bulk2 aggregate: packet W: 2585/2586, 1 to R 2587/2588
    buff = cmd.bulk2b(dev, bpmicro.pic.pic17c43_fw.p2585)
    validate_read("\x8C\x00", buff, "packet W: 2585/2586, R 1 to 2587/2588")
    # Generated from packet 2589/2590
    # bulk2 aggregate: packet W: 2589/2590, 1 to R 2591/2592
    cmd.cmd_02(dev, "\x8D\x00\xD0\x5D\x09\x00")
    # Generated from packet 2593/2594
    # bulk2 aggregate: packet W: 2593/2594, 1 to R 2597/2600
    cmd.cmd_57s(dev, "\x8C", "\x00\x00")
    # Generated from packet 2603/2604
    # bulk2 aggregate: packet W: 2603/2604, 1 to R 2605/2606
    cmd.cmd_57s(dev, "\x89\x8A", "\x00\x00")
    # Generated from packet 2609/2610
    cmd.cmd_50(dev, "\x12\x03")
    # Generated from packet 2611/2612
    # bulk2 aggregate: packet W: 2611/2612, 1 to R 2613/2614
    buff = cmd.bulk2b(dev, bpmicro.pic.pic17c43_fw.p2611)
    validate_read("\x8D\x00", buff, "packet W: 2611/2612, R 1 to 2613/2614")
    # Generated from packet 2617/2618
    # bulk2 aggregate: packet W: 2617/2618, 1 to R 2619/2620
    cmd.cmd_02(dev, "\x8E\x00\xF0\x60\x09\x00")
    # Generated from packet 2621/2622
    # bulk2 aggregate: packet W: 2621/2622, 17 to R 2681/2682
    main_read = cmd.bulk2b(dev,
        "\x04\x00\x05\x00\x06\x00\x07\x00\x08\x00\x09\x10\x0A\x00\x0B\x00" \
        "\x57\x8D\x00"
        )
    #validate_read(bpmicro.pic.pic17c43_fw.p2681, buff, "packet W: 2621/2622, R 17 to 2681/2682")
    # Generated from packet 2683/2684
    cmd.cmd_50(dev, "\x5E\x00")
    # Generated from packet 2685/2686
    # bulk2 aggregate: packet W: 2685/2686, 1 to R 2687/2688
    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\x01\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("\x8E\x00", buff, "packet W: 2685/2686, R 1 to 2687/2688")
    # Generated from packet 2689/2690
    # bulk2 aggregate: packet W: 2689/2690, 1 to R 2691/2692
    cmd.cmd_02(dev, "\x8F\x00\x50\x61\x09\x00")
    # Generated from packet 2693/2694
    # bulk2 aggregate: packet W: 2693/2694, 1 to R 2695/2696
    cmd.cmd_57s(dev, "\x8E", "\x00\x00")
    # Generated from packet 2697/2698
    cmd.cmd_50(dev, "\x96\x06")
    # Generated from packet 2699/2700
    # bulk2 aggregate: packet W: 2699/2700, 1 to R 2701/2702
    buff = cmd.bulk2b(dev, bpmicro.pic.pic17c43_fw.p2699)
    validate_read("\x8F\x00", buff, "packet W: 2699/2700, R 1 to 2701/2702")
    # Generated from packet 2703/2704
    # bulk2 aggregate: packet W: 2703/2704, 1 to R 2705/2706
    cmd.cmd_02(dev, "\x90\x00\xF0\x67\x09\x00")
    # Generated from packet 2707/2708
    # bulk2 aggregate: packet W: 2707/2708, 1 to R 2709/2710
    cmd.cmd_57s(dev, "\x8F", "\x00\x00")
    # Generated from packet 2711/2712
    cmd.cmd_50(dev, "\x92\x00")
    # Generated from packet 2713/2714
    # bulk2 aggregate: packet W: 2713/2714, 1 to R 2715/2716
    buff = cmd.bulk2b(dev,
        "\xE9\x03\x00\x00\x00\x90\x00\x00\x66\xC7\x05\xF6\x67\x09\x00\x00" \
        "\x00\x66\x8B\x05\xF6\x67\x09\x00\x81\xE0\xFF\xFF\x00\x00\xFF\xF0" \
        "\xB8\x01\x00\x00\x00\x59\x39\xC8\x0F\x86\x57\x00\x00\x00\x66\x8B" \
        "\x1D\xF6\x67\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\x67\x09\x00\x66\xFF\x05\xF6" \
        "\x67\x09\x00\xEB\x8C\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11" \
        "\x00\x00"
        )
    validate_read("\x90\x00", buff, "packet W: 2713/2714, R 1 to 2715/2716")
    # Generated from packet 2717/2718
    # bulk2 aggregate: packet W: 2717/2718, 1 to R 2719/2720
    cmd.cmd_02(dev, "\x91\x00\x90\x68\x09\x00")

    # Generated from packet 2721/2722
    # bulk2 aggregate: packet W: 2721/2722, 1 to R 2723/2724
    # Orig: "\xFF\xFF"
    buff = cmd.cmd_57s(dev, "\x90", None)

    def unpackw(buff):
        struct.unpack('<H', buff)[0]

    if verbose:
        print('2721/2722: %s' % binascii.hexlify(buff))

    # FIXME: confirm
    config['conf_word'] = unpackw(buff)

    # Generated from packet 2725/2726
    # bulk2 aggregate: packet W: 2725/2726, 1 to R 2727/2728
    cmd.cmd_57s(dev, "\x8C", "\x00\x00")

    # Generated from packet 2729/2730
    cmd.cmd_50(dev, "\x0D\x00")
    # Generated from packet 2731/2732
    # bulk2 aggregate: packet W: 2731/2732, 1 to R 2733/2734
    buff = cmd.bulk2b(dev,
                      "\x66\xB9\x00\x00\xB2\x00\xFB\xFF\x25\x44\x11\x00\x00")
    validate_read("\x91\x00", buff, "packet W: 2731/2732, R 1 to 2733/2734")
    # Generated from packet 2735/2736
    # bulk2 aggregate: packet W: 2735/2736, 1 to R 2737/2738
    cmd.cmd_02(dev, "\x92\x00\xA0\x68\x09\x00")
    # Generated from packet 2739/2740
    bulkWrite(0x02, "\x57\x91\x00\x50\x1A\x00\x00\x00")
    # Generated from packet 2741/2742
    # bulk2 aggregate: packet W: 2741/2742, 1 to R 2743/2744
    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("\x92\x00", buff, "packet W: 2741/2742, R 1 to 2743/2744")
    # Generated from packet 2745/2746
    # bulk2 aggregate: packet W: 2745/2746, 1 to R 2747/2748
    cmd.cmd_02(dev, "\x93\x00\xC0\x68\x09\x00")
    # Generated from packet 2749/2750
    # bulk2 aggregate: packet W: 2749/2750, 1 to R 2751/2752
    cmd.cmd_57s(dev, "\x92", "\x00\x00")
    # Generated from packet 2753/2754
    # bulk2 aggregate: packet W: 2753/2754, 1 to R 2755/2756
    cmd.led_mask(dev, "pass")
    # Generated from packet 2777/2778
    # bulk2 aggregate: packet W: 2777/2778, 1 to R 2779/2780
    cmd.cmd_49(dev)

    # Is it the full area or just the first half?
    # Ambiguous word vs byte
    # looks like upper memory has misc internal chip data
    # Fairly certain we just want this
    code = main_read[0:4 * 1024]
    #code = main_read
    fuses_buff = main_read[0x1FF0:0x2000]

    def fuse_unpack(buff, i):
        return struct.unpack('<H', buff[2 * i:2 * i + 2])[0]

    for i in range(0, 4):
        config['user_id%d' % i] = fuse_unpack(fuses_buff, i)

    return {'code': code, 'config': config}