Desktop Wallpapers Waste Memory.

My colleague often says something along the lines of:

I don’t know why everyone has a desktop wallpaper its nothing but a waste of memory

I thought that this sounded somewhat like an urban myth and decided to see if there was any evidence to support or dispell this claim. Well it turns out that although the wallpaper is pushed to video memory for rendering it cant be kept there as if it were just general purpose RAM. So the wallpaper does have to be stored in conventional memory, but is it a waste?

Well assuming a resolution of 1280×1024 and a 32bpp color (4 bytes per pixel) we get:

1280 × 1024 × 4 = 5 MiB

So I am wasting 5 MiB of my 8 GiB of RAM. As a percentage:

5/8192 × 100 ≈ 0.06%

But yes it is a bit of a waste, I should probably turn off my desktop wallpaper.


I like to write up my holidays so that I can look back and remember what I did, trouble is I usually take so long trying to capture everything that I end up not posting them at all. I have drafts for several Holidays that have been sitting there for years. I have decided that I am just going to post what I have written and improve the post at a later date.


My Dad kindly helped me build a nice decking area at the back of my house where we can have barbecues, and enjoy the sun. When I say he helped me, what I actually mean is that he did all the hard work.

I am really pleased with the results, Thank you Dad for being so kind and helpful.

Update: I created a panoramic view by stitching the above three images together in Hugin

How to write an operating system (Part 2)

You may have read my previous post about writing a Hello World operating system. Although I did post this on April 1st it wasn’t actually a prank, and it does actually work.

I decided to improve the code. With the following replacement for main.c we can print “Hello World!” on the screen in a more developer friendly way.

char * vidmem = (char*)0xB8000;
int pos = 0;

void putc(char ch){
	vidmem[pos++] = ch;
	vidmem[pos++] = 0x7;

void puts(char* s){
	int c;
	for(c = 0; s[c] != ''; c++)

int main(){
	puts("Hello World!");

Now this is all very good, but suppose you need to check that some number in your os is some value that you expected, we are going to have to write a function to convert the number into an ascii representation before displaying it on the screen, we can’t use the itoa() function of the standard c library, because we didn’t compile it into our OS. We need to instead roll our own itoa function.

int strsize(char* str){
	int i;
	for(i = 0;str[i]!='';i++);
	return i;
char* strrev(char* str){
	char* tmp;
	int i = strsize(str) - 1;
	int j = 0;
	    tmp[j] = str[i];
	tmp[j] = '';

	return tmp;

char* toDigit(int n){
	char digits[10] = "0123456789";
	char* str;

	int i = 0;
		str[i] = digits[n%10];
	str[i] = digits[n%10];
	str[i] = '';

	return strrev(str);

This initial attempt might have worked, however its riddled with errors, which I have since learned about. For example returning a pointer to a stack variable, is probably not a good idea!
When I originally wrote this I hadn’t seen the Kerrigan an Ritchie implementation thier implementation is much better has more features, and less bugs. After re-writing the code my final version of main.c was as follows
Continue reading How to write an operating system (Part 2)

SC101T Linux Cluster

I recently aquired a Netgear SC101T Network storage device. After discovering that the device is not a NAS and instead was a SAN device I was at first a little disappointed. Furthermore the device uses a proprietry file system and a proprietry protocol called zSAN to access the device. Well fortunately someone has developed an SC101-NBD linux userspace driver that translates the proprietry zSAN protocol into linux nbd (Network Block Device) protocol. After downloading and compiling the driver at first nothing worked, and I found the reason to be that the driver was developed for the SC101 not the SC101T. After a bit of hunting around I found that someone had posted the following fix in on the driver support group forum.

The fix is pretty simple. In psan.c the functions ‘psan_query_disk’ and ‘psan_query_root’ pass an info’ value of ‘1’ into the ‘psan_get_t’ struct. Doing so seems to cause the ‘select’ to fail in the ‘wait_for_packet’ function. Changing the value passed into ‘info’ to ‘0’ seems to allow the device, disks and partitions to be discovered fine – I’m now currently watching my linux box mkfs.ext3 /dev/nbd0

I followed the instructions and re-compiled the driver, this time it worked. Issuing a

sudo ut listall

Gave the following output

TOTAL(MB): 610480 # PARTITIONS : 1
FREE (MB): 64
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
F1A2F2EA-7C87-11DE-ACB7-0013A9D715B7 linux1 610407
TOTAL(MB): 610480 # PARTITIONS : 1
FREE (MB): 133594
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2B4F7D24-67FE-11DE-8CC5-0013A9D715B7 linux0 476877

This lists the partitions on the device that had been previously created using the Windows™ software. A partition can be attached by issuing

sudo ut attach F1A2F2EA-7C87-11DE-ACB7-0013A9D715B7 /dev/nbd0

So this provides block device access to the partition, to use the partition obviously one has to put a file system on it. The difference with this SAN based device and say a local hard disk device, is that a local harddisk is only accessed by one machine at a time. Since I wanted to access the device from multiple machines something like ext2fs is not suitable. What is much more suitable is gfs2 which is actually designed for SAN storage devices. To install gfs2 on debian based distributions you can run

sudo apt-get install gfs2-tools

mkfs.gfs2 -j 5 -t storage:linux0 /dev/nbd0

To actually mount the device the lock manager also has to be configured.

<?xml version="1.0"?>
<cluster name="storage" config_version="1">
<clusternode name="korma" nodeid="1">
<method name="human">
<device name="last_resort" ipaddr="korma"/>
<clusternode name="tikka" nodeid="2">
<method name="human">
<device name="last_resort" ipaddr="tikka"/>
<fencedevice name="last_resort" agent="fence_manual"/>

Continue reading SC101T Linux Cluster

Music Player Daemon on the MusicPal

Some time ago I recived a MusicPal as a gift. Out of the box the device is great fun, and made a very good present. The device is designed to work as an internet radio, It can connect to a wireless network and stream radio from various internet radio stations. However the device does have a few limitations when you want to play your own music. The device can connect to Media servers that use the UPnP Media Devices Protocol and the device is operated using two rotary knobs. For me the combination of these two features is the major design flaw in the product.  I don’t want to walk over to the device, twiddle some knobs and play a tune that is on my laptop, instead I want to select songs from my laptop and queue them up for playing on the device. There are two remote control applications for the MusicPal, one which is accessible through a web interface, and another which is Windows™ software. However both of the remote control applications are useless, all one can do is pause music, you can’t select a new song to be played, change the position of playback or even fast-forward and rewind!

Well a while ago,  I found a blog from someone who goes by the name of Nerdy Toad who was trying to run Music Player Deamon on his MusicPal.  At the time he had only managed to make a test sinewave come out of the devices internal speaker, and we worked together to see if we could get output from the line-out of the device. We were somewhat unsuccessful. However, about half a year later, someone called Maz took our research further. He was able not only to get sound fully working on the device, he was also able to patch Music Player Deamon to work on the device aswell.

For anyone else who has a MusicPal and wants to use it in conjunction with Linux you will need to do the following. First you have to enable the telnet interface for the device. You can enable it via a hidden web interface page:

You can then telnet to the device, login as root, and issue the following command.

This will get you a kernel module will will allow you to access a samba share on the device. This is important because the device has very limited disk space, and so its preferable to put mpd, config files, etc. In a samba share. Of course you will probably have your mp3 files in a samba share aswell. You will need to create an smb.conf on the machine that you will be sharing files from, (not the MusicPal). This is my smb.conf

server string = masala
security = SHARE
guest account = giles
comment = mpd
path = /home/giles/mpd
guest ok = Yes
read only = No
comment = Music
path = /home/giles/Music
guest ok = Yes

In my setup I have mpd on the machine sharing music, this is because of the limited space on the MusicPal, so still on this machine download the mpd binary


Then expand the gzip into the mpd directory. You will have to modify the mpd.conf file so that the directories are correct. Once you have done all this, you can mount the shares from the MusicPal telnet session

mount -t cifs // /tmp/mnt/mpd
mount -t cifs // /tmp/mnt/mpd/music

Finally from the telnet session you can launch mpd. Back on the client you should now be able to connect to mpd via your favorite mpd client program.

Webcam in Linux on Sony VGN-BX61MN

For anyone interested in using linux on this laptop, the following should be of help. The camera is labeled as Motion Eye but lsusb reports the device as:

05ca:1839 Ricoh Co., Ltd Visual Communication Camera VGP-VCC6 [R5U870]

After alot of messing around and installing defunct kernel modules, that seem to work, but actually include the wrong firmware versions. I found that the work being done by Alex Hixon on a generic R5U87x driver to be the most up to date. Previously the project rolled its own kernel module to support the camera, However the current version works by providing userspace tools to upload firmware to the device so that the standard uvcvideo driver in the kernel can communicate with the camera.

Unfortunately there wasn’t much around in the way of a howto to explain how to use the code. So I had to figure out the following for myself.

First of all install mercurial and some other project dependencies

sudo apt-get install mercurial libglib2.0-dev libusb-dev

Now you can download the source

hg clone

Change into the source directory and issue the following three commands.

cd r5u87x
make rules
sudo make install

If your user isn’t part of the video group you will probably have to modify /etc/group and make yourself a member of that group otherwise you might experience Permission Denied errors.

After you have rebooted you can test using mplayer

mplayer tv:// -tv driver=v4l2

Also make sure you can record because uploading the wrong firmware will in some cases allow you to see output but not record it.

mencoder tv:// -tv driver=v4l2:device=/dev/video0 -nosound -ovc lavc -o test.avi

If you want to clean things up afterwards you can run the following commands
sudo apt-get --purge remove mercurial libglib2.0-dev libusb-dev
sudo apt-get --purge autoremove
rm -r r5u87x

You may find the above steps also work for the following devices:

05ca:1830 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2 [R5U870]
05ca:1832 Ricoh Co., Ltd Visual Communication Camera VGP-VCC3 [R5U870]
05ca:1833 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2 [R5U870]
05ca:1834 Ricoh Co., Ltd Visual Communication Camera VGP-VCC2 [R5U870]
05ca:1835 Ricoh Co., Ltd Visual Communication Camera VGP-VCC5 [R5U870]
05ca:1836 Ricoh Co., Ltd Visual Communication Camera VGP-VCC4 [R5U870]
05ca:1837 Ricoh Co., Ltd Visual Communication Camera VGP-VCC4 [R5U870]
05ca:1839 Ricoh Co., Ltd Visual Communication Camera VGP-VCC6 [R5U870]
05ca:183a Ricoh Co., Ltd Visual Communication Camera VGP-VCC7 [R5U870]
05ca:183b Ricoh Co., Ltd Visual Communication Camera VGP-VCC8 [R5U870]
05ca:183e Ricoh Co., Ltd Visual Communication Camera VGP-VCC9 [R5U870]