First, download a clean raspbian image from the official RPI site http://www.raspberrypi.org/downloads. Then, unzip it.

We need to customize the image we just downloaded, install programs and configure the system for our needs.

For this, no need to install the image on the Pi yet. By using a machine emulator, we can fake a Raspberry Pi on our laptop, install our image there, and do all the configuration we need. We'll use a machine emulator called QEMU. You also need a RPI Linux kernel compiled for QEMU, which you can get here.

To configure our RPi image on Windows, we will need the following:

Create a working directory, e.g. C:\qemu. Unzip the Raspbian zip file and place the contents of it in C:\qemu. Move the kernel-qemu file to the same location. Unzip Qemu-1.6.0-windows.zip to C:\qemu as well

We will need to create two .bat files in the C:\qemu directory:

  1. rpi_setup.bat for setting up the image file so it can be emulated using Qemu;
  2. rpi_start.bat for emulating and doing the rest of the setup we need.

Let's start with adding content to the rpi_setup.bat file. Add the following:

qemu-system-armw -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 init=/bin/sh panic=1" -hda 2013-09-25-wheezy-raspbian.img

Note the 2013-09-25-wheezy-raspbian.img part - change the filename to whatever your raspbian image file name is. Remember to save changes.

Open the rpi_start.bat file. Add the same, except init=/bin/sh. It should look like this now:

qemu-system-armw -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda 2013-09-25-wheezy-raspbian.img

Save file and doubleclick on the rpi_setup.bat. A new window should open with a booting Linux system in it.

Note: if the emulator fails to run:

  1. Check if the path to your Raspbian image file is correct;
  2. It might be necessary to add the C:\qemu location to Windows Path variable.

Now you should see a plain and simple Linux shell in the emulator window. Execute these commands one by one there:

mount / -o remount,rw
echo > /etc/ld.so.preload
mount / -o remount,ro
exit

Enter these commands exactly as writen above or you will fail. The shell is very sensitive. This will remove all contents from the /etc/ld.so.preload file. Close the emulator window. Now the Raspbian .img file is ready to be booted.

Doubleclick the rpi_start.bat file. The Raspbian Linux should start. When fully booted, a config screen with blue background should be visible. Do the following:

  1. Change password;
  2. Enable SSH;
  3. And maybe overclock a bit.

Exit the config tool by selecting Finish (navigate by using the Tab key), later you will be able to access the tool by issuing the sudo raspi-config command.

If the system shuts down, click on the rpi_start.bat file again to restart the emulator.

Now, do this to install QEMU:

sudo apt-get install qemu-system

Now, we need to launch it and run our image. First, execute:

file your-raspbian.img

From the output of this command, take the partition 2 'startsector' value and multiply by 512, and use this figure as the offset value in the mount command below.

sudo mount your-raspbian.img -o offset=62914560 /mnt
nano /mnt/etc/ld.so.preload

Press Ctrl+X to save file and exit. Then unmount the image.

sudo umount your-raspbian.img

Make sure that you are in workshop working directory, then, you can start QEMU with your image:

qemu-system-arm -kernel your-linux-kernel -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda your-raspbian.img -redir tcp:5022::22

If it says that running fsck failed, just run

fsck /dev/sda2

and restart the emulator when done.

Because this is the first time we start the image on a machine, you will be prompted with a menu allowing you to configure some options. Don't forget to change your password, and to change the keyboard layout.

Download OSXFUSE. When installing, check the Compatibility Layer with MACFUSE (old version of OSXFUSE) option.

Download FUSE-EXT2 binary. Install it and unmount the OSXFUSE and FUSE-EXT2 installation drives.

Edit the FUSE-EXT2 auto mount script for read-write mounting. Open /System/Library/Filesystems/fuse-ext2.fs/fuse-ext2.util and around line 207 (in function Mount ()) you will find the line

OPTIONS="auto_xattr,defer_permissions"

Change that line to:

OPTIONS="auto_xattr,defer_permissions,rw+"

Save file, restart Terminal and navigate to your RPi workshop directory. Run:

sudo hdiutil mount your-rpi-image.img

You should see something like this:

/dev/disk1         FDisk_partition_scheme          
/dev/disk1s1        Windows_FAT_32        /Volumes/boot
/dev/disk1s2        Linux                 /Volumes/Untitled

Navigate to the mounted Linux partition:

cd /Volumes/Untitled

Run:

sudo nano etc/ld.so.preload

Comment out the only line there so it looks like this:

#/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so

Press Ctrl+X (Not Cmd+X) to save file and exit.

Before installing QEMU, make sure that you have MACPORTS. MACPORTS depend on XCode Command Line Tools that depend on XCode. To get XCode, go to Apple Developer website or use App Store application. XCode Command Line tools are only available through Apple Developer website.

Now, do this to install QEMU:

sudo port install qemu +target_arm

Make sure that you are in workshop working directory, then, you can start QEMU with your image:

sudo qemu-system-arm -kernel your-linux-kernel -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1" -hda your-raspbian.img -redir tcp:5022::22

Because this is the first time we start the image on a machine, you will be prompted with a menu allowing you to configure some options. Don't forget to change your password, and to change the keyboard layout.

References

Running the Raspbian image on a virtual machine is fine for the configuration phase, but we also need to have an access to the system while it is running on the board. For this we will use SSH.

SSH is already enabled on the last Raspbian versions, but we need to make sure the SSH client is running when we boot the Pi. To do that, run the following command in the emulator :

sudo update-rc.d ssh defaults

Then, as we will connect directly the Pi to our computer through a network cable, we need to configure a network. We will assign our Pi a static IP address, so we can find it from our laptop. For this open the file /etc/network/interfaces in the nano text editor:

sudo nano /etc/network/interfaces

Replace the contents of it with the following:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static

address 192.168.0.210   # your IP  
gateway 192.168.0.1     # IP of the Router
netmask 255.255.255.0   # Network mask

Press Ctrl+X to save and exit. The program will prompt you whether you want to save chenges - enter 'y' for 'yes' and hit Enter. Run the following command to shutdown:

sudo halt

References

The first thing we need to do is format the SD card to FAT32 (beware, this will erase all your data). For this, just open the disk utilities, find your SD card there, remove all existing partitions, and create a new one. When this is done, eject the card from the reader.

Now, you need to find the name of your SD card on your computer. But, don't insert the card yet and run :

df -h

Now insert the card and run the same command. The new partitions appearing in the list correspond to your SD Card. Unmount all these partitions using the umountdiskutil unmount command

Finally, let's install the image to the SD card. Now be very careful. You need to input the right device name or you might lose all the data on your computer (no joke).

dd bs=1m if=your-raspbian.img of=/dev/your-device-name

This should take a couple of minutes, so be patient even if nothing seems to happen.

Use SDFormatter to format the SD card. Select the Overwrite Format option before pressing Format.

Open Terminal, navigate to your working directory by using the cd command and run the following command:

diskutil list

You should see something like this:

/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *256.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            255.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *7.9 GB     disk1
   1:             Windows_FAT_32 boot                    58.7 MB    disk1s1

We are interested in the /dev/disk1 part - unmount it by unmounting it's partition. Enter this command in the Terminal window:

diskutil unmount /dev/disk1s1

Now the SD card is ready, remember the device path /dev/disk1 - you will need to add an 'r' before the disk1 part - it should increase the writing speed. Run the following command, but be careful as you can overwrite the whole contents of your hard drive just by missing out some letters:

dd bs=1m if=your-raspbian.img of=/dev/rdisk1

Note: replace the your-raspbian.img part with the actual name of your image file.

Now wait. It can take a couple of minutes for the computer to finish the task. Yes - there is no indicator that shows the progress, but you can open Activity Monitor to see that there is something happening if you start becomming inpatient.

When the installing is finished, place the SD card in your Raspberry Pi and start it up.

Now the image should be ready for burning on the SD card. To do that use SDFormatter to format the SD card and Win32DiskImager to burn the image file on to the SD card.

Note that you have to select the ON option in the Format Size Adjustment select box in the SDFormatter application options before you do the formatting. Be careful with selecting the correct drive letter as well.

The WinDiskImager application should be self-explainatory. Just select the Raspbian image file and the SD card drive and press Write

Reference http://elinux.org/RPi_Easy_SD_Card_Setup

Reference http://www.raspberrypi.org

Reference http://www.raspberrypi.org

Insert the SD card into the SD card slot of the Raspberry Pi, connect it to the local with an ethernet wire and power it up by connecting the power cable.

We will need to do two things remotely:

  1. Run commands on the Raspberry Pi;
  2. Upload files.

To run commands we will need to establish a SSH (Secure Shell) connection between our desktop computer and the Raspberry Pi. To do that, open Terminal and execute the following command:

ssh pi@192.168.0.201

Please note that you have to replace the 192.168.0.201 with the IP address of your Raspberry Pi.

We will use FileZilla for uploading files. Download and install it. When creating a new connection, you should specify SFTP as the Protocol.

We will need to do two things remotely:

  1. Run commands on the Raspberry Pi;
  2. Upload files.

To run commands we will need to establish a SSH (Secure Shell) connection between our desktop computer and the Raspberry Pi. To do that, open Terminal and execute the following command:

ssh pi@192.168.0.201

Please note that you have to replace the 192.168.0.201 with the IP address of your Raspberry Pi.

We will use FileZilla for uploading files. Download and install it. When creating a new connection, you should specify SFTP as the Protocol.

We will need to do two things remotely:

  1. Run commands on the Raspberry Pi;
  2. Upload files.

To run commands we will need to establish a SSH (Secure Shell) connection between our desktop computer and the Raspberry Pi. Download PuTTY for Windows for doing that.

To upload files we will use a tool that supports the SCP file transfer protocol. In the case of Windows there is WinSCP.

In both programs you will need to enter the IP address of the Raspberry Pi, it's username (most probably it is 'pi') and password (if you have not changed it in the previous steps, it might be 'raspberry').

When you have successfuly connected to your Pi the first time, you should run the config tool and expand the filesystem:

sudo raspi-config

Select the Expand Filesystem option. Go to Advanced Options and Select the Memory Split option. Type 128 and Hit Ok.

When done, select finish (by using Tab key on your keyboard and select Yes when prompted to reboot). The Pi will reboot and you will have to reconnect through SSH again.

Next - you should update and upgrade it. To do that, run the following commands:

sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade

The updating and upgrading process will take some time so be patient.

Reference http://www.openframeworks.cc/setup/raspberrypi/Raspberry-Pi-Getting-Started.html

We need the Linux armv6 verson of openFrameworks. With the following commands we will download and uncompress it into the folder /home/pi/openFrameworks

cd ~
wget http://www.openframeworks.cc/versions/v0.8.0/of_v0.8.0_linuxarmv6l_release.tar.gz
mkdir openFrameworks
tar vxfz of_v0.8.0_linuxarmv6l_release.tar.gz -C openFrameworks --strip-components 1

Reference http://www.openframeworks.cc/setup/raspberrypi/Raspberry-Pi-Getting-Started.html

We need to make sure that we have all necessary packages to compile openFrameworks. To do that, run these commands:

cd /home/pi/openFrameworks/scripts/linux/debian_armv6l
sudo ./install_dependencies.sh

This will take some time, but when ready, run the following command to start compiling openFrameworks itself:

make Release -C /home/pi/openFrameworks/libs/openFrameworksCompiled/project

The compiling process should take about an hour. It is possible that you encounter an error containing:

../../../libs/openFrameworks/app/ofAppEGLWindow.cpp:1073:66: error: cannot convert 'VC_IMAGE_TRANSFORM_T' to 'DISPMANX_TRANSFORM_T'

To solve that, run this:

sed -i 's/VC_IMAGE_TRANSFORM_T/DISPMANX_TRANSFORM_T/g' /home/pi/openFrameworks/libs/openFrameworks/app/ofAppEGLWindow.cpp

Run the make command again if necessary.

When complete, navigate to the /home/pi/openFrameworks/examples directory to see the available examples there. Choose one, e.g. polygonExample, enter it's directory by using cd polygonExample and execute the followig:

make
make run

The make command will compile the project, the make run - execute it. A screen should be connected to the RPi to see the output.

Reference http://www.openframeworks.cc/setup/raspberrypi/Raspberry-Pi-Getting-Started.html

While openFrameworks is compiling on the Raspberry Pi, make sure that your desktop computer installation of openFrameworks works as expected as we will use our desktop machines for developing and testing our apps mainly.

To use openFrameworks on Mac OSX, you have to make sure that you have XCode installed. If not, open the App Store application and search for XCode there or go to Apple Developer web site, log in and download XCode from there.

Download openFrameworks 0.8.0 for Mac OSX.

To use openFrameworks on Windows, you have to set up a development environment. We will install CodeBlocks (with MinGW), but if you have a Microsoft Visual Studio licence, you can use it as well.

You will also need Additions to CodeBlocks to work with openFrameworks. You will need to add files to your CodeBlocks installation include and lib directories.

Download openFrameworks 0.8.0 for Windows.

Unzip it to as safe location and go to libs/openFrameworksCompiled/project/win_cb directory and open the openFrameworks.cbp file. It should open in the CodeBlocks environment. Press the Build button. Do it for both - debug and release - targets

To test the openFrameworks installation, try to open and compile one of the example projects in the openFrameworks/examples directory. Open the .workspace project file, choose target in the CodeBlocks IDE and press Build and Run.

Reference http://www.openframeworks.cc

Auto-login the pi user

Run

sudo nano /etc/inittab

Comment the line starting the terminal tty1 ("1:2345:respawn:/sbin/getty 115200 tty1"), and just bellow it add :

1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1

Starting a program on boot

In /home/pi create an executable shell script called startup.sh :

touch startup.sh
chmod a+x startup.sh

Then open .bashrc and add the following line at the end of the file :

~/startup.sh

Now whatever commands are in startup.sh are exectued on boot of the system. We want to run our programm, so open startup.sh and add the following inside :

#!/bin/bash
/home/pi/openFrameworks/apps/myApps/blankExample/bin/blankExample

Remember to change the blankExample with the app that you have made.

There is another way using crontab. Execute this command to open the crontab editing mode:

sudo crontab -e

At the bottom of the file add this:

@reboot /home/pi/openFrameworks/apps/myApps/blankExample/bin/blankExample

Again - remember to replace the blankExample part with path to your application. Don't do both ways, as it will start your programm twice and it will eat RPi resources twice as bad.

Now to test that this works, reboot your Pi by running :

sudo reboot

Reference http://elinux.org/RPi_Debian_Auto_Login