M0Rf30 / simonpi

A quick & dirty script to emulate Raspberry PI family devices on your laptop.
https://m0rf30.github.io/simonpi
GNU General Public License v3.0
67 stars 9 forks source link

Can simonpi work with exiting raspbian-based images? #2

Closed guysoft closed 6 years ago

guysoft commented 6 years ago

Hey, So I am the developer of CustomPiOS. and I really want to get armv7 emulation working for Zynthian (the new upcomming distro for zynthian.org).

My question is - could this work with raspbian images? What kernel are you using to boot the images?

Currently I am using this script which fixes ld-preload and uses qemu-rpi-kernel project, where I got a recommendation for simonpi at https://github.com/dhruvvyas90/qemu-rpi-kernel/issues/48#issuecomment-367590189

M0Rf30 commented 6 years ago

Actually it doesn't, but should take some minutes to add Raspbian image support. I'll write here for any update. Take a look at Readme for used kernels

guysoft commented 6 years ago

Thanks, took a look, Tried to use this kernel but didn't work, might be missing something. This is my command:

/usr/bin/qemu-system-arm -kernel /tmp/qemu-kernel-4.15.0 -dtb /tmp/vexpress-v2p-ca15-tc1.dtb -cpu cortex-a15 -m 256 -M vexpress-a15  -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda /tmp/2017-11-29-zynthianos-stretch-lite-0.1.img

Suck on blank screen. An update would be amazing

M0Rf30 commented 6 years ago

Try this one, for me it works:

qemu-system-arm -nographic -cpu cortex-a15 -m 1024 -M vexpress-a15 -smp cpus=2 -drive file=/tmp/2017-11-29-zynthianos-stretch-lite-0.1.img,if=sd,format=raw -kernel /tmp/qemu-kernel-4.15.0 -append 'root=/dev/mmcblk0p2 rootfstype=ext4 rw console=ttyAMA0 loglevel=0 panic=1 quiet' -dtb /tmp/vexpress-v2p-ca15-tc1.dtb -semihosting -no-reboot
guysoft commented 6 years ago

Removed the -nographic, got:

guy@golem4:/tmp$ qemu-system-arm -cpu cortex-a15 -m 1024 -M vexpress-a15 -smp cpus=2 -drive file=/tmp/2017-11-29-zynthianos-stretch-lite-0.1.img,if=sd,format=raw -kernel /tmp/qemu-kernel-4.15.0 -append 'root=/dev/mmcblk0p2 rootfstype=ext4 rw console=ttyAMA0 loglevel=0 panic=1 quiet' -dtb /tmp/vexpress-v2p-ca15-tc1.dtb -semihosting -no-reboot
pulseaudio: set_sink_input_volume() failed
pulseaudio: Reason: Invalid argument
pulseaudio: set_sink_input_mute() failed
pulseaudio: Reason: Invalid argument
qemu-system-arm: Trying to execute code outside RAM or ROM at 0x04000000
This usually means one of the following happened:

(1) You told QEMU to execute a kernel for the wrong machine type, and it crashed on startup (eg trying to run a raspberry pi kernel on a versatilepb QEMU machine)
(2) You didn't give QEMU a kernel or BIOS filename at all, and QEMU executed a ROM full of no-op instructions until it fell off the end
(3) Your guest kernel has a bug and crashed by jumping off into nowhere

This is almost always one of the first two, so check your command line and that you are using the right type of kernel for this machine.
If you think option (3) is likely then you can try debugging your guest with the -d debug options; in particular -d guest_errors will cause the log to include a dump of the guest register state at this point.

Execution cannot continue; stopping here.
M0Rf30 commented 6 years ago

What version of QEMU are you running?

guysoft commented 6 years ago

QEMU emulator version 2.10.1(Debian 1:2.10+dfsg-0ubuntu3.4) I can also compile and build from master.

guysoft commented 6 years ago

Tried also from master today (QEMU emulator version 2.11.50 (v2.11.0-1755-g0a773d55ac-dirty) ). it boots! There is a blank screen for a while though. I am getting a strange import error when I try importing tornado.ioloop in python, will investigate screenshot_20180225_161111

M0Rf30 commented 6 years ago

Black screen is dued to quiet and loglevel=0 options. I've updated arm7 kernel to 4.15.5 with builtin command line and device tree blob. It shouldl work for every vexpress machine on qemu

guysoft commented 6 years ago

Cool, I'm thinking on updating the script to support your kernels too. Need to figure out how to do that so it will be nice and easy to manage. If you have any input how you would like it to look that would be nice. It would be shipped with CustomPiOS.

guysoft commented 6 years ago

screenshot_20180225_161111 ok, strange, I get this error when I import datetime, which is a standard library in python. Works fine on a raspberrypi. Not sure where to report it.

M0Rf30 commented 6 years ago

I've added -i option to load custom sd images like Raspbian ones. as example

simonpi rpi-X -i /home/a.img

for python error I really don't know

guysoft commented 6 years ago

Yay, confirm it works using rpi-2. Rpi-3 does not boot. And I had to still use master qemu. The latest on Ubuntu 17.10 is not new enough.

Next I guess it getting the network to work. DHCP fails here on tap. Not sure why. Should I open an issue for that?

M0Rf30 commented 6 years ago

check your ports with ss -ntl and let me know if port 53 is open before running simonpi. Yes open another issue and post your logs. You could also use simonpi docker container. QEMU version of alpine base image should work for every platform

guysoft commented 6 years ago

You mean like this?

$ ss -ntl | grep 53
LISTEN     0      128          *:5355                     *:*                  
LISTEN     0      32     192.168.122.1:53                       *:*                  
LISTEN     0      32     127.0.0.1:53                       *:*                  
LISTEN     0      128         :::5355                    :::*    
M0Rf30 commented 6 years ago

Latest commit fixes rpi-3 emulation for raspbian. It was a kernel binfmt_464c issue

guysoft commented 6 years ago

Tested, works!