[Qemu-discuss] Black screen when emulating Raspberry Pi with qemu 2.5

2016-03-08 Thread Per Olofsson
Hello,
  after some minor tweaks to pixman I got qemu 2.5.0 to compile and run
  on OS X 10.11. I'm trying to set it up to emulate a Raspberry Pi for
  development, but I can't get it to boot from the raspbian linux image.
  I'm using:

  2016-02-26-raspbian-jessie.img  downloaded from
  https://www.raspberrypi.org/downloads/raspbian/
  kernel-qemu-4.1.13-jessie   downloaded from
  https://github.com/dhruvvyas90/qemu-rpi-kernel

If I start with:

  /usr/local/qemu/bin/qemu-system-arm -M versatilepb -m 512 -cpu arm1176
  -no-reboot -kernel kernel-qemu-4.1.13-jessie -hda
  2016-02-26-raspbian-jessie.img -serial stdio

it prints "Uncompressing Linux... done, booting the kernel." and then
the kernel hangs since it can't find a root fs:

  
https://www.dropbox.com/s/ogmhcyser53ko32/Sk%C3%A4rmklipp%202016-03-08%2012.53.21.png

The problem is that if I try to add any kernel boot options with
-append, even if it's just "panic=1", all I get is a black screen for a
few seconds and then it exits:

  /usr/local/qemu/bin/qemu-system-arm -M versatilepb -m 512 -cpu arm1176
  -no-reboot -kernel kernel-qemu-4.1.13-jessie -hda
  2016-02-26-raspbian-jessie.img -serial stdio -append "panic=1"

  
https://www.dropbox.com/s/e11mzvdjcpcfylf/Sk%C3%A4rmklipp%202016-03-08%2012.57.22.png

If i use "root=/dev/sda" I still only get a black screen, but it doesn't
exit after a few seconds so maybe it's booting?

I also tried compiling the latest git version, and the results are the
same. I tried the experimental raspi2 machine too, but that just gives
me a debugger prompt. I'm completely new to qemu so any pointers are
welcome.

-- 
  Per Olofsson
  magerv...@fastmail.fm



Re: [Qemu-discuss] Black screen when emulating Raspberry Pi with qemu 2.5

2016-03-08 Thread Jakob Bohm

On 08/03/2016 13:01, Per Olofsson wrote:

Hello,
   after some minor tweaks to pixman I got qemu 2.5.0 to compile and run
   on OS X 10.11. I'm trying to set it up to emulate a Raspberry Pi for
   development, but I can't get it to boot from the raspbian linux image.
   I'm using:

   2016-02-26-raspbian-jessie.img  downloaded from
   https://www.raspberrypi.org/downloads/raspbian/
   kernel-qemu-4.1.13-jessie   downloaded from
   https://github.com/dhruvvyas90/qemu-rpi-kernel

If I start with:

   /usr/local/qemu/bin/qemu-system-arm -M versatilepb -m 512 -cpu arm1176
   -no-reboot -kernel kernel-qemu-4.1.13-jessie -hda
   2016-02-26-raspbian-jessie.img -serial stdio

Are you sure -hda filename.img causes filename.img to be used
as a virtual *SDCard* (which is what Raspberry Pi has)?

it prints "Uncompressing Linux... done, booting the kernel." and then
the kernel hangs since it can't find a root fs:

   
https://www.dropbox.com/s/ogmhcyser53ko32/Sk%C3%A4rmklipp%202016-03-08%2012.53.21.png

The problem is that if I try to add any kernel boot options with
-append, even if it's just "panic=1", all I get is a black screen for a
few seconds and then it exits:

   /usr/local/qemu/bin/qemu-system-arm -M versatilepb -m 512 -cpu arm1176
   -no-reboot -kernel kernel-qemu-4.1.13-jessie -hda
   2016-02-26-raspbian-jessie.img -serial stdio -append "panic=1"

   
https://www.dropbox.com/s/e11mzvdjcpcfylf/Sk%C3%A4rmklipp%202016-03-08%2012.57.22.png

Don't know about that.

If i use "root=/dev/sda" I still only get a black screen, but it doesn't
exit after a few seconds so maybe it's booting?

On the Raspberry Pi, root is not the whole SDcard, but a
partition on it.

root may even be a subitem within the first partition on
the SDcard, I don't remember right now, it depends on the
instructions for putting that .img file on a physical SDcard
for booting a real Raspberry.

I also tried compiling the latest git version, and the results are the
same. I tried the experimental raspi2 machine too, but that just gives
me a debugger prompt. I'm completely new to qemu so any pointers are
welcome.



In general, a real Raspberry Pi 1 boots like this:

1. ROM (not EPROM/Flash) code inside the Broadcom chip
  connects to the SDcard.

2. ROM looks on the first (FAT) partition for a magical
  file with a proprietary boot blob and copies the
  beginning of that to RAM.

3. The proprietary boot blob bootstraps the on-chip
  proprietary GPU and other global CPU features, then
  chains to the Linux kernel, using a config file on
  the FAT partition to specify part of the Linux
  command line).

4. The Linux kernel loads on the pre-initialized CPU
  and accesses the pre-initialized GPU for display
  output.

5. At some point in the boot process (maybe the kernel
  phase, maybe a script on an initrd) mounts the "ext2,
  ext3 or ext4" partition or file as Linux root, then
  proceeds with a mostly ordinary Debian boot process.

Enjoy

Jakob
--
Jakob Bohm, CIO, Partner, WiseMo A/S.  https://www.wisemo.com
Transformervej 29, 2860 Søborg, Denmark.  Direct +45 31 13 16 10
This public discussion message is non-binding and may contain errors.
WiseMo - Remote Service Management for PCs, Phones and Embedded




Re: [Qemu-discuss] Black screen when emulating Raspberry Pi with qemu 2.5

2016-03-08 Thread Per Olofsson
On Tue, Mar 8, 2016, at 01:29 PM, Jakob Bohm wrote:
> On 08/03/2016 13:01, Per Olofsson wrote:
> > If I start with:
> >
> >/usr/local/qemu/bin/qemu-system-arm -M versatilepb -m 512 -cpu arm1176
> >-no-reboot -kernel kernel-qemu-4.1.13-jessie -hda
> >2016-02-26-raspbian-jessie.img -serial stdio
> Are you sure -hda filename.img causes filename.img to be used
> as a virtual *SDCard* (which is what Raspberry Pi has)?

No, this mounts the image as an IDE device, but my goal at this point is
just to boot raspbian linux rather than full emulation. As I was typing
this reply and double checking everything I managed to see a point that
I'd overlooked before:

https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki#key-notes

versatilepb only supports 256 MB of RAM, and trying to run with 512
causes the black screen. Having a console makes things a lot easier, and
tells me that it successfully mounts the root filesystem (with
root=/dev/sda2) but it panics trying to run init (actually /bin/bash):

  /usr/local/qemu/bin/qemu-system-arm -kernel kernel-qemu-4.1.13-jessie
  -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -hda
  2016-02-26-raspbian-jessie.img -append "root=/dev/sda2 panic=0 rw
  init=/bin/bash"
  
https://www.dropbox.com/s/aopefzzyswl4eyn/Sk%C3%A4rmklipp%202016-03-08%2014.17.03.png

Still, progress!

-- 
  Per Olofsson
  magerv...@fastmail.fm



Re: [Qemu-discuss] Black screen when emulating Raspberry Pi with qemu 2.5

2016-03-08 Thread Per Olofsson
With console output fixed it wasn't too hard to make it all work. For
future reference, the instructions here had all the necessary pieces of
the puzzle:

  https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki
  
https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki/Emulating-Jessie-image-with-4.1.x-kernel

After converting the modified raw image to a qcow2 my final command line
for qemu 2.5.0 is:

/usr/local/qemu/bin/qemu-system-arm \
-cpu arm1176 \
-m 256 \
-M versatilepb \
-no-reboot \
-kernel kernel-qemu-4.1.13-jessie \
-hda raspbian-jessie-qemu.qcow \
-append "root=/dev/sda2 rootfstype=ext4 rw" \
-serial stdio

-- 
  Per Olofsson
  magerv...@fastmail.fm