Archive for category Rasberry Pi
A friend recommended me this distro for running XBMC which was released by one of the developers of the XBMC project with specific optimizations to run on the Rasberry’s hardware. So I decided to test it and I explain here all have to do to install it, that indeed was a little problematic but successfully at the end.
Raspbmc from the installer
The project’s page recommends to use the installer or Network Image, a python script which practically do the whole installing process, partitioning and doing the initial setup…or at least it tried to, because in my case it didn’t work due to my network connection at home didn’t help at all so I couldn’t download the image using the installer. Therefore I had to install the complete image of Raspbmc.
The complete image of Raspbmc
There’s another option offered on the project’s page which is to download the whole image of Raspbmc of 235 MB called Standalone Image, but after extract it it sizes 1.4 GB roughly. This was an issue because my SD card’s capacity is 1 GB and I didn’t buy another one as I have a 320 GB hard drive just for the Rasberry Pi. Therefore I came up that I could shrink the image to fix my 1 GB SD card.
Repartitioning the image
In a similar way as explained in How to run Raspberry Pi from a USB hard drive article, I dumped the image into a 8 GB pen drive to be able to extract the /boot and the operating system or system file’s root partition. In order to copy the image to the pen drive you must first extract the image and later extract the image and the dump it as raw, as shown next:
# gunzip raspbmc-final.img.gz# dd if=raspbmc-final.img of=/dev/sdb
If you check it with gparted you should see something like this:
Later using gparted itself I had to resize the partition /dev/sdb2 to 800 MB roughly, so I could put the /boot de 74 MB as well in my 1 GB SD card.
To extract the /boot partition from the pen drive you can do this:
# dd if=/dev/sdb1 of=raspbmc-final_boot.img
In a similar way extract the file system of 800 MB on the another partition:
# dd if=/dev/sdb2 of=raspbmc-final_fsext4.img
The initial setting it’s done by the installer, which is an script that ask some questions as networking parameters and such. Those values can be modifies later on XBMC with an script added for the Raspbmc:
The installation detected the hard drive automatically but it didn’t let me partition it, in fact it erases everything and creates a unique partition which is mounted into /media withe the partition’s UUID . But I wanted three partitions: one for the operating system (/), other for the memory swapping (swap) and the remaining space for data (/media/Toshiba320), and the /boot partition which must be in the SD card.
To partion the hard drive I deleted and created the partitions using fdisk. At the end the disk was distributed in this way:
Then I edited the /etc/fstab to reflect the changes:
proc /proc proc defaults 0 0 devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620 0 0 #/dev/sda2 / ext4 defaults,noatime 0 0 UUID=e7db90716-9911-4fc8-95da-86c463f926a4 / ext4 defaults,noatime 0 0 UUID=70a55bca-9fdb-4073-87f6-c15fd7b351dc none swap sw 0 0 UUID=1ff934a3-f7ce-451f-9a07-0915e174a007 /media/Toshiba320 ext4 defaults 0 0 /dev/mmcblk0p1 /boot vfat defaults,noatime 0 0
And later I edited the file /boot/cmdline.txt to indicate that the operating system will be read from the hard drive instead of the SD card:
dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 noatime quiet rootwait loglevel=1 persistent-logs sdhci-bcm2708.enable_llm=1 dwc_otg.microframe_schedule=1 dwc_otg.fiq_fix_enable=1
Disabling the Firewall
To disable the firewall that comes with a DROP rule by default on the Raspbmc, you have to edit the file /etc/network/if-up.d/secure-rmc, where you have to comment the following line:
iptables -A INPUT -i $IFACE -j DROP
You also can disable the firewall form the setting script of XBMC as show next:
I have a keyboard and a mouse connected to the Rasberry Pi but this is not practical, the ideal scenario is to have a remote. As the Rasberry Pi is connected to the WiFI the idea is to use this network instead of IR or Bluetooh. Therefore I thought in an Android application and mi first choice was XBMC Remote but it seems it has some communication issues that makes XBMC goes crazy ( The Raspbmc version and other for Raspbian behaves the same), but at the end I used another application called Yatse which works properly and it looks better as you can see in the next screenshots I took from my phone:
Comparing XBMC I had tried before on the Rasberry Pi, this version really runs well. It plays movies in several formats (.avi, .mkv, .mp4, etc) smoothly. On the other hand it has Linux inside so it’s my download center with qbittorrent-nox, and I use it for other testing purposes. And this is what XBMC reports as resources consumption:
- [SOLVED] Blocked tcp/udp incoming connections after final release? (iptables)
- How can I disable raspbmc’s firewall via SSH?
Due to I wanted to use my Rasberry Pi as a media center but I didn’t want to put lot of devices on my nightstand I came up with this idea. My Rasberry, a hard drive and a usb hub look like corronchos (loricariidaes) but they are behind the TV.
If you want to do something similar you can use stickers for holding photo frames (Command, Scoth, 3M, etc), and this way you can save some space and avoid to deal with a lot of devices on your room.
I’ve already install XBMC as my media center and also qbittorrent Web as my “download” center. But one piece was missing: a subtitle downloader program. I knew about subdownloader, so I decide to give it a try on my Rasberry Pi but it is not on Raspbian repos…what can you do?
Easy, just add Debian’s official repos for Sid and install it. Remember, Debian supports lot of architecture, even armhf. Let’s see how to do it…
- Edit file /etc/apt/sources.list to include sid’s repos:
deb http://ftp.debian.org/debian/ sid main contrib non-free
- Update the package list:
- Install SubDonwloader:
aptitude install subdownloader
- Edit file /etc/apt/sources.list to delete sid’s repos (it’s enough by commenting the line with #):
#deb http://ftp.debian.org/debian/ sid main contrib non-free
- Update the package list one more time:
Now you can run the program on your Rasberry Pi locally or using ssh…but keep in mind it would run a little slow. Enjoy it!
Reference: SubDownloader project page
I had been using my Raspberry Pi with a 4 GB – class 4 SD card Kingston until it decided to die (since I burn the image the first time that SD card was a little problematic). Because I didn’t have another 2GB or higher SD card, I decided to do a research to check if I could use the first partition as boot and another partition from an external USB hard drive of 320 GB. Effectively it can be done and I describe the needed steps on this article.
I decided to use the Raspbian image Raspbian 2013-02-09-wheezy-raspbian.img, but first I had to do a trick: dump the image to a 8 GB pen drive to be able separate the /boot partition and the remaining file system.
Dumping Raspbian to the pen drive
Just dump the Raspbian image as it were a SD card, but instead of using /dev/mmcblk0 do it on your pen drive:
# dd bs=4M if=/home/lgallard/Projects/RaspberryPi/2013-02-09-wheezy-raspbian.img of=/dev/sdb
Extracting the boot image
In order to extract the Raspbian’s boot image just dump the first partition of the pen drive:
# dd if=/dev/scb1 of=/home/lgallard/Projects/RaspberryPi/2013-02-09-wheezy-raspbian.boot.img
Extracting the operating system
Do the same to extract the file system where the operating systems resides:
# dd if=/dev/sdc2 of=/home/lgallard/Projects/RaspberryPi/2013-02-09-wheezy-raspbian.fsext4.img
Partition /boot on SD card
You will still need a SD card to boot your Rasberry, but it not longer need to be 2GB, in fact it could be much less, even 64 MB (I use a 1 GB SD card I found). To do so, you need to make a partition with GParted of about 60 MB as show in the next picture:
Now copy the content of the first image you dumped previously:
# dd if=/home/lgallard/Projects/RaspberryPi/2013-02-09-wheezy-raspbian.boot.img of=/dev/sdb1
Once you have copied the data you must mount that partition and then edit file /media/usb0/cmdline.txt (change /media/usb0 according to the mounting point), and put the following:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=deadline rootwait
Here is important to put root=/dev/sda1 so the Raspberry uses the first partition of the external USB hard drive as the root partition, I mean, the “/” directory at boot.
Partitioning the external USB hard drive
Connect the hard drive to a PC and make the partitions as shown in the next picture. The first partition will content the file system and the second one will be used for saving data (you can define later that in the /etc/fstab of your the RaspBerry Pi).
File system partition “/”
Now you can dump the Raspian image you got to the first partition of the USB hard drive. To do so type this:
# dd if=/home/lgallard/Projects/RaspberryPi/2013-02-09-wheezy-raspbian.fsext4.img of=/dev/sdc1
Fixing the size partition
As you can see in the last picture, the partition was created of 9 GB size, but if you mount the partition it will report it as only 2 GB because the Raspian image has that size by default. To fix this you must umount the partiton and and resize the file system:
# umount /dev/sdc1# e2fsck -f /dev/sdc1e2fsck 1.42.5 (29-Jul-2012) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information Raspbian: 66488/114688 files (0.1% non-contiguous), 346538/458240 blocks# resize2fs /dev/sdc1resize2fs 1.42.5 (29-Jul-2012) Resizing the filesystem on /dev/sdc1 to 2304000 (4k) blocks. The filesystem on /dev/sdc1 is now 2304000 blocks long.
After that check the available space. It should report something like this:
# df -h/dev/sdc2 285G 191M 271G 1% /media/Data /dev/sdc1 8.7G 1.3G 7.0G 16% /media/Raspbian
If you follow these steps, your Rasberry Pi will boot from a USB hard drive.
- It’s a fact that a hard drive have a higher price than a SD card but you have to consider the later will suffer more, specially a file system with journal can kill the SD card, so it’s not crazy to think in an external USB hard drive.
- This hard drive and keyword are powered by the Rasberry Pi without problems. But if I connect something more, for instance a mouse, it can’t handle all and the device reboots.
- Using a hard drive can solve the SD card compatibility issue (recommended class 6 type). In my case I used a Sandsik of 1 GB, class 4 and it worked perfectly.
- Probably you can use dd and extract the /boot and file system partitions, but due I didn’t know the exact size and because I was a little lazy a decide to dump the Rasbian image on a pen drive and extract the images that way.
If you want to install XBMC on your Raspberry Pi using Raspbian and got dependency problems, you can download it from this repo by adding the following line to /etc/apt/sources.list
# XBMC Repo deb http://archive.mene.za.net/raspbian wheezy contrib
Then update and install XBMC:
# aptitude update # aptitude install xbmc
After that, you can start it on boot and increase the priority level by editing file /etc/default/xbmc with these parameters:
# Set this to 1 to enable startup ENABLED=1# The user to run XBMC as USER=pi# Adjust niceness of XBMC (decrease for higher priority) NICE=-10
Remember to disable the LXDE or XFCE start on boot (you can ue rasp-config). Enjoy it!
Reference: XBMC for Raspberry Pi
My Raspberry Pi has arrived…and sooner than expected (they say in three weeks). I would say it just took one week to ship it to Venezuela. In my case I bought it at RS Raspberry Pi Store and the shipment was direct to Venezuela. And yes, IPOSTEL shipments do arrive.
Here I leave some picture of the unboxing…
I just need a SD card, which must be class 4…at the moment I continue experimenting with the QEMU image as I mentioned in my last post.
I bought a Raspberry Pi but it will take three weeks until it arrives (add three more weeks thanks to the postal service) so I decided to see what I can read about the Raspberry. Then it occur to me the idea of trying to emulate the Raspberry Pi and it came to my mind QEMU, because the Raspberry Pi has a ARM1176 processor. Doing a quick research I found this blog where explains how to do it. But I didn’t want to use the Rasberry project’s image but one of the Raspbian variations, in particular the Hexxeh image. Finally, and because I wanted to do some tests without the need of a graphic interface, I did a research to make a bridge on QEMU. Then I set the image as suggested by the Raspbian page, because it comes too plain, so I uninstall LXDE in favor of XFCe with Slim. Here I explain how to do so:
I downloaded the Raspbian Hexxeh image and applied the changes sugested:
- I installed the SSH server and regenerated the keys (you have to do this because everybody downloads that image and the keys must be unique). Just to this:
# rm /etc/ssh/ssh_host_* # dpkg-reconfigure openssh-server
- I upgraded the package list
- I installed XFCE and Slim (login manager) and uninstall LXDE because I thinks it’s ugly an heavier than XFCE.
- I updated the timezone to Caracas, and set the time with ntp.
- I set the locales to US_us UTF8
- I set the keyboard layout to Latin American Spanish.
If you want custom this image as above follow the steps explained at the Raspbian Hexxeh web page.
Raspbian on QEMU
Now to run Raspbian on QEMU you must follow these steps:
- Download the kernel for this proccesor:
$ wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
- Extract the Raspbian image downloaded. I put the Hexxeh image as example, but you can try any other image:
$ unzip raspbian-r3.zip
- Run QEMU with the following options:
$ qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2" -hda raspbian-r3/raspbian-r3.img
Keep in mind that is an emulation so no all the Raspberry’s hardware is supported. For example when booting the image you can see that the first partition is not loaded, which corresponds to the /boot partition, which is supplied by the downloaded kernel .
Setting the briged on QEMU
Another thing I wanted to do was to be able to access the emulation from a remote computer. The idea behind this is not to depend on a graphic environment but to be able to access the Raspberry image with ssh to, for example, be able to install packages with aptitude. To do so I had to make a bridge as explained next:
Installing the needed packages
First, you must download these packages:
# aptitude install bridge-utils uml-utilities
Granting permissions with sudo
In order add the network interfaces to the bridge you have to grant permissions to the user who launch the virtual machine. To do so you have to set sudo using the visudo command:
# This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying this file. # # See the man page for details on how to write a sudoers file. # Defaults env_reset Defaults mail_badpass Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"# Host alias specification# User alias specification# Cmnd alias specification Cmnd_Alias QEMU=/sbin/ifconfig, \ /sbin/brctl # User privilege specification root ALL=(ALL:ALL) ALL lgallard ALL=NOPASSWD: QEMU# Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" directives: #includedir /etc/sudoers.d
In this case lgallard is the user that is allowed to run ifconfig and brctl.
Setting the bridge
You have to set the file /etc/network/interfaces to bring up the bridge automatically . To do so you must disable the interfaces to be added to the bridge (for instance, ifdown eth0) and define just the bridge as explained below:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).# The loopback network interface auto lo iface lo inet loopback# The bridge network interface(s)auto br0iface br0 inet dhcp bridge_ports eth0 bridge_fd 9 bridge_hello 2 bridge_maxage 12 bridge_stp off
After this you can bring up the bridge by typing this:
# ifup br0
QEMU init script (/etc/eqemu-ifup)
This script let you bring up the network interfaces and the bridge with QEMU. To do so you have to edit /etc/qemu-ifup with the following info:
#!/bin/sh #sudo -p "Password for $0:" /sbin/ifconfig $1 172.20.0.1 echo "Executing /etc/qemu-ifup" echo "Bringing up $1 for bridged mode..." sudo /sbin/ifconfig $1 0.0.0.0 promisc up echo "Setting tap0" sudo tunctl -t tap0 -u lgallard echo "Adding $1 to br0..." sudo /sbin/brctl addif br0 $1 sleep 2
Here I leave some screenshots with the QEMU emulation:
As you can see in the last screenshot, not all is installed on the image, so if something doesn’t work you have to download it. In this case you can install midory browser:
# aptitude install midory
Or any other browser you prefer.