mirror of
https://github.com/AsahiLinux/m1n1
synced 2024-11-14 19:27:06 +00:00
81aaf2ed35
Signed-off-by: Hector Martin <marcan@marcan.st>
35 lines
777 B
Python
35 lines
777 B
Python
#!/usr/bin/python
|
|
|
|
import serial, os, struct, sys, time
|
|
from proxy import *
|
|
from tgtypes import *
|
|
|
|
uartdev = os.environ.get("M1N1DEVICE", "/dev/ttyUSB0")
|
|
usbuart = serial.Serial(uartdev, 115200)
|
|
|
|
iface = UartInterface(usbuart, debug=False)
|
|
proxy = M1N1Proxy(iface, debug=False)
|
|
|
|
proxy.set_baud(1500000)
|
|
|
|
payload = open(sys.argv[1], "rb").read()
|
|
|
|
base = proxy.get_base()
|
|
ba_addr = proxy.get_bootargs()
|
|
|
|
ba = iface.readstruct(ba_addr, BootArgs)
|
|
|
|
new_base = base + ((ba.top_of_kernel_data + 0xffff) & ~0xffff) - ba.phys_base
|
|
|
|
print("Loading %d bytes to 0x%x" % (len(payload), new_base))
|
|
|
|
iface.writemem(new_base + 0x4000, payload[0x4000:], True)
|
|
|
|
entry = new_base + 0x4800
|
|
|
|
print("Jumping to 0x%x" % entry)
|
|
|
|
proxy.vector(entry, ba_addr)
|
|
|
|
iface.nop()
|
|
print("Proxy is alive again")
|