Torlus
Posts: 45
Joined: Mon Nov 19, 2012 8:26 am

Re: QEMU patches for RPi emulation - Initial release

Sun Aug 18, 2013 8:15 pm

Hi,
There are a few bugs that have been reported and that I need to fix. Please allow me some time as I just came back from holidays ;)
About emulation status, well, some things might be easy to add/fix, but most stuff will require a significant amount of work...
If you had to choose between features that you require the most, which one would be your primary choice ?

jayachar
Posts: 6
Joined: Fri Aug 16, 2013 2:37 pm

Re: QEMU patches for RPi emulation - Initial release

Mon Aug 19, 2013 3:37 am

@JacobL my comment about "less successful" with later releases of Raspbian was perhaps unfounded and based on my interpretation of this thread. Reading some of the subsequent messages, seems like I was wrong. Sorry about that.

@Torlus, welcome back from vacations. A previous poster had requested GPIO support, and I get the impression that it may not be so hard to implement. Something like GPIO's in emulated RaspPi, if they can be mapped to a patch of shared-memory in the hostOS (well, it'd limit the concept to Linux / Unix / Unix-based OS's only), then a user-space app / script in host can do some fancy visuals, or perhaps even read it somehow using "processing" or even control GPIO on an Arduino... up to the developer's creativity. From a basic utility standpoint, it makes a Qemu based RaspPi emulation somewhat more useful for certain type of usages.

tvoverbeek
Posts: 99
Joined: Mon Feb 04, 2013 9:50 am
Location: Fieberbrunn, Austria

Re: QEMU patches for RPi emulation - Initial release

Mon Aug 19, 2013 9:16 am

@Torlus For me the first thing would be some form of net connectivity, either with qemu's net-usb or the smsc. I know this is probably a lot of work, but I would like to be able to do 'apt-get update' and 'apt-get upgrade'. Maybe there is an other solution using qemus 'serial over telnet' with ppp.

sweil
Posts: 7
Joined: Tue Aug 20, 2013 6:33 am

Re: QEMU patches for RPi emulation - Initial release

Tue Aug 20, 2013 6:42 am

Torlus wrote:If you had to choose between features that you require the most, which one would be your primary choice ?
Try getting at least some parts of your code into the official QEMU distribution?

This requires fixing the coding style. It's possible to get a list of required changes
by using QEMU's "scripts/checkpatch.pl -f <filename>".

Regards,
Stefan

Torlus
Posts: 45
Joined: Mon Nov 19, 2012 8:26 am

Re: QEMU patches for RPi emulation - Initial release

Fri Aug 23, 2013 8:38 pm

I just added a few fixes, and updated to latest QEmu (@sweil, check your messages).
I will now try to enhance the emulation itself, thanks all for your feedback.

jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Wed Nov 13, 2013 5:44 am

Torius,

I just registered the the board to check the status of RPi support in Qemu.
Seems it looks pretty useful. Can you tell me what if you are working
on further enhancements?

From my POV I think it should be interesting to add even current,
unfinished implementation to the Qemu upstream. It can extend
interest in the board and, I think, also more developers can work
on fixes.

What do you think?

If you want some help with upstreaming (code cleaning, etc)
let me know.

/Honza

Torlus
Posts: 45
Joined: Mon Nov 19, 2012 8:26 am

Re: QEMU patches for RPi emulation - Initial release

Wed Nov 13, 2013 7:41 pm

Well, you're right.
If you want to do some code cleaning, and help me comply with QEmu's coding standards, it would be greatly appreciated.
Regards,
Greg

michaell
Posts: 16
Joined: Mon Sep 17, 2012 8:08 am

Re: QEMU patches for RPi emulation - Initial release

Thu Nov 14, 2013 7:53 pm

I've compiled qemu from sources according to these instructions. http://xecdesign.com/compiling-qemu/

Problem is RPi won't boot. Here's a screenshot:

Image

I'm using this cmdline to start qemu:
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=0" -hda 2013-09-25-wheezy-raspbian.img

kernel-qemu is downloaded from here: http://xecdesign.com/downloads/linux-qemu/kernel-qemu

jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Thu Nov 14, 2013 8:02 pm

Torlus wrote:Well, you're right.
If you want to do some code cleaning, and help me comply with QEmu's coding standards, it would be greatly appreciated.
Regards,
Greg
Great,
I will look at it and try to clean stuffs according coding rules etc.

/Honza

jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 15, 2013 8:30 am

jp1 wrote:
Torlus wrote:Well, you're right.
If you want to do some code cleaning, and help me comply with QEmu's coding standards, it would be greatly appreciated.
Regards,
Greg
Great,
I will look at it and try to clean stuffs according coding rules etc.

/Honza
Well, after quick investigation I have decided to restructure your patches
because of source code moved during the development (from /hw/* to /hw/arm/
and at the same time the qemu internals changed).

We have only two ways: squash your patches, but there can be
some merge issue or we can recreate the patches against current
qemu dev tree. The latter is my preferred way.

So I just created the first, bigest one, patch which adds raspi board
with all devices in bcm2835_xxx.c files. After that we can add
the small patches for the rest of necessary changes.

Greg, is it OK for you?

Of course, all comes with yours "Signed-off-by" clause.

/Honza

PS: The initial checkpatch test shows:
"total: 2008 errors, 131 warnings, 6369 lines checked".
Most of them are about tabs, trailing whitespaces, etc :)

Torlus
Posts: 45
Joined: Mon Nov 19, 2012 8:26 am

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 15, 2013 2:19 pm

I merged with qemu's master branch 2 days ago, it should be ok now.
Can you please check?
Then we'll decide if there is a need to reincorporate them from "scratch".

My patches against the ARM emulation are not necessary anymore. Only the bcm* files are useful now, it should be easier to submit to qemu's team.

Regards,
Greg

jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 15, 2013 2:53 pm

I have already noticed your merges.

But I still think that the best (simpler) way would be to copy current bcm2835_*
and raspi.c files and to do initial commit to the current dev tree.

I also noticed that arm support for 1176 is already there, so I ignored
those changes (I mean from your commits).

Of course, if you think to pull all your commits as is, let me know,
I stop my work, no problem (it's your code).

/Honza

PS: My current progress:
$ grep total: 0001-arm-Raspberry-Pi-support*.log
0001-arm-Raspberry-Pi-support1.log:total: 2008 errors, 131 warnings, 6369 lines checked
0001-arm-Raspberry-Pi-support2.log:total: 493 errors, 124 warnings, 6369 lines checked
0001-arm-Raspberry-Pi-support3.log:total: 418 errors, 124 warnings, 6369 lines checked
0001-arm-Raspberry-Pi-support4.log:total: 400 errors, 124 warnings, 6369 lines checked
0001-arm-Raspberry-Pi-support5.log:total: 87 errors, 128 warnings, 6369 lines checked
(All fixes done by simple sed scripts)

Torlus
Posts: 45
Joined: Mon Nov 19, 2012 8:26 am

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 15, 2013 8:11 pm

No, please continue ;) Thanks again for your time.
I'm so glad someone else contributes :)

jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Tue Nov 19, 2013 7:04 am

Good, some step in:
$ grep total: 0001-arm-Raspberry-Pi-support6.log
total: 11 errors, 128 warnings, 6430 lines checked

Most of warnings are because of long line:
$ grep 'line over 80' 0001-arm-Raspberry-Pi-support6.log | wc -l
102

I guess one or max two steps and we have patch clean for review ;)

/Honza


jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Mon Nov 25, 2013 8:41 am

Torius,

I just finished my job :)

$ grep total: 0001-arm-Raspberry-Pi-support10.log
total: 11 errors, 27 warnings, 6516 lines checked

I think we are ready to contribute it to the QEMU, but
I would like to ack the patch by you, the original
author.

Let me know where I should send the 0001-arm-Raspberry-Pi-support.patch
to show you if everything is OK for you.

BTW, if you wonder why there are still few errors and warnings:
* 25 warnings are failed positive catches suggested to add block
brackets, in our cases it is totally nonsense.
* 2 warnings are about long lines, but we can not break the url,
so also ignored by me
* 11 errors are because of use C99 type comment (// instead of */)
But I think this is OK in such particular cases.

Anyway, if you mind we have change anything inside the patch
let me know.

/Honza

voltagex
Posts: 5
Joined: Thu Dec 20, 2012 9:59 pm

Re: QEMU patches for RPi emulation - Initial release

Thu Nov 28, 2013 3:52 am

Can you please post the patch to Gist or similar?

It seems like we should be talking to the qemu maintainers on the mailing lists by now (apologies if someone's already doing this)

jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Thu Nov 28, 2013 11:11 am

voltagex wrote:Can you please post the patch to Gist or similar?

It seems like we should be talking to the qemu maintainers on the mailing lists by now (apologies if someone's already doing this)
I have already sent my clean-up work to Torius. Now it depends
on him. If he mind to manage upstreaming communication himself
then he do it, otherwise I'm, of course, ready to do it myself.
But final ACK is needed.

So, please wait a little, I think it will be managed soon ;)

/Honza

Torlus
Posts: 45
Joined: Mon Nov 19, 2012 8:26 am

Re: QEMU patches for RPi emulation - Initial release

Thu Nov 28, 2013 10:15 pm

Hi,

@jp1: I've fixed the remaining warnings/errors, and sent the patch to you for review.
@voltagex: Once everything's fine, I will make it available on Gist as well.

About patch submission stuff, well, if any one you has already done this before, I would be glad if he can do it ;)
I think @sweil has already submitted some patches, he may help us too...

Regards,
Greg

jp1
Posts: 12
Joined: Wed Nov 13, 2013 5:32 am

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 29, 2013 5:51 am

Torlus wrote:Hi,

@jp1: I've fixed the remaining warnings/errors, and sent the patch to you for review.
Great. I will have look on it during today (I hope at least ;) )
@voltagex: Once everything's fine, I will make it available on Gist as well.

About patch submission stuff, well, if any one you has already done this before, I would be glad if he can do it ;)
I think @sweil has already submitted some patches, he may help us too...
I will do it. I sent some small patch to the QEMU already about month ago
(and it was ACKed by maintainers for submission) and spent some
time on bunch of others open-source projects as well, so no problem
for me to manage that :)

But let check your fixes first.

/Honza

User avatar
blachanc
Posts: 456
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 29, 2013 5:57 am

Hi,

not sure this question belongs here, but here it is:
qemu resolution seems limited to (800X600 max).
does this branch unlock this limitation?

If not, is there hope somebody sometime will unlock this?

the background for this question:
when I am not using startx, I use putty to the emulated PI in order to get a larger console,
but this does not work for startx.

regards,
ben
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6053
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 29, 2013 6:03 am

blachanc wrote:Hi,

not sure this question belongs here, but here it is:
qemu resolution seems limited to (800X600 max).
does this branch unlock this limitation?

If not, is there hope somebody sometime will unlock this?

the background for this question:
when I am not using startx, I use putty to the emulated PI in order to get a larger console,
but this does not work for startx.

regards,
ben
It does unlock this limitation, but in exchange for another limitation. As far as I know, the NIC isn't emulated yet, so there's no network. Would be awesome to have some sort of target like the rpi one but with the NIC from the versatile platform. (Torlus *hint*hint*nudge*nudge)

User avatar
blachanc
Posts: 456
Joined: Sat Jan 26, 2013 5:03 am
Location: Quebec,canada(french)

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 29, 2013 6:33 am

wow, that was a fast answer...
thank you,
this looks like a head or gut choice :D for now ;)

Ben
Autism/Asperger syndrome: what is your score on this quiz?
http://www.raspberrypi.org/forums/viewtopic.php?f=62&t=70191

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6053
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: QEMU patches for RPi emulation - Initial release

Fri Nov 29, 2013 6:35 am

blachanc wrote:wow, that was a fast answer...
thank you,
this looks like a head or gut choice :D for now ;)

Ben
Usermode chroot emulation is the best bet.

Torlus
Posts: 45
Joined: Mon Nov 19, 2012 8:26 am

Re: QEMU patches for RPi emulation - Initial release

Sat Nov 30, 2013 3:08 pm

Well, the issue with the NIC is that, IIRC, it's a USB 2 attached one, so first thing to do is to have the USB controller properly emulated.
However, the USB controller is not a standard one (it would have been too easy ;) ), but some kind of half-baked USB Device controller, to which some USB Host controller features have been crammed into. Datasheets are not available of course. I've been contacted some time ago by a Synopsys sales representative, and it seems that there's no way to get required information apart from signing a NDA, which would prevent keeping my work GPL'ed (which is out of question).

It would be possible to "cheat" at the emulation level, as suggested by ShiftPlusOne, but I don't really see the point of doing so... One intermediate step would be to emulate the USB 2 controller and use an already-emulated USB-attached NIC (if there's one already, I haven't looked at it yet).

Regards,
Greg

P.S : I've rebased my work on QEmu's master, applied jp1's formatted patch, fixed the remaining formatting issues in the source files, and regenerated the patch. I had to force-push it into GitHub, so you might want to perform a clean checkout of the branch, instead of updating it. Sorry for that.

Return to “Bare metal, Assembly language”