First Ride on Dubai Metro

The Metro is running! Its grand opening was on September 9th, with a fraction of the stations open. We rode it for the first time about a week later, and were very impressed.

Here's what a finished station looks like from the outside:

With my son at the station near Bur Juman. That's about 5 minutes' walk from where we live.

Inside the station, a slice of Dubai's shameless over-the-topedness.

The train wagons are simple and functional. You can walk from one wagon to another, except for the ladies' wagon and the "gold-class" wagons at the back of the train.

The ride is very smooth, and the stations are called out in Arabic and Brit-accented English. There's an annoying little music playing in the background, a few loops of electronica.

Some happy riders:

Minimal CVS Setup on Remote Server

This post briefly shows how to get cvs running on a remote server and access it in two different ways; as a pserver and over ssh. The main references I used are here:

Setting up CVS at CrazySquirrel
Getting Started with CVS by Dave O'Connor at linux.ie
Connecting to a Remote CVS Server via SSH on a non-standard TCP Port by Sean O'Donnell

As superuser, install cvs on the local and remote machines (sudo apt-get install cvs or equivalent). Then, on the remote server:

Handling Constants in ARM Assembler

This post has some examples of how to handle constants in ARM assembler.

It's nice to try things out by assembling a snippet of code, and then disassembling it to see what the assembler actually did. To test your snippets using as (the GNU assember) and GNU bintools, all you need are these two files:

min.s

                .text
                .arm
label1:         NOP
.end

Makefile

all: min.s
        arm-elf-as -ahls -mapcs-32 -o min.o min.s > min.gas
        arm-elf-objdump -Dslx min.o > min.dis

The disassembly will be dumped into min.dis.

ARM Programming with GCC and Ubuntu Linux

You can set up a cross-compiling toolchain for the ARM micro-controller using free software. For Windows, there's a package called Yagarto that includes all the components and a nifty installer. I found nothing comparable for Linux, so this post outlines a simple installation method for Ubuntu 8.10 and higher.

The Bare Metal

I've been looking for ways to learn more about low-level programming and how computers work at a really basic level. Books are useful, but nothing beats hands-on experience. You rarely get stuck and start asking good questions just from reading.

Most gadgets (routers, iPods, cameras, game consoles) are built around a micro-controller with some extra circuitry to handle I/O. Most of these chips are simpler and far less expensive than an Intel Pentium. They have different design constraints altogether.

Consider the ARM7; a 32-bit RISC processor with a 3-stage pipeline, built-in debugging support (the D in ARM7TDMI) and no MMU. ARM doesn't actually manufacture chips, they just design the core and various peripheral modules. Several companies have licensed those designs and assembled their own ARM7-based processor:

  • NXP (formerly Philips); the LPC2000 series
  • Atmel AT91 series
  • Samsung S3C2410 series
  • Cirrus EP73 series
  • Cortex M3 series

For a reasonable price you can buy a development board with an ARM7-based chip on board, with lots of break-out peripherals and I/O ports to play with. Here's the one I ordered from SKPang, with an NXP LPC-2378STK:

These boards have built-in hardware support for debugging and for transferring data to/from RAM or Flash, via JTAG. You'll find a 20-pin JTAG socket on the development board, connected to pins on the micro-controller.

So the basic idea is this

  • You connect the board to your PC using a JTAG to USB adapter.
  • Your PC runs OpenOCD (On Chip Debugger), that sends/receives JTAG-type data down the USB line.
  • OpenOCD also listens on port 3333 for GDB commands. So you can program and debug the board using GDB. This gives the possibility of using further tools that interface with GDB, such as Eclipse or Insight.

From your PC, you use a cross-compiler to turn your program into a binary file that will run on the ARM7TDMI. GCC is well-suited for this. You also need to transfer the executable code to your board in a raw form, without the containers that you use for various operating systems (Linux ELF, etc.). The GNU binutils collection provides tools for this and more.

In the next few posts I'll show an easy way to set up an ARM cross-compiling toolchain on Ubuntu Linux, using only free software.

Flight 666 to Dubai

A few days ago, I was sipping coffee and staring at a screen of FORTRAN 77 code when I got an email saying Bruce Dickinson of Iron Maiden would be dropping by the office, to take a ride in our A380 flight simulator.

Facts:

  1. Iron Maiden is one of the all-time most awesome metal bands.
  2. Mr. Dickinson is arguably the greatest metal singer of all time.

Dubai Metro Under Construction

It's not every day that you see a major piece of city infrastructure being built. Unless you live in Dubai.

Here are some pictures of the Dubai Metro, which is currently under construction. Once it's finished, it will supposedly be the largest fully automated transport system in the world. Check out these links to a Route map for the Metro, and an artist's impression of what it might look like when completed.

Most of the elevated railway runs parallel to major highways in the city. The photo above shows a section along Sheikh Zayed Road.

Construction takes place in spurts and stops along the whole network, but you can deduce some of the building methods from the various unfinished states. There are two types of railway sections: a simple span supported on both ends by a light column, and a heavier pivoting span supported by one large column in the center as you can see above (the left-most, fat column).

The light column supports are made in two steps: first the vertical column is built in place by pouring concrete on a rebar (steel) frame. Then a prefabricated horizontal cross-piece is lowered onto the vertical column by a crane. See the two right-most supports in the photo above. The heavy pivot-type supports are entirely molded and built in place. See all the red scaffolding in the photo.

The railway spans sitting on those heavy pivot-type supports are assembled in mid-air by stacking together short pre-fabricated sections. Heavy lifting is done by a crane. As you can see, bracing has been added under both sides to keep the span from pivoting during assembly.

The other simple railway spans, which are more common, are also assembled in mid-air by a weird yellow monster-machine. The machine straddles two support columns, and lifts pre-fabricated sections from the ground, lining them up with the rest of the span so they can be fastened:

Here's an interesting look at Jebel Ali Metro station, being built around the track:

Jeff Healy

With total shock and regret I just discovered that Jeff Healy is no longer of this world.

Jeff Healy was an outrageously talented Canadian guitar player, who happened to be blind. I got turned on to his music by my first and only guitar teacher, Joseph Poirier, when I was a kid growing up in Cheticamp, Nova Scotia. I was never a big fan of the blues, but Jeff's playing didn't fit neatly into that box or any other. Powerful, wild, melodic, endlessly creative. I saw some performances of his on MuchMusic, and he was even better live in person.

Pakistan's Oops

Pakistan accidentally disconnected itself from the Internet yesterday as it tried to block (censor) YouTube, apparently over some videos that offend their religion. While this was happening, YouTube became unavailable to the rest of the world for about two hours.

The best explanation I've found for what happened is at arstechnica.

Non-Programming

What's more fun than writing a new program? Avoiding to write a new program!

Every two months or so, I've been compiling a little movie of our son Noah, from all the little videos we take with our digital camera. The quality is not great (Super-8, anyone?), but quality is not really the point of the exercise.

My usual routine was :

  • transfer the camera's Quicktime files to my desktop PC
  • import them (slowwwwly) into a big bloated Windows video editor
  • drag the videos end-to-end onto the main video track
  • rotate some of them (Landscape -> Profile) by manipulating the editor's effects "track" that runs alongside the video
  • export the video to a Windows-compatible AVI format

It's not totally obvious how to automate this process, because I need to make decisions along the way : which videos will I include, which ones need to be rotated, some manual editing, and then setting up the choice of codec for the final output file.

Windows Explorer for WinXP has a neat feature where you can right-click on a picture (JPEG, GIF, etc.), and rotate it either clockwise or anti-clockwise. That saves a lot of time. You can look at a whole directory of picture thumbnails, visually select all the ones that need rotation, and do the batch in one step while I do something else productive like read Slashdot. Why can't I do that with video?

Well, it's "super easy" in Ubuntu. The default file manager for Ubuntu is Gnome's Nautilus. If you put a shell script in

~/.gnome2/nautilus-scripts/

it will be available in the Nautilus' right-click menu under "Scripts". That's wickedly cool. Now you can browse your directories, visually select a bunch of videos from their thumbnails, and Nautilus will run your script handing it the file names as command arguments.

That's exactly what I needed for my video editing job. After installing a few extra libraries (mencoder, GStreamer Quicktime plugin), here's what I can do with shell commands:

  • Convert Quicktime .MOV file to .AVI :

    mencoder -oac pcm -ovc lavc -o out.avi in.mov
  • Rotate a video file clockwise 90 degrees:

    mencoder -oac copy -ovc lavc -vf rotate=1 -o out.avi in.avi
  • Make all these portrait and landscape videos "square" (aspect ratio 1) by adding black bands, so that you can now merge them end-to-end into one big file.

    mencoder -oac copy -ovc lavc -vf expand=:::::1/1 -o out.avi in.avi
  • Concatenate a bunch of AVI videos into one big file:

    mencoder -oac copy -ovc copy -o cat.avi in1.avi in2.avi in3.avi
  • Create a Windows-compatible AVI file (MPEG4 video, PCM audio):

    mencoder -oac pcm -ovc lavc -lavcopts vcodec=msmpeg4v2 -o win_out.avi in.avi

You put these commands in a script file, and rewrite them to make use of the command-line arguments that are passed from Nautilus. Consider the case where you want to do an operation on each filename handed to your script:

#! /bin/bash
#
# Detects videos from the filenames in the
# command arguments, and adds what black bands are necessary to
# achieve an aspect ratio (w/h) of 1.0.
# This is useful because many merge utilities doesn't work properly if  
# merging avi files of differing aspect ratio.
# Only tested so far on .AVI
#
# Depends on
#  - mencoder (sudo apt-get install mencoder)

while [ $# -gt 0 ]; do

    mime=`file -b -i "$1"`
    if [ `echo $mime | cut -f1 -d"/"` = "video" ]; then

        # do the aspect ratio correction
        mencoder -oac copy -ovc lavc -vf expand=:::::1/1 -o "temp_$1" "$1"

        # remove old file if successful
        if [ $? = 0 ]; then
            rm "$1"
            mv "temp_$1" "$1"
        fi

    fi
    shift
done

Notice the quotes, used strategically to avoid problems with filenames which have spaces in them.

If you want to run one command on all the files at once, things are simpler:

#! /bin/bash
#
# Assumes filenames received are avi videos, and concatenates them into
# one large video, to be called cat.avi
#
# Depends on :
#  - mencoder (sudo apt-get install mencoder)
#
mencoder -oac copy -ovc copy -o cat.avi "$@"
Syndicate content