Here’s a tut showing how to cross-compile your own device driver (as a kernel module) on the Rascal and then load/unload it into Linux on the device. Before you attempt this tutorial, you need to set up a Rascal kernel build environment. The instructions are here: rascalmicro.com/docs/build-guide.html. Even if you’ve previously done this, remember that before compiling anything you need to re-run these commands (every time you open a new terminal window):
export CROSS_COMPILE=arm-linux-
PATH=$PATH:/opt/eldk/usr/bin:/opt/eldk/bin:/opt/cs/bin
Now for the driver building tutorial. Let’s download Dave Hylands’s gpio-event driver and usermode application for the Gumstix Overo. We can compile this driver for the Rascal unmodified once we get some paths set correctly in the Makefile. Check out the Rascal kernel git branch to ~/rascal/linux-2.6
and download Hylands’s code to ~/rascal/gpio-event
. Modify ~/rascal/gpio-event/module/Makefile
to use these alternate variable definitions:
CROSS_COMPILE ?= /opt/eldk/usr/arm-linux-gnueabi
KERNEL_PATH ?= /home/mike/rascal/linux-2.6/arch/arm/kernel
ARCH ?= arm
(Of course, the /home/mike
prefix is specific to my machine. What matters is that $(KERNAL_PATH)
is a directory containing a bunch of C source files, like module.c
.)
Now we’re ready to build the driver. Do this:
cd ~/rascal/gpio-event/module
make -C ~/rascal/linux-2.6/ M=`pwd` ARCH=arm modules
You should get a file called gpio-event-drv.ko
in ~/rascal/gpio-event/module
.
SCP this file to the Rascal and ssh in to it. From the directory where you put the gpio-event-drv.ko
file, you can use these commands:
insmod gpio-event-drv.ko
rmmod gpio-event-drv.ko
to load and unload the module respectively.
Leave a Reply