repl: bring up second cpu

Bring up the second cpu. This requires the most recent version of Renode.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2023-08-14 08:32:25 +02:00
parent 1283cd2eff
commit d2316d2d23
2 changed files with 27 additions and 19 deletions

View File

@ -1,4 +1,9 @@
cpu: CPU.Xtensa @ sysbus cpu1: CPU.Xtensa @ sysbus
cpuId: 1
cpuType: "esp32s3"
cpu2: CPU.Xtensa @ sysbus
cpuId: 2
cpuType: "esp32s3" cpuType: "esp32s3"
// External data memory // External data memory

View File

@ -37,9 +37,11 @@ sysbus LoadBinary @esp32s3-drom.bin 0x3FF00000
#sysbus LoadBinary @esp32s3-efuses.bin 0x60007000 #sysbus LoadBinary @esp32s3-efuses.bin 0x60007000
sysbus LoadELF @bootloader.elf sysbus LoadELF @bootloader.elf
#copy_bootrom_data #copy_bootrom_data
setup_hooks sysbus.cpu setup_hooks sysbus.cpu1 sysbus.cpu2
#sysbus WriteDoubleWord 0x600c40a0 0x8 drom WriteByte 0x41a6b 0x1d
cpu PC 0x40000400 drom WriteByte 0x41a6c 0xf0
cpu1 PC 0x40000400
cpu2 IsHalted true
""" """
python python
@ -48,11 +50,12 @@ def memcpy(dest, src, n):
data = self.Machine.SystemBus.ReadBytes(src, n) data = self.Machine.SystemBus.ReadBytes(src, n)
self.Machine.SystemBus.WriteBytes(data, dest) self.Machine.SystemBus.WriteBytes(data, dest)
def mc_setup_hooks(cpu): def mc_setup_hooks(cpu1, cpu2):
from Antmicro.Renode.Peripherals.CPU import RegisterValue from Antmicro.Renode.Peripherals.CPU import RegisterValue
# LR, SP, R0 # LR, SP, R0
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 = 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 = 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
cpu = self.Machine[cpu] cpu1 = self.Machine[cpu1]
cpu2 = self.Machine[cpu2]
def format_val(v): def format_val(v):
try: try:
@ -61,10 +64,10 @@ def mc_setup_hooks(cpu):
return str(v) return str(v)
def log(*args): def log(*args):
cpu.Log(LogLevel.Warning, "{0}", ", ".join(map(format_val, args))) cpu1.Log(LogLevel.Warning, "{0}", ", ".join(map(format_val, args)))
def get(reg, raw=True): def get(reg, raw=True):
v = cpu.GetRegisterUnsafe(reg) v = cpu1.GetRegisterUnsafe(reg)
if raw: if raw:
return v.RawValue return v.RawValue
return v return v
@ -76,7 +79,7 @@ def mc_setup_hooks(cpu):
return list(map(get, (A2, A3, A4))) return list(map(get, (A2, A3, A4)))
def set(reg, val): def set(reg, val):
cpu.SetRegisterUnsafe(reg, RegisterValue.Create(val, 32)) cpu1.SetRegisterUnsafe(reg, RegisterValue.Create(val, 32))
def cstr(addr): def cstr(addr):
out = bytearray() out = bytearray()
@ -93,38 +96,38 @@ def mc_setup_hooks(cpu):
addr = self.Machine.SystemBus.GetSymbolAddress(addr_or_name) addr = self.Machine.SystemBus.GetSymbolAddress(addr_or_name)
else: else:
addr = addr_or_name addr = addr_or_name
cpu.AddHook(addr, fn) cpu1.AddHook(addr, fn)
return fn return fn
return wrap return wrap
@hook(0x4004578f) @hook(0x4004578f)
def ets_run_flash_bootloader_hook(cpu, pc): def ets_run_flash_bootloader_hook(cpu1, pc):
log("ets_run_flash_bootloader", *args()) log("ets_run_flash_bootloader", *args())
# this function loads software bootloader # this function loads software bootloader
# we have it already loaded, just jump before # we have it already loaded, just jump before
# executing user code (software bootloader) # executing user code (software bootloader)
cpu.PC = RegisterValue.Create(0x40043ca3,32) cpu1.PC = RegisterValue.Create(0x40043ca3,32)
@hook(0x40043ca6) @hook(0x40043ca6)
def hook_soft_address(cpu, pc): def hook_soft_address(cpu1, pc):
log("hook_soft_address", *args()) log("hook_soft_address", *args())
# write address already loaded software bootloader to register # write address already loaded software bootloader to register
self.Machine.SystemBus.WriteDoubleWord(0x3fcedf14, 0x403c9908) self.Machine.SystemBus.WriteDoubleWord(0x3fcedf14, 0x403c9908)
@hook(0x403c9a1c) @hook(0x403c9a1c)
def hook_cpu_rev_check(cpu, pc): def hook_cpu_rev_check(cpu1, pc):
log("cpu_rev_check", *args()) log("cpu_rev_check", *args())
cpu.PC = RegisterValue.Create(0x403c9a1f,32) cpu1.PC = RegisterValue.Create(0x403c9a1f,32)
@hook (0x403ce971) @hook (0x403ce971)
def hook_skip_part_size_check(cpu, pc): def hook_skip_part_size_check(cpu1, pc):
log("skip_part_size_check", *args()) log("skip_part_size_check", *args())
cpu.PC = RegisterValue.Create(0x403ce9a3,32) cpu1.PC = RegisterValue.Create(0x403ce9a3,32)
@hook (0x403ce129) @hook (0x403ce129)
def hook_skip_flash_check(cpu, pc): def hook_skip_flash_check(cpu1, pc):
log("skip_flash_check", *args()) log("skip_flash_check", *args())
cpu.PC = RegisterValue.Create(0x403ce1b0,32) cpu1.PC = RegisterValue.Create(0x403ce1b0,32)
""" """
runMacro $reset runMacro $reset