The Raspberry Pi single board computer is something that I first heard about back in the spring, but the initial release was quick to sell out. So I was waiting until such time to acquire my own and I have read on some forums that people have them on back order for weeks. Fortunately for me Farnell in Canada had them in stock, and I managed to pick up two right away with no wait. So here now is my overview and initial setup of my Raspberry Pi Computer. Helpful links will be listed at the end of the article.
There were a couple of things that interested me with the R-Pi.
- Experimenting with assembler programming. Also known as 'Bare Metal' programming.
- Adding a Propeller microcontroller to the GPIO pins. I will show later how to setup a complete stand alone programming environment for the Prop.
- The addition of a Real Time Clock. This proved to be more difficult than I had imagined.
But first I had to get it up and running. I downloaded the Weezy image from the Raspberry Pi website and created the image on an 8Gb SD card, plugged in a monitor, keyboard, mouse, and network cable and turned on the power. Everything started up as it should. The first thing to do was to change the keyboard layout to US, as it defaults to UK and some of the keys are switched around. The next thing to do was to expand the partition to fill the rest of the SD card. You will need to do this if you want to add any real software. At this point you need to reboot in order for the R-Pi to re-size the partition.
A word of caution: As I was playing around the the R-Pi, it would freeze quite often when installing software which would also corrupt the image and require starting all over again. After much frustration, it turns out that the SD card socket wasn't making good contact with the card. After taking a pair of tweezers and slightly bending the fingers, the card now works perfectly.
Eventually I was up and running. Now I have tried Linux in the past, and I've been around since the days of DOS but I am pretty much a noob when it comes to the command line interpreter in Linux. So there was a bit of a learning curve. I found a website with a great tutorial on the basics of using UNIX which is the basis for Linux. You can find the tutorial here, which covers all the basic operations and is a great resource.
After pouring over many websites trying to add a driver to the Weezy image for a real time clock. I eventually found out that you can't simply add it to the kernel. As I am still too new to try my hand at compiling my own image, I downloaded a pre-compiled image with the real time clock drivers already added. It is called the Adafruit - Occidentials v0.2. This image contains the I2C drivers as well as a multitude of clock drivers. Make sure that you are using v0.2, as v0.1 won't work.
After installing this image and connecting our DS1338 based Real Time Clock, and following the initialization, the clock worked like a charm. You can follow the instructions at Adafruit here to initialize your clock.
Now with a working clock, I turned my attention to attaching a Propeller to the R-Pi. After a google search, I found that the program SimpleIDE combined with PropGCC would do the trick nicely. By connecting the TX, RX, and /RES lines from the R-Pi to the Prop, a stand alone programmer can be had. Below is a summary of how to get it up and running. The original forum link where this information came from is here.
- First you must edit two files in order to setup the UART to communicate to the Prop.
- Edit the /boot/cmdline.txt and change it
dwc_otg.lpm_enable=0 rpitestmode=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
dwc_otg.lpm_enable=0 rpitestmode=1 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
- Edit the /etc/inittab to remove the login (getty). Just comment out the following by putting a # in front. It will be at the end of the file.
2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
- Next, in a terminal window, download the SimpleIDE program.
$ wget http://dl.dropbox.com/u/81267937/SimpleIDE-0-8-4.armv6l.raspberrypi-linux.tar.bz2
- After downloading, unpack the package.
$ tar -jxf SimpleIDE-0-8-4.armv6l.raspberrypi-linux.tar.bz2
- Once unpacked, change to the package directory and install the program. 'pi' is the username. Replace with your username if different.
$ sudo ./setup.sh pi
- Now you have to replace the Propeller-Load program in order for SimpleIDE to be able to program the Prop directly over the GPIO pins. Download the program here, and update as below.
- Make a backup of your current propeller-load program
$ sudo cp /opt/parallax/bin/propeller-load /opt/parallax/bin/propeller-load.bak
- Put the attached propeller-load-rpi in it's place
$ sudo cp propeller-load-rpi /opt/parallax/bin/propeller-load
- Next we need to let the loader run as root to access the GPIO:
$ sudo chown root /opt/parallax/bin/propeller-load
$ sudo chmod +s /opt/parallax/bin/propeller-load
- Finally, it's time to run the program.
- Connect your Propeller to the R-Pi GPIO header as follows:
Under the settings of SimpleIDE, change the programming reset line to RTS, create a SPIN project and try programming the Prop. I used a simple program to flash an LED on pin 0 of the Prop as a test. Now you have a stand alone development system.
Hopefully this will help others like myself that are new to the Raspberry Pi and Linux, and will shorten the learning curve.
Below is a list of the links above as well as a few others of interest.
100RandomTasks.com DS1338 based Real Time Clock
Adafruit - Occidentalis v0.2
SimpleIDE-0-8-3 forum link.
SimpleIDE Propeller Load Program.
UNIX Beginners Tutorial.
How to setup your R-Pi for C programming.
A link to setup your R-Pi as a NAS, but also shows how to setup the Samba Server on your R-Pi.
Baking Pi - Operating System Development.
FASARM - Assembler for ARM, useful for 'Bare Metal' programming.