Adrian Dumitru Nicolau

Compile kernel module for specific Linux version on i.MX

Discussion created by Adrian Dumitru Nicolau Employee on Oct 9, 2014

Assuming a Linux kernel running on a i.MX powered machine, adding kernel modules to it needs the specific kernel sources and a toolchain for ARM. First, identify the kernel version running:

     $ uname -r

Next, download the kernel sources from the Freescale i.MX Linux Tree [1]. Change branch from master to the one seen above, the download links shall be seen under the commit tab.

The toolchain to be used is Linaro. It can be downloaded from [2]. Now that both the kernel sources and the toolchain are available, the steps to follow for compiling an additional kernel module are (assuming the working directory the kernel source tree):

     1. $ export PATH=/.../fsl-linaro-toolchain/bin/:$PATH

     2. $ export ARCH=arm

     3. $ export CROSS_COMPILE=arm-none-linux-gnueabi-

Now, inserting a kernel module on top of a running kernel needs that the module to be compiled in the same manner the kernel was, in terms of configuration. The configuration file which tells how the running kernel was compiled can be found under:

     $ /proc/config.gz (or under /boot sometimes)

Copy this file under the kernel source tree and issue:

     4. $ zcat config.gz > .config

Now modify aspects of .config to enable compilation of your desired module. E.g. to enable compilation of the CDC_ACM module, one should change the following line in .config:

     # CONFIG_USB_ACM is not set



     5. $ make

Trying to compile just the specific module may not work since not all dependencies may be present, so making the whole kernel is needed. If available, compile using multiple cores by using -j:

     $ make -j 4 (if 4 cores available)


[1] linux-2.6-imx.git - Freescale i.MX Linux Tree

[2] embest-tech/fsl-linaro-toolchain · GitHub