0

I am running Ubuntu:

#lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise
Kernel info:

3.8.0-38-generic #56~precise1-Ubuntu SMP Thu Mar 13 16:23:47 UTC 2014 i686 i686 i386 GNU/Linux

The source that I am having is : linux-lts-raring-3.8.0

When I am trying to make my first driver I get the following errors:

make -C /usr/linux-lts-raring-3.8.0 SUBDIRS=/home/drdr/Documents/drivers/first_driver modules
make[1]: Entering directory `/usr/linux-lts-raring-3.8.0'

  WARNING: Symbol version dump /usr/linux-lts-raring-3.8.0/Module.symvers
           is missing; modules will have no dependencies and modversions.

  Building modules, stage 2.
  MODPOST 1 modules
/bin/sh: 1: scripts/mod/modpost: not found
make[2]: *** [__modpost] Error 127
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/usr/linux-lts-raring-3.8.0'
make: *** [default] Error 2

Then I went to scripts/mod/ in my source directory I typed make:

root@drdr:/usr/linux-lts-raring-3.8.0/scripts/mod# make modpost
cc     modpost.c   -o modpost
In file included from modpost.c:18:0:
modpost.h:12:23: fatal error: elfconfig.h: No such file or directory
compilation terminated.
make: *** [modpost] Error 1

Update I found a related file mk_elfconfig.c. Is there a way to generate elfconfig.h from this;

root@drdr:/usr/linux-lts-raring-3.8.0/scripts/mod# ls -ld mk_elfconfig.c 
-rw-r--r-- 1 root root 1234 Feb 19  2013 mk_elfconfig.c

Why I am getting this error? I believe the version of the source code and what is running are the same.

The Makefile and source code for the driver is given here

Update after copying config- from /boot to my source code as .config: I did

root@drdr:/home/drdr/Documents/drivers/linux-lts-raring-3.8.0#make oldconfig 
scripts/kconfig/conf --oldconfig Kconfig
#
# configuration written to .config
#

root@drdr:/home/drdr/Documents/drivers/linux-lts-raring-3.8.0# make prepare
scripts/kconfig/conf --silentoldconfig Kconfig
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/syscalls/../include/generated/uapi/asm/unistd_x32.h
  SYSTBL  arch/x86/syscalls/../include/generated/asm/syscalls_32.h
  HOSTCC  arch/x86/tools/relocs
  WRAP    arch/x86/include/generated/asm/clkdev.h
  CHK     include/generated/uapi/linux/version.h
  UPD     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  CC      kernel/bounds.s
  GEN     include/generated/bounds.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
root@drdr:/home/drd/Documents/drivers/linux-lts-raring-3.8.0# 

But still same error in driver compilation:

root@drdr:/home/drdr/Documents/drivers/first_driver# make
make -C /usr/linux-lts-raring-3.8.0 SUBDIRS=/home/drdr/Documents/drivers/first_driver modules
make[1]: Entering directory `/usr/linux-lts-raring-3.8.0'

  WARNING: Symbol version dump /usr/linux-lts-raring-3.8.0/Module.symvers
           is missing; modules will have no dependencies and modversions.

  Building modules, stage 2.
  MODPOST 1 modules
/bin/sh: 1: scripts/mod/modpost: not found
make[2]: *** [__modpost] Error 127
make[1]: *** [modules] Error 2
make[1]: Leaving directory `/usr/linux-lts-raring-3.8.0'
make: *** [default] Error 2 
5
  • Did you do make config and make prepare inside the kernel source tree? Commented Apr 22, 2014 at 8:34
  • @AndreasWiese I think yes, let me try again. Commented Apr 22, 2014 at 8:47
  • @AndreasWiese I gave make config and it started question/answer ,and I know it would ask 100s of such question. I dont have so much petaince..so any alternative where it would not ask questions? Commented Apr 22, 2014 at 8:51
  • Copy your running kernel's config (found in /proc/config.gz or /boot/config-<kernelversion>) to .config in the kernel source and do make oldconfig. Commented Apr 22, 2014 at 8:54
  • @AndreasWiese Did that. Kindly see the update Commented Apr 22, 2014 at 9:08

1 Answer 1

1

I don't know exactly what you unpacked in /usr/linux-lts-raring-3.8.0, but:

  • It's probably not what you need.
  • The location is really weird, you shouldn't be creating directories directly under /usr.

To compile a kernel module, what you need is the headers plus a few more files produced by compiling the kernel with the same configuration. See Unable to load module: Disagrees about version of symbol module_layout for a more complete explanation.

Remove this /usr/linux-lts-raring-3.8.0 and instead install the kernel headers package corresponding to your runing kernel: for example, if your running kernel is from the linux-image-3.8.0-38-generic package, then install the linux-headers-3.8.0-38-generic package.

To compile a module against a particular Debian/Ubuntu/… kernel version such as linux-headers-3.8.0-38-generic, go to the module directory and run

make -C /usr/src/linux-headers-3.8.0-38-generic M=$PWD

To compile a module against the running kernel, make sure that the appropriate kernel headers package is installed and run

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

I recommend reading kbuild/modules.tt in the kernel documentation.

1
  • To add to Giles Answer: If you till want to use linux-lts-raring-3.8.0, you're going to need to compile it against the linux-headers for kernel 3.8.0 Commented Oct 1, 2014 at 22:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.