Cross-compiling a kernel module?

  • Thread starter Deleted member 42224
  • Start date
D

Deleted member 42224

Guest
Hi everyone! I'm trying to cross-compile a simple Hello World module for the A10 Cubieboard (which is ARM/Allwinner10 based) but I'm not sure of how to write my makefile. What I'm using to test it (on an amd64) is:

Code:
KMOD=hello
SRCS=hello.c

.include <bsd.kmod.mk>

I've been browsing the mailing list a bit and so far I've found a way but it involves rebuilding the whole kernel, and I just want to compile this module to load/unload in runtime.

Also, before you answer this: try and be as specific as you can, since I'm kind of a newbie at this. Stuff like where should I put/look for files, run commands, etc would be appreciated.
 
I'm no kernel developer but if you added your module to the tree it should cross-compile for ARMv6 with something like make TARGET_ARCH=armv6. The same way the rest of the kernel would be built. Since every part has it's own Makefile it should work. If I remember correctly the compiled module ends up in /usr/obj/${ARCH}/ somewhere.
 
trh411 said:
Philbrandeaux said:
I have. Have you? There's nothing useful there.
Was there anything useful in the response you got on the mailing list to this same inquiry?

There was indeed. Just in case anyone has the same inquiry, I'll paste the response here:

$ cd $SRC
$ make kernel-toolchain TARGET_ARCH=armXX
$ make buildenv TARGET_ARCH=armXX BUILDENV_SHELL=/usr/local/bin/shell
$ cd <moduledir>
$ make

The buildenv command sets up the new shell with an environment that is
the same as if you were running under a buildkernel or buildworld
environment.. You can use this to build one off programs like bin/ls
too.

Don’t forget to set the KERNBUILDDIR option as well to point to your
kernel object dir so the module will pick up all the right options.
 
Back
Top