I stumbled on gource the other day while browsing the interwebs.   It is a software version control visualization tool mainly designed to work with Git, Mercurial and Bazaar.   Since we have been using SVN for almost 2 years now here at Ciholas Technologies, I thought it would be cool to see our SVN activity visualized.

After a few hours of playing around and a wonderful suggestion for the music from my wife, here is the result:

ciholas-svn-vis-1080p from azeey on Vimeo.

Using Gource

Setup

Getting gource installed was a breeze since it’s already included in the Ubuntu repositories, although later on I had to build it from source to get the latest available version.  The next step was to generate the SVN log and convert it to a format gource would understand.  The easiest and quickest way that worked for me was issuing “svn log” on the svn repository and piping it to a file followed by running the conversion script on this file.

I found two scripts in the gource wiki to do the conversion.  The one that worked the best for me, albeit slower, was the ruby script svn2gource.

1
2
$ svn log --verbose svn://repo | tee changelog-plain.txt
$ ./svn2gource changelog.txt | tee changelog-gource.txt

Interactive Gource

At this point, you are ready to run gource.  You can run gource interactively.  In this mode you can manually change the camera mode, speed, and even the date.  The command for that is:

1
$ gource --log-format custom changelog-gource.txt

Interactive keyboard commands (Copied directly out of the manpage):

(V)   Toggle camera mode
(C)   Displays Gource logo
(M)   Toggle mouse visibility.
(N)   Jump forward in time to next log entry.
(+-)  Adjust simulation speed.
(<>)  Adjust time scale.
(TAB) Cycle through visible users
(ESC) Quit

Gource to Video

Gource has the ability to output uncompressed sequence of screenshots in PPM format using the “–output-ppm-stream” option, which can then be processed by another program (such as ffmpeg) to produce a video.  There are several options that gource provides to help you tweak your video such as font size, screen size,  and logo positions.  After several experimentation,  I came up with this script:

1
2
3
4
 #!/bin/bash
gource --title "Ciholas Technologies SVN Visualization" --font-size 14 --logo logo2.png --logo-offset 1620x30 -1920x1080 --highlight-all-users --camera-mode track --stop-at-end -s 0.5 -i 63072000 \
--log-format custom  ciholas-svn-plain-gource-sorted.log --output-ppm-stream - | ffmpeg -y -b 3000K \
-r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre default ciholas-svn-gource-sorted-1080p.mp4

FFmpeg with h264 Codec

In order for the script to work, you need to have the h264 codec libraries and ffmpeg compiled with the h264 codec flag.  Unfortunately, using ffmpeg with the libx264 option wouldn’t work for me in Ubuntu.  I believe this was because ffmpeg on ubuntu doesn’t have the h264 option enabled by default for legal reasons.  You would have to compile ffmpeg from the source yourself, and there are instructions here on how to do that.  Fortunately, I found a set of scripts here that automatically update both x264 and ffmpeg to the latest versions available from their SVN and git repos.  You might still have to install some dependencies but the scripts should handle all the compiling.

One of the tasks I have to carry out at work lately is test custom Vortex86DX based boards for build defects such as malfunctioning input pins, relays, serial ports, etc. I used this as an opportunity to use python’s unittest framework. I am not writing about the unit tests themselves but how I got them to work on the Vortex86DX. We are running a fairly recent version of Linux with a customized (stripped out) Ubuntu distro on this board and it has Python-2.6 installed on it. The tests involved using GPIO ports and so I had to use some kind of module that would expose the sysio c functions such as outb,inb and iopl so Cython came to mind. I found a nice pyx file for sysio on pypi and I was set until I realized my development environment was 64 bit Ubuntu and that cross compiling using distutils as far as I know, is impossible without installing 32 bit python. So I set out to do that but compiling 32 bit python wasn’t trivial either. Thanks to some google searching, I was finally successful.

Compiling 32 bit python on 64 bit Linux host:

Once I downloaded the python source from python.org here is the command I run to successfully build python.

1
2
3
4
5
$ CC="gcc -m32" LDFLAGS="-L/lib32 -L/usr/lib32 \
-L`pwd`/lib32 -Wl,-rpath,/lib32 -Wl,-rpath,/usr/lib32"
\
./configure --prefix=/usr/local/python32 --enable-unicode=ucs4
$ make
$ make install

This would only work if you have gcc-multilibs and all the necessary 32 bit libraries installed. It was necessary to have the –enable-unicode flag because the python on the Vortex86DX was compiled with this flag.

Using Scons to build Cython modules:

At this point, I could have used my newly installed python32 and use distutils to build the module but it didn’t occur to me until later on so I used scons. Scons understands how to build shared libraries with all the correct gcc flags so it was easier to use it than to write a makefile. Annoyingly scons adds the “lib” prefix to the libraries it builds so I had to change sysio.pyx to libsysio.pyx or else python wouldn’t import the resulting .so file.

1
2
3
4
5
6
7
8
9
libname='libsysio'
src=libname+'.c'
pyx=libname+'.pyx'
bld = Builder(action ='cython $SOURCE')
env = Environment(BUILDERS = {'cython': bld})
cython =env.cython(pyx)
SharedLibrary(libname, src, CCFLAGS='-m32',LINKFLAGS='-m32',CPPPATH='/usr/local/python32/include/python2.6')
Requires(src, cython)
Clean(cython,src)

I am really new to cython and scons so I am not sure if this is the best way to build cython modules but the user guide at the cython website had a “to be completed…” entry for scons.

Using the sysio module:

Now that I had a 32 bit module, I was able to start up the python shell and toggle some pins and proceed with my unit tests.

1
2
3
4
5
6
7
8
from libsysio import *
# Refer to the vortex86dx datasheet
port1dir = Device(0x99)
port1data = Device(0x79)
# Set all ports to output
port1dir.outb(0xff)
# Drive all pins high
port1data.outb(0xff)

I use Minicom as a serial terminal in most of my embedded systems projects. Recently I discovered how to use a Minicom session inside another Minicom session. It is not a trivial matter if you don’t know how to change the settings in Minicom. This was helpful when other means of accessing the terminal in [...]

Here is a small command that can be used to copy a file to several other files. That is, if you have a file called test and you want 5 copies of it names test1,test2,…test5, you would use this command: 1for i in {1..5}; do cp test{,$i};done I have submitted it to

This is a quick tip on making video from the Logitech Quickcam work on skype. I haven’t thoroughly tested this but its working for me. You may potentially need to install some more packages. I tested this on my webcam with usb info 046d:08da Logitech, Inc. QuickCam Messanger. Install the v4l library: 1sudo apt-get install [...]

If you use one of the many Debian derived distributions such as Ubuntu, you may be familiar with the network interfaces file located at /etc/network/interfaces.  This file is part of the ifupdown package and gives users a high level access to configure how their system is connected to the network.  One really cool feature of [...]