unicorn-engine / unicorn

Unicorn CPU emulator framework (ARM, AArch64, M68K, Mips, Sparc, PowerPC, RiscV, S390x, TriCore, X86)
http://www.unicorn-engine.org
GNU General Public License v2.0
7.33k stars 1.31k forks source link

ctl_set_cpu_model issues #1934

Closed SachaTending closed 2 months ago

SachaTending commented 2 months ago

im trying to emulate old hardware called webtv im trying to use r5230 cpu, but ctl_set_cpu_model fails

Traceback (most recent call last):
  File "/home/sasha/python-webtv-emu/e.py", line 66, in <module>
    uc.ctl_set_cpu_model(UC_CPU_MIPS32_4KC)
  File "/home/sasha/python-webtv-emu/venv/lib/python3.11/site-packages/unicorn/unicorn.py", line 798, in ctl_set_cpu_model
    self.__ctl_w_1_arg(uc.UC_CTL_CPU_MODEL, val, ctypes.c_int)
  File "/home/sasha/python-webtv-emu/venv/lib/python3.11/site-packages/unicorn/unicorn.py", line 748, in __ctl_w_1_arg
    self.ctl(self.__ctl_w(ctl, 1), arg)
  File "/home/sasha/python-webtv-emu/venv/lib/python3.11/site-packages/unicorn/unicorn.py", line 726, in ctl
    raise UcError(status)
unicorn.unicorn.UcError: Invalid argument (UC_ERR_ARG)

(yes im using 4kc bcz im trying to find most compatible cpu) webtv_emu.zip

saicao commented 2 months ago

Maybe, you can try to set cpu model before you do any thing to unicorn.

SachaTending commented 2 months ago

thanks for help now only issue is

>>> Tracing instruction at 0xbfc017e4, instruction size = 0x4
ohno, Unhandled CPU exception (UC_ERR_EXCEPTION)
  File "/home/sasha/w/e.py", line 81, in <module>
    uc.emu_start(BOOTROM_ADDR, BOOTROM_ADDR+len(bootrom))
  File "/home/sasha/webtv_emu/venv/lib/python3.11/site-packages/unicorn/unicorn.py", line 547, in emu_start
    raise UcError(status)

i try to fix it myself