Category : Nerd Stuff

Compiling kernel modules for Raspbian / Raspberry Pi

I needed to compile an out-of-tree (vendor supplied) driver for a USB device, to use it on my Raspberry Pi. Since the process was less than obvious, I’ll document it here. Maybe it will be of use to anyone else.

Normally, for compiling kernel modules, you need the kernel headers available. They have to match the version of the kernel you are targeting. In case of the Raspberry Pi running the 2012-07-15 image of Raspbian, that would be 3.1.9+. On plain Debian you would install a ‘linux-headers-x.y.z-flavour’ package, but that doesn’t seem to be available on Raspbian (at least not the right version), so we use the full kernel source from Github.

The main problem with that, is the absence of a file named Module.symvers, that contains the symbol versions of the running kernel and all of its modules. That file would normally come in the linux-headers package, that I mentioned above. To get that file, and be able to build ‘good’ modules for the kernel, you would need to build the entire kernel and all its modules yourself. At the end of the build, the file will be created. However, if you want to do that on the Pi itself, make sure you have plenty of time, because a complete kernel build will take quite a few hours.

To spare you the trouble, you can download it here: Module.symvers. Please note: this file is for the 3.1.9 kernel from Raspbian-2012-07-15, and it will not work for other kernel versions.

Assuming you have downloaded the file to your home directory, you can now download the Linux kernel source and prepare it for building out-of-tree modules like this:

cd /usr/src
sudo wget -O raspberrypi-linux-3.1.9.tar.gz https://github.com/raspberrypi/linux/tarball/rpi-patches
sudo tar xzf raspberrypi-linux-3.1.9.tar.gz
sudo ln -s /usr/src/raspberrypi-linux-eab45cb /lib/modules/`uname -r`/build
cd /usr/src/raspberrypi-linux-eab45cb
sudo sh -c 'zcat /proc/config.gz  > .config'
sudo sed -i 's/EXTRAVERSION =.*/EXTRAVERSION = +/' Makefile
sudo cp ~/Module.symvers .
sudo make oldconfig
sudo make modules_prepare

A few notes:

  • The name of the source directory is probably different in your case, because it contains the ID of the latest commit in the Git repository and commits occur regularly.
  • The sed command on line 7 is to add a ‘+’ to the version in the source. The version should be 3.1.9+, while the version in the repository is just 3.1.9.

Now most well-maintained drivers should ship a proper Makefile for building them, but the usual command line for building such a module would be something like this:

[code]
make -C /lib/modules/`uname -r`/build SUBDIRS=$PWD modules
[/code]

First steps with Arduino

This is the second post in a series to come. Recently, I have taken on the challenge of building a quadcopter, and I will report about my progess on this blog.

Read the first post, about part of my plan, here.

My quadcopter will be an AeroQuad, a design which is based on the Arduino Mega 2560 microcontroller. The board arrived in the mail last Saturday, and since I haven’t owned an Arduino before, everything about it was kind of new to me. So, I did some small experiments.

My laptop runs Debian Wheezy these days, and the Arduino IDE is packaged for that, so installation was as easy as typing:

[code]apt-get install arduino[/code]

The Arduino IDE is a Java application, that has a simple code editor and some built-in tools for compiling your code and uploading it to the Arduino. It comes with some example programs, the simplest of which is called ‘Blink‘ and does little more than make a LED on the board blink on and off.

That worked nicely, and as a first-time Arduino user, it is fun to make the LED blink in a variety of patterns. That grows old quickly though, so on to more challenging tasks.

The next experiment was to download the AeroQuad software and see if I could get that built. It took me a while to figure out where to put the AeroQuad libraries so that the IDE can find them, because the installation instructions described two options, both of which I didn’t like, but in the end, it was obvious.

The default setting in the Arduino IDE for ‘sketchbook location’ (where you keep you Arduino sketches) is $HOME/sketchbook. This means that the AeroQuad libraries need to live in $HOME/sketchbook/libraries, and they will be found.

Something else noteworthy is, that you cannot change the name of the folder containing the AeroQuad software itself. When you unpack the archive, you get a directory named ‘AeroQuad’. I changed it to ‘AeroQuad-3.0.1’, but that doesn’t work. The IDE told me that ‘The file “AeroQuad.ino” needs to be in a sketch folder named “AeroQuad”‘, so I renamed it back.

Now, compiling the code is generally just a matter of clicking a button, but when I tried that with the AeroQuad project, the compiler crashed:

[code]collect2: error: ld terminated with signal 11 [Segmentation fault][/code]

I did try to find out why, but Googling around for a while didn’t give me anything useful, except that the Arduino IDE, when downloaded from the official website, ships with GCC version 4.3.2, while Debian Wheezy is at 4.7.0 at the moment. That’s a rather big difference.

I decided to try the easy way, and just get the official Arduino IDE and install it in /opt/arduino-1.0.1. Clearly a good choice, because compiling the software just worked now. I even uploaded it to the Arduino, but since I don’t have anything to connect to it yet, that was pretty pointless.

The next step will be to assemble the AeroQuad v2.1 Shield, which is a print board that will contain sensors like triple-axis gyroscope, accelerometer, magnetometer and barometric pressure sensor; all the neat stuff that will make the AeroQuad stay up in the air. Today, after being underway for almost three weeks, they arrived at my doorstep. Well, after paying 37 euros for VAT and customs handling costs…

Next stop: “Hardware Assembly 2.1 Shield“…

Continue here: Quadcopter Project Rebooted

 

 

Building a quadcopter

Last week, I decided, I am finally going to build my own RC quadcopter (or quadrocopter, if you prefer). “Why?”, you might ask. Well, basically, it’s video’s like this one, that just make my heart go a little bit faster. So, the goal is to build a quadcopter, that can carry a camera (ideally this one, but…).

Basically, a quadcopter consists of the following parts:

  • a frame
  • a flight controller
  • 4 motors
  • 4 ESCs
  • a battery
  • an RC receiver

Without thinking too much about it (but having looked at several DIY descriptions, ready-made kits, complete solutions, etc.), I decided to use the information and software from AeroQuad (“The Open Source QuadCopter / Multicopter”) to do it.

I quote:

The AeroQuad is an open-source hardware and software project dedicated to the construction of remote controlled four-rotor helicopters, also known as quadcopters or quadrocopters.

The AeroQuad store can provide most -if not all- the necessary parts to build the quadcopter, but of course, it is fun (and probably financially rewarding) to shop around for parts elsewhere. I am not at all sure which parts I will be using for my quadcopter apart from the AeroQuad flight controller. And even though they provide a complete kit, I decided to order the Arduino Mega 2560 somewhere else, because it was cheaper.

So far, I ordered the following materials:

  • An Arduino Mega 2560 microcontroller (USD 19.00 at BuyInCoins). Ordered June 29, seems to have shipped July 2nd.
  • AeroQuad v2.1 Shield and other accessories from AeroQuad, for a total of USD 163,55 (+ USD 8,93 shipping). Ordered July 2nd, shipped July 3rd.

That’s basically all I need for the flight controller. I haven’t decided on what kind of motors, ESCs and batteries I will use, and I will have to see if I am going to buy a ready-made frame, or build one myself.

In the mean time, here are some interesting reads:

I will write about my progress on this website.

Next: First Steps With Arduino

“Confidential”

Ik ontving deze mail. Ik ben zelf niet geinteresseerd in het voorstel, maar mocht jij het wel zijn, dan moet je Bao effe contacten.

Hello,

I am Bao Ismail personal attorney to my late client, who was a private oil consultant/contractor with the Shell Petroleum Development Company before his death. My client died as a result of a heart-related condition on April 22nd 2005. His heart condition was due to the death of his wife and his three children in the tsunami natural disaster on 26th December 2004 in Sumatra Indonesia. It may interest you to know that my client died “intestate”.

PROPOSITION:

I decided to contact you purely on a personal conviction of trust and confidence to assist in distributing the money left behind by my client. The deceased had a deposit valued presently at (USD$3,500,000:00) and the Bank has issued me a notice to provide a next of kin or beneficiary, otherwise the deposit would be confiscated and reverted to the State as unclaimed.

My proposition to you is to seek your consent to present you as a relative/next-of-kin and beneficiary of my client, so that the proceeds of this account could be released to you. Then we can share the amount upon our perfect understanding. Please note; this is a legitimate transaction and must be handle through its legitimate procedure without any breach of law.

If this business proposition offends your moral values, do accept my apology. I must use this opportunity to implore you to exercise the utmost indulgence to keep this matter confidential, while I look forward to your prompt response.

Best regards,
Bao Ismail

1 3 4 5 6 7 12