Sunday, April 14, 2013

Raspberry Pi as Media Center

Assalamualaikum, Hi,

My Raspberry Pi just get delivered this week, so here are some notes for future me if I ever need to use my Rpi as a media centre again.

Raspbmc in action


I'm not really gonna use my Rpi mainly as a media centre since it would be wasteful for me, however I'll try it this time so I can get some idea on how easy or difficult it can be.

So for TL;DR:
1. Setup Raspbmc  - Very easy
2. Getting TP-LINK WN725N V2 nano usb WiFi module working with Raspbmc* - Easy (relative to your Googling skill)
3. Configure XBMC - Very Easy

Edit: *Finally, support for 8188EU chipsets already added into the Raspbmc kernel after latest hotfix update ~ http://www.raspbmc.com/2013/10/raspbmc-hotfix/

1. Setup Raspbmc
First I need to prepare the OS for my media centre. So I chose Raspbmc with no specific reason. The image can be downloaded from Raspbmc homepage. I chose the network image as recommended.

To detect the SD card file-system path, this command is executed before and after mounting the SD card
haziq@haziq-desktop:~$dh -f
example:
Before mounting the SD card
haziq@haziq-desktop:~$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lvroot   30G  5.9G   23G  21% /
udev                     3.9G  4.0K  3.9G   1% /dev
tmpfs                    1.6G  976K  1.6G   1% /run
none                     5.0M     0  5.0M   0% /run/lock
none                     3.9G  1.9M  3.9G   1% /run/shm
none                     100M   20K  100M   1% /run/user
/dev/mapper/vg00-lvhome  278G   40G  224G  16% /home

After mounting the SD card
haziq@haziq-desktop:~$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lvroot   30G  5.9G   23G  21% /
udev                     3.9G  4.0K  3.9G   1% /dev
tmpfs                    1.6G  976K  1.6G   1% /run
none                     5.0M     0  5.0M   0% /run/lock
none                     3.9G  1.9M  3.9G   1% /run/shm
none                     100M   20K  100M   1% /run/user
/dev/mapper/vg00-lvhome  278G   40G  224G  16% /home
/dev/sdf1                7.4G   32K  7.4G   1% /media/haziq/9016-4EF8

Since the device in this example is mapped at /dev/sdf1 so the path that will be used for dd command is /dev/sdf (not sdf1!)

Edit: or just check dmesg after you plugged in the sd

Unmount the device
haziq@haziq-desktop:~$ sudo umount /dev/sdf1 

Copy the image to the device
haziq@haziq-desktop:~$sudo dd bs=4M if=installer.img of=/dev/sdf

To confirm it already finished writing to the SD card,
haziq@haziq-desktop:~$ sudo sync

Insert the SD card into Raspberry Pi and power it up. It will continue downloading and installing the complete system.

And that's it.


2. Getting TP-LINK WN725N V2 nano usb WiFi module working with Raspbmc
I bought this wifi usb adapter which cost only RM26 since it is confirmed working with Raspbian. Unfortunately I've found out that it didn't work out of the box in either Raspbian nor the Raspbmc. After searching around, I've found out my dongle actually a V2 version of WN725N, and it's using a different driver. Luckily, there are few helpful people over the internet that shared the compiled kernel module(.ko) for Raspbmc kernel version 3.6.11.

So what I need to do is just to grab the kernel module from attachment in this forum post (login is required) and after that SSH into my Raspbian.

haziq@haziq-desktop:~$ ssh pi@192.168.0.109 

Beside using SSH, it is possible to open up terminal by pressing escape during shutting down from Raspbmc XBMC exit.

I download the file (8188eu.ko) to Rpi by using wget from my dropbox:
pi@raspbmc:~$ wget --no-check-certificate https://dl.dropboxusercontent.com/u/99979776/8188eu/september/8188eu.ko
(working for Raspbmc's September update)

Edit: You can also directly transfer the file to your pi by scp. Refer extra tips in the end of this guide.

Put the .ko file into your Rpi modules folder and probe the module
pi@raspbmc:~$ sudo mv 8188eu.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless/
pi@raspbmc:~$ sudo depmod -a
pi@raspbmc:~$ sudo modprobe 8188eu

Add 8188eu in the module list so that it will be probed on each boot automatically
pi@raspbmc:~$ sudo vi /etc/modules

Edit: Just add '8188eu' in a new line

Edit: Please remember to configure your wireless setting in your Raspbmc setting!  [Programs > Raspbmc settings]

Take a note that I'm using powered USB hub when using this dongle since my Rpi failed to boot up when the dongle is plugged in to the main board USB port.

Edit: I don't have to use a powered hub if I'm not attaching my usb keyboard. Refer my next guide on enabling remote control use by ir/remote receiver if you don't have any XBMC supported remote like me.

And that's it.


3. Configure XBMC
I have no intention to cover these easy stuff in detail since it's not very technical, so here are some screenshots of some basic stuff you can change around in XBMC:

With internet connection, it is so easy to fetch contents
from internet. Here I'm downloading a new skin.

Switching to Quartz skin

Adding YouTube Plugin

Browsing YouTube by using string search


4. Some extra tips, to move stuff from Rpi to your machine
haziq@haziq-desktop:~/Downloads$ scp pi@192.168.0.116:/home/pi/* .


References:

Raspbmc download page
http://www.raspbmc.com/download/

Rpi verified peripherals - USB wifi adapter list
http://elinux.org/RPi_VerifiedPeripherals#Working_USB_Wi-Fi_Adapters

Compiling kernel module/driver with RaspBMC release
http://forum.stmlabs.com/showthread.php?tid=7671&pid=61560

Copying Files To Or From The Pi and other Remote shell tips
http://www.raspbmc.com/wiki/user/using-ssh/



33 comments:

  1. I've tried your guide but got stuck when configuring the TP-LINK WN725N V2 nano usb.

    I've tried copying the .ko file and:

    root@raspbmc:~# cd /lib/modules/3.6.11/kernel/drivers/net/wireless/
    root@raspbmc:/lib/modules/3.6.11/kernel/drivers/net/wireless# ls
    8188eu.ko ath libertas_tf rndis_wlan.ko rtl818x zd1201.ko
    at76c50x-usb.ko libertas p54 rt2x00 rtl8192cu zd1211rw

    root@raspbmc:/lib/modules/3.6.11/kernel/drivers/net/wireless# sudo depmod -a
    root@raspbmc:/lib/modules/3.6.11/kernel/drivers/net/wireless# sudo modprobe 8188eu

    But I get this error:

    ERROR: could not insert '8188eu': Exec format error

    Have you ever encountered it?

    Thanks

    ReplyDelete
  2. Hmm.. I didn't encountered that problem,
    maybe you should check your dmesg output.
    If you need help with your dmesg output,
    put it to pastebin site, and share the link.

    Good luck

    ReplyDelete
  3. Thank you for your really quick reply.

    I've uploaded my dmesg output: http://pastebin.com/sPQAntjd

    Could it be this line: "8188eu: disagrees about version of symbol module_layout"?

    Thanks again buddy.

    ReplyDelete
  4. It might be a problem with the Kernel version the .ko file was compiled in. It might be different from the one I'm currently running...

    The problem is, I don't know how to compile a new .ko file for my kernel version...

    ReplyDelete
  5. Since you're running the same Kernel version as my Raspbmc,
    I'm not sure why it didn't work out.
    Can you confirm that you're using the .ko file attached to the forum post?
    You can try with the one I'd uploaded here:
    https://dl.dropboxusercontent.com/u/99979776/8188eu.ko

    If it's still not working, looks like you need to compile your own kernel module.
    You can follow the instruction on the same forum post that I grabbed the kernel module file:
    http://forum.stmlabs.com/showthread.php?tid=7671&pid=61560#pid61560

    ReplyDelete
  6. Ok! It worked great with your .ko file.
    I managed to connect to my hidden wifi as well!

    There's a major problem now though... As soon as I rebooted I lost Wlan0. I added 8188eu to /etc/modules. I even tried to do all the steps from the beginning. Now I've lost Wlan0...

    I installed Raspbmc from the beginning again... Wifi worked till the reboot... Then nothing.. What might be the problem?

    ReplyDelete
  7. After reboot,
    Check whether the module is loaded by lsmod.
    you should see 8188eu is in the list.
    if not, check dmesg again to check if there's any other issue.

    If the 8188eu kernel module inserted fine,
    you should check for your usb wifi device existence by 'lsusb'.
    it can be that the usb is not properly powered.
    You need a powered usb hub for your dongle.

    ReplyDelete
  8. I tried lsusb and the dongle is visible.
    I'll try lsmod and dmesg again.
    Thanks again.

    ReplyDelete
  9. So I finally got wlan0 to connect but only when eth0 is connected as well...
    As soon as I disconnect eth0... wlan0 disconnects as well...
    Any tips?

    ReplyDelete
  10. when you said wlan0 disconnect, is it only the internet connection?
    or is it when you type ifconfig, wlan0 is not listed?

    Maybe you should check how you connect to wlan0.
    I configure my wlan0 through raspbmc setting.

    Btw, there's a few time when my wlan0 disappear from ifconfig list,
    but plugging out-in the dongle solved this problem.

    ReplyDelete
  11. Thank you very much Haziq!
    I've got it working finally!
    Just for clarity these are the steps I followed:
    1. Install Raspbmc 12.2
    2. Downloaded your 8188.ko

    pi@raspbmc:~$ sudo mv 8188eu.ko /lib/modules/3.6.11/kernel/drivers/net/wireless/

    pi@raspbmc:~$ sudo depmod -a

    pi@raspbmc:~$ sudo modprobe 8188eu

    Add 8188eu in the module list /etc/modules

    3. Downloaded network manager add-on from GUI

    4. Connected to wifi :D

    I'm not even using a powered usb.

    Restarted and shutdown a few times.

    Everything seems fine.

    Thank you again for all the help.

    PS: HDMI CEC is AWESOME!

    ReplyDelete
  12. Congratz! No problem!
    Did you know raspbmc come with pre-install network manager?
    just go to Programs > Raspbmc settings

    Yep, I also realized my keyboard is the reason why my dongle need some extra power source.
    So no problem when the keyboard is detached.

    PS: I/R RECEIVER is AWESOME too!

    ReplyDelete
  13. Wicked! Didn't know about pre-installed network manager! Oh well!
    One quick question: Do you have any tips to quicken navigation in the GUI?

    ReplyDelete
  14. I'm not using it that much as media centre ,
    so most of the time the responsiveness is adequate for my minimal usage.
    But you can try to change to a lightweight skin like Quartz.

    and also I didn't yet try for hdmi cec, so if possible,
    try to benchmark it against keyboard or other supported remote controller.

    ReplyDelete
  15. Hi Haziq,
    thanks for this quick guide to install the wifi dongle.
    I'am sry for my question but i do not have much experience with linux!
    So i do not know what is exactly meant by "Add 8188eu in the module list /etc/modules".
    I have opened the text file with vi and have to write 8188eu and save it?
    But this does not work in reason of the readonly file.
    Thank you for your help!

    ReplyDelete
  16. Hi!,
    You need to have root permission to do that.
    Just add sudo in front of the vi command.
    I'll fix my guide. Thanks for pointing out!

    ReplyDelete
    Replies
    1. Hi Haziq,
      thank you very much for your fast response.
      I think now can handle a linuxbeginner this driver Installation.
      It was a pleasure for me if i could help you to improve this guide!
      Thomas

      Delete
  17. The July update broke the TP-LINK WiFi adapter drivers I believe. Will you be publishing a newer version, Thanks.

    ReplyDelete
    Replies
    1. Ok, updated my post. Please inform if it's not working for you

      Delete
  18. I cannot make it work Haziq, I'm using Aug 21 update. Is this driver working for that version?

    making lsmod i can see there's 8188eu with Used = 0

    When I go to Network-manager it says: No wifi device found. I tried plugging it to a USB hub aswell.

    Any idea?

    ReplyDelete
    Replies
    1. yup, i haven't compiled the driver for August update.
      I'll be busy until this weekend.
      but you can compile on your own by following this instruction:
      http://smhaziq.blogspot.com/2013/06/compiling-tp-link-wn725n-v2-driver-in.html

      Delete
    2. What is the output of lsusb? Is 0bda:8179 listed?
      I just tested with August update and it actually working out of the box.

      Delete
  19. Hi Haziq,
    i want to use your driver for my new Raspberry Pi. But know it gives a new Kernel Version (3.10.12) and i get an error when i do the command: sudo modprobe 8188eu.
    The Error called: Error: could not insert '8188eu': Exec format error
    What could i do that it will work.
    Thank you for helping.
    Thomas

    ReplyDelete
    Replies
    1. Here's the .ko file for September update: https://dl.dropboxusercontent.com/u/99979776/8188eu/september/8188eu.ko

      Delete
    2. Thank you very much :D

      Delete
    3. Today i noticed, that Sam Nazarko, added the driver into Raspbmc as he said in his new hotfix report. I tested it yet and it works fine but thank you so much for your help before this hotfix came out :D
      Thomas

      Delete
  20. I have the same problem as Thomas. I followed your instructions but I get the "Exec format error", too. A new kernel would explain this situation... I'm a total noob when it comes to linux, so compiling my own driver would be very hard for me. Is there any workaround for this?

    ReplyDelete
    Replies
    1. Grab the .ko file for September update from here: https://dl.dropboxusercontent.com/u/99979776/8188eu/september/8188eu.ko

      Delete
    2. Great, the driver works perfectly, thank you so much. But when I had to move the file into the wireless folder I got an error saying that the directory does not exist. Replacing this line:
      pi@raspbmc:~$ sudo mv 8188eu.ko /lib/modules/3.6.11/kernel/drivers/net/wireless/
      with this
      pi@raspbmc:~$ sudo mv 8188eu.ko /lib/modules/`uname -r` /kernel/drivers/net/wireless/
      solved the problem.

      Delete
    3. Owh, yeah, I didn't notice that since when I write this entry, it is never planned to be applied to various kernel version. Thanks for pointing that out.

      Delete
  21. Great, your update for the Sep update is working just fine.

    I was going to follow your other blog to compile the driver myself but would that be out of date now since the kernel version has changed from 3.6.11 to 3.10.13?

    Thank you for making the new driver available so quickly after each raspbmc update.

    Much appreciated,

    Ken

    ReplyDelete
    Replies
    1. I did posted the step for 3.10.13 here: http://smhaziq.blogspot.com/2013/10/compiling-tp-link-wn725n-v2-driver-in.html, but as I mentioned it just a copy paste guide from the linked Stm lab forum post. Even I didn't test them yet.

      Btw, I'm just mirroring others work. All credit should goes to here:
      http://forum.stmlabs.com/showthread.php?tid=10805

      Delete