Wednesday, 16 May 2012

Raspberry Pi Progress

In my last post I had issues with getting the kernel headers installed. I took another look today and spotted that there were suspiciously few items in the github clone on my SD card. It turned out that my SD card was full!


When creating the SD card I failed to spot the optional step to resize the root partition. I wasn't entirely convinced by the steps on the wiki as it talks about deleting the swap partition and doesn't appear to recreate it. After a bit of browsing I used the following process.

Resizing the root partition

Firstly, to be able to run gparted (next step) you need to set the root password:

sudo passwd root

Next I moved the swap partition to the end of the SD card:

Launch gparted from within the GUI (under the Preferences menu), select the swap partition, Partition -> Resize/Move. It is possible to just drag the swap partition to the end of the SD card and apply the changes. After a system reboot there is plenty of empty space beyond the end of the root partition.

Now I can resize the root partition using the instructions in the wiki:

Here is my fdisk output before I made any changes:


sudo fdisk -cu /dev/mmcblk0
  • p to see the current start of the main partition
  • d, 2 to delete the main partition
  • n, p, 2 to create a new primary partition
You need to enter the start of the partition. This MUST be the same start point as the old partition which was displayed in the first step. You also need to enter the end of the partition. This should be one less than the start of the swap partition.
  • w write the new partition table
Now you need to reboot:

sudo shutdown -r now

After the reboot you need to resize the actual partition. The resize2fs will resize your main partition to the new size from the changed partition table.

sudo resize2fs /dev/mmcblk0p2

Done! Here is my fdisk output after I made these changes:

Building Kernel Headers

With plenty of disk space available I was able to follow the instructions in my last post to build the kernel headers.

sudo apt-get install git
git clone --depth 1 https://github.com/raspberrypi/linux.git
sudo mv linux /lib/modules/3.1.9+/build
cd /lib/modules/3.1.9+/build
make mrproper
gzip -dc /proc/config.gz > .config
make modules_prepare

Building ar5523 driver

With the kernel headers in place I as able to get further with the driver build.


However this still failed a little further on with a different error message.


make[3]: Entering directory `/lib/modules/3.1.9+/build'

  WARNING: Symbol version dump /lib/modules/3.1.9+/build/Module.symvers
           is missing; modules will have no dependencies and modversions.

  CC [M]  /usr/src/modules/ar5523/ar5523.o
/usr/src/modules/ar5523/ar5523.c:873: warning: ‘struct ieee80211_if_init_conf’ declared inside parameter list
/usr/src/modules/ar5523/ar5523.c:873: warning: its scope is only this definition or declaration, which is probably not what you want
/usr/src/modules/ar5523/ar5523.c: In function ‘ar5523_add_interface’:
/usr/src/modules/ar5523/ar5523.c:885: error: dereferencing pointer to incomplete type
/usr/src/modules/ar5523/ar5523.c:888: error: dereferencing pointer to incomplete type
/usr/src/modules/ar5523/ar5523.c: At top level:
/usr/src/modules/ar5523/ar5523.c:898: warning: ‘struct ieee80211_if_init_conf’ declared inside parameter list
/usr/src/modules/ar5523/ar5523.c:1035: warning: initialization from incompatible pointer type
/usr/src/modules/ar5523/ar5523.c:1037: warning: initialization from incompatible pointer type
/usr/src/modules/ar5523/ar5523.c:1038: warning: initialization from incompatible pointer type
/usr/src/modules/ar5523/ar5523.c: In function ‘ar5523_free_tx_cmds’:
/usr/src/modules/ar5523/ar5523.c:1120: error: implicit declaration of function ‘usb_buffer_free’
/usr/src/modules/ar5523/ar5523.c: In function ‘ar5523_alloc_tx_cmds’:
/usr/src/modules/ar5523/ar5523.c:1140: error: implicit declaration of function ‘usb_buffer_alloc’
/usr/src/modules/ar5523/ar5523.c:1142: warning: assignment makes pointer from integer without a cast
/usr/src/modules/ar5523/ar5523.c: In function ‘ar5523_alloc_rx_cmds’:
/usr/src/modules/ar5523/ar5523.c:1195: warning: assignment makes pointer from integer without a cast

Setting up SSH

I extracted the error message in the last step by enabling ssh so that I could use WinSCP to transfer the error log back to my Windows PC:

sudo service ssh start

Raspberry Pi Kernel Headers

As i mentiomed in my last post I have been trying to follow some instructions for building a driver for my WG111T usb wifi. I have got as far as the module assistant step which fails due to the kernel headers Debian package not being available:


pi@raspberrypi:~$ sudo m-a a-i ar5523
Updated infos about 1 packages
Getting source for kernel version: 3.1.9+
apt-get install kernel-headers-3.1.9+
Reading package lists... Done
Building dependency tree      
Reading state information... Done
E: Unable to locate package kernel-headers-3.1.9
E: Couldn't find any package by regex 'kernel-headers-3.1.9'
apt-get install build-essential
Reading package lists... Done
Building dependency tree      
Reading state information... Done
build-essential is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 29 not upgraded.
Done!
Since then I have been trying to find out how to install the kernel headers but have so far failed to get a simple answer. 

I managed to find a forum thread which included some commands that sounded like they might do the right thing.

sudo apt-get install git
git clone –depth 1 https://github.com/raspberrypi/linux.git
sudo mv linux /lib/modules/3.1.9+/build
cd /lib/modules/3.1.9+/build
make mrproper
gzip -dc /proc/config.gz > .config
make modules_prepare

I tried to follow these instructions but only got as far as "make mrproper" before hitting an error.

pi@raspberrypi:/lib/modules/3.1.9+/build$ sudo make mrproper
Makefile:327: /lib/modules/3.1.9+/build/scripts/Kbuild.include: No such file or directory
/bin/bash: /lib/modules/3.1.9+/build/scripts/gcc-goto.sh: No such file or directory
make[1]: scripts/Makefile.clean: No such file or directory
make[1]: *** No rule to make target `scripts/Makefile.clean'.  Stop.
make: *** [_clean_.] Error 2


I can't see how this is meant to work and I'm now a bit stuck again. The key question is how I should get the kernel headers installed.

EDIT: I have got this working in my next post.

Wednesday, 9 May 2012

Raspberry Pi Wifi - WG111T

In this post I will describe the progress I have made so far in getting my WG111T USB wifi adaptor working with Debian Linux on my Raspberry Pi. 

My first stop was to consult the list of supported hardware. This was initially encouraging as it lists the WG111v2 as supported but sadly my WG111T uses a different chipset. This page also links to an example of getting an arbitrary USB wifi device working. This suggested I look for firmware on the linuxwireless.org site. Google suggested that I needed the ar5523 firmware. The change log for this firmware isn't very encouraging as it refers to the kernel panicking when the device is probed. Furthermore it's not clear how I would build and install this firmware.


More googling turned up a wiki page which described in much more detail about how to build and install the firmware. Following these steps I got as far as "dpkg-buildpackage -us -uc" before hitting an error that my version of debhelper was too old. Thankfully I was able to use apt-get to force an upgrade to an appropriately newer version. This got me as far as running "m-a a-i ar5523" where I hit the following error:

Without the kernel headers I am now stuck so my next task is to work out how to get these installed. It was late by this point so I gave up for the night.
 

Getting Started with Rasperry Pi

On Febuary 29th I got up at 6am along with far too many other geeks and tried to place an order for the newly released Raspberry Pi. The demand was so high for the original 10,000 units that the websites of both distributors were knocked offline. By 8:30 I managed to complete an order with Farnell from my iPhone on the way into work. Yesterday my Raspberry Pi arrived and I could finally get started!

Like any computer the Raspberry Pi needs to be hooked up to a number of peripherals to become useful. The first and most important addition is an SD card with one of the Raspberry Pi OS images loaded onto it. I never got round to preparing this in advance so my first step was to download the Debian Squeeze image onto my windows XP netbook (my only computer with an SD card writer) and write it to my 8GB SD card (using Win32DiskImager as per these instructions).

With the SD card ready I connected up my Pi.

  • 4 port powered USB hub - this expands the 2 built in USB ports to 5 USB ports. However, I'm using one of the hub ports plus a micro USB cable to power the Pi which only leaves me with 4 ports available.
  • 16GB USB memory stick for extra storage.
  • Combined USB keyboard/mouse wireless receiver.
  • HDMI cable from the Pi to my projector which I will use as the screen.
There is no power switch so as soon as I plug in the USB hub power supply the Raspberry Pi starts booting. Unfortunately the first time I did this there was no output on the screen. Thankfully this was just caused by the HDMI cable being loose in the Raspberry Pi - the connector is quite stiff and I had to push firmly to fully insert my cable. The screen didn't actually display anything with a properly inserted connector but a quick reboot of the Pi was enough to prompt the connection to be detected.

After all this I was rewarded with a login prompt requiring me to head back to the OS downloads page to check the default username and password. Once logged in I set the clock at the suggestion of the welcome message and then considered my next move.

I ultimately want to connect my Pi over wifi and I have an old WG111T USB wifi radio lying around. My first real challenge is to get this USB wifi working. While I work on this I dug out a huge network cable to stretch across my room to my router and hooked up my Pi. Amazingly, after a few seconds the Pi had successfully DHCP'd and I could ping www.google.com. At this point I decided to make my Pi experience a bit prettier and ran startx to launch the GUI.

I had a quick play with the browser and found that things seemed sluggish but usable. An impressive feat for such a cheap device! I was also amused by the -1% CPU being used by some processes :)

Before I got my Pi I had been encouraged about the possibility of getting my USB wifi working thanks to the list of verified hardware which included the WG111. Unfortunately the verified version was the WG111v2 not the WG111T so I am in fact stepping into uncharted territory. My next post will detail my progress with this task.
 

Wednesday, 2 May 2012

Little Bits

I have recently started watching some TED talks again on my way to work. Yesterday I saw an excellent presentation about a project called Little Bits.

Little Bits is an attempt to do to electronics what Lego did to construction - make it fun and accessible for kids to play with. It's worth checking out the TED talk.

Sunday, 22 April 2012

Electronics to keep the wife happy

This weekend I decided to do something a bit more obviously useful than my usual projects. My house includes a cupboard under the stairs that is lit by a battery powered light. However, the light is a bit useless as it is always running out of battery really quickly.

 

The first step is to open up the light and take a look inside. This turned out to be quite straightforward as I just needed to remove four screws and pull the top off.

The internals are very simple with color coded wires. The only surprise is that there was a round female connector fitted to a round hole on the rim of the light. This looks like it would allow the light to be mains powered but that is no good to me as there are no sockets in the cupboard I'm using the light in.

With the cover off I took the chance to measure the current used when the light is switched on. The result: 500mA! No wonder the batteries lasted for such a short time! However, I'm not entirely surprised by this result as the light was using an incandescent bulb.

As an aside - I always find measuring current really awkward as you have to insert the multimeter in series in the circuit which is tricky when the probes are just pointy metal tips rather than clips which can hold a wire.

The next step is to make this light better. I decided the easiest way to do this would be to replace the incandescent bulb with an LED. I took a look on maplin and picked out a bright white LED which runs at 3.6V and only draws 100mA to produce 18000mcd of light. According to this site 18000mcd is 2.1 lumens which compares to 850 lumens for a 60w incandescent light bulb.

The 3.6V requirement means that I only need three of my 1.2V rechargeable batteries and won't need to add a resistor. The first step was to insert a wire instead of the fourth battery.

The next step was to remove the incandescent bulb along with its screw socket (which I have saved in case I ever need them in another project) and solder an LED in its place. The only tricky part of this was that the wires in the light were stranded instead of solid core which made the soldering more fiddly.


That's all there was to it. I put the case back together, turned on the light and took a picture.


The light is brighter than this picture suggests (my phone overcompensated with the exposure) but it is a bit less bright than I had been hoping. In future I might add an extra LED or two which would double or triple the light output with a corresponding reduction in battery life (more LEDs = more current but the same voltage).

Once everything was assembled I got out my multimeter and measured the current and was pleasantly surprised to find the current was only 70mA rather than the expected 100mA. Since I am using 1700mA batteries this means I expect a battery life of about 24 hours compared to the 3 hours which I would have got with the incandescent bulb.

 

 

 

Wednesday, 18 April 2012

Wiimote Head Tracking - Follow Up

After my previous post I came across some interesting related content.

More Head Tracking

I found a tutorial which used a different Wii library (Wii Yourself) and describes how to create a clone of the Johnny Lee VR demo using Ogre3D.

Light Brush

I also decided to take a look at r/arduino and quickly spotted an interesting related project which uses the Wiimote as part of an Arduino powered Light Brush. The reddit thread credits this blog (http://liightbrush.wordpress.com/) with the idea and links to this blog (http://mrarduino.blogspot.co.uk/) about the implementation referenced in the reddit post.

A bit of further googling turned up http://kenfrederick.blogspot.co.uk/2009/08/lightbrush.html which was an interesting post about trying to implement a light brush. This post also links to some other similar projects such as the Lightscythe.