I have banana pi and installed debian with kernel 3.19.3-bananapi from http://www.igorpecovnik.com/2014/09/07/banana-pi-debian-sd-image/

So I want to compile a module so I downloaded kernel from kernel.org and when I try to compile any module, like for example I am in the root of kernel tree and execute sudo make M=drivers/android modules

I get error:

Building modules, stage 2.
  MODPOST 0 modules

Here is the output with the deubuging V=1

user1@bananapi:~/linux-3.19.3$ sudo make M=drivers/android modules V=1
test -e include/generated/autoconf.h -a -e include/config/auto.conf || (       \
        echo >&2;                                                       \
        echo >&2 "  ERROR: Kernel configuration is invalid.";           \
        echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\
        echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \
        echo >&2 ;                                                      \
mkdir -p drivers/android/.tmp_versions ; rm -f drivers/android/.tmp_versions/*
make -f ./scripts/Makefile.build obj=drivers/android
(cat /dev/null; ) > drivers/android/modules.order
make -f ./scripts/Makefile.modpost
  find drivers/android/.tmp_versions -name '*.mod' | xargs -r grep -h '\.ko$' | sort -u | sed 's/\.ko$/.o/' | scripts/mod/modpost   -i ./Module.symvers -I drivers/android/Module.symvers  -o drivers/android/Module.symvers -S -w  -s -T -

I have tried to change the GREP_OPTIONS='--color=always' to never and auto and got the same error.

the output of uname -r is 3.19.3-bananapi My headers are installed.

The output of dpkg -l linux*

user1@bananapi:~/linux-3.19.3$ dpkg -l linux\*
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
ii  linux-dtb-3.19 2.6          armhf        Linux DTB, version 3.19.3-bananap
un  linux-firmware <none>                    (no description available)
un  linux-headers  <none>                    (no description available)
un  linux-headers- <none>                    (no description available)
ii  linux-headers- 2.6          armhf        Linux kernel headers for 3.19.3-b
un  linux-image    <none>                    (no description available)
un  linux-image-2. <none>                    (no description available)
ii  linux-image-3. 2.6          armhf        Linux kernel, version 3.19.3-bana
un  linux-kernel-h <none>                    (no description available)
un  linux-kernel-l <none>                    (no description available)
ii  linux-libc-dev 2.6          armhf        Linux support headers for userspa
un  linux-modules- <none>                    (no description available)
un  linux-sound-ba <none>                    (no description available)
ii  linux-u-boot-3 2.6          all          Uboot loader
un  linux32        <none>                    (no description available)

2 Answers 2


If these are external modules, try building against the kernel first, then install using modules_install as described below. Make sure you are building in the path to your kernel source.

From https://www.kernel.org/doc/Documentation/kbuild/modules.txt

--- 2.1 Command Syntax

The command to build an external module is:

  $ make -C <path_to_kernel_src> M=$PWD

The kbuild system knows that an external module is being built due to the "M=" option given in the command.

To build against the running kernel use:

  $ make -C /lib/modules/`uname -r`/build M=$PWD

Then to install the module(s) just built, add the target "modules_install" to the command:

  $ make -C /lib/modules/`uname -r`/build M=$PWD modules_install

modules_install explained:

Install the external module(s). The default location is /lib/modules/<kernel_release>/extra/, but a prefix may be added with INSTALL_MOD_PATH (discussed in section 5).

If you intend to install the module in a custom directory under your main kernel directory (instead of /extra), use INSTALL_MOD_DIR.


External modules are by default installed to a directory under /lib/modules/$(KERNELRELEASE)/extra/, but you may wish to locate modules for a specific functionality in a separate directory. For this purpose, use INSTALL_MOD_DIR to specify an alternative name to "extra."

  $ make INSTALL_MOD_DIR=gandalf -C $KDIR \
         M=$PWD modules_install       
  => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/
  • Thank you for the answer. I tried the following command in the linux-3.19.3 folder: sudo make -C /lib/modules/uname -r/build v=1 M=$HOME/linux-3.19.3/drivers/android modules and got the following error: make: Entering directory /usr/src/linux-headers-3.19.3-bananapi' Building modules, stage 2. MODPOST 0 modules scripts/mod/modpost: 1: scripts/mod/modpost: Syntax error: "(" unexpected make[1]: *** [__modpost] Error 2 make: *** [modules] Error 2 make: Leaving directory /usr/src/linux-headers-3.19.3-bananapi' Apr 18, 2015 at 16:00
  • I just tried the following: make -C /lib/modules/$(uname -r)/build M=$PWD. $PWD and got: user1@bananapi:~/linux-3.19.3$ make -C /lib/modules/$(uname -r)/build M=$PWD. $PWD make: Entering directory /usr/src/linux-headers-3.19.3-bananapi' make: Nothing to be done for /home/user1/linux-3.19.3'. make: Leaving directory `/usr/src/linux-headers-3.19.3-bananapi' I also tried: ~/linux-3.19.3/drivers$ make INSTALL_MOD_DIR=android -C $KDIR \ M=$PWD modules_install and got make: *** M=/home/user1/linux-3.19.3/drivers: No such file or directory. Stop. Sorry but I am a newbie. Apr 18, 2015 at 16:38
  • Sorry for the bad visual in the comment, but it's just make -C /lib/modules/$(uname -r)/build M=$PWD
    – iyrin
    Apr 18, 2015 at 16:40
  • Here is what it gave me: root@bananapi:/home/user1/linux-3.19.3# make -C /lib/modules/$(uname -r)/build M=$PWD make: Entering directory /usr/src/linux-headers-3.19.3-bananapi' CC kernel/bounds.s GEN /home/user1/linux-3.19.3/include/generated/bounds.h CC arch/arm/kernel/asm-offsets.s GEN /home/user1/linux-3.19.3/include/generated/asm-offsets.h make[1]: *** No rule to make target /home/user1/linux-3.19.3/missing-syscalls', needed by __build'. Stop. make: *** [_module_/home/user1/linux-3.19.3] Error 2 make: Leaving directory /usr/src/linux-headers-3.19.3-bananapi' Apr 18, 2015 at 16:43
  • Sorry, I was mistaken earlier. M=$PWD will use your current working directory. You should cd to your module source directory where the Makefile is located prior to running the command.
    – iyrin
    Apr 18, 2015 at 17:39

Check to see if there's a /proc/config.gz on the banana when the system is running (it will not be there if it is not). Most likely it does exist.1 Copy that into the top level of the source tree and:

make clean
gunzip -c config.gz > .config
make oldconfig

Then try building the module again.

  1. If it doesn't, try sudo modprobe configs and check again. If you got an error trying to load that module (see man modprobe) because it doesn't exist, you are out-of-luck.
  • Thanks! I just did this and when I tried to do sudo make drivers/android modules I got the same error: Building modules, stage 2. MODPOST 0 modules But when I did another random module, it worked. for the bluetooth module it worked. make M=/drivers/bluetooth modules works fine. I have noticed that on some modules the compile process works great but on others I get the Building modules, stage 2. MODPOST 0 modules error. And on the modules which I need I get the error. I did not modify any files. The kernel is original from kernel.org. Apr 18, 2015 at 16:20
  • /proc/config.gz only exists if you have set a flag when configuring the kernel -- although that flag may be set when the kernel was first compiled by the maintainer of the distro. Also look for .config under /usr/src in the kernel source tree.
    – llywrch
    May 21, 2020 at 15:04
  • It can also be modular, ie., requires modprobe configs; when/if that loads /proc/config.gz will be available (edited).
    – goldilocks
    May 21, 2020 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .