Recovery Pi

17 07 2012

My previous single Raspberry Pi posts have been steps towards my “Recovery Pi”

a small self sufficient system that can be shipped to
a remote site to facilitate serial (console) & network
(mgmt lan) connectivity to the remote devices

• Raspberry Pi ($45)
http://www.raspberrypi.org/faqs

• USB->Serial Convertor ($30)
http://www.jaycar.com.au/productView.asp?ID=XC4834

• Cisco Console Cable

• Telstra 3G “Elite” USB Modem ($29)
http://www.telstra.com.au/internet/mobile-broadband-prepaid/get-started/#tab-elite-usb
– Telstra AUS Mobile Internet $180/year (365 day access | 1.46c per MB in AUS | $15.36 per MB Intl Roaming)

• 8GB SDHC Mem Card ($10)

• USB Power Brick (~10hrs run) ($20)
http://www.tevion-cameras.com/popups/MPP_7400_au_popup_02/

• USB Powered Hub ($18)
http://hakshop.myshopify.com/products/usb-powered-hub

• Total Retail Startup Cost: $152 AUD


===Built on the existing Debian Squeeze image===

http://downloads.raspberrypi.org/images/debian/6/debian6-19-04-2012/debian6-19-04-2012.zip

===Telstra 3G USB Modem===

root@raspberrypi:~# apt-get install usb-modeswitch pppd

root@raspberrypi:~# dmesg | grep ttyUSB
usb 1-1.2.4: GSM modem (1-port) converter now attached to ttyUSB0
usb 1-1.2.4: GSM modem (1-port) converter now attached to ttyUSB1
usb 1-1.2.4: GSM modem (1-port) converter now attached to ttyUSB2
usb 1-1.2.3: pl2303 converter now attached to ttyUSB3

root@raspberrypi:~# cat /etc/chatscripts/telstra
ABORT ‘NO CARRIER’
ABORT ‘NO DIALTONE’
ABORT ‘BUSY’
ABORT ‘ERROR’
ABORT ‘NO ANSWER’
” ‘ATZ’
OK ‘AT&F’
OK ‘ATQ0 V1 E1′
OK ‘AT&D2 &C1′
OK ‘AT+FCLASS=0′
OK ‘ATS0=0′
OK ‘AT+CGDCONT=1,”IP”,”telstra.internet”‘
OK ‘ATDT*99#’
CONNECT ”

root@raspberrypi:~# cat /etc/ppp/peers/telstra
/dev/ttyUSB2
460800
modem
crtscts
defaultroute
noipdefault
usepeerdns
ktune
noauth
lock
nobsdcomp
novj
connect “/usr/sbin/chat -v -f /chatscripts/telstra”

root@raspberrypi:~# pon

root@raspberrypi:~# ifconfig ppp0
ppp0      Link encap:Point-to-Point Protocol
inet addr:10.138.162.113  P-t-P:10.64.64.64  Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP PROMISC MULTICAST  MTU:1500  Metric:1
RX packets:705 errors:0 dropped:0 overruns:0 frame:0
TX packets:624 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:621353 (606.7 KiB)  TX bytes:40301 (39.3 KiB)

root@raspberrypi:~# poff

===3G Connection On Boot===

root@raspberrypi:~# cat /etc/network/interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo
iface lo inet loopback

auto ppp0
iface ppp0 inet ppp
provider telstra

===Reverse SSH Connection & AutoSSH===

root@raspberrypi:~# ssh-keygen

root@raspberrypi:~# ssh-copy-id recoverypi@jumphost

-Manual-
root@raspberrypi:~# ssh -R 2222:localhost:22 recoverypi@jumphost

-Auto-
root@raspberrypi:~# apt-get install autossh

root@raspberrypi:~# autossh -M 20000 -f -N -R 2222:localhost:22 recoverypi@jumphost  -i /root/.ssh/id_rsa

Add the command into /etc/rc.local before the “exit 0” line & you are good to go on every reboot.

autossh -M 20000 -f -N -R 2222:localhost:22 recoverypi@jumphost  -i /root/.ssh/id_rsa

– Connect to your JumpBox & verify the Pi has “phoned home”

recoverypi@jumpbox:~$ netstat -ant | grep 2222
tcp 0 0 127.0.0.1:2222 0.0.0.0:* LISTEN
tcp6 0 0 ::1:2222 :::* LISTEN

– Connect across the reverse SSH tunnel to the Pi

recoverypi@jumpbox:~$ ssh root@127.0.0.1 -p 2222
root@127.0.0.1’s password:
Linux raspberrypi 3.1.9+ #84 Fri Apr 13 12:27:52 BST 2012 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Tue Jul 17 22:27:42 2012 from raspberrypi
root@raspberrypi:~#

===MINICOM===

root@raspberrypi:~# apt-get install minicom

root@raspberrypi:~# minicom -D /dev/ttyUSB3 -b 9600 -o

Welcome to minicom 2.4

OPTIONS: I18n
Compiled on Sep  7 2010, 01:26:06.
Port /dev/ttyUSB3

Press CTRL-A Z for help on special keys

border-rtr>
border-rtr>en
Password:
border-rtr#sh ver
Cisco Internetwork Operating System Software
IOS ™ C2600 Software (C2600-IO3-M), Version 12.2(46a), RELEASE SOFTWARE (fc1)

===TFTP===

root@raspberrypi:~# apt-get install xinetd tftpd tftp

root@raspberrypi:~# vi /etc/xinetd.d/tftp

————————————-
service tftp
{
protocol        = udp
port            = 69
socket_type     = dgram
wait            = yes
user            = nobody
server          = /usr/sbin/in.tftpd
server_args     = /tftpboot
disable         = no
}
————————————-

root@raspberrypi:~# mkdir /tftpboot
root@raspberrypi:~# chmod -R 777 /tftpboot
root@raspberrypi:~# chown -R nobody /tftpboot

root@raspberrypi:~# /etc/init.d/xinetd stop
Stopping internet superserver: xinetd.
root@raspberrypi:~# /etc/init.d/xinetd start
Starting internet superserver: xinetd.
root@raspberrypi:~#


Advertisements




Raspberry Pi Runtime on Battery

4 07 2012

In a previous post, I mentioned the battery pack I bought from our local Aldi store “Tevion MPP 7400” – portable 7400mAh Li-Po Battery Pack. After many questions of “how long will it run” – I decided to find out.

I ran the Pi on this with the USB Wireless NIC & USB->Serial Console cable until it ran no more – and to my surprise, this nearly ran for 11 hours straight.

10hrs 55minutes to be exact

 22:17:01 up 10:55,  1 user,  load average: 0.00, 0.01, 0.05

Sooooo – with that runtime – it should give plenty of portable time on target between charges.





Telstra3G USB in Linux

23 06 2012

Telstra 3G USB Dongles are good for connectivity on the go.

http://www.zte.com.au/telstra/MF626i.htm
https://wiki.ubuntu.com/AustralianTeam/Projects/WirelessBroadbandInformation

root@bt:~# lsusb | grep ZTE
Bus 001 Device 005: ID 19d2:0031 ONDA Communication S.p.A. ZTE MF110/MF636

root@bt:~# dmesg | grep ttyUSB
[ 2306.101269] usb 1-4: GSM modem (1-port) converter now attached to ttyUSB0
[ 2306.101613] usb 1-4: GSM modem (1-port) converter now attached to ttyUSB1
[ 2306.102140] usb 1-4: GSM modem (1-port) converter now attached to ttyUSB2
[ 2306.102487] usb 1-4: GSM modem (1-port) converter now attached to ttyUSB3
root@bt:~#

There is a hard way using wvdial etc – or an easy way. I chose the easy way – a great little script called sakis3g

====================================

http://wiki.sakis3g.org/wiki/index.php?title=Sakis3G_script
http://www.sakis3g.org/#download

wget “http://www.sakis3g.org/versions/latest/i386/sakis3g.gz”
gunzip sakis3g.gz
chmod +x sakis3g
./sakis3g –interactive

====================================

root@bt:~/scripts# ./sakis3g connect USBINTERFACE=”3″ APN=”telstra.internet”

root@bt:~/scripts# ./sakis3g connect info
MF626s connected to Telstra (50501).
Connection Information

Interface: P-t-P (ppp0)

Connected since: 2012-06-11 20:52
Kilobytes received: 376
Kilobytes sent: 57

Network ID: 50501
Operator name: Telstra
APN: telstra.internet

Modem: MF626s
Modem type: USB
Kernel driver: option
Device: /dev/ttyUSB2

IP Address: 10.192.124.71
Subnet Mask: 255.255.255.255
Peer IP Address: 10.64.64.64
Default route(s): 10.64.64.64
====================================

root@bt:~/scripts# ./sakis3g disconnect
Disconnected.





Raspberry Pi Console Server

16 06 2012

It occurred to me that the Raspberry Pi would make a great low cost, portable console server.

1. Plug in a USB -> Serial convertor & appropriate serial console cable to your device

http://www.jaycar.com.au/productView.asp?ID=XC4834

Check that it is detected

root@raspberrypi:~# dmesg

usb 1-1.2: new full speed USB device number 5 using dwc_otg
usb 1-1.2: New USB device found, idVendor=067b, idProduct=2303
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1.2: Product: USB-Serial Controller D
usb 1-1.2: Manufacturer: Prolific Technology Inc.
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for pl2303
pl2303 1-1.2:1.0: pl2303 converter detected
usb 1-1.2: pl2303 converter now attached to ttyUSB0
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver

Install minicom to drive it

root@raspberrypi:~# apt-get install minicom

Hurrah – Portable console access 😀

root@raspberrypi:~# minicom -D /dev/ttyUSB0 -b 9600 -o
Welcome to minicom 2.4

OPTIONS: I18n
Compiled on Sep 7 2010, 01:26:06.
Port /dev/ttyUSB0

Press CTRL-A Z for help on special keys
FORTIBORDER login: admin
Password: ************
Welcome !

FORTIBORDER # get system status
Version: FortiWiFi-60CM v4.0,build0535,120511 (MR3 Patch 7)
Virus-DB: 15.00698(2012-06-15 03:29)
Extended DB: 14.00000(2011-08-24 17:09)
IPS-DB: 3.00201(2012-06-14 00:30)
FortiClient application signature package: 1.496(2012-06-08 08:51)
Serial-Number: FW60CM3GXXXXXXXX
BIOS version: 04000018
System Part-Number: P08962-03
Log hard disk: Available
Internal Switch mode: interface
Hostname: FORTIBORDER
Operation Mode: NAT
Current virtual domain: root
Max number of virtual domains: 10
Virtual domains status: 1 in NAT mode, 0 in TP mode
Virtual domain configuration: disable
FIPS-CC mode: disable
Current HA mode: standalone
Distribution: International
Branch point: 535
Release Version Information: MR3 Patch 7
System time: Sat Jun 16 20:50:32 2012





My Raspberry Pi comes to life

16 06 2012

Like most of the rest of the world’s IT population, I got excited about the Pi & ordered one.

It has arrived & I have had a little bit of time to play with it & I am pretty impressed.

BUILD A CASE

The first thing to do was a case, I didnt want to short it out on anything & it just felt too fragile & vulnerable naked

I printed this one (http://www.raspberrypi.org/phpBB3/viewtopic.php?f=40&t=6500) on some card (manila folder) & folded it up

 

A larger selection can be found here: http://elinux.org/RPi_Cases

PREPARE A DISTRO

Next we need a Distro:

http://elinux.org/RaspberryPiBoardDistributions

For each image, just use dd in Linux **Be Careful – make sure you have the right device to write the image to. This would be the SD card, not your hard drive !!

dd if=.img of=/dev/sdb

I have been primarily playing with the Debian Squeeze distro

http://downloads.raspberrypi.org/images/debian/6/debian6-19-04-2012/debian6-19-04-2012.zip
User: pi / raspberry

Raspbian is based on Debian Wheezy, which is newer than Squeeze

http://www.raspbian.org/
User: root / raspbian

The developing Raspbmc (XBMC) looks very promising – I have watched a couple of movies with it, with no performance issues

http://wiki.xbmc.org/index.php?title=Raspbmc

http://www.raspbmc.com/2012/05/raspbmc-is-now-in-beta/

http://download.raspbmc.com/downloads/bin/ramdistribution/installer-testing.img.gz

Note: you need at least a 2GB SD card. Raspbmc will use the full size of your card.

**First boot needs internet (ethernet cable/ dhcp) – the installer prepares the sdcard, then raspbmc is downloaded & setup at first boot.

TIME FOR POWER

The Pi runs on 5v, connected via Micro USB http://elinux.org/RPi_Hardware_Basic_Setup#Power_Supply – which can be supplied by pretty much any phone charger / USB port these days. The only recommendation provided by the vendor is choose a supply that will provide 5v and ~700mA. They will apparently run “stable” on any voltage between  4.75 and 5.25 volts.

Many people have been using the iPhone / iPad chargers without any issues (me included). But as an experiment, I decided to see what they were putting out. The Pi has two test ports TP1 & TP2 – these are to check the voltage being supplied to the board. There are mutterings about voltages under 5volt providing unexpected behavior on some boards.

I found that my white iPhone/iPod power supply (Rated @ 5V 1A dropped to about 4.8v when the Pi is running with HDMI, SD Card & USB WiFi Dongle.

Apple (A1205) Drops to about 4.8V under load

My HTC charger (Rated @ 5V 1A)performed about the same – around 4.8v under load

HTC (TC P300) Drops to around 4.8V under load

Another generic branded “Switching power supply” that was also rated @ 5V 1A showed the same voltage drop to around 4.8V under load.

Enter the Samsung Galaxy Tab 5V 2A charger, this bad boy kept me running at 5V under load.

Samsung (ETA-P10X) Keeps pushing 5V under load

The general consensus is that a 5V 1A phone charger should be fine, but if you are planning on plugging things into the USB port (WiFi / Storage etc) then you would be probably best off getting a higher rated PSU. I am going to check out Jaycar for a regulated 5V 2A supply next. Your results may vary, I didnt experience any strange issues or performance problems when running of any of the listed PSUs – but possibly got more interface drops on the USB WiFi adapter (thats a subject for another blog post).

On the subject of power – having such a tiny / portable device is much more useful when you can take it with you away from a power point. From our local Aldi store, I picked up a “Tevion MPP 7400” This is a portable 7400mAh Li-Po Battery Pack. This little guy has two USB ports on it & will apparently provide up to 2.1A on one, or 1A each with both in use. Its primarily aimed at charging a smartphone on the go, but it works beautifully as a portable power supply for the Pi. I have not tested how long it will keep the Pi running, but I was playing on it for several hours without the pack dropping an LED on the power meter.

Battery Pack – providing 4.78V under load – just within the allowable range – so far no problems, but we will see how it goes.

Well, that’s it for now, my Pi lives and breathes (as much as a piece of electronic equipment can) – time to try out some more distros & “projects” with it.