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 the target system such as ssh were unavailable.

When started without special command line arguments, Minicom defaults to Ctrl-A as the command key combination. Once you have issued Ctrl-A, you can press any of several keys which do different things.

Minicom main menu

Minicom main menu

In order to run another Minicom session within the one you are running currently, you need to change the command key (Default Ctrl-A).  You would do this by doing the following steps:

1. Ctrl-A o

2. Screen and Keyboard

3. A

4. Press the new key combination (I changed mine to Ctrl-B)

Minicom configuration menu

Minicom configuration menu

Minicom's screen and keyboard configuration menu

Minicom's screen and keyboard configuration menu

Minicom's menu for changing command key

Minicom's menu for changing command key

Now that you have changed the the command key combination for your first Minicom session, you can start another session.  Obviously this would work only if the second Minicom session is setup to use a command key other than Ctrl-B.  Since the default is Ctrl-A, you don’t have to do anything to the second session.  You can probably run even more Minicom sessions by just changing the command key but I have never tried it.  Besides, if you need more sessions, you probably ought to find a better way of accessing the target system.

Two minicom sessions

Two Minicom sessions

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 [...]

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 [...]

Here is a quick tip on how to insert the svn revision number in your c/c++ code.  This is a simple Makefile trick that will define a preprocessor constant that holds the revision number of your project.  It only works if you are using gcc as your compiler, and GNU version of make.  You will [...]