Larry Martin | 21 Jun 21:44 2013

Re: Linaro linux-source has no makefiles - help?

I can now natively compile kernel modules in my Linaro image on Air Storm. 
This is a summary of the steps:

* Follow the instructions to download a Linaro image and write it to an SD
card (mine was 8 GB):

* Assemble a system with network and a Storm COM.  Boot and get into the
console.  Verify that the image already includes the linux-headers package:

     # ls /usr/src

* install the linux-sources package.  I am not sure if this is necessary, or
which other packages may have been necessary.  I don't think I really needed
git or the Debian developer tools.

     # apt-get install linux-source

This creates a skeleton in /usr/src/linux-source-3.2.0, along with a big
source tarball.  Unfortunately, my kernel is not 3.2.0:

     # uname -r

* Get the Gumstix sources for 3.5.0.  This is the same as the ZIP button on

     # cd
     # apt-get install wget
     # mkdir build
     # cd build
     # wget
     # unzip

* Review some critical links:

     Make sure /lib/modules/blah/build points to
         The particulars may vary by system and over time.
     # ls -l /lib/modules/3.5.0-2-linaro-omap/build
     lrwxrwxrwx 1 root root 42 Dec 10  2012
/lib/modules/3.5.0-2-linaro-omap/build ->

     Make sure /usr/src/linux-headers~blah/source points to the base of your
source tree
         The particulars may vary by system and over time.
     # ls -l /usr/src/linux-headers-3.5.0-2-linaro-omap/source
     lrwxrwxrwx 1 root root 26 Jun 21 16:05
/usr/src/linux-headers-3.5.0-2-linaro-omap/source ->

* Make a basic config builder.  I am not sure if the later step that makes
defconfig overwrites this or not

     # cd
     # cat > get_config
     ## see



     curl "$COMMON_UBUNTU" "$COMMON_ARMEL" "$FLAVOR_OMAP" > .config
     # chmod a+x get_config

* You should now have all the sources and makefiles you need, and
/usr/linux-source-blah seems irrelevant.
Run basic make commands in the correct places:

     # cd /usr/src/linux-headers-3.5.0-2-linaro-omap
     # make scripts
     # cd ~/build/linux-omap-3.5
     # ~/get_config
     # make ARCH=arm CROSS_COMPILE="" omap2plus_defconfig

* Make sure your top level Makefile agrees with your kernel 
  (thanks to the kernel module Programming Guide:

     # cd ~/build/linux-omap-3.5
     # uname -r
     # head Makefile
     VERSION = 3
     SUBLEVEL = 0
     EXTRAVERSION = -2-linaro-omap

     Edit the Makefile if necessary, using vi if you have not installed
anything else.
     Note that EXTRAVERSION is a string that holds everything after the
N.N.N pattern.

* Make modules, just to be sure stuff builds.  You can ^C out after a few
compiles work.
Modules built this way will not load into your kernel.  This is just a quick
check that
everything is in place.

     # cd ~/build/linux-omap-3.5
     # make ARCH=arm CROSS_COMPILE="" modules

* Now make the modules you care about.  This form of the Make command sets
your build environment 
to the -C path but points back your sources via the M path.

     # cd ~/build/linux-omap-3.5/drivers/usb/gadget
     # make ARCH=arm CROSS_COMPILE="" -C
/lib/modules/3.5.0-2-linaro-omap/build M=`pwd` modules
     CC      /root/build/linux-omap-3.5/drivers/usb/gadget/g_printer.mod.o
     LD [M]  /root/build/linux-omap-3.5/drivers/usb/gadget/g_printer.ko

(thanks to:

* Try your module

     # insmod g_printer.ko
     # lsmod
     Module                  Size  Used by
     g_printer              30375  0

If insmod fails, look in dmesg for detailed error messages and Google them.

That's my guide to native kernel module compilation on Linaro.


View this message in context:
Sent from the Gumstix mailing list archive at

This email is sponsored by Windows:

Build for Windows Store.