update pi section

This commit is contained in:
Torsten Ruger 2018-04-28 18:32:42 +03:00
parent e562a97028
commit f02304e457
2 changed files with 62 additions and 40 deletions

View File

@ -2,7 +2,7 @@
%h1= title "How to configure Qemu" %h1= title "How to configure Qemu"
%h2#target-pi-on-mac Target Pi on Mac %h2 Target Pi on Mac
%p So even the idea is to run software on the Pi, not everyone has a Pi (yet :-) %p So even the idea is to run software on the Pi, not everyone has a Pi (yet :-)
%p Others, like me, prefer to develop on a laptop and not carry the Pi around. %p Others, like me, prefer to develop on a laptop and not carry the Pi around.
%p For all those, this here explains how to emulate the Pi on a Mac. %p For all those, this here explains how to emulate the Pi on a Mac.
@ -10,30 +10,33 @@
Even if you have a Pi, Even if you have a Pi,
=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.
%h3#replace-the-buggy-llvm Replace the buggy llvm
%p 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. %h3 Qemu
%p So type gcc -v and if the output contains “LLVM version 5.1”, you must install gcc4.2. Easily done with homebrew: %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”.
%pre %pre
%code %code
:preserve :preserve
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb brew install qemu
%p This will not interfere with the systems compiler as the gcc4.2 has postfixed executables (ie gcc-4.2)
%h3#qemu Qemu %h3 Pi images
%p 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”.
%pre
%code
:preserve
brew install qemu --env=std --cc=gcc-4.2
%p For people not on Maverick it may work without the -cc option.
%h3#pi-images Pi images
%p Create a directory for the stuff on your mac, ie pi. %p Create a directory for the stuff on your mac, ie pi.
%p Get the latest Raspian image. %p Get the latest Raspian image.
%p There seems to be some chicken and egg problem, so quemu needs the kernel seperately. There is one in the links.
%h3#configure Configure
%p %p
In the blog post there is some fun configuration, I did it and it works. Not sure what happens if you dont. There seems to be some chicken and egg problem, so qemu needs the kernel separately.
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: There is one in the links.
%p nano /etc/ld.so.preload
%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
%pre
%code
nano /etc/ld.so.preload
%p Put a # in front of the first to comment it out. Should just be one line there. %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. %p Press ctrl-x then y then enter to save and exit.
%p (Optional) Create a file /etc/udev/rules.d/90-qemu.rules with the following content: %p (Optional) Create a file /etc/udev/rules.d/90-qemu.rules with the following content:
@ -53,8 +56,8 @@
: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 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
%ul %ul
%li the cpu is what braodcom precifies, ok %li the cpu is what broadcom specifies, ok
%li memory is unfortuantely 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 redir redircts the port 2222 to let you log into the pi
@ -92,11 +95,14 @@
resize2fs resize2fs
%h2#links Links %h2#links Links
%p %p
Blog post: Blog post (i used):
=ext_link "http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/", "http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/" =ext_link "http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/", "http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/"
%p
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 %p
Kernel: Kernel:
=ext_link "http://xecdesign.com/downloads/linux-qemu/kernel-qemu", "http://xecdesign.com/downloads/linux-qemu/kernel-qemu" =ext_link "http://xecdesign.com/downloads/linux-qemu/kernel-qemu", "http://xecdesign.com/downloads/linux-qemu/kernel-qemu"
%p %p
Rasbian file system(preferably be torrent): Rasbian file system(preferably by torrent):
=ext_link "http://www.raspberrypi.org/downloads/", "http://www.raspberrypi.org/downloads/" =ext_link "http://www.raspberrypi.org/downloads/", "http://www.raspberrypi.org/downloads/"

View File

@ -2,7 +2,7 @@
%h1= title "How to use a remote pi" %h1= title "How to use a remote pi"
%h3#headless Headless %h3 Headless
%p The pi is a strange mix, development board and full pc in one. Some people use it as a pc, but not me. %p The pi is a strange mix, development board and full pc in one. Some people use it as a pc, but not me.
%p I use the pi because it is the same price as an Arduino, but much more powerful. %p I use the pi because it is the same price as an Arduino, but much more powerful.
%p As such i dont use the keyboard or display and that is called headless mode, logging in with ssh. %p As such i dont use the keyboard or display and that is called headless mode, logging in with ssh.
@ -11,7 +11,7 @@
:preserve :preserve
ssh -p 2222 -l pi localhost ssh -p 2222 -l pi localhost
%p the -p 2222 is only needed for the qemu version, not the real pi. %p the -p 2222 is only needed for the qemu version, not the real pi.
%h3#authorized Authorized %h3 Authorise yourself
%p %p
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.
@ -22,20 +22,33 @@
%p %p
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 youll be typing that) id_rsa.pub then you have to generate a key pair (public/private) using ssh-keygen (no password, otherwise youll be typing that)
%h3#syncing Syncing
%h3 Sync the working tree
%p %p
Off course I do all that to be able to actually work on my machine. On the Pi my keyboard doesnt even work and Off course I do all that to be able to actually work on my machine.
id have to use emacs or nano instead of TextMate. So i need to get the files accross. On the Pi my keyboard doesnt even work and id have to use emacs or nano instead
For this there is a million ways, but since i just go one way (mac to pi) i use rsync (over ssh). of Atom. So i need to get the files across.
%p I set up a directory (home) in my pi directory (on the mac), that i copy to the home directory on the pi using: %br
For this there is a million ways, but since i just go one way (mac to pi)
i use rsync (over ssh).
%p
I set up a directory (home) in my pi directory (on the mac),
that i copy to the home directory on the pi using:
%pre %pre
%code %code
:preserve :preserve
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
%p The pi/home is on my laptop and the command transfers all files to /home/pi , the default directory of the pi user. %p The pi/home is on my laptop and the command transfers all files to /home/pi , the default directory of the pi user.
%h3#automatic-sync Automatic sync
%p Transferring files is off course nice, but having to do it by hand after saving quickly becomes tedious. %h3 Automatic sync
%p Fswatch to the rescue. It will watch the filesystem (fs) for changes. Install with brew install fswatch
%p
Transferring files is off course nice, but having to do it by hand after
saving quickly becomes tedious.
%p
Fswatch to the rescue. It will watch the filesystem (fs) for changes.
Install with 'brew install fswatch'
%p %p
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.
@ -43,15 +56,18 @@
%pre %pre
%code %code
:preserve :preserve
fswatch ~/pi/home/ sync.sh fswatch -o ~/pi/home | xargs -n1 -I{} ~/sync.sh
%p And hear the ping each time you save. %p
%h2#conclusion Conclusion And hear the ping each time you save. (btw -I{} makes it so the file name that changed
does not get passed on. Rsync figures that out)
%h2 Conclusion
%p So the total setup involves the qemu set up as described. To work i %p So the total setup involves the qemu set up as described. To work i
%ul %ul
%li start the terminal (iterm) %li start the terminal (iterm)
%li start the pi, with my alias “pi” * %li start the pi, with my alias “pi” *
%li log in to the pi in its window %li log in to the pi in its window
%li open textmate with the directory i work (within the home) %li open atom with the directory i work (within the home)
%li %li edit, save, wait for ping, alt-tab to pi window, run my whatever and repeat until its time for tea
%p edit, save, wait for ping, alt-tab to pi window, run my whatever and repeat until its time for tea
%li (i dont log into the prompt it gives in item so as not to accidentally quit the qemu session with ctr-c ) PS: (i dont log into the prompt it gives in item so as not to accidentally quit the qemu session with ctr-c )