randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
488 stars 59 forks source link

Possible to run bmc64 in qemu? #108

Closed Jammmmm closed 4 years ago

Jammmmm commented 4 years ago

I've been trying for hours to get bmc64 running in qemu with no success. I can get a Raspberry Pi3 with Raspbian running just fine though.

I've tried every combination of this command:

qemu-system-aarch64 -M raspi3 \
-m 1024 \
-serial stdio \
-kernel ./bmc64files/kernel8-32.img \
-append "root=/dev/mmcblk0p1 rootfstype=raw rw terminal=ttyS0 rootwait" \
-dtb ./bmc64files/bcm2710-rpi-3-b.dtb \
-cpu cortex-a53 \
-drive file=./bmc64files/bmc64withfiles.img,if=sd,format=raw

Where:

It just sits at a blank screen. I've tried qemu-system-arm, -M raspi2, different versions of the kernel, with and without the "append" parameters (and every combination within it too), with and without the dtb, etc. Nothing.

I've even tried redirecting all output to qemu's stdio with "console=ttyAMA0,115200 console=tty highres=off console=ttyS0" in the append parameters and adding -nographic. This works for Raspbian but again, nothing for bmc64.

Help!

randyrossi commented 4 years ago

Some hardware is not emulated by qemu. You can try adding enable_serial=true to the cmdline.txt parameters and see how far it's getting.

randyrossi commented 4 years ago

BTW: enable_serial=true will use the tx/rx GPIO 14/15 @ 115200 bps for logging. I'm not sure how you tell qemu to interpret that though. But there is probably a way.

Jammmmm commented 4 years ago

Unfortunately that didn't do anything.

-append "console=ttyAMA0,115200 console=tty highres=off console=ttyS0" -nographic is how I was able to get Raspbian to display everything to stdio so it definitely works. It just doesn't work with bmc64.

It's a shame, but I guess any dev I do will mean writing changes to SD and trying on a physical Pi.

boras-pl commented 4 years ago

AFAIK raspi3 emulation has no USB support, so default Raspbian has neither working input in a window nor networking. Only serial console. If the emulator has not been finished yet, it is hard to say how the Circle library reacts when it experiences lack of some functionalities. Some hints are there: https://github.com/rsta2/circle/blob/master/doc/qemu.txt

Jammmmm commented 4 years ago

I tried everything there and nothing. I even tried building a minimal circle-stdlib kernel image and it doesn't seem to work either. Everything works fine on a normal Pi though.

Oh well. Thanks for the tips!


EDIT: Whoops. I was using the wrong command line. I got the circle-stdlib kernel booting in qemu. I'll see if I can get bmc64 booting too.

Jammmmm commented 4 years ago

I think this issue should be closed.

qemu's Pi emulation is really really flaky and getting Circle and BMC64 to play nice with it is a nightmare for subpar results.

My hope was to be able to debug to screen, or even stdio/stderr/etc. on my dev machine but realistically that's not going to happen anytime soon. Hopefully qemu improves but for now I've found that if anyone's serious about developing for BMC64, you need a USB to Serial cable.

pppq commented 3 years ago

In case anyone is interested, I managed to start bmc64 in QEMU 5.2.0 (v5.2.0-11850-g0f27b14b91-dirty) from Stefan Weil's Windows builds: https://qemu.weilnetz.de/w64/2021/

The modifications needed can be found in my fork: https://github.com/randyrossi/bmc64/compare/master...pppq:qemu

To summarize: VideoCore emulation for sound, OpenGL ES and dispmanx support is missing, so I have disabled these features and wrote a very rudimentary FrameBufferLayer implementation that uses the emulated frame buffer, with "nearest neighbor" interpolation, a hard-coded screen resolution and a timer-based FPS limiter.

Some of the layers are stacked incorrectly, but the VIC-II screen is visible, and the menu also works by and large.

I also had to enable the serial port and set the SD card's first partition for use by default, as command line parsing also seems to have problems (although this should be supported, in theory).

I used the following CLI options:

$ qemu-system-arm -M raspi2b -kernel kernel7.img -serial stdio -device usb-kbd -sd sdcard.qcow2

It should be possible to compile the C64 build using make_all.sh pi2; I have only tried this one, not the other emulated machine types.

image