Sunday, 24 February 2013

Connecting a NAS drive to the Raspberry PI

One small limitation of the Raspberry PI is the limited amount of storage - just the size of the SD card. A simple solution is to use some external storage on the network. In my case this would be my NAS box which is already on my network and is being used by all the family. A quick search with Google found a nice explanation of how to achieve this at www.stuffaboutcode.com.

As I am using the latest Raspbian I did not need to install Samba or the cif-utils. The only issue I had with these instructions was I could not get it to work using the name of my NAS box, I had to use its IP address. So I changed //myNAS/myShare to //192.168.x.x/myShare. This is not a problem for me as I have a fixed IP address for my NAS box.

The text you add to the fstab file has the following meaning
//myNAS/myShare - this is the name of your NAS or its IP address followed by the name of the directory on the NAS you want to mount.
/home/pi/myNAS/myShare - this is the directory where you want you NAS to appear. It must exist.
cifs - specifies the type of connection used to access the remote NAS
username= ,password= - the username and password of someone with access to the NAS.
workgroup= - the name of your workgroup
users,auto - not sure what they mean - need to do some more research
user_xattr - enable extended attributes

One thing I did do was add file_mode=0777,dir_mode=0777 after the workgroup as without them I could only read the files. If you want to write to files and create directories you need to add these.

The one big issue with this method is that your username and password for your network share is stored in a simple text file. This is acceptable to me, but may not be for you. There is a link in the instructions that gives another more secure method of mounting an external NAS.

So I now have access to my network storage from the Raspberry PI.

Thursday, 21 February 2013

Connecting using SSH

So I have installed Raspbian on an SD card and got the Raspberry PI to boot - so now what.

As my desk is rather cluttered I would like remove the keyboard and mouse from the Raspberry PI and connect to it through a window on my main PC over my local network. A good solution to this is to use SSH (Secure Shell). When I first installed Raspbian I used the raspi-config utility to enable the SSH server which is disabled by default. If you did not do this the you can change the setting by running "sudo raspi-config" from the command prompt. You will see the use of the "sudo" command a lot. It is used to run a program with raised privileges that are required to change some system settings.

Once the SSH server is enabled it is a simple matter of using a program like PuTTY to connect to the Raspberry PI. The only hard thing to using SSH is knowing what the IP address of the Raspberry PI is. If you have a screen and keyboard connected the IP address can be found by typing "ifconfig" at a command prompt. The network IP address is shown as the "inet addr" on the second line of "eth0". However, depending on how your network is setup it could get a different IP address every time you turn on the Raspberry PI. Having the display and keyboard connected to just find out the IP address kind of goes against the benefit of SSH. On my network I have configured my Router to assign a fixed IP address to the Raspberry PI. This then makes it simple (just need to remember the address) to connect over SSH. Alternatively there are many applications that will scan your network and show a list of connected devices and their addresses. The one I use on my network is Advanced-ip-scanner but there are many others.

So I now have a window on my main PC with a connection to the Raspberry PI and some desk space back.

One limitation of using PuTTY and SSH is that you only get a command prompt. You cannot run the GUI. If you type the command "startx" you will have to connect you display and mouse to be able to exit (logout) of the GUI desktop.

Wednesday, 20 February 2013

Getting started with Raspbian “wheezy”

So to get going with the Raspberry PI you need to get an operating system loaded onto a SD card. The instructions on the Downloads page for the Raspberry PI make the process look simple - so here goes.

I started by downloading the latest Raspbian (2013-02-09-wheezy-raspbian.zip). My choice of this particular image was quite simply that it was the first in the list (don't like hard choices) and recommended for people just starting out (like ME). It is then a simple process of following the instructions in the guide for beginners.

As I am primarily a Windows user the first task is to download Win32DiskImager by following the link. The page that appears is rather confusing at first glance. The developer of this software is moving the project to SourceForge. So I clicked the link to Sourceforge project to get to a page where I could download the current version of Win32DiskImager-v0.7-binary.zip It is then a simple process of unzipping the file to a directory and running it - First mistake.

I then spent ages trying to get the program to see the SD card. Windows would detect the card as soon as I plugged in the USB reader with the SD card fitted, but Win32DiskImager would not see it. That's when I discovered that you have to have the SD card seen by Windows before you run the application - simple really. The instructions do tell you to insert the the SD card first before even downloading the utility. So lesson 1 - curb the excitement and follow the nicely written instructions.

It is then a simple matter of choosing the image to write and selecting the correct drive for the SD card and finally clicking the Write button. So I now have a nice new 4GB SD card with the latest version of Raspbian on it ready to be plugged into my Raspberry PI.

Now the moment of truth - does it work.

I connected everything up following the Quick start guide - Keyboard, mouse, DVI monitor (using a HDMI to DVI lead) and even an Ethernet connection (spare one lying on the desk). Finally time to apply power.

Lots of text scrolling up the screen can only be seen as a successful start. After a while the Raspi-config window appears. The Quick start guide suggest changing the Locale and Timezone. I only changed the Timezone as I was not sure which of the cryptic Locale names to choose. You have to use the keyboard arrow keys to select the menu options as the mouse does not work (Yet ?).

I then expanded the root partition to fully utilise the SD card I am using. I also Enabled ssh as I would like to use my main PC to access the PI - saves having two keyboards and mouse on my desk to get confused with. Selecting finish suggest a Reboot, so why not.

After the reboot had completed I was left with a nice simple login prompt. So I entered the default user name "pi" and password "raspberry" and got to the command prompt. One of the things I did know about Linux is it does not show any characters when entering the password. So you have to be careful as you get no indication if you accidentally press two keys.





Tuesday, 19 February 2013

Why a Raspberry PI

So here we go then with my first Blogger post on my chosen subject of the Raspberry PI. I have spent a lot of years designing electronics for various products mostly for the telecoms market. This has included many designs using various processors and operating systems. However I have not written much in the way of software, only the odd bit of test code to prove some hardware functionality. This is what I want to change. I want to know more about software and operating systems like Linux.

For all the projects I have worked on, a small team of people have been responsible for getting the software development environment set up and then writing the software. Then I come along and taken something that is already working and add some small bits of code - nice and easy for me. This does mean that I have very little knowledge of the software and can only guess where you would start.

I have attempted in the past to learn more by getting hold of some processor evaluation boards with some grand ideas for projects. These projects have usually failed fairly quickly because they either require you to then spend thousands on the development tools or assume you already know how to set up the development environment. They typically come with very little or even NO working examples. These evaluation boards are slowly getting better, many now come with free (but limited) development tools and examples to get you going. But those that have good support tend to come with a price tag to match.

Then the Raspberry PI was launched. This looked like it might be my ideal learning platform. It is cheap and has a fast processor, lots of RAM and storage, Networking, usable GPIO and even a pre-configured operating system that you can easily download. It also has a lot of people in the same position as me, trying to learn as much as possible from a growing bunch of very helpful experts. What more could you ask for.

So let the fun begin.