Sunday, 7 October 2012

More Parrot 2.0

I haven't been doing anything with electronics recently but I have been flying my Parrot 2.0 drone. Here are some videos:





Tuesday, 26 June 2012

Quadrocopters

I have recently upgraded my Parrot AR Drone to the new 2.0 version. The new version features a number of upgrades but there are two in particular which are really standing out so far.

The front facing camera has been upgraded to 720P HD quality. This is much better than the first Parrot drone which had a camera which really wasn't great. Unfortunately the new camera uses a rolling shutter which means that at times the video can be quite wobbly but mostly the video quality is good enough to still be impressive.

The other big upgrade in the 2.0 is the addition of an "Absolute Control" mode where control is done relative to the pilot rather than relative to the drone. For example, this means that when you tilt your iPad towards you the drone will move towards you rather than simply moving backwards. This makes flying the drone much easier!

Here are a couple of videos from some flights which I did today.



The Parrot 2.0 delivers impressive performance for a relatively low price tag. However, it is interesting to see what can be achieved if you have a (much) higher budget. The OktoKopter-XL costs >£5K-£10K for the drone + camera + other necessary parts and can produce some really impressive videos such as the following.


MikroKopter - Zoom from Holger Buss on Vimeo.


MikroKopter - Wind turbine from Holger Buss on Vimeo.

Monday, 25 June 2012

Exciting Components

I haven't been spending much time on electronics recently but I have been seeing some really interesting components.

HackHD (http://hackhd.com/)

I think this is a very recent project but I can't see any dates on the HackHD site. This simple PCB features a 1080P 30FPS camera which can be controlled electronically and records to an SD card. The website is very bare with some details about the PCB but no example videos. Thankfully there are some good examples and comparisons on Youtube.


The site offers to sell you a starter kit including PCB, battery, memory card and some other components for US $140 (about £90) which seems pretty reasonable.

808 Car Key Micro Camera (http://chucklohr.com/808/)

While Googling for reviews of the HackHD I came across a thread on a paintballing forum which was discussing the HackHD. One poster in this thread suggested that they would prefer to use an 808 Camera which supposedly only costs USD $38 for 720P video. A bit more Googling turned up the link above which describes the 808 camera as a line of cheap HD cameras out of China. The most recent edition is the #18 model which supports 720P 30FPS video and is available for around USD $36 on ebay.



The same ebay sellers are offering a cheap 1080P video camera but this thread suggests that the video capture is unreliable.

Electric Imp (http://www.electricimp.com/)

Electric Imp is a micro controller with a wifi connection in a standard SD card form factor.


The card will retail for USD $25 and there are several interesting development kits which cost between USD $7 and $25. This is a very recent project so the products haven't actually been released yet but are due very soon.

I'm particularly interested in this as it is impressively cheap for a wifi solution.


Thursday, 31 May 2012

Raspberry Pi Kernel Image

At the end of my last post I needed a Debian Linux Image package. I posted on the forums but didn't get anywhere. A bit of googling turned up a couple of useful pages which talked about how to build a Debian Linux image package. Based on these pages I ran the following commands.
cd /lib/modules/3.1.9+/build
time make-kpkg kernel_image
This ended with an error:
arm-Linux-gnueabi-ld: not found
I ran the following command and spotted that there were some existing symlinks for other gnueabi tools:
ls -l  /usr/bin/arm-linux-gnueabi*
I therefore tried adding a symlink for ld. A couple of hours later the build failed and in the end (after several more multi hour builds) I needed all of these links:
sudo ln -s /usr/bin/ld /usr/bin/arm-linux-gnueabi-ld
sudo ln -s /usr/bin/ar /usr/bin/arm-linux-gnueabi-ar
sudo ln -s /usr/bin/nm /usr/bin/arm-linux-gnueabi-nm
sudo ln -s /usr/bin/objcopy /usr/bin/arm-linux-gnueabi-objcopy
sudo ln -s /usr/bin/objdump /usr/bin/arm-linux-gnueabi-objdump
sudo ln -s /usr/bin/strip /usr/bin/arm-linux-gnueabi-strip
With these links in place I cleaned the build point and rebuilt the kernel.
time fakeroot make-kpkg clean
gzip -dc /proc/config.gz > .config
time fakeroot make-kpkg kernel_image
Sadly after 6 hours of building the Debian package failed to be created due to permissions issues. Cue restarting with sudo.
time sudo fakeroot make-kpkg clean
gzip -dc /proc/config.gz > .config
time sudo fakeroot make-kpkg kernel_image
Attempting to install the resulting Debian package prompted a warning that I already had a kernel in /lib/modules/3.1.9+. I moved the existing kernel out of the way and installed the new kernel package. I then copied the kernel headers back into place.
sudo mv /lib/modules/3.1.9+ /lib/modules/3.1.9+.old
sudo dpkg -i linux-image-3.1.9+_3.1.9+-10.00.Custom_armel.deb
sudo cp -r /lib/modules/3.1.9+.old/build /lib/modules/3.1.9+/build
With all of this in place I could finally try again to build and install my ar5523 module.
cd ~/ar5523
sudo m-a a-i ar5523
sudo cp ../uath-ar5523.bin /usr/local/lib/firmware/
sudo modprobe ar5523
sudo shutdown -r now
After all this I plugged in my WG111T and sadly it didn't work! The following errors show up in dmesg while the WG111T is plugged in:
usb 1-1.3.4: new high speed USB device number 49 using dwc_otg
usb 1-1.3.4: New USB device found, idVendor=1385, idProduct=4250
usb 1-1.3.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.3.4: Product: WG111T
usb 1-1.3.4: Manufacturer: Atheros Communications Inc
usb 1-1.3.4: SerialNumber: 1.0
usb 1-1.3.4: MAC/BBP AR5523, RF AR2112
ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

usb 1-1.3.4: timeout waiting for command reply
usb 1-1.3.4: could not send read command 07h
DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

usb 1-1.3.4: timeout waiting for command reply
usb 1-1.3.4: could not send read command 07h
DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

usb 1-1.3.4: timeout waiting for command reply
usb 1-1.3.4: could not send read command 07h
DEBUG:handle_hc_chhltd_intr_dma:: XactErr with NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK
 

Thursday, 17 May 2012

Patching the ar5523 driver

I made further progress with building a driver for my WG111T USB wifi. This is the latest incantation that I am using:

svn co svn://svn.berlios.de/fullstory/ar5523/trunk ar5523
wget http://verein.lst.de/~hch/ar5523.tgz
tar -xf ar5523.tgz ar5523/uath-ar5523.bin --strip 1
cd ar5523
QUILT_PATCHES="debian/patches" quilt delete kcompat-2.6.34
QUILT_PATCHES="debian/patches" quilt new usbfix
QUILT_PATCHES="debian/patches" quilt add ar5523.c

... edit ar5523.c as per the diff below ...

QUILT_PATCHES="debian/patches" quilt refresh
dpkg-buildpackage -us -uc
sudo dpkg -i ../ar5523-source*deb
sudo m-a a-i ar5523


Here are the diffs of the fixes which I had to make. A couple of USB functions have changed name and a networking structure has changed a bit:

Index: ar5523/ar5523.c
===================================================================
--- ar5523.orig/ar5523.c 2012-05-17 22:59:30.741403331 +0100
+++ ar5523/ar5523.c 2012-05-17 23:01:02.500427071 +0100
@@ -886,7 +886,7 @@
}

static int ar5523_add_interface(struct ieee80211_hw *hw,
- struct ieee80211_if_init_conf *conf)
+ struct ieee80211_vif *conf)
{
struct ar5523 *ar = hw->priv;

@@ -1122,7 +1122,7 @@
struct ar5523_tx_cmd *cmd = &ar->tx_cmd[i];

usb_kill_urb(cmd->urb);
- usb_buffer_free(ar->dev, AR5523_MAX_TXCMDSZ,
+ usb_free_coherent(ar->dev, AR5523_MAX_TXCMDSZ,
cmd->buf, cmd->urb->transfer_dma);
usb_free_urb(cmd->urb);
}
@@ -1142,7 +1142,7 @@
ar5523_err(ar, "could not allocate tx urb");
goto out;
}
- cmd->buf = usb_buffer_alloc(ar->dev, AR5523_MAX_TXCMDSZ,
+ cmd->buf = usb_alloc_coherent(ar->dev, AR5523_MAX_TXCMDSZ,
GFP_KERNEL,
&cmd->urb->transfer_dma);
if (!cmd->buf) {
@@ -1159,7 +1159,7 @@
while (--i >= 0) {
struct ar5523_tx_cmd *cmd = &ar->tx_cmd[i];

- usb_buffer_free(ar->dev, AR5523_MAX_TXCMDSZ,
+ usb_free_coherent(ar->dev, AR5523_MAX_TXCMDSZ,
cmd->buf, cmd->urb->transfer_dma);
usb_free_urb(cmd->urb);
}
@@ -1175,7 +1175,7 @@
struct ar5523_rx_cmd *cmd = &ar->rx_cmd[i];

usb_kill_urb(cmd->urb);
- usb_buffer_free(ar->dev, AR5523_MAX_RXCMDSZ,
+ usb_free_coherent(ar->dev, AR5523_MAX_RXCMDSZ,
cmd->buf, cmd->urb->transfer_dma);
usb_free_urb(cmd->urb);
}
@@ -1195,7 +1195,7 @@
ar5523_err(ar, "could not allocate rx urb");
goto out;
}
- cmd->buf = usb_buffer_alloc(ar->dev, AR5523_MAX_TXCMDSZ,
+ cmd->buf = usb_alloc_coherent(ar->dev, AR5523_MAX_TXCMDSZ,
GFP_KERNEL,
&cmd->urb->transfer_dma);
if (!cmd->buf) {
@@ -1213,7 +1213,7 @@
if (error) {
ar5523_err(ar, "error %d when submitting rx urb",
error);
- usb_buffer_free(ar->dev, AR5523_MAX_RXCMDSZ,
+ usb_free_coherent(ar->dev, AR5523_MAX_RXCMDSZ,
cmd->buf, cmd->urb->transfer_dma);
usb_free_urb(cmd->urb);
return error;
@@ -1228,7 +1228,7 @@

usb_kill_urb(cmd->urb);

- usb_buffer_free(ar->dev, AR5523_MAX_RXCMDSZ,
+ usb_free_coherent(ar->dev, AR5523_MAX_RXCMDSZ,
cmd->buf, cmd->urb->transfer_dma);
usb_free_urb(cmd->urb);
}

With this patch in place I can now build the ar5523 module but I can't install it because of the following error:

Done!
unpack
Extracting the package tarball, /usr/src/ar5523.tar.bz2, please wait...
"/usr/share/modass/packages/default.sh" build KVERS=3.1.9+ KSRC=/usr/src/linux-OLDVERSION.1337203974 kdist_image
Done with /lib/modules/3.1.9+/ar5523-modules-3.1.9+_0~slh.12_armel.deb .
dpkg -Ei /lib/modules/3.1.9+/ar5523-modules-3.1.9+_0~slh.12_armel.deb
Selecting previously deselected package ar5523-modules-3.1.9+.
(Reading database ... 48573 files and directories currently installed.)
Unpacking ar5523-modules-3.1.9+ (from .../ar5523-modules-3.1.9+_0~slh.12_armel.deb) ...
dpkg: dependency problems prevent configuration of ar5523-modules-3.1.9+:
ar5523-modules-3.1.9+ depends on linux-image-3.1.9+; however:
Package linux-image-3.1.9+ is not installed.
dpkg: error processing ar5523-modules-3.1.9+ (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
ar5523-modules-3.1.9+

I: Direct installation failed, trying to post-install the dependencies

apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
ar5523-modules-3.1.9+
0 upgraded, 0 newly installed, 1 to remove and 29 not upgraded.
1 not fully installed or removed.
After this operation, 81.9 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 48579 files and directories currently installed.)
Removing ar5523-modules-3.1.9+ ...

Clearly the next challenge is to get a linux-image-3.1.9+ package installed.

 

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.