Monday, December 3, 2012

Raspberry Pi with some goodies!!!

All of the stuff I ordered from dealextreme has finally arrived. I'll address on how I got each time working. I didn't buy any of the following item at random. I looked at this list and looked at the comments of the products on dealextreme to find out if anyone had tested it on a RPI.

0) PSU (Power source)


I ordered this power source because it's rated at 5V, 2.1A, which seemed more than enough. The problem was that this PSU has a pretty bad voltage regulation (closed circuit voltage / open circuit voltage) and while it delivers 5.2 V with no load connected, while my RPI was idle the voltage measured between TP1 and TP2 was only 4.75 V, the bare minimum recommended.


Lucky me I had the charger of my former HTC cell phone handy. It's output plug is miniUSB but I had bought a miniUSB-microUSB adapter so I could easily use it to feed my RPI. Using this HTC cell phne charge, while the RPI is idle, the voltage measured between TP1 and TP2 is 5.03 V.


1) 16GB Class10 Kingston SD card (SD10V)


Since I had an install going on my 2GB SD card, I dd'ed an image of it to my HDD (dd bs=1M if=/dev/sdd of=./arch-arm.img, /dev/sdd on my case, use lsblk to list all disks) and then dd'ed this image to my 16GB card. Then using Gparted I resized the EXT4 partition. Tried the card on the RPI but it didn't work. Dd'ed the image again but this time I didn't resize the EXT4 partition. Didn't work either.


What happens is that even though systemd started the login service, the login prompt was never displayed. I asked for help on the Arch Linux ARM (ALARM) forums. One of the developers helped me out and I thought it was just a PSU problem, but it wasn't. My current PSU keeps 5.03 V on the RPI on idle (measured from TP1 to TP2) so I reckon it's just the card reader that doesn't like it. I ended up swapping this SD card with the 4GB Class4 one of my Wii and I'm using a USB stick as the rootfs (just formatted it as EXT4, copied the files with "cp -ar"  from the SD card to it and changed /etc/fstab so that /dev/sda1 was mounted as root).


The reason for running the rootfs from a USB stick was just speed, as I'm using a 4GB one and also have a 4GB SD card. I did some benchmarking using the dd command and regarding the write speed (writing a 512 MB file) I could only achieve 3.6 MB/s on the C4 SD card but got 8.1 MB/s on the USB stick. I did the same benchmark on my USB hdd (Seagate Expansion 500 GB) that I use on my Wii and managed to get 22 MB/s. Next week I'll buy a 1 TB USB hdd just for the RPI and I'll run the rootfs from there. Of course, it'll also be used to store my bittorrents downloads.


2) USB Hub


I ordered this guy. The power source of this USB hub is rated at 5 V, 4 A. Good enough, I guess. Everything I plugged on this USB hub worked properly (wifi dongle, bluetooth dongle, external hdd, wireless keyboard, etc.)


3) Wifi dongle


I ordered this one. It uses the well known RTL8188CUS chip and worked out of the box. To configure the wifi connections I used netcfg, a easy to use and lightweight solution, great when you're not using a mobile device, just set the ESSID and password for the connection and you're good to go. I'll not explain step-by-step because the Arch Wiki entry is pretty clear.


4) Wireless keyboard with touchpad


I ordered this one. It's very small, not so comfortable if you need to write a lot because only the thumbs are used to type but it's great for browsing the web, writing quick commands or using as a remote on XBMC. Also, I think the wifi signal sometimes interferes with the keyboard signal, but nothing majorly annoying.


5) Bluetooth dongle


I ordered this one. Cheap as hell and worked like a charm, Wiimote + classic controller recognized by RPI and ready to be used.


6) Heatsinks


I ordered this. It comes with 8 small heatsinks that fits perfectly the ARM CPU. I only installed a heatsink on the CPU but I also intend to install one on the USB controller and another one on the voltage regulator. These last two ones will need some customizing, I'll need to cut the heatsinks as they're too big.


---------------------------------------


Ok, so I got all the hardware I wanted (actually, I also ordered a case from modmypi.com around 10 days but it hasn't arrived yet) now I can get to the software configuration part.


Two posts ago I listed what I wanted to do with the RPI:

1) Old console emulator (mainly MAME and SNES);
2) Media center (streaming media from my desktop);
3) Torrent box (saving stuff on the SD card then ssh or ftp the stuff to my desktop);
4) Printer server (my printer is currently connected to my desktop, so if my wife wants to print something from her laptop, she needs to turn on my desktop).

Number 4 will not happen. Wifey don't want no printers in the living room.


Didn't have enough time to mess around and get number 1 working (didn't even TRY to get it working yet).


I did manage to get number 2 and 3 working properly. Like I said on my previous post, I'm using XBMC for playing H264 encoded HD videos, and it's working great.


As for number 3, I'm using Transmission. I've used Transmission ever since I ditched Windows for Linux (on Windows I used utorrent) but I've been using the regular gtk client (transmission-gtk package). What I'm using on the RPI is the transmission-cli package, running transmission as a daemon. This package also comes with transmission-remote which enables you to control the transmission-daemon from the CLI. Transmission-daemon also comes with a WebUI in case you want to control it through a web browser. As for configuring transmission, refer to the Arch Wiki entrySo, this is my basic setup, but there are some security considerations that have to be made.


About Transmission's WebUI: it supports authentication but it does not support SSL (https) connections natively (you have to so some extra work yourself, like putting a proxy in front of your server) so if you want to monitor your server from a remote network, then using this authentication is not very secure, someone eavesdropping can get your username and password and screw your server. Of course, when monitoring transmission-daemon from the LAN, there are no security problems (except for the fact that someone can break into the router by cracking your wifi signal). I want to be able to remotely check that status of my RPI Transmission-daemon, but I wanna do it in a secure manner. I decided to set up a SSH server (using SSH Keys, not username and passwords, check Arch Wiki) so I could monitor and interact with transmission-daemon using transmission-remote.


I'll not post a guide on how to setup Transmission or SSH server because the Arch Wiki entries (SSH, SSH Keys, Transmission) are very well explained. I'll just make a few remarks regarding some choices I made when configuring these servers and some stuff that people sometimes overlook:


1) When setting up a SSH server, choose a random port to run it from, don't use the default one (port 22). I ran a SSH server on my desktop one time using port 22 and going through the logs (/var/log/auth.log) I saw serveral login attempts. Changing the port eliminated the problem.
2) If you want to be able to login from outside your LAN, remember to forward the port on the router.
3) As for SSH keys, I made a 1024 bit long RSA pair. I had use RSA because I wanted to access my SSH server from a windows box (from work) using PuTTY. PuTTY doesn't support the regular OpenSSH key format, just his own key format generated using the PuTTYgen utility, and PuTTYgen only supports RSA and DSA keys. So, I had to take my private key and generate a PuTTY compatible one using PuTTYgen.
4) Since my Transmission server WebUI is not accessible from outside my LAN, I used the default port (9091) just to make things easier.
5) Remember to forward the listening port used by Transmission.

I guess that's it for now. See ya.

EDIT: I forgot to mention I signed up for a free DNS service called no-ip.com. It's working great so far and it was a breeze to install: simply install the noip client from the arch linux arm repo (pacman -S noip), run it (watch the instructions displayed after it's installed by pacman) and enable the daemon on systemd (systemctl enable noip2.service). 

EDIT 2: My RPI case from modmypi.com arrived. I really recommend it. It fits very well and even though it doesn't use any screws, it's closed tight.

EDIT 3: I said I'd buy a 1TB USB hdd and run the rootfs of the RPI from there. I ended up buying a 500GB Western Digital My Passport USB 3.0 drive, even though the RPI doesn't support USB3. Anyway, it's WAY faster than running from a C4 SD card or from a USB stick. The boot is VERY fasy and the programs also load faster. Also, I'm overclocking the RPI with the following settings:

arm_freq=1000
core_freq=500
sdram_freq=500
over_voltage=6


With that and the default cpu scaling governor being "on demand", the RPI runs at 700MHz whe the CPU load is low and at 1000MHZ when the CPU load increases.