adds the emulator and ssh howto pages

This commit is contained in:
Torsten Ruger 2014-05-27 12:30:12 +03:00
parent 011bb6dd7c
commit 971b3af10e
3 changed files with 52 additions and 41 deletions

View File

@ -47,6 +47,9 @@
<li class="link3"> <li class="link3">
<a href="/about.html">About</a> <a href="/about.html">About</a>
</li> </li>
<li class="link3">
<a href="/contribute.html">Contribute</a>
</li>
<li class="link4"> <li class="link4">
<a href="{{site.posts.first.url}}">News</a> <a href="{{site.posts.first.url}}">News</a>
</li> </li>

66
qemu.md
View File

@ -3,8 +3,8 @@ layout: site
title: How to configure Qemu title: How to configure Qemu
--- ---
Target Pi on Mac ##Target Pi on Mac
----------------
So even the idea is to run software on the Pi, not everyone has a Pi (yet :-) So even the idea is to run software on the Pi, not everyone has a Pi (yet :-)
@ -12,28 +12,28 @@ Others, like me, prefer to develop on a laptop and not carry the Pi around.
For all those, this here explains how to emulate the Pi on a Mac. For all those, this here explains how to emulate the Pi on a Mac.
Replace the buggy llvm Even if you have a Pi, [this explains](/remote_pi.html) a nice way to develop with it.
-----------------------
###Replace the buggy llvm
Written April 2014: as of writing the latest and greatest llvm based gcc (5.1) on Maverick (10.9) has a bug that makes qemu hang. Written April 2014: as of writing the latest and greatest llvm based gcc (5.1) on Maverick (10.9) has a bug that makes qemu hang.
So type gcc -v and if the output contains "LLVM version 5.1", you must install gcc4.2. Easily donw with homebrew: So type gcc -v and if the output contains "LLVM version 5.1", you must install gcc4.2. Easily donw with homebrew:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
This will not interfere with the systems compiler as the gcc4.3 has postfixed executables (ie gcc-4.2) This will not interfere with the systems compiler as the gcc4.3 has postfixed executables (ie gcc-4.2)
Qemu ###Qemu
----
Then its time to 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". Then its time to 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".
brew install qemu --env=std --cc=gcc-4.2 brew install qemu --env=std --cc=gcc-4.2
For people not on Maverick it may work without the -cc option. For people not on Maverick it may work without the -cc option.
Pi images ###Pi images
----------
Create a directory for the stuff on your mac, ie pi. Create a directory for the stuff on your mac, ie pi.
@ -41,32 +41,31 @@ Get the latest Raspian image.
There seems to be some chicken and egg problem, so quemu needs the kernel seperately. There is one in the links. There seems to be some chicken and egg problem, so quemu needs the kernel seperately. There is one in the links.
Configure ###Configure
---------
In the blog post there is some fun configuration, I did it and it works. Not sure what happens if you don't. In the blog post there is some fun configuration, I did it and it works. Not sure what happens if you don't.
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: 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:
nano /etc/ld.so.preload nano /etc/ld.so.preload
Put a # in front of the first to comment it out. Should just be one line there. Put a # in front of the first to comment it out. Should just be one line there.
Press ctrl-x then y then enter to save and exit. Press ctrl-x then y then enter to save and exit.
(Optional) Create a file /etc/udev/rules.d/90-qemu.rules with the following content: (Optional) Create a file /etc/udev/rules.d/90-qemu.rules with the following content:
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n" KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda2", SYMLINK+="root" KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"
The kernel sees the disk as /dev/sda, while a real pi sees /dev/mmcblk0. The kernel sees the disk as /dev/sda, while a real pi sees /dev/mmcblk0.
This will create symlinks to be more consistent with the real pi. This will create symlinks to be more consistent with the real pi.
Boot ###Boot
-----
There is quite a bit to the command line to boot the pi (i have an alias), here it is: There is quite a bit to the command line to boot the pi (i have an alias), here it is:
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 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
- the cpu is what braodcom precifies, ok - the cpu is what braodcom precifies, ok
- memory is unfortuantely hardcoded in the versatilepb "machine" - memory is unfortuantely hardcoded in the versatilepb "machine"
@ -74,20 +73,27 @@ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboo
- raspbian.img is the image you downloaded. Renamed as it probably had the datestamp on it - raspbian.img is the image you downloaded. Renamed as it probably had the datestamp on it
- the redir redircts the port 2222 to let you log into the pi - the redir redircts the port 2222 to let you log into the pi
So "ssh -p 2222 -l pi localhost" will get you "in". Ie username pi (password raspberry is the default) and port 2222 So
ssh -p 2222 -l pi localhost
will get you "in". Ie username pi (password raspberry is the default) and port 2222
Qemu bridges the network (that it emulates), and so your pi is now as connected as your mac. Qemu bridges the network (that it emulates), and so your pi is now as connected as your mac.
More Disk ###More Disk
---------
The image that you download has only 200Mb free. Since the gcc is included and we're developing (tiny little files of) ruby, this may be ok. If not there is a 3 step procedure to up the space. The image that you download has only 200Mb free. Since the gcc is included and we're developing (tiny little files of) ruby, this may be ok. If not there is a 3 step procedure to up the space.
1. dd if=/dev/zero bs=1m count=2048 >> raspbian.img dd if=/dev/zero bs=1m count=2048 >> raspbian.img
The 2048 gets you 2Gb as we specified 1m (meg). The 2048 gets you 2Gb as we specified 1m (meg).
2. On the pi launch "sudo fdisk /dev/sda" . This will probably only work if your do the (Optional) config above. On the pi launch
sudo fdisk /dev/sda
This will probably only work if your do the (Optional) config above.
Say p, and write down the start of the second partition (122880 for me). Say p, and write down the start of the second partition (122880 for me).
d 2 will delete the second partition d 2 will delete the second partition
@ -96,11 +102,15 @@ write the number as start and just return to the end.
p to check p to check
w to write and quit. w to write and quit.
3. Reboot, and run resize2fs Reboot, and run
resize2fs
Links Links
----- -----
Blog post: http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/ Blog post: [http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/](http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/)
Kernel: http://xecdesign.com/downloads/linux-qemu/kernel-qemu
Rasbian file system(preferably be torrent): http://www.raspberrypi.org/downloads/ Kernel: [http://xecdesign.com/downloads/linux-qemu/kernel-qemu](http://xecdesign.com/downloads/linux-qemu/kernel-qemu)
Rasbian file system(preferably be torrent): [http://www.raspberrypi.org/downloads/](http://www.raspberrypi.org/downloads/)

View File

@ -3,8 +3,7 @@ layout: site
title: How to use a remote pi title: How to use a remote pi
--- ---
Headless ###Headless
--------
The pi is a strange mix, development board and full pc in one. Some people use it as a pc, but not me. The pi is a strange mix, development board and full pc in one. Some people use it as a pc, but not me.
@ -12,23 +11,21 @@ I use the pi because it is the same price as an Arduino, but much more powerful.
As such i don't use the keyboard or display and that is called headless mode, logging in with ssh. As such i don't use the keyboard or display and that is called headless mode, logging in with ssh.
ssh -p 2222 -l pi localhost ssh -p 2222 -l pi localhost
the -p 2222 is only needed for the qemu version, not the real pi. the -p 2222 is only needed for the qemu version, not the real pi.
Authorized ###Authorized
-----------
Over ssh one can use many other tools, but the password soon gets to be a pain. Over ssh one can use many other tools, but the password soon gets to be a pain.
So the first thing i do is copy my public key over to the pi. This will allow login without password. So the first thing i do is copy my public key over to the pi. This will allow login without password.
scp -P 2222 .ssh/id_rsa.pub pi@localhost:.ssh/authorized_keys scp -P 2222 .ssh/id_rsa.pub pi@localhost:.ssh/authorized_keys
This assumes a fresh pi, otherwise you have to append your key to the authorized ones. Also if it complains about no This assumes a fresh pi, otherwise you have to append your key to the authorized ones. Also if it complains about no
id_rsa.pub then you have to generate a key pair (public/private) using ssh-keygen (no password, otherwise you'll be typing that) id_rsa.pub then you have to generate a key pair (public/private) using ssh-keygen (no password, otherwise you'll be typing that)
Syncing ###Syncing
-------
Off course I do all that to be able to actually work on my machine. On the Pi my keyboard doesn't even work and Off course I do all that to be able to actually work on my machine. On the Pi my keyboard doesn't even work and
i'd have to use emacs or nano instead of TextMate. So i need to get the files accross. i'd have to use emacs or nano instead of TextMate. So i need to get the files accross.
@ -36,12 +33,11 @@ For this there is a million ways, but since i just go one way (mac to pi) i use
I set up a directory (home) in my pi directory (on the mac), that i copy to the home directory on the pi using: I set up a directory (home) in my pi directory (on the mac), that i copy to the home directory on the pi using:
rsync -r -a -v -e "ssh -l pi -p 2222" ~/pi/home/ localhost:/home/pi rsync -r -a -v -e "ssh -l pi -p 2222" ~/pi/home/ localhost:/home/pi
The pi/home is on my laptop and the command transfers all files to /home/pi , the default directory of the pi user. The pi/home is on my laptop and the command transfers all files to /home/pi , the default directory of the pi user.
Automatic sync ###Automatic sync
--------------
Transferring files is off course nice, but having to do it by hand after saving quickly becomes tedious. Transferring files is off course nice, but having to do it by hand after saving quickly becomes tedious.
@ -50,7 +46,9 @@ Fswatch to the rescue. It will watch the filesystem (fs) for changes. Install wi
Then you can store the above rsync command in a shell script, say sync.sh. Then you can store the above rsync command in a shell script, say sync.sh.
Add afplay "/System/Library/Sounds/Morse.aiff" if you like to know it worked. Add afplay "/System/Library/Sounds/Morse.aiff" if you like to know it worked.
Then just run fswatch ~/pi/home/ sync.sh Then just run
fswatch ~/pi/home/ sync.sh
And hear the ping each time you save. And hear the ping each time you save.