building a driver in /lib/modules/2.6.9-1.667/build/ - how? need src.rpm?

Carlos Puchol cpg at users.sourceforge.net
Wed Nov 17 02:13:40 UTC 2004


hi, i have a driver, called my-driver.c here, that builds cleanly
on a clean, official 2.6.9 tree:

...
  MODPOST
  CC      drivers/char/my-driver.mod.o
  LD [M]  drivers/char/my-driver.ko
..

i made modifications to the Kconfig and Makefile, .config, etc. so that it
all goes well.

however, i would like to compile and run it in the stock kernel
that a given fc3 machine is running.

i gather that i have to build it in /lib/modules/2.6.9-1.667/build/
however, i am not sure _exactly_ how.

first, do i need the kernel sources in /usr/src/linux-2.6.9-1.667?
i would hope not, since i see a build/include directory, etc.
(also, i guess not, since the nvidia driver seems to have been partially
compiled dynamically).

currently i don't have the sources in the official place,
but i think i know that i can build them and make them available [*].

however, still what do i do then?

i edited Kconfig, .config and the Makefile just like i did in the official
tree, did make oldconfig, and then ... make or make modules barfs ...

[17:45:55](2)machina:build# pwd
/lib/modules/2.6.9-1.667/build
[17:47:10](2)machina:build# make modules
  CHK     include/linux/version.h
  CHK     include/asm-x86_64/offset.h
/bin/sh: arch/x86_64/kernel/asm-offsets.s: No such file or directory
  UPD     include/asm-x86_64/offset.h
mv: cannot stat `include/asm-x86_64/offset.h.tmp': No such file or directory
make: *** [include/asm-x86_64/offset.h] Error 1
[17:47:11](2)machina:build# 

however, interestingly, i seem to compile the module just fine
like this:

[17:47:11](2)machina:build# make drivers/char/my-driver.o
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/basic/split-include
  HOSTCC  scripts/basic/docproc
  HOSTCC  scripts/genksyms/genksyms.o
  HOSTCC  scripts/genksyms/lex.o
  HOSTCC  scripts/genksyms/parse.o
  HOSTLD  scripts/genksyms/genksyms
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/modpost.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/pnmtologo
  HOSTCC  scripts/conmakehash
  CC [M]  drivers/char/my-driver.o
[17:47:29](2)machina:build#

however .. i can't seem to be able to load it:

[17:49:34](2)machina:build# insmod drivers/char/my-driver.o
my-driver: error inserting 'drivers/char/my-driver.o': -1 Invalid module format
[17:50:00](2)machina:build# 

[17:50:14](2)machina:build# uname -a
Linux machina 2.6.9-1.667 #1 Tue Nov 2 14:50:10 EST 2004 x86_64 x86_64 x86_64 GNU/Linux
[17:51:08](2)machina:build#

i think i am missing something simple.

one thing i have noticed, though, is that working in this directory
is really easy to _blow away_ /lib/modules/2.6.9-1.667/kernel/.
this is very alarming, so i need to be careful about building this stuff.

again, the goal is to automate compiling this module,
for _any_ FC3 machine (even if the kernel has been upgraded)
without installing a new kernel, of course.
the assumption is that the kernel running has been installed
relatively "properly" within the system, with all modules, etc.

thanks in advance,

-c

[*] i got the hint from the recent thread about the kernel sources ...




More information about the fedora-test-list mailing list