Cross-Compiling Modules/Drivers for ARM?

I am trying to build a device driver as a Linux module for an ARM architecture. I have the ARM kernel configured and built, a cross- compiling toolchain to compile, as well as the driver's sources. The trouble I am having is specifying the location of the kernel sources and which compiler to use for the makefile. Could someone please run me though the steps (makefile operations) for simply building the module using the ARM kernel source tree and the cross-compiler toolset?

Thanks in advance.

Reply to
Loading thread data ...

Refer to this chapter by arm-linux official site, which describes full detailed steps of compiling the kernel. You can find the way to compile kernel modules too.

formatting link

Also there's various choices of toolchains for use. A brief description of this can be found at:

formatting link

Denx's ELDK is a good choice for arm-based cross-compile and devel>

Reply to

Assuming you are talking about a 2.6.x kernel, the driver makefile will use the kernel build system.

You'll probably have to look into the makefile to see where it gets the kernel directory from. You'll see something like

obj-m := yourdriver.o ... modules: $(MAKE) -C /path/to/the/kernel SUBDIRS=$(PWD) modules

The path_to_the_kernel could be a variable, like $(KERNELSRC), which may be defined further up in the Makefile. If not, you have to pass it to make on the command line.

So, to build your driver you do

#> CROSS_COMPILE=arm-linux- ARCH=arm make or #> CROSS_COMPILE=arm-linux- ARCH=arm KERNELSRC=/path/to/the/kernel make

Make sure the 'bin' directory of your cross compiler (arm-linux-gcc) is in your PATH. If your cross compiler is not known as arm-linux-gcc, change the CROSS_COMPILE variable accordingly.

Kind regards,


Reply to
Iwo Mergler

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.