Compare commits
8 commits
89aacc5041
...
f8eba63cf0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8eba63cf0 | ||
|
|
026ff1956c | ||
|
|
c1f6282116 | ||
|
|
e21db04aad | ||
|
|
89b991b296 | ||
|
|
5100364de0 | ||
|
|
a6a3d5a54c | ||
|
|
3a7d3337f7 |
6 changed files with 54 additions and 18 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -6,3 +6,7 @@ irena.rom*
|
||||||
revision.h
|
revision.h
|
||||||
*.fat
|
*.fat
|
||||||
__pycache__
|
__pycache__
|
||||||
|
revision.h+
|
||||||
|
*~
|
||||||
|
*.s
|
||||||
|
oops.txt
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/ipython --profile=armlib
|
#!/usr/bin/ipython3 --profile=armlib
|
||||||
|
|
||||||
import sys, time, threading
|
import sys, time, threading
|
||||||
|
|
||||||
|
|
@ -604,7 +604,7 @@ def init_irena(scope, name="xRENA", prod=None, options="", long_options=[]):
|
||||||
oo,ff = getopt.getopt(sys.argv[1:],
|
oo,ff = getopt.getopt(sys.argv[1:],
|
||||||
"A:U:N:S:X"+options,
|
"A:U:N:S:X"+options,
|
||||||
["autostart=","network=","usb=",
|
["autostart=","network=","usb=",
|
||||||
"serial=","isp=","reset-port=",
|
"serialr=", "serial=","isp=","reset-port=",
|
||||||
"none"]+long_options)
|
"none"]+long_options)
|
||||||
_opt = (oo,ff)
|
_opt = (oo,ff)
|
||||||
autostart = None
|
autostart = None
|
||||||
|
|
@ -620,10 +620,13 @@ def init_irena(scope, name="xRENA", prod=None, options="", long_options=[]):
|
||||||
if o in "-N -U -S -X --network --usb --serial --isp --none":
|
if o in "-N -U -S -X --network --usb --serial --isp --none":
|
||||||
if _ifc:
|
if _ifc:
|
||||||
raise ValueError("multiple interface options -N -U -S -X")
|
raise ValueError("multiple interface options -N -U -S -X")
|
||||||
if o in "-S --serial --isp --reset-port":
|
if o in "-S --serialr --isp --reset-port":
|
||||||
if _ifc_uart:
|
if _ifc_uart:
|
||||||
raise ValueError("--reset-port with --serial")
|
raise ValueError("--reset-port with --serial")
|
||||||
import uartterm
|
import uartterm
|
||||||
|
if o == "--serialr":
|
||||||
|
uartterm.uart.RESET_ASSERT=False
|
||||||
|
uartterm.uart.RESET_DEASSERT=True
|
||||||
if not o=="--reset-port":
|
if not o=="--reset-port":
|
||||||
_ifc_uart = uartterm.init_uart(scope=scope, dname=name, addr=v, isp=o=="--isp")
|
_ifc_uart = uartterm.init_uart(scope=scope, dname=name, addr=v, isp=o=="--isp")
|
||||||
_ifc = _ifc_uart
|
_ifc = _ifc_uart
|
||||||
|
|
|
||||||
14
nm64.py
14
nm64.py
|
|
@ -29,6 +29,20 @@ class NM64Thread(usbterm.DataThread):
|
||||||
def Restart(self):
|
def Restart(self):
|
||||||
start_nm64()
|
start_nm64()
|
||||||
|
|
||||||
|
def Reboot(self, status):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
sys.stderr.write(f"\nRebooting for reason {repr(status)}\n")
|
||||||
|
self.Reset()
|
||||||
|
findnmrena()
|
||||||
|
if self.ifc.connected_p():
|
||||||
|
self.Restart()
|
||||||
|
self.ifc.cmd("e/i \"%s\"" % repr(status)[:50])
|
||||||
|
break;
|
||||||
|
time.sleep(1)
|
||||||
|
except Exception as e:
|
||||||
|
sys.stderr.write(f"Reboot {repr(e)}\n")
|
||||||
|
|
||||||
def StartNM(filename=None):
|
def StartNM(filename=None):
|
||||||
disable()
|
disable()
|
||||||
if not filename:
|
if not filename:
|
||||||
|
|
|
||||||
18
oops.py
18
oops.py
|
|
@ -1,4 +1,4 @@
|
||||||
#! /usr/bin/pythom
|
#! /usr/bin/python3
|
||||||
|
|
||||||
|
|
||||||
class oops(object):
|
class oops(object):
|
||||||
|
|
@ -102,14 +102,14 @@ class oops(object):
|
||||||
|
|
||||||
def report_addr(self, addr):
|
def report_addr(self, addr):
|
||||||
m,s = self.find_addr(addr)
|
m,s = self.find_addr(addr)
|
||||||
r = "0x%08x " % addr
|
r = f"0x{addr:08x} "
|
||||||
if s:
|
if s:
|
||||||
if isinstance(s, tuple):
|
if isinstance(s, tuple):
|
||||||
r += "%s %s:" % (s[1],s[0])
|
r += f"{s[1]} {s[0]}:"
|
||||||
else:
|
else:
|
||||||
r += "%s " % s
|
r += "{s} "
|
||||||
if m:
|
if m:
|
||||||
r += "%s + 0x%04x" % (m, addr - self.map[m]["addr"])
|
r += f"{m} + 0x{addr - self.map[m]['addr']:04x}"
|
||||||
return r+'\n'
|
return r+'\n'
|
||||||
|
|
||||||
def open(self, filename="oops.txt"):
|
def open(self, filename="oops.txt"):
|
||||||
|
|
@ -119,17 +119,17 @@ class oops(object):
|
||||||
|
|
||||||
def stackdump(self, l):
|
def stackdump(self, l):
|
||||||
ll = l.split()
|
ll = l.split()
|
||||||
if ll[0][:3] != "@0x" or ll[0][-1]!=":":
|
if ll[0][:3] != b"@0x" or ll[0][-1:]!=b":":
|
||||||
return ""
|
return ""
|
||||||
a = int(ll[0][1:-1], 16)
|
a = int(ll[0][1:-1], 16)
|
||||||
import time
|
import time
|
||||||
r = time.strftime("Stackdump at %Y-%m-%dT%H:%M:%SZ:\n", time.gmtime())
|
r = time.strftime("Stackdump at %Y-%m-%dT%H:%M:%SZ:\n", time.gmtime())
|
||||||
for aa in ll[1:]:
|
for aa in ll[1:]:
|
||||||
r += "@0x%08x " % a
|
r += f"@0x{a:08x} "
|
||||||
a += 4
|
a += 4
|
||||||
aaa = int(aa,16)
|
aaa = int(aa, 16)
|
||||||
if aaa==self.stack_guard:
|
if aaa==self.stack_guard:
|
||||||
r += "0x%08x Stack guard\n" % aaa
|
r += f"0x{aaa:08x} Stack guard\n"
|
||||||
else:
|
else:
|
||||||
r += self.report_addr(aaa)
|
r += self.report_addr(aaa)
|
||||||
self.f.write(r)
|
self.f.write(r)
|
||||||
|
|
|
||||||
|
|
@ -177,12 +177,14 @@ class uart(threading.Thread):
|
||||||
self.send_fct()
|
self.send_fct()
|
||||||
|
|
||||||
def wait_for_message(self, mes, timeout=10):
|
def wait_for_message(self, mes, timeout=10):
|
||||||
|
self._log(f"waiting for {repr(mes)}\n")
|
||||||
t = time.time()
|
t = time.time()
|
||||||
until = t+timeout
|
until = t+timeout
|
||||||
while t < until:
|
while t < until:
|
||||||
self.parse()
|
self.parse()
|
||||||
for m in self.infos:
|
for m in self.infos:
|
||||||
if mes in m:
|
if mes in m:
|
||||||
|
self._log(f"got {repr(m)} after {until-t}s\n")
|
||||||
return m
|
return m
|
||||||
with self.resp_ready:
|
with self.resp_ready:
|
||||||
self.resp_ready.wait(until - t + 0.1)
|
self.resp_ready.wait(until - t + 0.1)
|
||||||
|
|
@ -190,11 +192,11 @@ class uart(threading.Thread):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def wait_for_usb(self, timeout=10):
|
def wait_for_usb(self, timeout=10):
|
||||||
m = self.wait_for_message(b"USB set address")
|
m = self.wait_for_message(b"USB set address", timeout)
|
||||||
if not m:
|
if not m:
|
||||||
return 0
|
return 0
|
||||||
a = int(m.split()[-1])
|
a = int(m.split()[-1])
|
||||||
self.wait_for_message(b"USB set configuration")
|
self.wait_for_message(b"USB set configuration", timeout)
|
||||||
self._log(f"got USB address {a} from serial message\n")
|
self._log(f"got USB address {a} from serial message\n")
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
|
@ -881,6 +883,9 @@ class irena_uart(irena_ifc):
|
||||||
|
|
||||||
_CMDN = 1 # skip the first response character
|
_CMDN = 1 # skip the first response character
|
||||||
|
|
||||||
|
def arm_reset(self):
|
||||||
|
self.uart.Reset_ARM()
|
||||||
|
|
||||||
def cmd(self, c, timeout=10000):
|
def cmd(self, c, timeout=10000):
|
||||||
self._data.flush_responses()
|
self._data.flush_responses()
|
||||||
self._data.serial.write(utf8_encode(c).strip()+b'\n')
|
self._data.serial.write(utf8_encode(c).strip()+b'\n')
|
||||||
|
|
|
||||||
18
usbterm.py
18
usbterm.py
|
|
@ -320,13 +320,18 @@ class DataThread(DumpThread):
|
||||||
if armlib._ifc_uart:
|
if armlib._ifc_uart:
|
||||||
try:
|
try:
|
||||||
armlib.Reset_ARM()
|
armlib.Reset_ARM()
|
||||||
s=1
|
|
||||||
sys.stderr.write("Sent reset via %s\n" % armlib._ifc_uart.uart.serial.port)
|
sys.stderr.write("Sent reset via %s\n" % armlib._ifc_uart.uart.serial.port)
|
||||||
time.sleep(10)
|
armlib._ifc_uart.wait_for_usb(timeout=30);
|
||||||
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.stderr.write("%s\n" % repr(e))
|
sys.stderr.write("Reset_ARM %s\n" % repr(e))
|
||||||
|
try:
|
||||||
|
self.ifc.arm_reset()
|
||||||
|
sleep(30)
|
||||||
return True
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
sys.stderr.write("arm_reset %s\n" % repr(e))
|
||||||
|
|
||||||
def Reboot(self, status):
|
def Reboot(self, status):
|
||||||
sys.stderr.write("\nRebooting the %s\n" % self.name)
|
sys.stderr.write("\nRebooting the %s\n" % self.name)
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -507,6 +512,11 @@ class irena_usb(irena_ifc):
|
||||||
|
|
||||||
_CMDN = 1
|
_CMDN = 1
|
||||||
|
|
||||||
|
def arm_reset(self, m=b'arm/reset/usb'):
|
||||||
|
self._log(f"sending: {repr(m)}\n")
|
||||||
|
self._h.bulkWrite(2, m, 10000)
|
||||||
|
self._h = None
|
||||||
|
|
||||||
def ucmd(self, c, timeout=10000, raise_e=True):
|
def ucmd(self, c, timeout=10000, raise_e=True):
|
||||||
if self.verbosity>2:
|
if self.verbosity>2:
|
||||||
self._log("send: %s\n" % (c.strip()))
|
self._log("send: %s\n" % (c.strip()))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue