...

Raspberry Pi

Raspbian install (3.2015)

Downoaded Raspbain Wheezy (2015-02-16-raspbian-wheezy.img, Version:February2015, ReleaseDate:2015-02-16, KernelVersion:3.18) from http://downloads.raspberrypi.org/raspbian_latest Wanted to install on an SD card that already had an old OS on it,
$ df -h 
showed /dev/mmcblk0p1 and /dev/mmcblk0p1
$ umount /dev/mmcblk0p1
unmount both the partitions
$ umount /dev/mmcblk0p2
unmount both the partitions
$ df -h
check that the partitions are unmounted
$ sudo dd bs=4M if=Desktop/2015-02-16-raspbian-wheezy.img of=/dev/mmcblk0
image to sd card
$ sync
flush
ssh to the raspberry pi, Default login:pi / raspberry
$ sudo raspi-config
$ sudo apt-get update

$ wget http://nodejs.org/dist/v0.10.2/node-v0.10.2-linux-arm-pi.tar.gz 
installing node
$ tar -xvzf node-v0.10.2-linux-arm-pi.tar.gz $ node-v0.10.2-linux-arm-pi/bin/node --version
node running from here
$ node-v0.10.2-linux-arm-pi/bin/npm
npm running from here
added "export PATH=$PATH:~pi/node-v0.10.2-linux-arm-pi/bin" to the end of .bashrc
$ sudo apt-get install avahi-daemon
for zero conf, was then able to avahi-discover to see the pi to get it's IP
$ sudo apt-get install espeak $ espeak "hello world"
working, out of headphone jack, but was also getting some ALSA errors

Also, can use nmap to try to get IP, to connect from another machine.

See this tutorial to use to login from a serial console.

How to set up the RPi as an AP.


Prepping the SD Card:

Bought Kingston 4GB Class 4 SDHC card (SD4/4GB). Followed instructions from
http://elinux.org/RPi_Easy_SD_Card_Setup


Debian Squeeze install (old):

Downloaded debian squeeze.
http://downloads.raspberrypi.org/images/debian/6/debian6-19-04-2012/debian6-19-04-2012.zip
verify download
$ sha1sum debian6-19-04-2012.zip
1852df83a11ee7083ca0e5f3fb41f93ecc59b1c8

$ unzip debian6-19-04-2012.zip 
Archive:  debian6-19-04-2012.zip
   creating: debian6-19-04-2012/
  inflating: debian6-19-04-2012/debian6-19-04-2012.img.sha1  
  inflating: debian6-19-04-2012/debian6-19-04-2012.img 

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
...
/dev/mmcblk0p1        3.7G   32K  3.7G   1% /media/231D-221A
(this means device is /dev/mmcblk0, with partition p1) unmount the whole thing
$ umount /dev/mmcblk0p1

$ sudo dd bs=1M if=debian6-19-04-2012.img of=/dev/mmcblk0
(took a looong time, dd command does not give any information of its progress and so looks like frozen.)
1859+1 records in
1859+1 records out
1950000000 bytes (2.0 GB) copied, 348.278 s, 5.6 MB/s
ensure the write cache is flushed and that it is safe to remove the SD card
$ sudo sync
insert the card in again, then
$df -h
Filesystem            Size  Used Avail Use% Mounted on
...
/dev/mmcblk0p2        1.6G  1.2G  298M  80% /media/18c27e44-ad29-4264-9506-c93bb7083f47
/dev/mmcblk0p1         75M   28M   47M  37% /media/95F5-0D7A

The RPi image is designed for a 2G card, this was a 4G card. so using gparted to claim the unused space.
The card had p1, a small unallocated piece, p2 (ext4), swap, and the rest to the end is unallocated.
Moved the swap partition (keeping the same size) all the way to the end. So now the large unallocated piece is between p2 and swap.
Then unmounted p2, and resize it (move the right edge) to have it take over the unallocated piece. Apply the changes.

Inserted this into the raspberry pi, turned on, it booted up, then restsrted itself, then asked to login,
Default login Username: pi Password: raspberry

Sweet!

Set the timezone

$ sudo dpkg-reconfigure tzdata
Set the date and time
$ sudo date --set="2012-07-04 10:22"

To enable ssh:

$ sudo ssh-keygen
(should have created the keys in /root/.ssh/)

To make it start up automatically
$ sudo update-rc.d ssh defaults
I gave it a static IP from the router DHCP, so I can have it run headless and still ssh into it.


Installing the Adafruit Occidentalis image:

Instructions from here

Downloaded http://adafruit-raspberry-pi.s3.amazonaws.com/Occidentalisv02.zip.
Unzipped it, it is a 2.6G img file. Verified integrity of the img
$ sha1sum Occidentalis_v02.img
a609f588bca86694989ab7672badbce423aa89fd
Put the sdcard on the computer, then
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/mmcblk0p1  3.7G   32K  3.7G   1% /media/2A31-221A
Copy the image over (Note that the "of" target is the mount point, without the partition portion in the name "mmcblk0")
$ sudo dd bs=4M if=Occidentalis_v02.img of=/dev/mmcblk0
This took a looong time, dd does not give any progress indication while it does its stuff.
619+1 records in
619+1 records out
2600000000 bytes (2.6 GB) copied, 460.289 s, 5.6 MB/s
Flush the writes
$sudo sync
Remove the card, and insert it again. Should be able to see the copied image. Note that the second partition is not being used (we'll reclaim that later during the raspi-config)
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/mmcblk0p1   56M   37M   20M  66% /media/A1B1-918F
/dev/mmcblk0p2  2.4G  1.8G  490M  79% /media/10b4c001-2137-4418-b29e-57b7d15a6cbc

Put sdcard into raspi and booted up. It generated the ssh keys. Thenthen the raspi- config screen came up.
Chose expand_rootfs, (to make the whole 4 card available)
Chose to enable ssh-server
Note, should be able to run raspi-config again later using

sudo /usr/bin/raspi-config
(default login is pi raspberry)

This Occidentalis build apprently has I2C, SPI and Onewire support. See adafruit learning for some details on this. Also hardware RTC, modules for Serv, PWM, some sensors...

Note, do this for a clean hard shutdown:
$ sudo shutdown -h now

Connecting a USB powered hub:

Got this powered hub (Model UH5200T) from TigerDirect and connected it.

$ dmesg | grep -i usb

usb 1-1.2: new high speed USB device number 4 using dwc_otg
usb 1-1.2: New USB device found, idVendor=05e3, idProduct=0608
usb 1-1.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
usb 1-1.2: Product: USB2.0 Hub
hub 1-1.2:1.0: USB hub found
Also tried using this hub, this seemd to work fine too. I don't remember where I got it from (dx.com maybe ?)

Both the hubs took 5V through a small barrel connector for the external power.
Read up some notes regd. Raspberry Pi power options (elinux RPi site). The generic hub was able to back power the RPi (but the RPi was not able to recognize the wireless dongle, when connected in this fashion). Had to also power te RPi separately through the microUSB, in order for the wireless dongle to be recognized.

The UH5200T hub was not backpowering the RPi, probably smarter model that only powers connected USB devices.


Wireless:

Got this wireless dongle from Adafruit. Apparently they have support for this dongle (Realtek RTL8188CUS chipset?) built in to the Occidentalis distribution.
  • RTl8192cu Chipset
  • Wireless Standards: IEEE 802.11n (draft), IEEE 802.11g, IEEE 802.11b
  • Host Interface: High speed USB2.0/1.1 interface
  • Data Rate: 802.11n: up to 150Mbps (downlink) and up to 150Mbps (uplink) , 802.11g: 54 / 48 / 36 / 24 / 18/ 12 / 9 / 6 Mbps auto fallback, 802.11b: 11 / 5.5 / 2 / 1 Mbps auto fallback
  • Frequency Band: 2.4GHz ISM (Industrial Scientific Medical) Band
  • Chipset: Realtek
  • RF Frequency: 2412 ~ 2462 MHz (North America), 2412 ~ 2472 MHz (Europe), 2412 ~ 2484 MHz (Japan)
  • Radio Channel: 1 ~ 14 channels (Universal Domain Selection)
  • Range Coverage: Up to 3 times farther range than 802.11g
  • RF Output Power: 13 ~17 dBm (Typical)
  • Modulation: 11n: BPSK, QPSK, 16QAM, 64QAM with OFDM, 11g: BPSK, QPSK, 16QAM, 64QAM, OFDM, 11b: DQPSK, DBPSK, DSSS, CCK
  • Data Security: 64/128-bit WEP Encryption WPA, WPA-PSK, WPA2, WPA2-PSK. TKIP/AES
  • Network: Auto-switch to use 802.11n or 802.11g or 802.11b mode Supports Ad-Hoc, Infrastructure WLAN network, Wireless roaming, Data rate auto fall-back under noisy environment or longer range distance, Site Survey with Profile function
  • Media Access Control CSMA/CA with ACK
  • LED Indicator Link/Active ( Green )
  • Requirements Available USB 2.0 port
It really "just works" with the Occidentalis distro. Typing
$ifconfig -a 
showed a wlan0 entry.
Used
$ sudo vi /etc/network/interfaces
to set ssid and wireless password. On the wireless routher, this showed up as a wireless device ("raspberrypi"). Gave it a static ip, and changed the device name in the router list for this to "raspberrypi2"

Python related:

Python (2.7) was already available, with the Debian install
Installed pyserial

$ sudo apt-get install python-serial

Installed RPi.GPIO package
$ wget http://raspberry-gpio-python.googlecode.com/files/RPi.GPIO-0.2.0.tar.gz
$ tar zxf RPi.GPIO-0.2.0.tar.gz
$ cd RPi.GPIO-0.2.0
$ sudo python setup.py install 
sample program
#!/usr/bin/python

import time
import RPi.GPIO as GPIO 

GPIO.setmode(GPIO.BCM)

GPIO.setup(18, GPIO.OUT)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(25, GPIO.OUT)


while True:
    GPIO.output(25, False)
    GPIO.output(18, True)
    time.sleep(0.5)  
    GPIO.output(18, False)
    GPIO.output(23, True)
    time.sleep(0.5) 
    GPIO.output(23, False)
    GPIO.output(24, True)
    time.sleep(0.5) 
    GPIO.output(24, False)
    GPIO.output(25, True)
    time.sleep(0.5) 

Connecting a webcam:

Connected a webcam (Logitech RightLight2 something) to the powered USB hub.

$ dmesg | grep -i usb

usb 1-1.2.1: new high speed USB device number 5 using dwc_otg
usb 1-1.2.1: New USB device found, idVendor=046d, idProduct=0992
usb 1-1.2.1: New USB device strings: Mfr=0, Product=0, SerialNumber=2
usb 1-1.2.1: SerialNumber: 55A0B8ED
usbcore: registered new interface driver snd-usb-audio

Installing mjpg-streamer:

Wanted to be able to stream from the webcam, so wanted to install mjpeg-streamer on the debian squeeze image.
Got mjpg-streamer-r63.tar.gz source code from sourceforge, and scp'd it over to the RPi.
http://sourceforge.net/projects/mjpg-streamer/files/mjpg-streamer/Sourcecode/mjpg-streamer-r63.tar.gz/download

$ gunzip mjpg-streamer-r63.tar.gz
$ tar -xvf mjpg-streamer-r63.tar
$ cd mjpg-streamer-r63
$ sudo apt-get install libjpeg8-dev

looks like I might have to get uvc video support on the debian kernel, first. see http://tsuki-chama.livejournal.com/363418.html

USB camera support:

Tried to get the Raspberry Pi with the Occidentalis build to pick up USB cameras.

Plugged in the Lifecam usb camera
[  811.065889] usb 1-1.3.1: New USB device found, idVendor=045e, idProduct=0728
[  811.065926] usb 1-1.3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  811.065947] usb 1-1.3.1: Product: Microsoft LifeCam VX-5000
[  811.065964] usb 1-1.3.1: Manufacturer: Microsoft
[  811.253597] Linux video capture interface: v2.00
[  811.275818] uvcvideo: Found UVC 1.00 device Microsoft LifeCam VX-5000 (045e:0728)
[  811.285749] input: Microsoft LifeCam VX-5000 as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0/input/input3
[  811.290660] usbcore: registered new interface driver uvcvideo
[  811.290698] USB Video Class driver (1.1.1)
[  811.469019] usbcore: registered new interface driver snd-usb-audio
Now had a /dev/video0 entry

Tried pygame code to fire up the camera

[ 1388.622782] INFO:: schedule_periodic: No host channel available for periodic transfer.
[ 1388.622794] 
[ 1388.623056] ERROR::dwc_otg_hcd_urb_enqueue:518: DWC OTG HCD URB Enqueue failed adding QTD. Error status -4008
uvcvideo: Failed to submit URB 0 (-4008).

EnvironmentError: ioctl(VIDIOC_STREAM) failure : 4008, Unknown error 4008
Tried with the Rightlight camera
[ 1929.741953] usb 1-1.3.1: new high speed USB device number 10 using dwc_otg
[ 1929.958355] usb 1-1.3.1: New USB device found, idVendor=046d, idProduct=0992
[ 1929.958395] usb 1-1.3.1: New USB device strings: Mfr=0, Product=0, SerialNumber=2
[ 1929.958416] usb 1-1.3.1: SerialNumber: 55A0B8ED
[ 1929.965732] uvcvideo: Found UVC 1.00 device  (046d:0992)
[ 1930.003405] input: UVC Camera (046d:0992) as /devices/platform/bcm2708_usb/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0/input/input4
Saw the same error

Then tried to see if I could get uvccapture to work

 $ sudo apt-get install uvccapture
 Setting up uvccapture (0.5-2) ...

$ uvccapture -S80 -B80 -C80 -G80 -x640 -y480
it seemed to light up the camera, and then
ioctl querycontrol error 5
Unable to start capture: 4008
Error grabbing

Tried with sudo, tried adding user pi to video group,

$ sudo usermod -a -G video pi

$ id pi
uid=1000(pi) gid=1000(pi) groups=1000(pi),4(adm),20(dialout),24(cdrom),27(sudo),29(audio),44(video),46(plugdev),60(games),100(users),1001(input)
Nothing worked. I'm giving up, and waiting to see if the upcoming Pi camera will work out.

Note: check out the foll, links, see if we gan get any further with webcam related:
guvcview
http://wolfpaulus.com/category/journal/embedded (http://wolfpaulus.com/journal/embedded/raspberrypi_webcam)
http://www.oz9aec.net/index.php/gstreamer/473-using-the-logitech-c920-webcam-with-gstreamer