update qemu setup

old one was wheezy based, every thing outdated
stretch has ruby2.3 out of the box
This commit is contained in:
Torsten Ruger 2018-04-30 15:06:36 +03:00
parent f02304e457
commit 6b3fd1533f

View File

@ -11,8 +11,15 @@
=link_to "this explains", "remote_pi.html" =link_to "this explains", "remote_pi.html"
a nice way to develop with it. a nice way to develop with it.
%p
We'll more or less follow a
=ext_link "blog post", "https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/"
i found, with small additions.
%h3 Qemu %h3 Qemu
%p Get the Qemu. There may be other emulators out there, and i have read of armulator, but this is what i found discribed and it works and is “easy enough”. %p
Get the Qemu. There may be other emulators out there, and i have read of armulator,
but this is what i found described and it works and is “easy enough”.
%pre %pre
%code %code
:preserve :preserve
@ -20,47 +27,52 @@
%h3 Pi images %h3 Pi images
%p Create a directory for the stuff on your mac, ie pi.
%p Get the latest Raspian image.
%p
There seems to be some chicken and egg problem, so qemu needs the kernel separately.
There is one in the links.
%h3 Configure
%p
In the blog post there is some fun configuration, I did it and it works.
Not sure what happens if you dont.
The booting is described below (you may or may not need an extra init=/bin/bash in the root… quotes),
so boot your Pi and then configure:
%p %p
Create a directory for the stuff on your mac, ie pi.
%pre %pre
%code %code
nano /etc/ld.so.preload mkdir pi
%p Put a # in front of the first to comment it out. Should just be one line there.
%p Press ctrl-x then y then enter to save and exit. pi is in the gitignore, and the scripts in bin, will assume pi.
%p (Optional) Create a file /etc/udev/rules.d/90-qemu.rules with the following content:
%pre
%code
:preserve
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"
%p %p
The kernel sees the disk as /dev/sda, while a real pi sees /dev/mmcblk0. Get the latest Raspian image. The
This will create symlinks to be more consistent with the real pi. =ext_link "lite version" "https://www.raspberrypi.org/downloads/raspbian/"
%h3#boot Boot without Gui is fine, and smaller.
%p There is quite a bit to the command line to boot the pi (i have an alias), here it is: %p
Change the file format with something like:
%pre
%code
qemu-img convert -f raw -O qcow2 2017-08-16-raspbian-stretch-lite.img raspbian-stretch-lite.qcow
So we can then resize the file, without it taking extra space
%pre
%code
qemu-img resize raspbian-stretch-lite.qcow +6G
Put the resulting file into the pi directory.
%h3 Kernel
%p
One still needs a kernel (even there is one on the image?), and Druv kindly keeps a
repository of them. Since we downloaded the stretch image, grap the
=ext_link "stretch kernel" , "https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.9.59-stretch"
and also the mysterious
=ext_link "tdb file." , "https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/versatile-pb.dtb"
Both go into the pi directory.
%h3 Boot
%p
There is quite a bit to the command line to boot the pi. There is a script in the bin
directory, but here it is:
%pre %pre
%code %code
:preserve :preserve
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda raspbian.img -redir tcp:2222::22 qemu-system-arm -kernel pi/kernel-qemu-4.9.59-stretch -dtb pi/versatile-pb.dtb -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append 'root=/dev/sda2 panic=1 rootfstype=ext4 rw' -hda pi/raspbian-stretch-lite.qcow -net nic -net user,hostfwd=tcp::2222-:22
%ul %ul
%li the cpu is what broadcom specifies, ok %li the cpu is what broadcom specifies, ok
%li memory is unfortunately hardcoded in the versatilepb “machine” %li memory is unfortunately hardcoded in the versatilepb “machine”
%li the kernel is the file name of the kernel you downloaded (or extracted) %li the kernel is the file name of the kernel you downloaded (or extracted)
%li raspbian.img is the image you downloaded. Renamed as it probably had the datestamp on it %li raspbian.img is the image you downloaded. Renamed as it probably had the datestamp on it
%li the redir redircts the port 2222 to let you log into the pi %li the "-net user,hostfwd=tcp::2222-:22" redircts the port 2222 to let you log into the pi
%p So %p So
%pre %pre
%code %code
@ -68,41 +80,24 @@
ssh -p 2222 -l pi localhost ssh -p 2222 -l pi localhost
%p will get you “in”. Ie username pi (password raspberry is the default) and port 2222 %p will get you “in”. Ie username pi (password raspberry is the default) and port 2222
%p Qemu bridges the network (that it emulates), and so your pi is now as connected as your mac. %p Qemu bridges the network (that it emulates), and so your pi is now as connected as your mac.
%h3#more-disk More Disk
%p The image that you download has only 200Mb free. Since the gcc is included and were developing (tiny little files of) ruby, this may be ok. If not there is a 3 step procedure to up the space. %h3 Working on the pi
%pre
%code
:preserve
dd if=/dev/zero bs=1m count=2048 >> raspbian.img
%p The 2048 gets you 2Gb as we specified 1m (meg).
%p On the pi launch
%pre
%code
:preserve
sudo fdisk /dev/sda
%p This will probably only work if your do the (Optional) config above.
%p %p
Say p, and write down the start of the second partition (122880 for me). You'll probably want to log in by ssh at some point. If for no other reason than
d 2 will delete the second partition Ctl-C will stop the emulator when you are logged in, and not the program you are
n p 2 will create a new primary second partition running on the emulator. This gets old _really_ quickly.
write the number as start and just return to the end. %p
p to check To configure the ssh server on the pi, log in and run
w to write and quit. %pre
%p Reboot, and run %code
%pre sudo raspi-config
%code and enable ssh in the interface options.
:preserve There is another text on how to
resize2fs =link_to "work on" , "/arm/remote_pi.html"
the pi. Off course google is good , and raspian site can help too.
%h2#links Links %h2#links Links
%p %ul#selector
Blog post (i used): %li=ext_link "Post used for instructions", "https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/"
=ext_link "http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/", "http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/" %li=ext_link "stretch kernel" , "https://github.com/dhruvvyas90/qemu-rpi-kernel/raw/master/kernel-qemu-4.9.59-stretch"
%p %li=ext_link "Rasbian image file", "http://www.raspberrypi.org/downloads/"
More Recent post (i googled):
=ext_link "https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/", "https://blog.agchapman.com/using-qemu-to-emulate-a-raspberry-pi/"
%p
Kernel:
=ext_link "http://xecdesign.com/downloads/linux-qemu/kernel-qemu", "http://xecdesign.com/downloads/linux-qemu/kernel-qemu"
%p
Rasbian file system(preferably by torrent):
=ext_link "http://www.raspberrypi.org/downloads/", "http://www.raspberrypi.org/downloads/"