Newbie - Help compiling kernel modules

Andy Green andy at openmoko.com
Tue Mar 3 08:04:44 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Somebody in the thread at some point said:

| I am new to the *OpenMoko* community and appreciate your patience.
| I am trying to compile a simple "Hello World" *kernel* module.

| I have downloaded the tool chain and am trying to compile the module as
| follows:
| /usr/local/*openmoko*/arm/bin/arm-angstrom-linux-gnueabi-gcc
| -D__KERNEL__ -DMODULE -c hello.c

You need to abandon that way of coming at it.

The way that will give results is to leverage the kernel makefile to
build the module.

Here is how I did this for a hardware RNG driver I wrote as a module:

Makefile:

#
# Makefile for whirlygig-rng
#

obj-m := whirlygig-rng.o

clean:
~        rm -f *~ *.mod.c *.mod.o *.ko *.o *.symvers


Then build something like this:

export
CROSS_COMPILE=/usr/local/openmoko/arm/bin/arm-angstrom-linux-gnueabi- ;
make ARCH=arm -C <path to kernel source dir> KBUILD_SRC=<path to kernel
source dir> M=`pwd`

This will build the module in the current directory against the kernel
source tree in the given directory.

- -Andy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkms1osACgkQOjLpvpq7dMrGNgCfVn+nglPJ5bDpgd1ZvraR2sPf
F8gAn3gwXGE4zg/ZJWxdRFsOqGxLspCl
=t39W
-----END PGP SIGNATURE-----



More information about the devel mailing list