diff --git a/ShofEL2-for-T124/payloads/payload.c b/ShofEL2-for-T124/payloads/payload.c index 191b8c1..51e4e61 100644 --- a/ShofEL2-for-T124/payloads/payload.c +++ b/ShofEL2-for-T124/payloads/payload.c @@ -35,7 +35,7 @@ void payload_main() { usb_log("cmd_handler", &error_code); while(1){ usb_read(&data, 4, &error_code); - if(data[0] == 'M' && data[1] == 'E' && data[2] == 'M' && data[3] == 'D') { + if(data[0] == 'P' && data[1] == 'E' && data[2] == 'E' && data[3] == 'K') { usb_write(&data, 4, &error_code); usb_read(&data, 8,&error_code); // Receive uint64_t size and and uint32_t offset mem_off = *(uint32_t *)data; @@ -53,6 +53,27 @@ void payload_main() { } } } + else if(data[0] == 'P' && data[1] == 'O' && data[2] == 'K' && data[3] == 'E') { + usb_write(&data, 4, &error_code); + usb_read(&data, 8, &error_code); // Receive uint64_t size and and uint32_t offset + mem_off = *(uint32_t *)data; + mem_sz = *(uint32_t *)(data+4); + + for(unsigned int i=0;i 0: + remaining = 0x200 + if(len(data) < 0x200): + remaining = len(data) + send = data[:remaining] + data = data[remaining:] + self.dev.write(send) + message = self.dev.read(0x200) + if(message != b"OK"): + error("Error on writing data to device!") + return + self.dev.write(b"ACK\x00") + self.handle_done() + #Read back data + if(check): + after = self.memdump_region(address, size) + if(after == before and send != before): + error(f"Memory written succesfully, but no changes detected! | {hex(address)}") def search_bootrom(self): dumped = BytesIO() @@ -244,7 +282,7 @@ class TegraRCM(): if(cpsr_to_r0_ins in d or r1_to_cpsr in d): info(f"Found cpsr instruction at {hex(i)}") print(".", end="") - info(f"dumped {hex(len(dumped))} data") + # info(f"dumped {hex(len(dumped))} data") def dump_bootrom(self): d = self.memdump_region(0x100000, 0x1000) @@ -255,6 +293,7 @@ class TegraRCM(): while True: cmd = self.dev.read(0x200) if(cmd == b"cmd_handler"): + self.memwrite_region(0x40000000, 0x100 * b"\xaa") self.search_bootrom() #dump memory self.dump_bootrom() @@ -263,9 +302,16 @@ class TegraRCM(): if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("payload", help="Payload to send to the tablet") + parser.add_argument("--ga", help="Prepare for GA", action="store_true") args = parser.parse_args() rcm = TegraRCM() rcm.dev.read_chip_id() rcm.send_payload(args.payload) - rcm.cmd_handler() \ No newline at end of file + if args.ga: + d = rcm.dev.read(4) + d2 = rcm.dev.read(0x200) + if d == b"GiAs": + ok("Device in GA debugger") + else: + rcm.cmd_handler() \ No newline at end of file diff --git a/imem_ref0_t124.bin b/imem_ref0_t124.bin new file mode 100644 index 0000000..bc3ae5b Binary files /dev/null and b/imem_ref0_t124.bin differ