-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qemu emulation #34
Comments
OK I have it almost running using the kernel provided here http://xecdesign.com/downloads/linux-qemu/kernel-qemu with this command line:
It get this installer but it fails because the kernel sees the disk as /dev/sda, while a real pi sees /dev/mmcblk0. |
At first I tried to dev with QEMU, but because of the huge differences it wasn't possible to have a single install script. There's also a Pi QEMU fork but it doesn't have networking so while it has proper device support for USB and everything it still was unable to perform a networked installation. |
Any new progress to report on this @mcanevet ? |
@diederikdehaas no. I don't really have time to play with my raspberry this days. |
Ok, thanks for your response. It was worth a shot ;-) |
In case anyone still interested, I actually managed to run raspbian-ua-netinst on qemu-system-arm and generate bootable raspbian image with the hints provided by @mcanevet on Mar 29. Basically, what I did was I downloaded "raspbian-ua-netinst-v1.0.5.img", take the "installer.cpio", extract it and then edit the "rcS" file with the following. bootdev=/dev/sda After that, rebuild the "installer.cpio" and then boot the "raspbian-ua-netinst-v1.0.5.img" with qemu-system-arm using "kernel-qemu" and the modified "installer.cpio". In order to boot the resulting raspbian image on a real Raspberry Pi, an adjustment on the config.txt and fstab is required (replace /dev/sda* with /dev/mmcblk0*). It would be nice if this configuration for booting on qemu-system-arm can be implemented in raspbian-ua-netinst, but I still have no idea how to integrate it elegantly. For now, I execute the above steps manually everytime I need to boot raspbian-ua-netinst on qemu-system-arm. |
👍 good to know, and I agree it would be nice to automate this in some manner, but I'm not sure how, have to think about it... |
I haven't tried it myself, but whtat happens if you specify those 4 params in And thanks for diving into this, I'm definitively interested 👍 |
If I specify those 4 params in "installer-config.txt", it does not work. This is because the "installer-config.txt" is only parsed after "Copying boot files... " step. In other words, it is too late. I have tried to move the parsing of "installer-config.txt" before "Copying boot files... " step, but then it became a chicken and egg problem. We need to read "installer-config.txt" from $bootpartition, but the correct $bootpartition is not yet set and the correct value for $bootpartition is inside "installer-config.txt". This is a crazy suggestion but to solve the chicken and egg problem, is it possible to move the setting for those 4 params to cmdline.txt then make rcS script to read from /proc/cmdline? I don't know if it can work because I haven't got the time to test it yet. |
that might work, but might have serious side effects as well, cmdline is intended for kernel use... I was thinking in the line of building (and naming the files appropriately) 2 different cmdline.cpio files (like I said, it's not elegant, but the differences are large enough for this to be an option to consider... IMHO, of course) |
I'm also against abusing cmdline.txt for this. I have to give this some more thought, but I was thinking of having a |
I am not sure if cmdline is intended only for kernel use. This is because in Debian (squeeze, wheezy) I remember that by appending "text" to the cmdline on boot, the X server won't be started because it detects "text" in /proc/cmdline. But, I don't know. Anyway, I have written a script which will generate "installer-qemu.cpio" and prepare "raspbian-ua-netinst-v1.0.5.img" for running on qemu-system-arm. It is here: http://pastebin.com/sqtQ19Ci |
Thanks a LOT for sharing your findings and code 👍 |
You are welcome. But the heavy lifting is to somehow integrate that to raspbian-ua-netinst. I will leave that to the project owner and collaborators to decide what is the best way to do that. |
I was thinking of including a setting option (boolean flag) like "build-quemu-image" (well, probably something shorter 👼 ), and rebuild the image with -qemu attached to the filename... now that becomes almost as easy as directly copy-pasting the code from @dhanar10 👍 |
I thought about sth like that too, only to realize that we don't have a configuration file for the build process, only for the to be installed system. Doesn't mean we can't create one 😉 |
command line parameters FTW!!! (ok, it's not exactly cmdline, but close 👼 ) also, who says the build script can't actually read the same config file, just respond to different options |
It's be great if the raspian netinstall could run easily on QEMU so +1 for some sort of option that can be run OOTB. But in the meantime I too have been having issues. I was hoping that this thread may help me... I am running QEMU 2.1.2 (from wheezy-backports) on a headless Debian Wheezy server. I am trying to launch with this command:
I have essentially used the same command to successfully launch the full Raspian image but the netinstaller quits with: @dhanar10 I was hoping that your script might solve my issue but I'm not quite sure what to do with the resulting installer-qemu.cpio!? After running your script: What am I doing wrong...? |
@JedMeister Basically, the script generates "installer-qemu.cpio" and modifies "raspbian-ua-netinst-v1.0.5.img" for booting on qemu. I assume you have read the script and understand this, yes? After that, to boot raspbian-ua-netinst on qemu, you need to use the "installer-qemu.cpio" and the modified "raspbian-ua-netinst-v1.0.5.img". I use the following command. qemu-system-arm -kernel "kernel-qemu" -initrd "installer-qemu.cpio" -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "consoleblank=0" "raspbian-ua-netinst-v1.0.5.img" It seems that you missed the -initrd "installer-qemu.cpio" option. |
@dhanar10 Thanks champ! :) That did it... I got the theory of what your script did, but just wasn't clear on the exact usage. As usual I was overcomplicating it! I just had to run the script...Doh! :) Also the fundamental bit I was missing was For the info of other newbish types it was this simple (on Wheezy headless server with QEMU installed from backports)
|
Awesome guys 👍 |
Sorry guys... New problem... The created image hangs during boot (local console hangs just after starting SSH) although I can log in via SSH ok. Full details in #149 (I thought it best to start a new 'issue'). |
I'll go back to one of the original comments about "abusing the kernel command-line". It's not only the kernel's. You're more than welcome to add more parameters you might need, just make sure to namespace them. So "raspbian-ua-netinst.boot=/dev/sda" is a fine solution. |
I personally don't agree with that... it is the kernels command line (even the name says so 😉 ) and shouldn't be used for other things (unless there really is no other way, and even then you should be able to find another way) |
Do you want a list of things that aren't the kernel and that use the kernel command-line? Installers, init systems, boot splashes, and usually, hardware detection override (there's a couple of them in GNOME for that purpose). |
do you think that such a list would change my opinion about the kernel command line being a kernel thing? 😉 |
I think it's much better to build for QEMU then add 'run-time detection' for QEMU in rcS. diff --git a/build.sh b/build.sh
index 661cc03..830a44f 100755
--- a/build.sh
+++ b/build.sh
@@ -2,6 +2,8 @@
set -e
+QEMU="true"
+
KERNEL_VERSION=3.12-1-rpi
INSTALL_MODULES="kernel/fs/f2fs/f2fs.ko"
INSTALL_MODULES="$INSTALL_MODULES kernel/fs/btrfs/btrfs.ko"
@@ -213,6 +215,17 @@ cp tmp/lib/*/libz.so.1 rootfs/lib/libz.so.1
cd rootfs && find . | cpio -H newc -ov > ../installer.cpio
cd ..
+if [ "$QEMU" = "true" ] ; then
+ # let's also make an installer.cpio suitable for qemu
+ sed -i '/^bootdev=/s|/dev/mmcblk0|/dev/sda|' "rootfs/etc/init.d/rcS"
+ sed -i '/^bootpartition=/s|/dev/mmcblk0p1|/dev/sda1|' "rootfs/etc/init.d/rcS"
+ sed -i '/^rootdev=/s|/dev/mmcblk0|/dev/sda|' "rootfs/etc/init.d/rcS"
+ sed -i '/^rootpartition=/s|$|/dev/sda2|' "rootfs/etc/init.d/rcS"
+ cd rootfs && find . | cpio -H newc -ov > ../installer-qemu.cpio
+ cd ..
+ # end qemu part
+fi
+
rm -rf tmp
rm -rf rootfs
@@ -235,7 +248,21 @@ if [ -d config ] ; then
cp -r config/* bootfs/config
fi
-ZIPFILE=raspbian-ua-netinst-`date +%Y%m%d`-git`git rev-parse --short @{0}`.zip
+ZIPFILE_BASE=raspbian-ua-netinst-`date +%Y%m%d`-git`git rev-parse --short @{0}`
+ZIPFILE=${ZIPFILE_BASE}.zip
rm -f $ZIPFILE
cd bootfs && zip -r -9 ../$ZIPFILE *; cd ..
+
+if [ "$QEMU" = "true" ] ; then
+ # replace installer.cpio with the qemu variant
+ rm bootfs/installer.cpio
+ cp installer-qemu.cpio bootfs/installer.cpio
+ ZIPFILE_QEMU=${ZIPFILE_BASE}-qemu.zip
+ rm -f $ZIPFILE_QEMU
+ cd bootfs && zip -r -9 ../$ZIPFILE_QEMU *; cd ..
+ # restore the original installer.cpio
+ rm bootfs/installer.cpio
+ cp installer.cpio bootfs/
+fi
+ This was before the RPi2 support code was there and it's probably easier to do now. |
The problem I see with this is that you're modifying the rootfs files, so the changes are not undone when you create a non-QEmu images, and it makes it impossible to create an installer that go through the image creation on QEmu but targetted at physical Raspberry Pis. |
The idea is to create either an image for use with QEMU or an image for the RPi. |
Fair enough. |
Hi, I have these errors: How to resolve them ? Thx. |
I resolved my problem, see my tuto : http://framboisepi.fr/lancement-de-raspbian-a-partir-de-qemu/ |
Anyone has any tips as to how to get networking working with QEMU? |
Not sure @diederikdehaas. I'm using QEMU from Wheezy backports and my guest was built with v1.0.6 of the UA-netinstall. I'm running a 3.10 kernel I compiled myself and it all just works OOTB... Although FWIW by default QEMU uses NATed network AFAIK. So outgoing should be fine. I use redirection to allow incoming SSH connections: i.e. I use |
Looks like it was false alarm 😄 $ stty intr ^]
$ qemu-system-arm -kernel "kernel-3.12.9-1+rpi2-qemu" -initrd "installer-qemu.cpio" \
-cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio \
-append "consoleblank=0 console=ttyAMA0 console=ttyS0" \
"raspbian-ua-netinst-20150325-git17e4c6d.img" The first command is to remap quitting QEMU to Ctrl-] (instead of Ctrl-C) and then it starts QEMU and I get a serial console to interact with it, which works great. I finally got around to (trying to) develop using QEMU and I have to say it's quite nice 😄 |
Since we're doing runtime detection now to distinguish between RPi 1 and 2, doing so for QEMU might not be such a bad idea. The following commands look useful in my situation: grep Hardware /proc/cpuinfo | cut -d " " -f 2-3
if [ $(dmesg | grep QEMU | wc -l) -gt 0 ] ; then
QEMU=true
fi |
+1 it would be great to be able to run the same image on both rpi and Qemu |
I'm removing this from the v1.1.0 milestone, as there doesn't seem to be too much interest in working on this one... not closing it though, as it is still an interesting one |
Closing this issue as there hasn't been any activity here for more than a year. If you feel the closure was in error please feel free to re-open with your comment and/or new info. |
This sets F2FS instead of EXT4 as default root file system which is better for usage with SD cards and flash storage.
It would be great if we could use qemu to debug the installer but I don't really know how to make it work.
I tried with this command line without any success:
The only thing I get is a black screen.
Any idea ?
The text was updated successfully, but these errors were encountered: