Cross-compiling a kernel module?

John-Mark Gurney jmg at funkthat.com
Wed Mar 26 22:44:50 UTC 2014


Martin Galvan wrote this message on Wed, Mar 26, 2014 at 18:48 -0300:
> 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:
> 
> 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.

$ 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.

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."


More information about the freebsd-drivers mailing list