Om den senaste tidens fildelarjakt

Märker i DN att upphovsrättsindustrin börjat jaga fildelare igen. Hittills verkar metoden vara hyffsat grovhuggen, och man förlitar sig på enkel skrämseltaktik. Min hållning till det hela är som vanligt: nerladdningens påverkan på industrin är gynnsam. Annars skulle detta motsäga en annan uppsättning lagstiftning, de mot barnporr och olaga våldsskildring (snuff). Antingen gynnar spridning av ljud och bild produktionen därav, eller så gör den det inte. Vissa skulle kunna hävda att det beror på materialets natur, men det resonemanget tror jag inte på.

Detta är för övrigt varför vi inte bör konsumera innehåll producerat av de som lobbat för nuvarande lagstiftning.

23cm QSO attempt

Time for another radio post. Yesterday me and SA2KNG made an attempt at holding a conversation (QSO) on the 23cm band. The plan was to use HackRF to do narrowband FM modulation/demodulation on my end, with KNG using proven equipment on his end. We only got as far as him possibly detecting a carrier from my location, which might have been the HackRF’s local oscillator. Future attempts may yield more success..

23cm setup, with Yagi-Uda antenna, HackRF and laptop

23cm setup, with Yagi-Uda antenna, HackRF and laptop

Contributing a Golay encoder/decoder to codec2

I’ve been following the development of FreeDV, a libre very-low bitrate digital voice system for amateur radio. Central to this is codec2, the codec used in the system. A few days ago a thread popped on the [codec2-dev] mailing list that the existing implementation of binary Golay codes was not (L)GPL compatible and that a replacement was needed. Since I’ve held a bit of an interest in forward error correction (FEC) lately I decided to take a stab at reimplementation.

The implementation ended up not taking terribly long. The main issue was that the old decoder would shift the return value of golay23_decode() left 11 bits compared to golay23_encode() whereas my initial attempt would do the most obvious thing, having golay23_decode(golay23_encode(x)) == x. But once I figured this out the rest was trivial.

The result of my efforts can now be seen in golay32.c on the codec2-dev SVN. This whole thing is also giving me inspiration to continue further down the FEC path, which is especially relevant for the ULV project (putting a scientific instrument on the moon). I might do a post with more information about that on the other blog..

Revision 2016

Went to the Revision demoparty in Saarbrücken this easter, which has become a bit of a tradition. The trip went via a flight to Amsterdam, from which me and four others rented a car and drove the rest of the way. The trip itself went quite well. Didn’t end up producing any entries, which is unusual. But I was not alone – jvb didn’t have anything either, and we both just sort of poked a little at various projects and hung out with people talking about all kinds of things. Knoeki on the other hand was considerably more productive, having two productions entered in the compos and winning third place in the 2D demo competiion (congrats!)

On to the pictures:

Tracked music compo

Tracked music compo

Knoeki's notoriously crusty/heavily modified C64

Knoeki’s notorious modified C64

Nighttime bonfire with people

Nighttime bonfire with people

The winner of the Wild compo, with their gigantic RGB LED display made from a building facade

The winner of the Wild compo, with their gigantic RGB LED display made from a building facade

Tried to grab a shot of the full moon, went so-so

Tried to grab a shot of the full moon, went so-so

Managed to snag a HACKERS poster, for Jupiter 666

Managed to snag a HACKERS poster, for the ill-fated Jupiter 666 system

Didn’t manage to snap many pictures of people this year, for some reason. Maybe next year

Compiling KiCAD

While drawing some schematics for Umeå Music Hack Space I noticed around half of my footprints aren’t working. Long story short, turns out I needed to compile KiCAD because Debian chose to disable the Github plugin for getting proper footprints. This post documents the process.

First install prerequisites per this site, plus a few more:

apt-get install libwxbase3.0-dev libwxgtk3.0-dev libgl1-mesa-dev \
libglew-dev libglm-dev libcurl4-openssl-dev libboost-dev \
libboost-thread-dev libboost-system-dev libboost-context-dev \
libboost-iostreams-dev libboost-locale-dev libboost-regex-dev \
libssl-dev wx-common swig libbz2-dev bzr

The Boost version at the time of writing was 1.58.

Download and extract the source code:

dtrx -n kicad-4.0.2.tar.xz

Configure using cmake:

cd kicad-4.0.2
mkdir build
cd build

Finally, we’re ready to compile:

make -j3 -k; make; make

This will take half an hour or so, so go do some errands. The repeated makes are due to KiCAD’s build system having some kind of depency issue or something. I have to “make” several times, so running it first with -k should get as much as possible built, then the last two takes it the rest of the way.

Finally, we’re ready to install. As root just:

make install

That’s it!

In order to avoid having to run proprietary code from Google I cobbled together a script a few days ago combining youtube-dl and vlc. The result is far from perfect, but allows me to both download videos off of YouTube for safekeeping and make use of features in vlc such as fixing aspect ratios and incorrect cropping. I’m placing the following script in the public domain, in the hope that it will be useful to someone:

TITLE=$(youtube-dl -j $1 | sed -e 's/.*"fulltitle": "//;s/".*//')
echo $TITLE
cd /tmp
youtube-dl $1 -o "${TITLE}.mp4" &

# A bit of an ugly hack here, but it works
#if [ -f "${TITLE}.mp4" ]
#    # Already have the file
#    vlc "${TITLE}.mp4"
#    exit 0

# Wait for the download to start
while [ ! -f "${TITLE}.mp4.part" ]
    echo Waiting
    sleep 1

# Wait a little more so we have some data..
sleep 1
vlc "${TITLE}.mp4.part"

Some improvements could still be made. One issue is that sometimes the download finished during the final sleep, so vlc get the wrong filename. Meh!

edit: this feature is now built into both vlc and mpv, and implemented much better. Yay!

Setting up GNURadio for Raspberry Pi 2

ACTUALLY just download this Raspbian image which comes with gnuradio + hackrf + all the good stuff already (magnet link, direct link).

Another possibility is to use the regular Raspbian image and add the appropriate ppa with a prebuilt gnuradio in it. See this link for more information about that. In short:

Edit /etc/apt/sources.list and add the following line:

deb jessie main

Then update apt and install gnuradio and gnuradio-dev:

sudo apt-get update && sudo apt-get install gnuradio gnuradio-dev

Installing gqrx + osmocom + related stuff is also recommended:

sudo apt-get install gr-osmosdr libosmosdr-dev gqrx-sdr

That should get you set up for developing with gnuradio, grc and related python things :)

So far I’ve found 500 ksps is about the maximum samplerate the RPi2 can handle when running gnuradio via Python. It might be possible to go faster, since hackrf_transfer claims a transfer speed of 20 MiB/s is possible (corresponding to 10 Msps).

I’m leaving the compilation guide I already started as-is, despite not getting it to do what I wanted. Perhaps it’ll be useful to someone:

This post is an attempt at document my getting hackRF One + GNURadio running on Raspberry Pi 2.

gnuradio requires CMake>=2.8.10 for NEON support, raspbian ships with cmake 2.8.9. Grrmblr. So install that first:

git clone
cd cmake
git checkout v2.8.10
./configure && make -j3 && sudo make install

Three cores are used for make to speed things up (-j3). Four would cause X to hang. Configuring and compiling cmake will take a while, so go grab a coffee, do laundry or somesuch.

Next set up hackrf. I didn’t record this step, but if I recall correctly you need to download, compile and install gr-osmosdr. Something like this:

git clone git://
cd gr-osmosdr
mkdir build
cd build
cmake ..
make -j3
sudo make install

You can check that you got it right by running hackrf_info, then hackrf_transfer -c 127 -f 433960000 to check that the transmit functionality works (remember to attach an antenna).

Finally it is time to install gnuradio itself. A small note on boost here, since it always tends to be a problem for people stumbling upon guides like this: I’m using version 1.49. At the time of writing the latest version available via apt was 1.50. The latest official version (outside Debian) was 1.60.0.

sudo apt-get install libboost-dev libboost-filesystem-dev \
    libboost-system-dev libboost-test-dev \
    libboost-program-options-dev python-pip libcppunit-dev \
    libfftw3-dev   #TODO: gr-fft doesn't build, figure out why
sudo pip install cheetah
git clone gnuradio
git checkout 72dcbdb  #optional, master as of writing
git submodule init
git submodule update
mkdir build
cd build
cmake ..
# For some reason NEON doesn't work, so disable it by in CMakeCache.txt changing the line
# to
nano CMakeCache.txt  #do the thing
sudo make install

This will build and install.. some parts of gnuradio. Not the Python stuff though, which is what I need. Fffffff-