Category Archives: Softwareengineering

Fixing a broken Git repository

After having several hard kernel crashes, some of my files ended up empty on my disk. I then got errors like:

error: object file .git/objects/81/b43db0dadcafe18eef75c60c57cc496d523d83 is empty
error: object file .git/objects/fb/9b5b3daa56c7833be66f0eaac2b5a906474627 is empty

I can recommend this Wiki page on which tells how recovery basically should be done. This post shows some of those steps a bit more “hands-on”. I started with moving this corrupt (empty) object away, and then got this message when doing some git operations:

fatal: unable to read 81b43db0dadcafe18eef75c60c57cc496d523d83

Read more »

Vybrid bare-metal fun

Freescale Vybrid SoC

Freescale Vybrid SoC

In preparation to my talk at BetterEmbedded I had a deeper look into the second core of Freescales Vybrid VF6xx SoC. I wanted to create a bare-metal test firmware for the Cortex-M4 processor. As the Cortex-M4 is a companion of the Cotex-A5 in the same SoC, its boot process is different compared to a normal Microcontroller (e.g. STM32F4 or similar). Microcontroller usually boot directly from memory mapped NOR flash.

ARM SoCs in general contain a small, internal boot ROM where the cores start from. This boot ROM then tries to boot from different devices, such as NAND or SD-Card. For the Vybrid SoCs normally the Cotex-A5 is the boot CPU, which in my case is running Linux from NAND (the Timesys BSP). On startup, the Cortex-M4 is in an unclocked state and need to be started from the Linux side. With the Timesys BSP, a Vybrid specific kernel module called mcc is provided. This kernel module not only implements the Multi-Core Communication library but also allows to load an image into RAM and start the secondary CPU. The utility mqxboot allows to access this functionality from userspace. This components implement the boot procedure for the Cortex-M4 described in chapter 19.11, “Running Secondary Core”, of the Vybrid Reference Manaul.

The secondary core has not access to a NOR storage as it would have in a microcontroller. Instead the firmware runs completely from RAM. Read more »

Cortex-M3 supervisor call (SVC) using GCC

The Cortex-M3 has a new assembler instruction SVC to call the supervisor (usually the operating system). The ARM7TDMI used to call this interrupt SWI, but since this interrupt works differently on Cortex-M3, ARM renamed the instruction to make sure people recognize the difference and implement those calls correctly. The machine opcode however is still the same (bits 0-23 are user defined, bits 24-27 are ones).

On the Cortex-M3, other interrupts can interrupt the processor during state saving of the SVC interrupt (late arrival interrupt handling). Those late arriving interrupts most certainly leave the registers corrupted after execution. Therefor we cannot read the parameters form registers r0 to r4 directly as we could on the ARM7TDMI using SWI interrupts. Fortunately, the Cortex-M3 saves all registers used in standard C procedure call specification (ABI) on the stack. So the SVC handler can get the parameters directly from the stack.

Cortex-M3 stack frame

Cortex-M3 stack frame

Read more »

Linaro embedded toolchain on Ubuntu 64-Bit

Linaro provides a specialized toolchain for embedded (bare metal) development. But after installing, I could not execute the binary:

$ gcc-arm-none-eabi-4_7-2012q4/bin/arm-none-eabi-gcc
-bash: gcc-arm-none-eabi-4_7-2012q4/bin/arm-none-eabi-gcc: No such file or directory

Also ldd claims its not dynamically linked:

$ ldd gcc-arm-none-eabi-4_7-2012q4/bin/arm-none-eabi-gcc
 not a dynamic executable

The truth is: it is dynamically linked, but against 32-Bit libraries. And since I have not yet installed any 32-Bit library, ldd doesn’t work properly. According to the readme, you should install the 32-Bit variant of libc and libncurses. Since Ubuntu is Multi-Arch, you can easily install those libs:

sudo apt-get install libc6:i386 libncurses5:i386

Now you should be able to run the Linaro toolchain on 64-Bit variants of Ubuntu.

Building an image for BeagleBone



A few day’s ago TI anaounced a new BeagleBoard: BeagleBone. It’s a stripped down BeagleBoard which basically only has a USB slave-client (providing a serial console, a JTAG debugger and an USB connection to the processor) an USB host controller, an ethernet port and a lot of I/O’s on the PIN-Headers for $89. It’s a bit inspired by the popular Arduino boards. I always thought about buying a BeagleBoard, but it was a too expensive and too functional to use it for my electronic projects…

So in my case, TI’s strategy worked: I want some more power, I want Linux, but it souldn’t be too expensive. I’m going to buy the BeagleBone, i’m just not yet sure about the quantity 😉 But it’s not here yet, in the meanwhile I looked at the software a bit: How can I create root images for the BeagleBone? Read more »

Subversion: Move folder from one repository to another

A branch of a project went into a totally different direction. Therfor I wanted to move that specific folder into a new repository e.g.:


To archive this there are several steps needed. You will need shell access to the server where the repository is located.

  1. Backup the source repository (creating a dump) and filter the specific source folder
  2. Create the new repository and the folder structure
  3. Import the dump file into the new repository
  4. Move the folder to trunk Read more »

Python web frameworks

Lately I played around with python web frameworks. After working on a web project with Django last year, I discovered Aspen lately. There are many other frameworks out there. Nevertheless, I’d like to share my findings about Django and Aspen. 🙂

  • Both use python, which is generally known as being fast. It’s compiled and therefore usually less memory hungry than other web oriented languages. There are also better ways to optimize performance, e.g. by writing a custom web server, if your website has high traffic.
  • Both frameworks are nicely object oriented. You get a request object (Django, Aspen) which encapsulate all information from the client. The application can use all its information to generate the output, encapsulated in a response object (Django, Aspen). When errors occur, you can simply raise an error response object in the middle of your code.
  • Aspen and Django are providing templating engines which are very similar to each other.
  • URL’s like score in terms of readability and alterability. Also, they simply look better! Both frameworks encourage the user to use such URL’s without file endings or unreadable long query strings (like ?page=start&session=123). While Django uses a configuration file, Aspen uses the file system itself to create such URL’s.

However, there are also big differences between these frameworks… Read more »

Zenphoto Dokuwiki integration

For a small web project I recently decided to use Zenphoto as photo gallery and Dokuwiki as Main page. I wanted that Dokuwiki and Zenphoto share they’re user database. But both ways, neither Zenphotos user database in Dokuwiki nor Dokuwikis user database in Zenphoto seemed to be simple to implement. So I ended up in a Dokuwiki plug in which synchronize the user database with Zenphotos user database. For that purpose the plug in need the MySQL login information for Zenphotos database. It also allows to enable auto login for Zenphoto when login on Dokuwiki (by simple setting the right cookie). I created a Github repository and added a plug in wiki page to the Dokuwiki website. I thought it might be useful for anybody else…

Glibc 2.11 breaks gcc’s backward compatibility

Today I compiled a ARM Toolchain on my Ubuntu Lucid Lynx 10.04 PC. As I passed that to my friend he got this message:

arm-elf-gcc: /lib/ version `GLIBC_2.11' not found (required by arm-elf-gcc)

Oh yeah, binary compatibility is sometimes hard in open source world. On the other side, why binary compatibility, we have the source! 😀 But of course, its easier to use binaries then compile the same on every machine…
I found out that the function mkstemps is used from the new glibc version:

$ readelf -a arm-elf-gcc | grep GLIBC_2.11
    11: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mkstemps@GLIBC_2.11 (4)
   427: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mkstemps@@GLIBC_2.11
  008:   3 (GLIBC_2.3.4)   0 (*local*)       2 (GLIBC_2.2.5)   4 (GLIBC_2.11)
  0x0030:   Name: GLIBC_2.11  Flags: none  Version: 4

The functions, namly mkstemps and mkstemps64, were added with glibc 2.11. Grepping showed that the function mkstemps is used inside the library “libiberty”. The configure script checks if the function is available on the host, if yes, it will use the hosts function, if not, it will build its own. As soon as the compiler descide to use the hosts mkstemps function, the resulting binary need glibc 2.11, which I would like to avoid.
The solution is pretty simple: Add the object file “mkstemps.o” to the variable REQUIRED_OFILES in This forces the Makefile to compile its own mkstemps function, which will be prefered when gcc is linked.

$ vi libiberty/
REQUIRED_OFILES = ./mkstemps.o                                          \
        ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o ./sha1.o        \

My gcc’s glibc requirement is now 2.4, which is much older then gcc 2.11! As a result my gcc runs even on very old linux systems 🙂

Tastatur in Netbeans wird gelockt (Ubuntu 7.04)

Seit einiger Zeit hatte ich öfters das Problem beim Abeiten mit Netbeans unter Ubuntu 7.04 dass die Tastatur gelockt wurde. Ich konnte einfach keine Eingaben mehr machen in irgendeine Sourcedatei. Das Problem ist ein Fehler in der aktuellen Version der JavaVM. Ich habe die beiden aktuellsten Versionen, Java 5 und 6, installiert. Für Netbeans verwendete ich Java 6, wobei ich gelesen habe dass Java 5 diesen Bug nicht hatt. Deshalb versuchte ich Netbeans mit Java 5 zu starten, was jedoch auch beim wechseln der Standard VM nicht gelang (was ich mit galternatives änderte).

Netbeans verwendet ein eigene Konfigurationsdatei um die zu verwendende VM zu finden. Dieser Pfad kann in der Datei netbeans.conf angepasst werden.

$ sudo vi /opt/netbeans-5.5/etc/netbeans.conf

Nun läuft Netbeans wieder ohne Keyboardlocks, und das Programmieren macht wieder richtig Spass 🙂