# Cross-compiling a kernel module?



## Deleted member 42224 (Mar 26, 2014)

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.


----------



## trh411 (Mar 26, 2014)

Have you taken a look at the FreeBSD Embedded Handbook and FreeBSD Guide to Cross Compiling.


----------



## Deleted member 42224 (Mar 27, 2014)

trh411 said:
			
		

> Have you taken a look at the FreeBSD Embedded Handbook and FreeBSD Guide to Cross Compiling.



I have. Have you? There's nothing useful there.


----------



## trh411 (Mar 27, 2014)

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?


----------



## SirDice (Mar 28, 2014)

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.


----------



## Deleted member 42224 (Mar 28, 2014)

trh411 said:
			
		

> Philbrandeaux said:
> 
> 
> 
> ...



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


----------

