Simon-Willcocks / RISC-OS-Kernel-in-C

A multiprocessing RISC OS kernel in C
Apache License 2.0
17 stars 2 forks source link

how to use qemu with the rom? #7

Closed jr-peterzon closed 3 years ago

jr-peterzon commented 3 years ago

I have tried various machine configurations with qemu-system-arm but none of them actually did anything. Would be useful to have some info on how to run qemu since it is mentioned as being used to test.

Simon-Willcocks commented 3 years ago

I use the following command, but I have modified, self-built, qemu. I'll quickly install the standard version and try it out.

qemu-system-arm -bios rom.bin -machine raspi2b

Simon-Willcocks commented 3 years ago

It doesn't work. I'll create a patch file for the source that's here: https://download.qemu.org/qemu-5.2.0.tar.xz

../configure' '--enable-gtk' '--enable-vnc' '--enable-sdl' '--target-list=aarch64-softmmu,arm-softmmu

Simon-Willcocks commented 3 years ago

I hope this will work, and I have to be somewhere for a while. HTH. Thanks for the interest, it caught me by surprise!

qemu-5.2.0.patch.zip

Simon-Willcocks commented 3 years ago

And now, that's stubbornly refusing to work.

FWIW, the real machine puts code at the bottom of memory as well as loading the kernel7.img, qemu does not, it just starts at 0. The patch loads the "bios" at zero, and runs it. If you make an SD card, the config.txt file needs to contain kernel_old=1.

janrinze commented 3 years ago

building qemu 5.2.0 now. will report later if it works with the newly built rom.bin.

janrinze commented 3 years ago

Could you try to do a clean check-out of RISC-OS-Kernel-in-C in a new directory and rebuild there? There still may be a difference somewhere.. I even installed arm-linux-gnueabi-gcc-8 and tried your main tree to no avail..

Simon-Willcocks commented 3 years ago

I just downloaded the zip (-main branch) and executed build, which appeared to work OK, including the creation of ro_rom.o.

The compiler version I have is: arm-linux-gnueabi-gcc-8 (Ubuntu/Linaro 8.4.0-3ubuntu1) 8.4.0

The resulting image, rom.bin, copied to an SD card as kernel7.img with the attached files, runs on my Pi, at least, but qemu just sits there. Frustrating! sdcard.zip

Simon-Willcocks commented 3 years ago

qemu doesn't seem to like msr SPSR_svc, r3

(A good place to set a breakpoint is raise_exception, and display /x env.regs

Simon-Willcocks commented 3 years ago

Because the processor is in SVC mode already, QEMU treats the instruction as UNDEF.

See the comment in msr_banked_access_decode of qemu-5.2.0/target/arm/translate.c

The annoying thing is that the function doesn't really achieve anything, although there probably will be registers that should be initialised in there.

I've updated processor/ARMv6/processor.c

janrinze commented 3 years ago

The build works now! Thanks for debugging this.

janrinze commented 3 years ago

I will update my repo as well and try to add the last step to generate the final rom.

jr-peterzon commented 3 years ago

The build steps for cmake are in my repositiory. Finding out how to automate which compiler to use will be another challenge for cmake but we can close this issue now.