Saturday, October 27, 2012

Transferring Files to the Raspberry Pi over the Network

Hmmm, I'm going to have to do something about those titles.  They're descriptive but, really, very boring.  Maybe I should be chanelling GaGa.

I was having trouble getting file transfers working from within PuTTY, so like all good noobs I gave up and did it the easy way.  FileZilla is probably the easiest option.  You can download it from here.  Then click on the .exe file to install it (like all good easy-to-use windows programs it comes as a self extracting file).

Now open it.  Remember how to get the IP address using Angry IP Scanner?  Good, do that again.

Now enter the number into the Host box (top left) and enter your Username and Password.  If they're pi and raspbian, then you should really think about changing the password.

Wow, look, the contents of your computer is on the left, and the contents of the Pi will be on the right.  You can just drag on drop files from here.

Thanks to Pix from the Adelaide Hackerspace for his help working this out.

First Step: Changing the Default Password

Okay guys, I think this is probably the most important first step you can do on the Pi, so sorry for the delayed how-to.  Hope it's useful - all the info is from the site.  There's some pretty good tips there on setting up your Pi, but changing your password should be easy.  Just open the terminal program and type:
sudo passwd
You'll be prompted for your original password (raspbian if you're running Raspbian as your OS).  Then you'll be asked for your new password - make sure it's something you'll remember.  Enter it once more.  You're done.  Your Raspberry Pi is now a lot more secure - and you only had to type five words.

Shelling In from Windows

So I'm guessing that you may have heard the phrase 'shell in' before.  No, it's not betting on a rigged shell game on the streets of New York City.  I had heard 'shell in' a lot of times (I hang with geeks), and vaguely understood that it meant controlling one computer from another computer (via a network) - but that was about as far as I went before owning a Pi.  It is a very useful ability to have, however, as it will let you do things on the Pi with only an ethernet cable, power, and your internet router.

Firstly you will need to scan the IP addresses on the router.  This will tell you what is connected (including the Windows machine you are using, and the the Raspberry Pi).  The program I use is called Angry IP Scanner.

Step 1:  Download it here.  I am using version 3.0 beta-6 (if you don't know what that means, don't worry about it).

Step 2:  Run the program (it's called ipscan-win32-3.0-beta6 in my case, yours will be ipscan-win...? where the ...? is whether it's 64 or 32 bit (32 bit will run in 64 bit windows, so it's easier to just use that one unless you have issues) and the rest of the ...? is the name of the version.  I use it enough that it was worth pinning a shortcut to my taskbar.

Step 3:  When you first open it it'll scan only a range of 1 IP address (shown at the very top of the screen).  That is the address of the computer you are running the program you are working on.  The IP address of the Pi will probably be within a few numbers of this, depending on how many devices you have joined to your router

So in the first box of the IP range (highlighted in blue) put a number 10 below and in the second box enter a number 10 above your computer's address.  Press 'Start.'  Since it's plugged directly into the router the 'Ping' will be very low.  Yup, the Pi's address on this router is '' - remember that number, you'll need it in a minute.

Now that you know where your Pi is on the network.  You need to connect - for that we'll be using PuTTY.

Step 1:  Download and run it.

Step 2:   Enter the address of the Pi into the Host Name (or IP address) box:

Leave the Port as 22 (no changes there) and click the Open button (highlighted in blue).

Step 3: Then the PuTTY window opens you will be asked who you want to 'login:as' - This is your user name.  If you are running Raspbian the default is:

You will then need to enter your password.  Hopefully you've changed this from the default, but if not, this will be:

Congratulations, you've successfully shelled in to your pi.  You will only be able to use the command line tools from here (since anything else will require a monitor to be plugged into the pi), but that's enough to install software, and do cool stuff like 'Dark Pi Rises' or creating an IP camera to watch your animals.

 Wow, exciting.

A bit shout-out to Tim for teaching me how to shell in and helping me grab the software.

Thursday, October 25, 2012

Unrar ra rar raaah!

/channelling Lady GaGa.  Wow, that was unexpected.

So I needed to 'unrar' an archive...

Do I need to take a step back from that statement?

Fair enough, so 'RAR' is a kind of archive (where you shrink, or 'compress' a file, document, program, etc so that it takes up less space).  Most Windows users will be familiar with ZIP files, well RAR does the same thing, only using a different compression algorithm.

XArchiver is a pretty good front end, and will automatically extract archives using the installed programs.

The only problem is that there is no 'unrar' installed.  Normally I'd just 'apt-get' it, but that didn't work, so here is how:

Step 1: Open the sources.list file in leafpad:
sudo leafpad /etc/apt/sources.list
and add the following line:
deb-src wheezy main contrib non-free rpi
 Then save and close leafpad.

Step 2:  Enter the following into Terminal, in order:
sudo apt-get update
sudo apt-get build-dep unrar-nonfree
sudo apt-get source -b unrar-nonfree
sudo dpkg -i unrar_4.1.4-1_armhf.deb 

Now (once you've rebooted) you should be able to use XArchiver to unrar your archives.  Or you can do it from the command line (in Terminal):
unrar file.rar
(where 'file.rar' is the name of the file you want to unrar).

Getting 'Flash' 'Running'

Sorry for the quotation marks, but it's not really Flash, but rather an open source version, called Gnash, that you will be 'running.'  Yeah, the quotation marks around 'running' are important too.  Remember that the Pi is not a very powerful machine, and any Flash heavy page is going to bog it down - especially since most browsers already max out the Raspberry's CPU and RAM.  You certainly won't be able to use it to watch Youtube videos.  :(  If you still need to run Flash, for whatever reason, here's how.

Step 1:  Type the following into the terminal:
sudo apt-get install browser-plugin-gnash

Step 2:  You will need to restart the browser (if you have it open).

You can now play (very simple small) Flash Games and view annoying advertising.  Congrats!  :)

Sunday, October 21, 2012

Surfing the Web

Not something the Pi does well, but it can still be improved.  Firstly Midori is not a bad browser, but Iceape will probably be better.  It is less intensive, and has an adblocker which is pretty damn handy given the state of the web these days.  You can even switch off java and images to save bandwidth / processing power.

Step 1:  sudo apt-get install iceape

That's it, iceape is now installed.  I recommend the adblockplus plugin as a bare minimum

Step 2:  Go to 'Tools>Add-ons Manager and search for adblock.  When it comes up click on the install button.  You'll need to restart the browser to make it work.

If you think you'll need flash then I recommend gnash (an open source alternative):

Step 3:  sudo apt-get install browser-plugin-gnash
Don't try and view / play anything too big though - the RPi's not built for it.  Youtube is still a big fail.  Sorry.

Watching Movies on the Pi

A word to the wise.  Don't even think about trying to get VLC working.  I have one of the new 512 meg of ram RPis and it is still super chunky and slow.  Omxplayer is your best bet (once it's working) and, based on my reading at least, is the only viewer able to utilise hardware acceleration.

Step 1:  Buy the MPEG-2 license key.  No really, not affiliated with the store or anything, but it makes such a huge difference for high resolution DivX, Xvid, MPEG-2, etc, files for such a small price, why wouldn't you?  To get your serial number type cat /proc/cpuinfo into the terminal.

Step 2:  Enter the licence key they send you into the config.txt file in the boot folder.  You can do this from the terminal by typing sudo leafpad /boot/config.txt
Then pasting the text from the email into its own line (it'll be all 'one word' and begin with 'decode_MPG2=' followed by a string of numbers and letter).

Step 3:  Reboot

Presumably you want to be able to control your movies without 'shelling in' (I know, right, I only vaguely know what that means, let alone am able to do it).  In that case just opening a file using omxplayer won't cut it.  Also, their is a good chance that there won't be any sound.  To fix these issues...

Step 4:  apt-get install xterm

Step 5:  Right click on the movie file you want to play and select 'Open with...'  Tick the box that says 'Set selected application as default action for this file type.'  Then click on the 'Custom Command Line' tab and enter the following:
xterm -e omxplayer -o hdmi -r %f
and click OK.

Step 6:  You can control the video (skip forward, back, pause, etc) using the following commands:

Space or p Pause/Resume

- Decrease Volume
+ Increase Volume

Left Seek -30
Right Seek +30
Down Seek -600
Seek +600

1 Increase Speed
2 Decrease Speed

j Previous Audio stream
k Next Audio stream

i Previous Chapter
o Next Chapter

s Toggle Subtitles
n Previous Subtitle stream
m Next Subtitle stream

q Quit

Connect to the Internet Using your Mobile Phone

So my ethernet worked easily and simply.  The only drawback?  I don't have a router at home.  I do all my internet surfing by tethering my mobile phone to the computer.  Something that didn't work with the RPi.  At least not yet.  Luckily I had access to a friend's router, and so installed wicd that way, but if you're not so lucky here's how to do it (you will need to install libpcap, ppp, and pppoeconf anyway).

Step 1:  You will need to download libpcap0.8, ppp and pppoeconf.

Step 2:  Open LXTerminal in the same folder where you have the files saved and type dpkg -i libpcap then press the 'Tab' button (the rest of the name should auto-complete - if not, then you'll have to type it in full (or copy and paste the name).

Step 3:  Do the same for ppp and pppoeconf.

Step 4:  Open LXTerminal in the root folder and type:
sudo leafpad /root/interfaces.txt and add the following line:
iface usb0 inet dhcp
then save and quit.

Step 5:  Enter ifup usb0 in the terminal

Step 6:  Make sure your phone is connected, and tethering is switched on.

Step 7:  Type sudo ppoeconf and follow the prompts

Step 8:  Reboot.

You should now have networking (or at least I did).  You can now apt-get install wicd which will give you better access to your networking.

Step 9:  Open wicd, and from the drop down menu on the right select 'preferences' and replace eth0 with usb0 in the wired interface box.  Tick the 'always show wired interface' box.

You can also turn wireless on and use your phone as a wireless dongle - just as handy, but without using your bandwidth.

Thanks to Mast for his instructions on getting a Network Manager working and Plugwash on getting usb tethering working.

Set Up

Congratulations!  You've got an operating system installed, and a working Raspberry Pi - now what?  This blue screen doesn't look particularly useful.  Well, it is and it isn't.  This is the raspi-config menu, and it's for getting things organised before you get down to using your raspberry pi.

The main step here is to select 'expand_rootfs' so that you can use your whole card as your hard disk drive (not just the 2GB in the image you downloaded).  Next you might want to 'change_timezone' and select yours (so that the pi knows what time it is where you are, and displays it correctly).  Finally, as a noob, you will want to arrow down to 'boot_behavious' and tell your computer to start the desktop on boot.  Then arrow down (or press tab) until you get to the <Finish> menu.  You will be asked if you want to reboot.  You do.

When the RPi has finished rebooting you should be looking at your nice neat Raspbian operating system.  Even if you haven't used Linux before this screen should be similar enough to Windows for you to feel at home.  Where you go from here will depend upon what you want to do with your RPi.

Getting Started

First things first, we have to get some kind of operating system running so we can use our Raspberry Pi.  I chose Raspbian because it has hard float, is recommended by the Raspberry Pi Foundation, and (this was the clincher) because portmanteaus make me smile (I am an English major after all).  If you are a complete and total noob, then it might be easier to buy an SD card with Raspbian (or one of the other operating systems) already installed.  If you'd like to know how to make your own, though, here is a step-by-step.

Step 1:  Download the latest Raspbian version from here:

(it was for me).

Step 2:  I'm going to assume that most noobs will be running windows on their home machine, and thus will need to download and unzip Win32DiskImager.

Step 3:  Insert a blank compatible SD card in your SD card reader, open up Win32DiskImager, and select the image you downloaded in step 1 (it should automatically select your SD card as the write destination).

Step 4:  Click the "Write" button.

Step 5:  Wait (patiently or impatiently) for your SD card to finish writing.

Step 6:  Eject it from your SD card reader, insert it in your (unpowered) Raspberry Pi, then connect everything up and go!

Step 7:  Set Up.

What do you think you're doing?

It's been harder than I thought - getting the Pi up and running the way I want. Lots of trawling and trial and error (oh, the errors). Then I had to do it all again! when I corrupted the SD card (more about avoiding that later).
Raspberry Pi
So here we are, the reason for my blog. I figured I might as well document my experience getting pi up and running for others as well as myself. Hope it's of some use.

A big thanks to the folks at the Adelaide Hackerspace who've helped me get my baby up and running.  Especially Pix, Tim, and Jon.  I promise to mostly use my new skills for good.  :)