|
11 | 11 | from m1n1.hw.dockchannel import DockChannel |
12 | 12 | from m1n1.fw.smc import SMCClient, SMCError |
13 | 13 | from m1n1.shell import run_shell |
| 14 | +from m1n1.fw.mtp import * |
14 | 15 |
|
15 | 16 | from construct import * |
16 | 17 |
|
| 18 | +mon = RegMonitor(u) |
| 19 | + |
| 20 | +#mon.add(0x23b700000, 0x10000) |
| 21 | +mon.add(0x23d28c000, 0x4000) |
| 22 | +mon.poll() |
| 23 | +mon.poll() |
| 24 | +mon.poll() |
| 25 | +mon.add(0x24e400000, 0x4000) |
| 26 | +mon.add(0x24e808000, 0x14000) |
| 27 | + |
| 28 | +smc_addr = u.adt["arm-io/smc"].get_reg(0)[0] |
| 29 | +smc = SMCClient(u, smc_addr) |
| 30 | +smc.start() |
| 31 | +smc.start_ep(0x20) |
| 32 | +smc.verbose = 0 |
| 33 | + |
17 | 34 | p.dapf_init_all() |
18 | 35 |
|
19 | 36 | dart = DART8110.from_adt(u, "/arm-io/dart-mtp", iova_range=(0x8000, 0x100000)) |
20 | 37 |
|
21 | 38 | dart.regs.TCR[1].set(BYPASS_DAPF=0, BYPASS_DART=0, TRANSLATE_ENABLE=1) |
22 | 39 |
|
23 | | -mtp_addr = u.adt["/arm-io/mtp"].get_reg(0)[0] |
24 | | -mtp = StandardASC(u, mtp_addr, dart, stream=1) |
25 | | -mtp.verbose = 3 |
26 | | -mtp.allow_phys = True |
27 | | -mtp.start() |
28 | | - |
29 | 40 | irq_base = u.adt["/arm-io/dockchannel-mtp"].get_reg(1)[0] |
30 | 41 | fifo_base = u.adt["/arm-io/dockchannel-mtp"].get_reg(2)[0] |
31 | 42 | dc = DockChannel(u, irq_base, fifo_base, 1) |
32 | 43 |
|
33 | | -for i in range(128): |
34 | | - mtp.work() |
| 44 | +node = u.adt["/arm-io/dockchannel-mtp/mtp-transport"] |
35 | 45 |
|
36 | | -dc.write(bytes.fromhex("08110c00010000008000020000000000b4010000c2ecf1ff")) |
37 | | -dc.write(bytes.fromhex("08110c00020000008000020000000000b4020000c1ebf1ff")) |
| 46 | +while dc.rx_count: |
| 47 | + dc.read(dc.rx_count) |
| 48 | + |
| 49 | +mtp_addr = u.adt["/arm-io/mtp"].get_reg(0)[0] |
| 50 | +mtp = StandardASC(u, mtp_addr, dart, stream=1) |
| 51 | +mtp.allow_phys = True |
| 52 | +print("pre start") |
| 53 | +mon.poll() |
| 54 | +mtp.start() |
| 55 | +print("started") |
| 56 | +mon.poll() |
| 57 | +print("ok") |
38 | 58 |
|
39 | 59 | def poll(): |
40 | | - v = dc.read_all() |
41 | | - if v: |
42 | | - chexdump(v) |
43 | 60 | mtp.work() |
| 61 | + mp.work_pending() |
| 62 | + |
| 63 | +# 0x40: device reset |
| 64 | +# 0x42: |
| 65 | + |
| 66 | +# 0 -> mbox? |
| 67 | +# 2 -> dapf? |
| 68 | +# 3 -> dart? |
| 69 | +# 3 -> dockchannel? |
| 70 | +# 5 -> mbox? |
| 71 | +def reset(i): |
| 72 | + reg = 0x23d28c000 + i*8 |
| 73 | + p.set32(reg, 1<<10) |
| 74 | + p.set32(reg, 1<<31) |
| 75 | + p.clear32(reg, 1<<31) |
| 76 | + p.clear32(reg, 1<<10) |
| 77 | + |
| 78 | +try: |
| 79 | + |
| 80 | + mp = MTPProtocol(u, node, mtp, dc, smc) |
| 81 | + |
| 82 | + mp.wait_init("keyboard") |
| 83 | + mp.wait_init("multi_touch") |
| 84 | + |
| 85 | + mtp.stop() |
| 86 | + mtp.start() |
| 87 | + mon.poll() |
| 88 | + |
| 89 | + #for i in range(256): |
| 90 | + #if i in (0x40, 0x42): |
| 91 | + #continue |
| 92 | + #m = UnkDeviceControlMsg() |
| 93 | + #m.command = i |
| 94 | + #for args in (b"", b"\x00", b"\x01", b"\x02", |
| 95 | + #b"\x01\x00", b"\x01\x01", b"\x01\x02", |
| 96 | + #b"\x00\x01", b"\x00\x02", b"\x00\x00", |
| 97 | + #b"\x00\x00\x00", |
| 98 | + #b"\x00\x00\x00\x00", |
| 99 | + #b"\x00\x00\x00\x00\x00", |
| 100 | + #b"\x00\x00\x00\x00\x00\x00", |
| 101 | + #b"\x00\x00\x00\x00\x00\x00\x00", |
| 102 | + #b"\x00\x00\x00\x00\x00\x00\x00\x00",): |
| 103 | + #m.args = args |
| 104 | + #print(f"{m.command:#x} {m.args.hex()}") |
| 105 | + #mp.comm.device_control(m) |
| 106 | + |
| 107 | + mon.poll() |
| 108 | + mtp.stop() |
| 109 | + mon.poll() |
| 110 | + mtp.start() |
| 111 | + |
| 112 | + mon.poll() |
| 113 | + mtp.stop(1) |
| 114 | + #reset(1) |
| 115 | + #p.dapf_init_all() |
| 116 | + |
| 117 | + #mtp.boot() |
44 | 118 |
|
45 | | -mtp.stop() |
| 119 | + run_shell(locals(), poll_func=poll) |
46 | 120 |
|
47 | | -#run_shell(locals(), poll_func=poll) |
| 121 | +finally: |
| 122 | + #mtp.stop() |
| 123 | + p.reboot() |
0 commit comments