mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
update tools to work with a debug-less SoC
it will automatically determine which reset/halt approach should be used based on the available registers.
This commit is contained in:
parent
fb3dabbd5d
commit
e8275d4009
4 changed files with 42 additions and 13 deletions
|
|
@ -734,9 +734,8 @@ def main():
|
|||
|
||||
print("\nPhase 2: Apply the update")
|
||||
print("Halting CPU for update.")
|
||||
vexdbg_addr = int(pc_usb.regions['vexriscv_debug'][0], 0)
|
||||
pc_usb.ping_wdt()
|
||||
pc_usb.poke(vexdbg_addr, 0x00020000)
|
||||
pc_usb.halt()
|
||||
for work in worklist:
|
||||
|
||||
retry_usb = False
|
||||
|
|
@ -750,9 +749,8 @@ def main():
|
|||
print("Abort by user request!\n\nSystem may not be bootable, but you can retry an update as long as you do not power-off or hard-reset the device.")
|
||||
exit(0)
|
||||
|
||||
vexdbg_addr = int(pc_usb.regions['vexriscv_debug'][0], 0)
|
||||
pc_usb.ping_wdt()
|
||||
pc_usb.poke(vexdbg_addr, 0x00020000)
|
||||
pc_usb.halt()
|
||||
retry_usb = False
|
||||
|
||||
try:
|
||||
|
|
@ -781,7 +779,7 @@ def main():
|
|||
retry_usb = True
|
||||
|
||||
print("Resuming CPU.")
|
||||
pc_usb.poke(vexdbg_addr, 0x02000000)
|
||||
pc_usb.unhalt()
|
||||
|
||||
print("Resetting SOC...")
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -20,6 +20,22 @@ class PrecursorUsb:
|
|||
self.regions = {}
|
||||
self.gitrev = ''
|
||||
|
||||
def halt(self):
|
||||
if 'vexriscv_debug' in self.regions:
|
||||
self.poke(int(self.regions['vexriscv_debug'][0], 0), 0x00020000)
|
||||
elif 'reboot_cpu_hold_reset' in self.registers:
|
||||
self.poke(self.register('reboot_cpu_hold_reset'), 1)
|
||||
else:
|
||||
print("Can't find reset CSR. Try updating to the latest version of this program")
|
||||
|
||||
def unhalt(self):
|
||||
if 'vexriscv_debug' in self.regions:
|
||||
self.poke(int(self.regions['vexriscv_debug'][0], 0), 0x02000000)
|
||||
elif 'reboot_cpu_hold_reset' in self.registers:
|
||||
self.poke(self.register('reboot_cpu_hold_reset'), 0)
|
||||
else:
|
||||
print("Can't find reset CSR. Try updating to the latest version of this program")
|
||||
|
||||
def register(self, name):
|
||||
return int(self.registers[name], 0)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ with open('README.md') as f:
|
|||
|
||||
setup(
|
||||
name="precursorupdater",
|
||||
version="0.1.2",
|
||||
version="0.1.3",
|
||||
author="bunnie",
|
||||
description="Precursor USB Updater",
|
||||
long_description=long_description,
|
||||
|
|
|
|||
|
|
@ -365,6 +365,22 @@ class PrecursorUsb:
|
|||
def register(self, name):
|
||||
return int(self.registers[name], 0)
|
||||
|
||||
def halt(self):
|
||||
if 'vexriscv_debug' in self.regions:
|
||||
self.poke(int(self.regions['vexriscv_debug'][0], 0), 0x00020000)
|
||||
elif 'reboot_cpu_hold_reset' in self.registers:
|
||||
self.poke(self.register('reboot_cpu_hold_reset'), 1)
|
||||
else:
|
||||
print("Can't find reset CSR. Try updating to the latest version of this program")
|
||||
|
||||
def unhalt(self):
|
||||
if 'vexriscv_debug' in self.regions:
|
||||
self.poke(int(self.regions['vexriscv_debug'][0], 0), 0x02000000)
|
||||
elif 'reboot_cpu_hold_reset' in self.registers:
|
||||
self.poke(self.register('reboot_cpu_hold_reset'), 0)
|
||||
else:
|
||||
print("Can't find reset CSR. Try updating to the latest version of this program")
|
||||
|
||||
def peek(self, addr, display=False):
|
||||
_dummy_s = '\x00'.encode('utf-8')
|
||||
data = array.array('B', _dummy_s * 4)
|
||||
|
|
@ -1066,7 +1082,6 @@ def main():
|
|||
print("SoC is from an unknown rev '{}', use --force to continue anyways with v0.9 firmware offsets".format(pc_usb.load_csrs()))
|
||||
exit(1)
|
||||
|
||||
vexdbg_addr = int(pc_usb.regions['vexriscv_debug'][0], 0)
|
||||
pc_usb.ping_wdt()
|
||||
|
||||
if args.dump:
|
||||
|
|
@ -1083,14 +1098,14 @@ def main():
|
|||
exit(0)
|
||||
with open(args.dump_file, 'wb') as f:
|
||||
for page in table:
|
||||
pc_usb.poke(vexdbg_addr, 0x00020000)
|
||||
pc_usb.halt()
|
||||
data = pc_usb.burst_read(page, 4096)
|
||||
pc_usb.poke(vexdbg_addr, 0x02000000)
|
||||
pc_usb.unhalt()
|
||||
f.write(data)
|
||||
exit(0)
|
||||
|
||||
print("Halting CPU.")
|
||||
pc_usb.poke(vexdbg_addr, 0x00020000)
|
||||
pc_usb.halt()
|
||||
|
||||
if args.erase_pddb:
|
||||
print("Erasing PDDB region")
|
||||
|
|
@ -1127,7 +1142,7 @@ def main():
|
|||
pc_usb.erase_region(locs['LOC_PDDB'][0], 1024 * 1024)
|
||||
|
||||
print("Resuming CPU.")
|
||||
pc_usb.poke(vexdbg_addr, 0x02000000)
|
||||
pc_usb.unhalt()
|
||||
|
||||
print("Resetting SOC...")
|
||||
try:
|
||||
|
|
@ -1154,7 +1169,7 @@ def main():
|
|||
pc_usb.flash_program(locs['LOC_STAGING'][0], image, verify=verify)
|
||||
|
||||
print("Resuming CPU.")
|
||||
pc_usb.poke(vexdbg_addr, 0x02000000)
|
||||
pc_usb.unhalt()
|
||||
|
||||
print("Resetting SOC...")
|
||||
try:
|
||||
|
|
@ -1262,7 +1277,7 @@ def main():
|
|||
|
||||
|
||||
print("Resuming CPU.")
|
||||
pc_usb.poke(vexdbg_addr, 0x02000000)
|
||||
pc_usb.unhalt()
|
||||
|
||||
print("Resetting SOC...")
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue