Category : Nerd Stuff

YouTube naar XBMC

Sinds de komst van XBMC op mijn Raspberry Pi heb ik ook een paar appjes op mijn Android telefoon geprobeerd, om XBMC mee te kunnen besturen. Een van de leukste features van die apps is eigenlijk dat je een filmpje op YouTube met een druk op de knop af kunt laten spelen op XBMC op een andere computer.

Deze functionaliteit wilde ik ook op mijn laptop, want ik zit vaker met de laptop op de bank te surfen dan met m’n mobiele telefoon. Wat zoekwerk leverde wel wat dingetjes op, namelijk in de vorm van een Firefox-extensie en een bookmarklet, maar beide werkten niet naar behoren.

Het idee van een bookmarklet sprak me wel aan, dus ben ik zelf aan het stoeien gegaan. Hieronder vind je het resultaat.

XMBC (we hebben het over versie 12, a.k.a. ‘Frodo’) heeft een JSON-RPC API, die het mogelijk maakt om de applicatie van buitenaf te besturen. Via Settings -> Services -> Remote control -> Allow programs on other systems to control XMBC kun je deze API inschakelen. Daarnaast moet de YouTube video add-on geinstalleerd zijn.

De code

javascript:(function(){var%20h='raspi';var%20v=document.URL.match(/v=([^&]+)/);if(v){var%20vid=v[1];var%20url='plugin://plugin.video.youtube/?path=/root/video&action=play_video&videoid='+vid;var%20request=JSON.stringify({jsonrpc:%20"2.0",method:"Player.Open",params:{item:{file:url}},id:1});var%20url='http://'+h+'/jsonrpc?request='+escape(request);var%20w=window.open(url);}else{alert('No%20video%20ID%20found');};})();

Gebruiken is simpel. Maak een nieuwe bookmark in je browser, en op de plaats van de URL voer je de bovenstaande code in. Vervang daarin de hostname van mijn XMBC computer (de waarde ‘raspi’ in de variable ‘h’ aan het begin van de code) door de hostname of het IP-adres van jouw XBMC.

Surf vervolgens lekker rond op YouTube, en als je een filmpje ziet waarvan je vindt dat iedereen het moet zien, klik dan op de net aangemaakte bookmark. Als het goed is, begint XBMC direct met het afpelen van de video. Getest en werkend bevonden in Firefox en Chrome.

Introducing “Taggert”, a GTK+3 geotagging application

Up to now, I have been geotagging my pictures with gpsPhoto.pl, a command-line tool, that matches coordinates from GPX files with the timestamps on images. This works nicely, but it requires that you indeed have a GPX track from the time the picture was taken. For some time, I have been looking for a tool that allows me to do manual geotagging using a map.

I have found several tools that offer this functionality, or part of it. As a matter of fact, there are quite a few tools available for Windows, but I need one that runs on Linux, so I will not discuss those here. First, I found Geotag, a Java application, but it does not offer a map, so it isn’t very convenient. What I was looking for should look a lot like locr GPS Photo for Windows. This is, as the name suggests, a Windows-only tool.

Finally, I found GottenGeography, a GTK+ tool, written in Python, that does almost everything I want. Almost.

When I found GottenGeography, I had already started to explore the possibilities of writing a tool of my own, and the basis for Taggert was already there. After playing around with GottenGeography for a while, I decided I don’t like some of its design choices, and because creating a GTK+ application in Python seemed like a nice challenge, I decided to continue. And here it is: Taggert v1.0.

The README on Github explains what Taggert is, what it aims to be and how to try it out.

In short: Taggert allows add, change and remove geotags on your pictures, either manually using a marker on a map, or automatically using one of more GPX files containing GPS tracks. It allows you to store bookmarks for frequently-used locations and it supports multiple map sources, like OpenStreetMap and MapQuest.

In the near future, I hope to provide packages for different Linux distributions (at least Debian and Ubuntu). For now, you can download it from Github.

Octocopter bij Lowlands-camping

Afgelopen zaterdag zagen we op Lowlands camping 1 ineens een UFO boven de camping vliegen. Nader onderzoek wees uit, dat het om een octocopter ging:

Op de octocopter staat de URL tfcm.nl, wat blijkt te staan voor The Flying Camera Men. Ik heb ze een mail gestuurd met de vraag of de beelden die ze op Lowlands hebben geschoten ergens te zien zijn. Ben benieuwd…

Cross-compiling kernel modules for Raspbian

This is a follow-up post to my post about compiling out-of-tree kernel modules for Raspbian / Raspberry Pi from last week. In that post I talked about compiling a kernel module on the Raspberry Pi itself. This time, I did the same thing, but I did it on my i386 Ubuntu workstation, using a cross-compiler.

For this to work, you need the following software:

  • The kernel source
  • A cross-compiler, and it has to be the same version that your actual Raspbian-kernel was compiled with
  • A Module.symvers file, or the kernel and all modules built

The easiest thing is to create a directory that you keep all the Raspberry Pi stuff in. If you haven’t downloaded the kernel source yet, clone the Git repository; it allows you to stay up to date. Also download the pre-built compiler toolchain using Git:

[code]
mkdir ~/raspberrypi
cd ~/raspberrypi
git clone https://github.com/raspberrypi/linux.git
git clone https://github.com/raspberrypi/tools.git
[/code]

Just for fun & exercise, instead of using the downloaded Modules.symvers, build the kernel. See http://elinux.org/RPi_Kernel_Compilation#compiling for more detailed information.

[code]
cd linux
zcat /proc/config.gz > .config
make -j 6 ARCH=arm CROSS_COMPILE=$HOME/raspberrypi/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi- oldconfig
make -j 6 ARCH=arm CROSS_COMPILE=$HOME/raspberrypi/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-
make -j 6 ARCH=arm CROSS_COMPILE=$HOME/raspberrypi/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi- modules
[/code]

Please note the ‘-j 6’, which sets the number of concurrent jobs to 6, which may be less than ideal if you have a slow (single/dual core) machine. If your computer has a quad-core processor or better, -j 6 should be fine. It will make your build go a whole lot faster.

Note: if you don’t feel like waiting for a kernel build to complete, you can also use the provided Module.symvers file, prepare and configure the kernel tree and build your module from there. Please see my previous post on how to do that; just add the cross-compilation flags.

Now, you are ready to cross-compile your out-of-tree kernel module:

[code]
cd /path/to/module/source
make -C $HOME/raspberrypi/linux ARCH=arm \
CROSS_COMPILE=$HOME/raspberrypi/tools/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi- \
SUBDIRS=$PWD modules
[/code]

Compiling kernel modules for Raspbian / Raspberry Pi

I needed to compile an out-of-tree (vendor supplied) driver for a USB device, to use it on my Raspberry Pi. Since the process was less than obvious, I’ll document it here. Maybe it will be of use to anyone else.

Normally, for compiling kernel modules, you need the kernel headers available. They have to match the version of the kernel you are targeting. In case of the Raspberry Pi running the 2012-07-15 image of Raspbian, that would be 3.1.9+. On plain Debian you would install a ‘linux-headers-x.y.z-flavour’ package, but that doesn’t seem to be available on Raspbian (at least not the right version), so we use the full kernel source from Github.

The main problem with that, is the absence of a file named Module.symvers, that contains the symbol versions of the running kernel and all of its modules. That file would normally come in the linux-headers package, that I mentioned above. To get that file, and be able to build ‘good’ modules for the kernel, you would need to build the entire kernel and all its modules yourself. At the end of the build, the file will be created. However, if you want to do that on the Pi itself, make sure you have plenty of time, because a complete kernel build will take quite a few hours.

To spare you the trouble, you can download it here: Module.symvers. Please note: this file is for the 3.1.9 kernel from Raspbian-2012-07-15, and it will not work for other kernel versions.

Assuming you have downloaded the file to your home directory, you can now download the Linux kernel source and prepare it for building out-of-tree modules like this:

cd /usr/src
sudo wget -O raspberrypi-linux-3.1.9.tar.gz https://github.com/raspberrypi/linux/tarball/rpi-patches
sudo tar xzf raspberrypi-linux-3.1.9.tar.gz
sudo ln -s /usr/src/raspberrypi-linux-eab45cb /lib/modules/`uname -r`/build
cd /usr/src/raspberrypi-linux-eab45cb
sudo sh -c 'zcat /proc/config.gz  > .config'
sudo sed -i 's/EXTRAVERSION =.*/EXTRAVERSION = +/' Makefile
sudo cp ~/Module.symvers .
sudo make oldconfig
sudo make modules_prepare

A few notes:

  • The name of the source directory is probably different in your case, because it contains the ID of the latest commit in the Git repository and commits occur regularly.
  • The sed command on line 7 is to add a ‘+’ to the version in the source. The version should be 3.1.9+, while the version in the repository is just 3.1.9.

Now most well-maintained drivers should ship a proper Makefile for building them, but the usual command line for building such a module would be something like this:

[code]
make -C /lib/modules/`uname -r`/build SUBDIRS=$PWD modules
[/code]

1 2 3 4 5 6 12