# Invalid module format - nvidia-kernel and mm-sources-2.6.5

## Aphex3K

I want to run the mm-sources because my WLAN NIC finally works there!  :Very Happy:  yeah

The problem is that support for nvidia-card is gone  :Crying or Very sad:  so I reemerge nvidia-kernel and nvidia-glx. First i didn't reset the /usr/src/linux symlink so it allways installed it for the former kernel 2.6.4. After successfully emerging the modules i make

```
# modprobe nvidia
```

and get the error

```
FATAL: Error inserting nvidia (/lib/modules/2.6.5-rc3-mm1/video/nvidia.o): Invalid module format
```

Whats the problem? It doesnt work with the stable nvidia-kernel 1.4xxx and i'be also tried 1.5336 with no success...

----------

## ()

I think the problem is a change in ABI (or more specific kernel stack size) with 2.6.5-mm, which breaks compatibility with binary modules.

----------

## Aphex3K

oh, ok.

I didn't need the 2.6.5 kernel anymore so the problem solved itself (literaly)  :Wink: 

----------

## wastedimage

ok so the rest of us...well it worked for me:

1) Have 5-6 Corona's

2) Repeat Step 1 as needed

3) Download nvidia's version

4) somewhere between here and there it fixed it

5) Smile and know you got that 10% boost  ; w00t

----------

## converter

Go to Morton's directory (the URL should be in the ebuilds) and find the

"move-__this_module-to-modpost" patch. Copy it to the root of the kernel source tree, and use the command:

```
patch -R -p1 < move-__this_module-to-modpost.patch
```

to back the patch out. If -p1 doesn't work, try -p0, I can't recall exactly which one works. This should get you past the "invalid module format" hitch.

----------

## stillman

for all bloody beginners like me who didn't know where to look for this patch-stuff: download ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2

bzip2 -d 2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2 and tar -xf2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2

cd broken-out

cp move-__this_module-to-modpost.patch /usr/src/linux

cp 4k-stacks-always-on.patch /usr/src/linux

(make sure that linux is linked to your actual kernel source) 

and do 

patch -R -p1 < move-__this_module-to-modpost.patch 

patch -R -p1 < 4k-stacks-always-on.patch

make menuconfig 

->kernel hacking-> [ ] Use 4Kb for kernel stacks instead of 8Kb...Last edited by stillman on Wed Apr 07, 2004 10:06 am; edited 1 time in total

----------

## [UK]Superdude

You can also go to the broken out directory and grab just the one patch, handy if your on dial-up!

http://kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mm1/broken-out/

Oh and damn dial-up btw!~

You may want to grab these patches to reverse:

```

move-__this_module-to-modpost.patch

4k-stacks-always-on.patch

```

and reverse them like above:

```

patch -R -p1 < 4k-stacks-always-on.patch

patch -R -p1 < move-__this_module-to-modpost.patch

```

----------

## Gil-galad55

Can someone confirm that using nVidia's version of the driver solves the problem?  I have no problem using their version--it's a lot easier than backing out patches every time I want to upgrade the kernel!

----------

## stillman

well, i don't know what you exactly mean by 'nvidias version' of the driver but in my case with mm-kernel-sources 2.6.5 and a nvidia ti4200 with the kernel unpatching and 

```
ACCEPT_KEYWORDS="~x86" emerge nvidia-glx
```

it worked well(i didn't try the stable nvidia 4496-driver, guess it also works).

@[UK]Superdude: oh, i didn't see that one, damnit  :Very Happy: 

----------

## wishkah

 *stillman wrote:*   

> for all bloody beginners like me who didn't know where to look for this patch-stuff: download ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2
> 
> bzip2 -d 2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2 and tar -xf2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2
> 
> cd broken-out
> ...

 

This fixed the problem, thanks man.

----------

## Cheesefoam

Strangely, reversing the "move-__this_module-to-modpost.patch" also had a VERY interesting side effect.  Before, my PS/2 port mouse would only function with three buttons, no scrolling.

After reversing the patch, it suddenly works again.

I filed this as a bug, because under gentoo-dev-sources, my system would kernel panic if the PS/2 mouse was plugged in at any point.  With mm-sources it at least fell back to three button mode.

----------

## davecs

 *stillman wrote:*   

> 
> 
> ```
> ACCEPT_KEYWORDS="~x86" emerge nvidia-glx
> ```
> ...

 

I understand that you MUST have the *supposedly* unstable nvidia driver to use kernel 2.6.

With my current PC I found that emerging it just worked, but in the past when I have had problems I have tried loading it the nvidia way and that has sometimes worked better.

----------

## Aphex3K

 *stillman wrote:*   

> for all bloody beginners like me who didn't know where to look for this patch-stuff: download ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2
> 
> bzip2 -d 2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2 and tar -xf2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2
> 
> cd broken-out
> ...

 

What about the 2.6.6-mm1 sources? There is a broken-out archive but it does not contain any of the patches mentioned above?!

----------

## Gentree

 *stillman wrote:*   

> for all bloody beginners like me who didn't know where to look for this patch-stuff: download ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.5/2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2
> 
> bzip2 -d 2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2 and tar -xf2.6.5-mm1/2.6.5-mm1-broken-out.tar.bz2
> 
> cd broken-out
> ...

 

just a note : use tar -xjf ........ you dont need to do the bzip first.

Saves some painful typing.

 :Cool: 

----------

## stahlsau

you can use this ebuild (works for me--so you don´t have to reverse the patches):

```
# Copyright 1999-2004 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-x86/media-video/nvidia-kernel/nvidia-kernel-1.0.5336-r2.ebuild,v 1.2 2004/04/13 17:07:54 cyfred Exp $

inherit eutils rpm

PKG_V="pkg1"

NV_V="${PV/1.0./1.0-}"

NV_PACKAGE="NVIDIA-Linux-x86-${NV_V}"

S="${WORKDIR}/${NV_PACKAGE}-${PKG_V}/usr/src/nv"

DESCRIPTION="Linux kernel module for the NVIDIA's X driver"

HOMEPAGE="http://www.nvidia.com/"

SRC_URI="ftp://download.nvidia.com/XFree86/Linux-x86/${NV_V}/${NV_PACKAGE}-${PKG_V}.run"

# The slot needs to be set to $KV to prevent unmerges of modules for other kernels.

LICENSE="NVIDIA"

SLOT="${KV}"

KEYWORDS="-* ~x86"

RESTRICT="nostrip"

DEPEND="virtual/linux-sources"

export _POSIX2_VERSION="199209"

pkg_setup() {

   if [ ! -f /proc/mtrr ]

   then

      eerror "This version needs MTRR support for most chipsets!"

      eerror "Please enable MTRR support in your kernel config, found at:"

      eerror

      eerror "  Processor type and features -> [*] MTRR (Memory Type Range Register) support"

      eerror

      eerror "and recompile your kernel ..."

      die "MTRR support not detected!"

   fi

   check_version_h

}

check_version_h() {

   if [ ! -f "${ROOT}/usr/src/linux/include/linux/version.h" ]

   then

      eerror "Please verify that your /usr/src/linux symlink is pointing"

      eerror "to your current kernel sources, and that you did run:"

      eerror

      eerror "  # make dep"

      die "/usr/src/linux symlink not setup!"

   fi

}

get_KV_info() {

   check_version_h

   # Get the kernel version of sources in /usr/src/linux ...

   export KV_full="$(awk '/UTS_RELEASE/ { gsub("\"", "", $3); print $3 }' \

      "${ROOT}/usr/src/linux/include/linux/version.h")"

   export KV_major="$(echo "${KV_full}" | cut -d. -f1)"

   export KV_minor="$(echo "${KV_full}" | cut -d. -f2)"

   export KV_micro="$(echo "${KV_full}" | cut -d. -f3 | sed -e 's:[^0-9].*::')"

}

is_kernel() {

   [ -z "$1" -o -z "$2" ] && return 1

   get_KV_info

   if [ "${KV_major}" -eq "$1" -a "${KV_minor}" -eq "$2" ]

   then

      return 0

   else

      return 1

   fi

}

pkg_setup() {

   ewarn "This ebuild may require write access to the sources of your current kernel,"

   ewarn "so this directory will be omitted from the sandbox restrictions."

   einfo "This requirement will be overcome in future ebuilds."

}

src_unpack() {

   cd ${WORKDIR}

   bash ${DISTDIR}/${NV_PACKAGE}-${PKG_V}.run --extract-only

   # Next section applies patches for linux-2.5 kernel, and/or

   # bugfixes for linux-2.4.  All these are from:

   #

   #   http://www.minion.de/nvidia/

   #

   # Many thanks to Christian Zander <zander@minion.de> for bringing

   # these to us, and being so helpful to select which to use.

   get_KV_info

   cd ${S}

   einfo "Linux kernel ${KV_major}.${KV_minor}.${KV_micro}"

   if is_kernel 2 5 || is_kernel 2 6

   then

      EPATCH_SINGLE_MSG="Applying basic sysfs patch ..." \

      epatch ${FILESDIR}/${PV}/NVIDIA_kernel-${NV_V}-basic-sysfs-support.patch

      rm makefile

      ln -snf Makefile.kbuild Makefile

   fi

   # if you set this then it's your own fault when stuff breaks :)

   [ ! -z "${USE_CRAZY_OPTS}" ] && sed -i "s:-O:${CFLAGS}:" Makefile

}

src_compile() {

   # Portage should determine the version of the kernel sources

   check_KV

   # IGNORE_CC_MISMATCH disables a sanity check that's needed when gcc has been

   # updated but the running kernel is still compiled with an older gcc.  This is

   # needed for chrooted building, where the sanity check detects the gcc of the

   # kernel outside the chroot rather than within.

   if is_kernel 2 5 || is_kernel 2 6

   then

      addwrite "/usr/src/linux"

      env -u ARCH make IGNORE_CC_MISMATCH="yes" KERNDIR="/usr/src/linux" \

         SYSSRC="/usr/src/linux" clean module || die

   else

      env -u ARCH make IGNORE_CC_MISMATCH="yes" KERNDIR="/usr/src/linux" \

         clean module || die

   fi

}

src_install() {

   # The driver goes into the standard modules location

   insinto /lib/modules/${KV}/video

   if is_kernel 2 5 || is_kernel 2 6

   then

      doins nvidia.ko

   else

      doins nvidia.o

   fi

   # Add the aliases

   insinto /etc/modules.d

   newins ${FILESDIR}/nvidia-1.1 nvidia

   # Docs

   dodoc ${S}/README

   # The device creation script

   into /

   newsbin ${S}/makedevices.sh NVmakedevices.sh

}

pkg_postinst() {

   if [ "${ROOT}" = "/" ]

   then

      # Update module dependency

      [ -x /usr/sbin/update-modules ] && /usr/sbin/update-modules

      if [ ! -e /dev/.devfsd ] && [ ! -e /dev/.udev ] && [ -x /sbin/NVmakedevices.sh ]

      then

         /sbin/NVmakedevices.sh >/dev/null 2>&1

      fi

   fi

   echo

   einfo "If you are not using devfs, loading the module automatically at"

   einfo "boot up, you need to add \"nvidia\" to your /etc/modules.autoload."

   echo

   ewarn "Please note that the driver name changed from \"NVdriver\""

   ewarn "to \"nvidia.o\"."

   echo

}

```

----------

## Aphex3K

Ok, it's solved. The new drivers provided by nvidia (nvidia-kernel-1.5536-r3) solved the problem for the new kernels! (2.6.5+)

----------

