Building kernel modules fails for Debian Jessie Linux Arm 4.1.6

1,402 views
Skip to first unread message

Andrew P. Lentvorski

unread,
Aug 28, 2015, 6:37:38 AM8/28/15
to BeagleBoard
I tried a couple of different ways to build the "hello world" kernel module, but I seem to be lacking the proper "build" to use in my makefiles.

So, I installed the linux headers, but I seem to be missing a "classmap.h" file.

I also managed to get past git crashing by downloading the repo and then rsync'ing it to the BBB.  So, after 8 hours(!), the BBB fully compiled a 4.1.6-ti-r12 build.  So, if there is something I can do to build a kernel module using that tree and scripts, I can do that, too.

What obvious thing am I missing?

Thanks.


The following NEW packages will be installed:
  linux-headers-4.1.6-ti-r11
0 upgraded, 1 newly installed, 0 to remove and 9 not upgraded.
Need to get 6,992 kB of archives.
After this operation, 52.9 MB of additional disk space will be used.
Get:1 http://repos.rcn-ee.com/debian/ jessie/main linux-headers-4.1.6-ti-r11 armhf 1jessie [6,992 kB]
Fetched 6,992 kB in 3s (2,199 kB/s)                     
Selecting previously unselected package linux-headers-4.1.6-ti-r11.
(Reading database ... 84339 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.1.6-ti-r11_1jessie_armhf.deb ...
Unpacking linux-headers-4.1.6-ti-r11 (1jessie) ...
Setting up linux-headers-4.1.6-ti-r11 (1jessie) ...
root@arm:~/kernels# cd /lib/modules/`uname -r`/build
root@arm:/lib/modules/4.1.6-ti-r11/build# ls
arch  block  crypto  Documentation  drivers  firmware  fs  include  init  ipc  Kconfig  kernel  lib  Makefile  mm  Module.symvers  net  samples  scripts  security  sound  tools  usr  virt
root@arm:/lib/modules/4.1.6-ti-r11/build# make scripts
scripts/kconfig/conf  --silentoldconfig Kconfig
  HOSTCC  scripts/selinux/genheaders/genheaders
scripts/selinux/genheaders/genheaders.c:13:22: fatal error: classmap.h: No such file or directory
 #include "classmap.h"
                      ^
compilation terminated.
scripts/Makefile.host:91: recipe for target 'scripts/selinux/genheaders/genheaders' failed
make[3]: *** [scripts/selinux/genheaders/genheaders] Error 1
scripts/Makefile.build:403: recipe for target 'scripts/selinux/genheaders' failed
make[2]: *** [scripts/selinux/genheaders] Error 2
scripts/Makefile.build:403: recipe for target 'scripts/selinux' failed
make[1]: *** [scripts/selinux] Error 2
Makefile:555: recipe for target 'scripts' failed
make: *** [scripts] Error 2




root@arm:~/bb-kernel/mymodules# cat makefile

obj-m += hello.o

all:
        make -C /root/bb-kernel/KERNEL/tools/build M=$(PWD) modules

clean:
        make -C /root/bb-kernel/KERNEL/tools/build M=$(PWD) clean


root@arm:~/bb-kernel/mymodules# make
make -C /root/bb-kernel/KERNEL/tools/build M=/root/bb-kernel/mymodules modules
make[1]: Entering directory '/root/bb-kernel/KERNEL/tools/build'
make[1]: *** No rule to make target 'modules'.  Stop.
make[1]: Leaving directory '/root/bb-kernel/KERNEL/tools/build'
makefile:5: recipe for target 'all' failed
make: *** [all] Error 2
root@arm:~/bb-kernel/mymodules# 



Robert Nelson

unread,
Aug 28, 2015, 10:21:39 AM8/28/15
to Beagle Board
This just means, for your external module, you need more then just the
'headers" you need the full kernel source..

Regards,

--
Robert Nelson
https://rcn-ee.com/

Andrew P. Lentvorski

unread,
Aug 28, 2015, 4:57:07 PM8/28/15
to BeagleBoard
After I clean up my own two *very* stupid errors of not capitalizing the name of the Makefile and installing the *r12* headers (I had r11), it compiles and inserts.

During my experiments, though, I came across something odd.  As the missing piece appeared to be this symlink:

root@arm:~/mymodules# ls -al /lib/modules/4.1.6-ti-r12/build
lrwxrwxrwx 1 root root 35 Aug 26 21:17 /lib/modules/4.1.6-ti-r12/build -> /usr/src/linux-headers-4.1.6-ti-r12



To make r12 compile, I tried creating this symlink:

root@arm:/# ln -s  /root/bb-kernel/KERNEL /lib/modules/4.1.6-ti-r12/build


Which does compile, but unfortunately doesn't seem to get the module info correct, so I can't insmod:

root@arm:~/mymodules# insmod hello.ko
insmod: ERROR: could not insert module hello.ko: Invalid module format
root@arm:~/mymodules# modinfo hello.ko
filename:       /root/mymodules/hello.ko
description:    A Simple Hello World module
depends:        
vermagic:       4.1.6-bone15 mod_unload modversions ARMv7 thumb2 p2v8 
root@arm:~/mymodules# uname -r
4.1.6-ti-r12



The conflict appears to be that vermagic gets set to 4.1.6-bone15 instead of r12.

Anyway, thanks for the advice.

For the record, here is my new Makefile (careful copying as make is nuts about tabs vs spaces):

root@arm:~/mymodules# cat Makefile

obj-m += hello.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean




Robert Nelson

unread,
Aug 28, 2015, 5:11:43 PM8/28/15
to Beagle Board
On Fri, Aug 28, 2015 at 8:57 PM, Andrew P. Lentvorski <bsd...@gmail.com> wrote:
> After I clean up my own two *very* stupid errors of not capitalizing the
> name of the Makefile and installing the *r12* headers (I had r11), it
> compiles and inserts.
>
> During my experiments, though, I came across something odd. As the missing
> piece appeared to be this symlink:
>
> root@arm:~/mymodules# ls -al /lib/modules/4.1.6-ti-r12/build
> lrwxrwxrwx 1 root root 35 Aug 26 21:17 /lib/modules/4.1.6-ti-r12/build ->
> /usr/src/linux-headers-4.1.6-ti-r12
>
>
>
> To make r12 compile, I tried creating this symlink:
>
> root@arm:/# ln -s /root/bb-kernel/KERNEL /lib/modules/4.1.6-ti-r12/build
>
>
> Which does compile, but unfortunately doesn't seem to get the module info
> correct, so I can't insmod:
>
> root@arm:~/mymodules# insmod hello.ko
> insmod: ERROR: could not insert module hello.ko: Invalid module format
> root@arm:~/mymodules# modinfo hello.ko
> filename: /root/mymodules/hello.ko
> description: A Simple Hello World module
> depends:
> vermagic: 4.1.6-bone15 mod_unload modversions ARMv7 thumb2 p2v8
> root@arm:~/mymodules# uname -r
> 4.1.6-ti-r12
>
>
>
> The conflict appears to be that vermagic gets set to 4.1.6-bone15 instead of
> r12.

"bb-kernel" repo has w.x.y-bonez kernel names...

https://github.com/RobertCNelson/ti-linux-kernel-dev

has what your are looking for kernel source...

Andrew P. Lentvorski

unread,
Aug 28, 2015, 6:16:02 PM8/28/15
to BeagleBoard


On Friday, August 28, 2015 at 2:11:43 PM UTC-7, RobertCNelson wrote:
"bb-kernel" repo has w.x.y-bonez kernel names...

https://github.com/RobertCNelson/ti-linux-kernel-dev

has what your are looking for kernel source...

Aha!

Thank you.  That was the piece I was missing. 
Reply all
Reply to author
Forward
0 new messages