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
|
revision.h
|
||||||
*.fat
|
*.fat
|
||||||
__pycache__
|
__pycache__
|
||||||
revision.h+
|
|
||||||
*~
|
|
||||||
*.s
|
|
||||||
oops.txt
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/ipython3 --profile=armlib
|
#!/usr/bin/ipython --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=",
|
||||||
"serialr=", "serial=","isp=","reset-port=",
|
"serial=","isp=","reset-port=",
|
||||||
"none"]+long_options)
|
"none"]+long_options)
|
||||||
_opt = (oo,ff)
|
_opt = (oo,ff)
|
||||||
autostart = None
|
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 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 --serialr --isp --reset-port":
|
if o in "-S --serial --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,20 +29,6 @@ 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:
|
||||||
|
|
|
||||||
16
oops.py
16
oops.py
|
|
@ -1,4 +1,4 @@
|
||||||
#! /usr/bin/python3
|
#! /usr/bin/pythom
|
||||||
|
|
||||||
|
|
||||||
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 = f"0x{addr:08x} "
|
r = "0x%08x " % addr
|
||||||
if s:
|
if s:
|
||||||
if isinstance(s, tuple):
|
if isinstance(s, tuple):
|
||||||
r += f"{s[1]} {s[0]}:"
|
r += "%s %s:" % (s[1],s[0])
|
||||||
else:
|
else:
|
||||||
r += "{s} "
|
r += "%s " % s
|
||||||
if m:
|
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'
|
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] != b"@0x" or ll[0][-1:]!=b":":
|
if ll[0][:3] != "@0x" or ll[0][-1]!=":":
|
||||||
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 += f"@0x{a:08x} "
|
r += "@0x%08x " % a
|
||||||
a += 4
|
a += 4
|
||||||
aaa = int(aa,16)
|
aaa = int(aa,16)
|
||||||
if aaa==self.stack_guard:
|
if aaa==self.stack_guard:
|
||||||
r += f"0x{aaa:08x} Stack guard\n"
|
r += "0x%08x Stack guard\n" % aaa
|
||||||
else:
|
else:
|
||||||
r += self.report_addr(aaa)
|
r += self.report_addr(aaa)
|
||||||
self.f.write(r)
|
self.f.write(r)
|
||||||
|
|
|
||||||
|
|
@ -177,14 +177,12 @@ 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)
|
||||||
|
|
@ -192,11 +190,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", timeout)
|
m = self.wait_for_message(b"USB set address")
|
||||||
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", timeout)
|
self.wait_for_message(b"USB set configuration")
|
||||||
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
|
||||||
|
|
||||||
|
|
@ -883,9 +881,6 @@ 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')
|
||||||
|
|
|
||||||
16
usbterm.py
16
usbterm.py
|
|
@ -320,17 +320,12 @@ 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)
|
||||||
armlib._ifc_uart.wait_for_usb(timeout=30);
|
time.sleep(10)
|
||||||
return True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.stderr.write("Reset_ARM %s\n" % repr(e))
|
sys.stderr.write("%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)
|
||||||
|
|
@ -512,11 +507,6 @@ 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