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