Walkera helicopters under Linux – part 1

A couple of months ago, I bought a Walkera Dragonfly #04, just for fun. While actually flying an RC helicopter is great fun, sometimes you will want to use a simulator. As Linux is my platform of choice, I tried using the Walkera transmitter with a serial cable to run a heli-sim. I found out how to do that; here’s the results of my quest. This article will be split in 3 parts: kernel; utility; Heli-X. This is the first part.

I will use Ubuntu Linux 8.04 Hardy Heron for my explanation. You can use other versions of Linux – but please beware, you will need a pretty recent kernel to be able to build the kernel module.

First, what will you need. You’ll need the right hardware: a sim cable to connect to your Walkera transmitter; and most likely a serial-to-USB converter to connect the serial cable to your PC. You will need a PC with 3D acceleration, as the simulator we’ll be using makes use of it. Software 3D won’t cut it here.

Then the software. If I’m right, from kernel 2.6.26, the Zhen Hua kernel module will be included in Linux right away. By then, you won’t be needing any patching and recompiling – and this article will be out of date anyway. Until then, read on. You will need a kernel module for your transmitter; a new version of the inputattach utility. For simulation, we’ll be using Heli-X, a great Java-based helicopter simulator.


First, the kernel module. We could go the “official” way and compile a new kernel with a new version number. This gives us a proper .deb file with a proper version number. However, it also gives us a lot of work. So we’ll go the rogue way: we will just compile a single module and sneak it into the kernel module tree. Then, we will compile the inputattach utility with an extra header-file to accommodate to this new module. And please remember: if you’re old enough to complain about the mess we’re making, then you’re old enough to make it clean as well.

Firstly, we will install a couple of packages to be able to build our stuff:
$ sudo aptitude install build-essential fakeroot debhelper devscripts
Now get your kernel version:
$ uname -r

We will get the source of this kernel. Put it anywhere you like.
$ apt-get source linux-image-`uname -r`
Now patch your code. Get the zhen-hua.patch and type
$ cd linux-source-2.6.24-2.6.24/ ; patch -p1 < zhen-hua.patch.txt
Select the module: one way to do that is to configure the kernel with your current configuration, telling it you want a Zhen Hua module (answer “m”):
$ cp /boot/config-`uname -r` .config; make oldconfig
Then build:
$ make drivers/input/joystick/zhenhua.ko
Copy to your current modules:
$ sudo cp drivers/input/joystick/zhenhua.ko /lib/modules/`uname -r`/kernel/drivers/input/joystick/; sudo depmod -a
And finally, insert the module in your kernel:
$ sudo modprobe zhenhua
You are now ready for step 2, the inputattach utility.