Sunday, 25 April 2010

XCB programming is hard

I have been looking at writing a program with XCB today. I seem to pick projects that are an exercise in undocumented frustration.

All I wanted to do was have an x window open and be able to plot an arbitrary changeable image to it (no I am not writing yet another image viewer!). The XCB documentation seems to be a cross between "good luck with that" and some rather erratic doxygen output.

The utility libraries are rather skimpy on examples and its tiresome worrying that when you feed any of the xcb function names into Google (web or codesearch) there are very, very few hits beyond the freedesktop API docs.

My favourite has to be the xcb_image_create documentation, go on I challenge anyone to follow that logic without going and reading the sources! The answer (afaict) is that if you pass a pointer in base that pointer will be freed by xcb_image_destroy otherwise the data pointer will be used, unless the bytes value is too small in which case memory will be allocated with malloc and the passed pointer ignored.
Anyhow, I have succeeded and the result is below, mainly so I do not loose it :-)

/* XCB application drawing an updating bitmap in a window
*
* Inspired by the xcb black rectangle in a window example
*
* Copyright 2010 V. R. Sanders, released under the MIT licence
*/

/* compile with:
* gcc -Wall -lxcb-icccm -lxcb -lxcb-image -o disp disp.c
*/

#include <string.h>

#include <xcb/xcb.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_atom.h>
#include <xcb/xcb_icccm.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

static xcb_format_t *
find_format (xcb_connection_t * c, uint8_t depth, uint8_t bpp)
{
const xcb_setup_t *setup = xcb_get_setup(c);
xcb_format_t *fmt = xcb_setup_pixmap_formats(setup);
xcb_format_t *fmtend = fmt + xcb_setup_pixmap_formats_length(setup);
for(; fmt != fmtend; ++fmt)
if((fmt->depth == depth) && (fmt->bits_per_pixel == bpp)) {
/* printf("fmt %p has pad %d depth %d, bpp %d\n",
fmt,fmt->scanline_pad, depth,bpp); */
return fmt;
}
return 0;
}

void
fillimage(unsigned char *p, int width, int height)
{
int i, j;
for(i=0; i < width; i++)
{
for(j=0; j < height; j++)
{
if((i < 256)&&(j < 256))
{
*p++=rand()%256; // blue
*p++=rand()%256; // green
*p++=rand()%256; // red
} else {
*p++=i%256; // blue
*p++=j%256; // green
if(i < 256)
*p++=i%256; // red
else if(j < 256)
*p++=j%256; // red
else
*p++=(256-j)%256; // red
}
p++; /* unused byte */
}
}
}

xcb_image_t *
CreateTrueColorImage(xcb_connection_t *c,
int width,
int height)
{
const xcb_setup_t *setup = xcb_get_setup(c);
unsigned char *image32=(unsigned char *)malloc(width*height*4);
xcb_format_t *fmt = find_format(c, 24, 32);
if (fmt == NULL)
return NULL;

fillimage(image32, width, height);

return xcb_image_create(width,
height,
XCB_IMAGE_FORMAT_Z_PIXMAP,
fmt->scanline_pad,
fmt->depth,
fmt->bits_per_pixel,
0,
setup->image_byte_order,
XCB_IMAGE_ORDER_LSB_FIRST,
image32,
width*height*4,
image32);
}

int
main (int argc, char **argv)
{
xcb_connection_t *c;
xcb_screen_t *s;
xcb_window_t w;
xcb_pixmap_t pmap;
xcb_gcontext_t gc;
xcb_generic_event_t *e;
uint32_t mask;
uint32_t values[2];
int done=0;
xcb_image_t *image;
uint8_t *image32;
xcb_expose_event_t *ee;
char *title="Hello World!";
xcb_size_hints_t *hints;

/* open connection with the server */
c = xcb_connect (NULL, NULL);

if (!c) {
printf ("Cannot open display\n");
exit (1);
}

s = xcb_setup_roots_iterator (xcb_get_setup (c)).data;

/* printf("root depth %d\n",s->root_depth); */

/* create image */
image = CreateTrueColorImage(c, 640, 480);
if (image == NULL) {
printf ("Cannot create iamge\n");
xcb_disconnect(c);
return 1;
}
image32 = image->data;

/* create window */
mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
values[0] = s->white_pixel;
values[1] = XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_KEY_PRESS |
XCB_EVENT_MASK_BUTTON_PRESS;

w = xcb_generate_id (c);
xcb_create_window (c, XCB_COPY_FROM_PARENT, w, s->root,
10, 10, image->width, image->height, 1,
XCB_WINDOW_CLASS_INPUT_OUTPUT,
s->root_visual,
mask, values);

/* set title on window */
xcb_set_wm_name(c, w, STRING, strlen(title), title);

/* set size hits on window */
hints = xcb_alloc_size_hints();
xcb_size_hints_set_max_size(hints, image->width,image->height);
xcb_size_hints_set_min_size(hints, image->width,image->height);
xcb_set_wm_size_hints(c, w, WM_NORMAL_HINTS, hints);

/* create backing pixmap */
pmap = xcb_generate_id(c);
xcb_create_pixmap(c, 24, pmap, w, image->width, image->height);

/* create pixmap plot gc */
mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND;
values[0] = s->black_pixel;
values[1] = 0xffffff;

gc = xcb_generate_id (c);
xcb_create_gc (c, gc, pmap, mask, values);

/* put the image into the pixmap */
xcb_image_put(c, pmap, gc, image, 0, 0, 0);

/* show the window */
xcb_map_window (c, w);
xcb_flush (c);

/* event loop */
while (!done && (e = xcb_wait_for_event (c))) {
switch (e->response_type) {
case XCB_EXPOSE:
ee=(xcb_expose_event_t *)e;
/* printf ("expose %d,%d - %d,%d\n",
ee->x,ee->y,ee->width,ee->height); */
xcb_copy_area(c, pmap, w, gc,
ee->x,
ee->y,
ee->x,
ee->y,
ee->width,
ee->height);
xcb_flush (c);
image32+=16;
break;

case XCB_KEY_PRESS:
/* exit on keypress */
done = 1;
break;

case XCB_BUTTON_PRESS:
fillimage(image->data, image->width, image->height);
memset(image->data, 0, image32 - image->data);
xcb_image_put(c, pmap, gc, image, 0, 0, 0);
xcb_copy_area(c, pmap, w, gc, 0,0,0,0,image->width,image->height);
xcb_flush (c);
break;
}
free (e);
}

/* free pixmap */
xcb_free_pixmap(c, pmap);

/* close connection to server */
xcb_disconnect (c);

return 0;
}




Friday, 16 April 2010

Claudia black makes this look good

OK maybe the title is a bit of a reach, but she is pretty and my topic is dull.

It is the school holidays and between entertaining the kids I have been experimenting with the vala (see there is the link to the title) language. Overall I really like it, building a usable graphical GTK application is a snap and that side of it works well.

Unfortunately, and here comes a a whole pile of fail, the documentation is lacking, not just poor but mostly non-existent. You rapidly discover yourself using the Glib and GTK library documentation to try and infer how things work.

Underneath, the vala compiler is clever, it is really a c code generator. It takes your vala source file converts it to c and compiles it. When it works smoothly it works very well, when something is not quite right you can end up with a large pile of pieces complete with the C compiler spitting out cryptic nonsense.

This is all exasperated to new heights of madness when you want to access a simple c library. I say simple because if you want to access a Glib based library its easy and "there is an app for that". Because vala is object oriented c interfaces must be described as an object. This description is performed using vapi files. The file format is documented by the simple approach of "we already wrapped a load of libs go look at their vapi files"

For my small starter project I wanted to access a tiny c library I had written. The entire interface described in a single header header (excluding copyright) is:
typedef enum motor_dir {
motor_off = 0,
motor_forward = 1,
motor_back = 2,
motor_brake = 3,
} motor_dir;

int edgerbtarm_init(void);
int edgerbtarm_close(void);
void edgerbtarm_ctrl_motor(int motorn, motor_dir direction);

Yes that is it! one enum, an initialise a finalise and a single operation function. The vapi file I came up with after a great deal of trial, error and head scratching was.
[CCode(cheader_filename = "libedgerbtarm.h",
lower_case_cprefix = "edgerbtarm_",
cprefix = "")]
namespace edgerbtarm {
[CCode(cprefix = "motor_")]
public enum motor_dir {
off,
forward,
back,
brake
}

public int init();
public int close();
public void ctrl_motor(int motorn, motor_dir direction);
}
This seemed to work until I tried to use the motor_dir type within my vala code at which point the c compiler started throwing errors about undeclared macros
arm.vala.c:297: error: ‘EDGERBTARM_TYPE_MOTOR_DIR’ undeclared (first use in this function)
I struggled for some time and finally ended up asking my friend Enrico for help. He initially suggested I simply use an int instead of the motor_dir type and cast when I needed to. This approch worked and let me compile the program, it did however seem a bit grubby and removed the type safety of the enum.

Then Enrico came up with the "correct" solution. the enum description in the in the vapi file needed an extra parameter so vala would know the enum did not have a Glib type...yeah it was obvious to me too :-/

so by altering the vapi file enum declaration to
[CCode(cprefix = "motor_", has_type_id = false)]
public enum motor_dir {
off,
forward,
back,
brake
}
Everything works as you might expect and the motor_dir enum can be used as a type within the vala program with no more fuss.

So the outcome of all this is that while vala is an interesting language which I may well use again in future, one should be aware that it is still very immature as a solution and has nowhere near enough documentation especially round the awkward stuff where it needs it most.

Monday, 8 March 2010

Music hath charms to soothe a savage breast, to soften rocks, or bend a knotted oak.

Since I last mentioned music back in January I have accumulated another ten albums and unlike last time where there were only a couple of stand outs, this time I have he opposite problem.

The unordered list:

Justin Sandercoe - "Small town eyes"

I am learning to play the guitar, I have been using Justins' course, it is very very good, this album? Also very good. If you like melodic guitar lead music with varied influences this is for you. A couple of tracks made me immediately think of some Crowded House riffs (which is not a bad thing). Only minor niggle is the uneven levels on some of the louder pieces, but it really is a minor observation on an otherwise fine first album.

Molly Lewis - "I made you a CD, but I eated it."

Although this is only a short selection of original material from Molly, it is a very promising first album. I really like her voice and although a ukulele is not generally the most well respected of instruments, in her hands, it has an odd charm. This album is available from DFTBA records.

Rhett and Link - "Up to this point"

A pair of talented comedians who use music very effectively to highlight their humour. I originally stumbled across them on youtube and decided to take a punt. The album is 27 short pieces which fit together surprisingly well. Difficult to categorise but think a cross between Flight of the Choncords and Jonathan Coulton with a dash of youtube immediacy.

They Might Be Giants - "Flood", "Apollo 18" and "John Henry"

Strictly a replacement of the old tapes which have completely disintegrated in the intervening couple of decades since first purchased. Flood is still one of my favourite albums ever, certainly in my top 10. If you do not know them TMBG are just ace, please try their music!

Seasick Steve - "Started out with nothin and i still got most of it left"

Well its a kinda fun album primarily based on blues electric "guitar" (some of the instruments are little more than a stick with a nail in and a guitar pickup.) Nothing bad, easy to get along with, definitely worth a listen.

La Roux - "La Roux"

This synth pop album was on remainder in ASDA and I took a gamble. Its OK I guess and for 3quid I cannot really complain.

Red Hot Chili Peppers - "By the way"

Not their best, but competent enough.

Aqua - "Aquarium" , "Aquarius"

Um...yes, I have a soft spot for 90's cheese OK? Nothing more than a gross self indulgence of my silly side. But they are fun ;-)


So that is my new music since January all 166 tracks of it . Most of it pretty good, certainly no lemons (well aside from the Aqua but that is supposed to be silly!)

Oh and The XX has really grown on me from last time and I am looking forward to their next release.







Squashfs

Well my last post elicited a response from Mr Lougher the squashfs author. Just not one I was expecting. Apparently he did receive one of my emails (I sent five in total) to which he has not replied as I have accidentally come across as critical.

This is absolutely not my intent and I wish to publicly say that, It would have perhaps been more constructive to actually tell me this by email and this misunderstanding could have been avoided.

For reference The final email in the series is reproduced below, if I have been overly unhelpful please let me know in the comments so I can avoid this mistake in future.

Hi, we are using Squashfs and have come across several issues. We
initialy tried to use the Debian source package of the 4.0 release but
then moved to using the the CVS edition which fixed some bugs but had
issues of its own.

Couple of things to start with:

- The commit you made recently titled "Change get_basename() to use
getcwd rather than getting the PWD env var." does not seem to be
what you intended?
http://squashfs.cvs.sourceforge.net/viewvc/squashfs/squashfs/squashfs-tools/mksquashfs.c?r1=1.145&r2=1.146

- I would like to assist in improving these tools so they work better
for our use cases. To aid in this have you considered updating the
revision control system the project is kept in? an SVN or GIT
repository is much easier to work with than CVS.

- I will probably assist with maintainership of the Debian and Ubuntu
packages (I am a Debian Developer ) and would
like to bring a couple of patches to your attention, one to avoid a
division by zero error and a second to enable building with
alternative libc. These are both attached to this mail.

- The tools currently make a number of assumptions about structure
alignment which are incorrect on some architectures. I am crafting
a patch to address this which should make the tools work correctly
on ARM (they currently simply segfault).

I hope this is seen as constructive and we can work together to
improve this software. If you do not feel you want to interact with me
and choose to take a differnt route, please let me know at your earliest
conveniance.

I do hope that Mr. Lougher will accept that I intended to be helpful and constructive and not cause offence. I have chosen to use the blog format for this as that is the form I made the previous complaint and also email between myself and Mr. Lougher appears somewhat erratic.

It should be noted that some of there points have already been addressed, however there are several more issues which I hope to be able to contribute towards.


Wednesday, 3 March 2010

Limited Success

I spent the day working with Daniel. He has been trying to get the correct runes for a GCC build in a strange environment. Turns out all he needed was me to throw stupid ideas at him until one caused him to examine some of the generated intermediate symbol maps...

Turns out that busybox awk fails in an interesting way which (eventually) causes half the symbols to be missing in the stage 1 libgcc.so object. Switched to using gawk and managed a successful build.

Seems to be a relatively good time for solutions, last week I managed to make squashfs-tools work on ARM. Unfortunately the author seems to be completely unresponsive to my (repeated) emails (if anyone wants the patch series feel free to mail me). The main issue with the tools is their complete blind assumption that a c structure can simply be cast to an arbitrary character array and get sensible results.

The structure casting method simply does not work on ARM (or indeed any platform which has alignment restrictions) without at least adhering to some minimal rules, primary among these is that the structure *must* be aligned to a word (32bit) boundary and that if you have 16bit or 8bit quantities within the structure they may cause gaps between members i.e. the structures are not packed by default.

No this behaviour is not a bug, it is perfectly acceptable by the c standard. Just because on x86 the practice of arbitrary casting works does not mean it is safe or sensible. Nonetheless many programmers simply do not want to believe its wrong.

Anyhow, rant over, back to work!

Tuesday, 16 February 2010

Tempus fugit

Seems I managed to loose a month in there. Been working very hard on a project with an improbable deadline which has not left much time for anything else.

Finally brought to a standstill this weekend by something Joshua brought home (I think it was some form of micro biological warfare agent, judging by how I feel) It is incrediably hard to shrug off the lethargy of illness when you realize all you have to go back to is work.

On the plus side the project deadline is in three weeks time so whatever happens It will all be over by then! Whereupon I can take some time off, calm down and then start all over on the next project...

Yay?

Tuesday, 5 January 2010

Back to work

Well that is the end of my time off, tomorrow it is back to work. However my break started with snow and it seems its finishing that way.


Unfortunately despite my previous enthusiasm this weather is becoming a little tedious. Schools have been closed today so I had to child mind instead of getting anything done.

Speaking of getting things done...I have completely failed to do anything productive whatsoever for the last couple of weeks. I have played some computer games, watched some TV read some books and listened to music and you know what? Aside from a tiny guilty feeling, I have thoroughly enjoyed myself.

I suppose I should apologize for not contributing to all those open source projects that could have used my help, but that would imply remorse which I seem to be lacking. Oh well

Mentioning music, I have acquired a selection of new music over the holiday which I ought to talk about. In no particular order:
  • Iron and Wine - "Our Endless, Numbered Days"
  • Paramore - "All We Know Is Falling", "RIOT" and "Brand new eyes"
  • Phoenix - "Wolfgang Amadeus Phoenix"
  • Lady Gaga - "The Fame Monster"
  • The xx - "XX"
  • Muse - "The Resistance"
  • Cymbals Eat Guitars - "Why There Are Mountains"
  • St. Vincent - "Actor"
  • Carter Burwell - "Twilight-The Score"
  • The Darkness - "Permission to Land"
  • Oasis - "Stop the Clocks"
  • Chameleon Circuit - "Chameleon Circuit"
  • Hank_Green - "I'm So Bad at This" and "So Jokes"
Unfortunately none of it was outstanding which sometimes happens when I take a punt on a large pile of new music. On the upside none of it was particularly bad either, so a kind of "no win" deal. Though on re-listening the "XX" album is starting to grow on me and the albums from the DFTBA label are so inexpensive they are more than worth it.

Tuesday, 22 December 2009

Time off

I have the time over Christmas off, partly because I needed some distance from work but mostly because the children need looking after while their schools are on break.

Usually switching off from the work mindset is hard for me and I end up "helping" anyway. Not this time...come last Friday at quitting time I was gone. I was apparently in desperate need of this break and spending time with the kids has been great.

It has also been snowing! I used to love the snow when I was a kid and watching the boys build a snowman and have a snowball fight brought back good memories. It somehow has less amusement value when you are older and have to go to work in it and deal with all the problems with transport induces in the UK. Did I mention I was off work? ;-) I had a great time with them...and got a very cold neck.

I have also managed to solve the cat box problem. Turns out it was not the boxes, their placement or type. It seems they wanted three to choose from! They now have three boxes in which to sprawl and they use the original two in the original locations...just as long as they have the option of a third they are happy.

Now I have unwound sufficiently I am looking at tackling some Open source projects of my own which I have been neglecting. I am planning on finishing my whether station recording software and feeding my observations to the weather underground. Possibly doing some more work on Netsurf and maybe even fixing some RC bugs for Debian.

Thursday, 17 December 2009

What is it with embedded computing?

Last week I was given a development board for a system on chip (SoC) we were looking at using. All i had to do was ensure I could get a reasonable, supportable, bootloader and Linux kernel running on it.

Now I am a fairly competent engineer, I have worked with the ARM processors and SoC for many years. It should not therefor take me four days of almost continuous frustration to get a bootloader and kernel onto a system, but it has.

Firstly the system arrives and we look it over, the hardware design is not exactly elegant but seems like it will get the job done. That is at least a step up from several previous offerings which have been just plain broken. So I power it up and it boots into Fedora core 8, possibly not my first OS choice for a diskless system, but it does work.

Perhaps its worth mentioning that my experience with doing any Open Source development has caused me to have a severe aversion to software which is not upstream, especially kernels. The effort required to run your own patch series and keep it up to date is nothing short of Herculean.

Let us be honest, how many developers do you know who are talented enough to generate good code and patient enough to separately maintain it over a long period of time? I shall not belabor this point as others have repeatedly made it for me in much more eloquent ways. Lets us just say from my point of view. Upstream - good. Long term forks - bad.

With this in mind, the solutions Simtec develop are always with a view to our customers being able to simply download and use the standard upstream software wherever possible. Here is where the story stops being smooth and becomes a rant.

The system was running 2.6.22, one that was patched all which ways. "maybe they just shipped an old kernel" I thought. I opened the CD they provided and...oh, OK its just zips and tarballs of the binaries and source they used (actually that in itself is a minor miracle with a lot of vendors right now - see the almost continuous stream of copyright infringement litigation from the FSF) but sill stuck back in July 2007.

So i did teh normal thing, entered the URL printed on the outside of the box and went looking for the updates. No dice, just the same old stuff. So I contacted the company and recived the news that no there were no updates, that was what was published for the device, thats what I could have.

My initial reaction was of tired resignation...this would not be my first SoC port (probably around the fifth or sixth!) So I responded with cd linux-2.6;git checkout master;git pull and went to see what I could see. and lo and behold, there in the kernel, was full support for not only the SoC but for the other version of the very board I had.

Fortunately after mentioning this on IRC my giraffe loving friend. pointed me at the correct community git tree to find the tiny patch required to support my board.

So the vendor was not only shipping old code but actively dissuading customers from even looking for new stuff, which it turns out was mainline anyway! To add to this somewhere along the lines the company name on the box and contact information has changed and...well confusion reigned.

Right Plain sailing from here on? not quite...that would have been too easy. So you can build a mainline kernel...but you cannot boot it. you guessed it the bootloader they ship on the board is ancient, specifically a u-boot fork from December 2005. Having finally figured out how this was going to go, I went to the uboot repo, pulled the latest and built it for my target. And then I needed to upgrade the u-boot and joy of joys bricked the system.

Fortunately the system has a integrated FDTI serial/JTAG port so re-writing the flash should be as simple as running openOCD configured correctly. Of course this did not work...in the end I resorted to running their binary built versions from the CD (tarfile inside a zip inside a tarfile...whatever) and wrote their original image back to the board...which worked.

Long story short, next day I discover that i need a magic different uboot target (make u-boot.kwb for those that care) write this with the binary openocd build and...success
From then on its all been a bit anticlimactic and straightforward and I now have a system capable of starting a kernel over the network and a root fs on network, disc or flash.

My main complaint from all of this is what the hell are vendors doing shipping crap like this? Why do they all insist on taking a dreadful code drop from the SoC manufacturer when they first brought the part up and shipping that prototype junk until the part reaches the end of its life?!?

All the usual excuses about support etc. will come out, but seriously, you recive *no* support from vendors unless you pay for it and even then they will simply tell you whats on the CD is "it". Btw the diff for u-boot to support this board is larger than the original sources and the 2.6.22 is attacked with a 65MB diff which cannot be good.

The Open Source option is continuously innovating and improving, producing ever better software...but the embedded world seems to be forever stuck shipping crap. Is this just me? Does anyone have any solutions? Or am I stuck with this until I change profession?

Monday, 14 December 2009

Two pussies, one box

Our household contains two felis catus. These evil creatures (sorry I repeat myself, I already mentioned they were cats) are not sweet kittens, they are grumpy old animals who spend the majority of their lives sleeping indoors and rarely venturing out.

Historically they have had free reign of the house and slept wherever it suited them but with the arrival of the children they were confined to the lower half of the house and provided simple cardboard boxes in which they can reside completely undisturbed.

All well and good you might say and indeed this has produced happy cats for the last eight years. however I recently caused a great deal of discord in the household by providing new boxes never imagining this could possibly cause as much trouble as it has. Currently the two of them are attempting to occupy a single box and win some form of passive aggressive fight for occupancy.

This has been going on for a month now and shows no sign of easing. I do wonder what I need to do to aleviate this situation before it results in a full blown outbreak of evil. Any ideas?

Friday, 4 December 2009

Where did that that go?

Wow. OK, so its a week later and the time seems to have vanished.

I did get bored of getting nowhere with open source projects though, so last night I went back to the Netsurf browser and fixed a pile of bugs. It is nice to have commit rights to a project where they actually appreciate your contributions.

Most of the week I have been the only person working at Simtec (only other person about was a director in for a couple of days) so I was supposed to answer all inquiries and support etc. but perversely its been almost silent. Seems no one wants anything doing just before Christmas which suits me just fine ;-)

Friday, 27 November 2009

Here comes the weekend

Well that was an unproductive week. Maybe I can do something interesting over the weekend? Nope, looks like I get to run around after the kids and do household chores.

Fortunately the interweb is here to entertain you! I am sure most of you have already seen it but the Muppets doing bohemian rhapsody is fun. The Nottingham university scientists explaining the small hotrod collider is amusing and two girls, one uke is safe for work.

Unfortunately there have been other happenings this week which are not so amusing, the extensive flooding in parts of the UK has caused many people a great deal of harm and in one case a policeman, protecting others, was swept to his death from a collapsing bridge.

Unfortunately due to a confluence of events I will not be able to attend the Bug Squashing Party (BSP) in Cambridge this weekend as I had originally intended. I do hope to be able to contribute some work on Sunday from here.

Thursday, 26 November 2009

Sometimes it don't come easy, sometimes it don't come at all

My work sometimes causes me to have reason to change small things in open source projects which I then have to submit for consideration upstream. Often this is as simple as providing a patch on the relevant mailing list and moving on.

Sometimes however the change is larger and I really would like to see the feature or bug fix accepted by the project. I am fortunate that my employer is enlightened enough to not only accept this but actively encourage participation in open source communities.

Most of the time the patches are accepted, with changes or updates, in a reasonable timescale. Certainly for kernel work I have got used to a submission/accept time measured in hours!

On occasion the change gets dropped on the floor or missed and you have to resubmit (even if its just to get told its uninteresting and to go away ;-). Unfortunately there are a small number of projects where getting something merged is an experience in frustration.

The particular project which has caused me the most trouble along these lines is Qemu. Daniel and I did the work to support the Samsung ARM based 2410 and 2440 System on Chip (SoC) and a couple of boards they were used on. Of course we then presented the patch to the Qemu mailing list. That was in November...No, not this year, or even last, we are talking 2006!

Unsurprisingly there were numerous issues with our first cut, we improved the patches and resubmitted them and received absolutely no feedback. Eventually we provoked the maintainer to respond, we took his feedback into account and resubmitted. After a year of so of this Daniel got bored and gave up.

Being a complete idiot and apparently sucker for punishment I decided to re-try. I completely restructured the port and started by just trying to get the absolute minimal core changed accepted. It took some time to provoke a response (oh and they altered RCS which meant I had to change my submission again, but they did change to git so that is acceptable ;-)

Earlier this year resulted in my all time favorite maintainer response. Eventually I managed to find out he actually objected to the patch because the SoC we were using actually required a slightly different processor capability set (the emulation is ARMv5 by default and the SoC in question is ARM v4te, hey I had not noticed any practical difference, and Qemu is an emulator not a simulator...but OK)

Remember this is the first time this objection has been raised in 30months of patch submission. Fine, I create a patch which adds V4te emulation and submit that. I eventually get a response, to which my reply is a little frustrated I will admit.

I have since resubmitted the patch with the corner cases fixed, it has been ignored, and I never have received a reply to my direct questions. On this three year anniversary of the original submission I am simply going to give up, something I detest doing.

I am one of those dull people that finishes what he starts, that is pretty much my role in Simtec these days, ensuring stuff we start gets finished or at least drawing the line and calling it complete. To end up with a complete failure offends my personal values.

Now please do not think I hold any ill feelings towards anyone concerned, open source maintainers perform their roles without pay and, by extension, without responsibility to anyone but themselves. I am sure people are too busy to care about the itch I wanted scratched and that overall their project has not really lost all that much by not having me as a contributor.

I know I could have forked the project, or maintained my own tree or any number of other technical solutions but at the end of 1,100 days I have finally exhausted my enthusiasm and can move on. Speaking of which, time to resubmit a kbuild change which got dropped ;-)

Tuesday, 24 November 2009

Getting things done

It seems that despite having a very important work deadline today I am destined to be interrupted every five minutes. Unfortunately I need to concentrate to get this done. And while i managed to get "in the zone" earlier, now I cannot string two words together.

This seems to be a recurring theme recently, my productivity is horribly low because I get interrupted all the time for "can you just" jobs. I turn the phone ringer off and hide my email window and I get called on my mobile and get asked why don't you answer your phone?

Its not so much the time lost to answering the specific query or doing the job but more my context switch time to restore to my previous task becomes huge. Somehow my switching time is absolutely non linear and today it has become so large I have decided to dump state altogether.

Because I know I have to do the school run soon and the interruptions continue I have abandoned the critical task altogether for now in the hope I can get back to it fresh. Do others get this I wonder? or is it a personal fault I should strive to fix? I know I used to be able to deal with this sort of thing with much less trouble, maybe I am getting less flexible as I age?

Fortunately (umm, you know what I mean) the Entropy Key software has some cleanups required which is an easy job and does not matter if I get interrupted so I do have a productive task to complete.

Oh speaking of the entropy key Niel blogged something silly I created the other day. I had a senior moment and filked the children's nursery rhyme "If You're happy and you know it" slapping some guitar chords on it.

It seems I cannot simply leave well enough alone and last Friday night (with the help of Mark Hymers) I made it a whole lot worse. I present to you the score of "If you're happy with your ekey, blog your praise" for piano and guitar. In fact I wrote this out in rosegarden so it can be turned into a midi file etc. all the source files are available. It is released under a CC license so I suppose someone could put the lyrics back to the proper nursery rhyme and use it for something less tacky.

Monday, 23 November 2009

Fitting Everything In

Recently I have been having issues fitting everything I want to do into the time available.

As my kids grow up they always seem to need to be taken someplace or picked up from an activity and that is on top of the daily school run. I recently worked out I spend over eight hours a week, a whole five hundred minutes, taking them to and fro.

Now do not get me wrong, I actually enjoy spending time with my children and we do talk and interact during these occasions but it is hardly a stimulating activity walking to school or being driven to a club.

Add to that my job and its traveling requirements and assuming I want to sleep, eat etc. and all of a sudden I discover I have about forty hours left in a week to share between my family and hobbies.

Anyone with kids knows they are a wonderful time sink :-) and of course the family home often needs something doing. All of a sudden I realize why I feel like I often end up having to trade sleep for my hobbies!

As I get older I find I still have the same number of ideas for projects but the realization that even if I find the time to start something I am unlikely to be able to devote the resources to finishing it. Being one of life's boring people who like to finish a project they start (ok at least make something useful) this means I tend not to start new things too often.

All of this has lead me to become very careful about how I spend my free time and on what. It means my personal involvement in software projects like Debian and the Linux kernel is nowhere near the level I might like. Similarly my music practice (or absolute lack thereof) causes my teacher to get snippy with me.

As you can imagine starting something like a blog when I do not have enough time for what I am already doing is something of a challenge for me and may indeed falter. However I shall give it a chance as I feel a need for public place to share all those small things which I would probably put on my personal website if I had time to work on it ;-)