You are not logged in.

#1 2008-06-08 06:02:08

shepheb
Member
Registered: 2008-06-08
Posts: 12

Compiling nvidia driver for custom kernel

I have a Toshiba M200 tablet PC running Arch Linux (which I love, btw) and it's running fine, including the tablet.

There's an irritating bug with suspend-to-ram (suspend-to-disk doesn't work with the nvidia driver) where the tablet pen stops working after resume.

There's a patch slated to be in some future kernel, but I compiled my own with that patch included. It boots fine and all seems to be well with it.

However, I need to compile the nvidia driver for it, since the binary does not work. So I copy /var/abs/extra/nvidia and modify the PKGBUILD and nvidia.install files per the instructions on this wiki page, and run makepkg -i -c .

I get a big error message early on, saying

If you are using a Linux 2.4 kernel, please make sure
you either have configured kernel sources matching your
kernel or the correct set of kernel headers installed
on your system.

If you are using a Linux 2.6 kernel, please make sure
you have configured kernel sources matching your kernel
installed on your system. If you specified a separate
output directory using either the "KBUILD_OUTPUT" or
the "O" KBUILD parameter, make sure to specify this
directory with the SYSOUT environment variable or with
the equivalent nvidia-installer command line option.

Depending on where and how the kernel sources (or the
kernel headers) were installed, you may need to specify
their location with the SYSSRC environment variable or
the equivalent nvidia-installer command line option.

*** Unable to determine the target kernel version. ***

I've checked everything I can think of.

$ uname -r
2.6.25-tablet

ls -l /usr/src shows linux-2.6.25-tablet, and linux is a symlink to it. /lib/modules/2.6.25-tablet/build is also symlinked to the right kernel source tree.

So I'm out of ideas for why the nvidia makefile can't seem to find the kernel source.

Thanks in advance.

Offline

#2 2008-06-08 06:37:15

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: Compiling nvidia driver for custom kernel

it would help if you post the PKGBUILD.

Also, the PKGBUILD probably uses a symlink in the /lib/modules/2.6.25-tablet directory, pointing to linux-2.6.25-tablet. There should be a symlink called "build" and one named "source" there.

did you clean out the source-tree after building? if so, copy in you .config and run a "make prepare" and try again... The tree should be left as it was after you built the kernel when you want to compile drivers for it.


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#3 2008-06-08 06:46:57

shazeal
Member
From: New Zealand
Registered: 2007-06-05
Posts: 341

Re: Compiling nvidia driver for custom kernel

You probably didnt copy the makefile_32 file to the /usr/src/linux-xxx dir, compare your build dirs arch/x86/ to the /usr/src/linux-xxx/arch/x86.

Offline

#4 2008-06-08 06:59:24

shepheb
Member
Registered: 2008-06-08
Posts: 12

Re: Compiling nvidia driver for custom kernel

@klixon:
I think that may be the root of the trouble: I compiled the kernel on my desktop (C2D 2.8) rather than my wussy laptop (1.6 Centrino). It installed and ran fine and all that, but I only have the kernel source tree that was included in the package, not the one that really compiled the code. Would simply copying it suffice, or should I rebuild the kernel on my laptop? Also, the PKGBUILD is included below.

@shazeal:
I believe this is a subset of the problem I describe above?


The PKGBUILD, somewhat customized from the nvidia ABS. I don't think any of the changes are overly shocking.
I've tried dozens of different modifications of it now. The simplest one is just appending '-tablet' to pkgname and _kernver.

# $Id: PKGBUILD 1567 2008-05-13 10:11:25Z thomas $
# Maintainer : Thomas Baechler <thomas@archlinux.org>

pkgname=nvidia-tablet
pkgver=169.12
_kernver='2.6.25-tablet'
pkgrel=4
pkgdesc="NVIDIA drivers for kernel26."
arch=('i686')
ARCH=x86
url="http://www.nvidia.com/"
depends=('kernel2625-tablet' 'nvidia-utils')
conflicts=('nvidia-96xx' 'nvidia-71xx' 'nvidia-legacy')
license=('custom')
install=nvidia.install
source=(http://us.download.nvidia.com/XFree86/Linux-$ARCH/${pkgver}/NVIDIA-Linux-$ARCH-${pkgver}-pkg0.run
        NVIDIA_kernel-169.12-2286310.diff)
md5sums=('e7aaca79c846e34cfe8111040bfee2d0'
         'a6b6d9d7ff0306343be3fa40e72337fd')
[ "$CARCH" = "x86_64" ] && md5sums=('843a1e8bc1923ba2e4b60f6fab31ad3b'
                                    'a6b6d9d7ff0306343be3fa40e72337fd')

build()
{
  # Extract
  cd $startdir/src/
  sh NVIDIA-Linux-$ARCH-${pkgver}-pkg0.run --extract-only
  cd NVIDIA-Linux-$ARCH-${pkgver}-pkg0
  
  # Any extra patches are applied in here...
  patch -Np0 -i ../NVIDIA_kernel-169.12-2286310.diff || return 1

  cd usr/src/nv/
  ln -s Makefile.kbuild Makefile
  make SYSSRC=/usr/src/linux module || return 1
  
  # install kernel module
  mkdir -p $startdir/pkg/lib/modules/${_kernver}/kernel/drivers/video/
  install -m644 nvidia.ko $startdir/pkg/lib/modules/${_kernver}/kernel/drivers/video/

  sed -i -e "s/KERNEL_VERSION='.*'/KERNEL_VERSION='${_kernver}'/" $startdir/*.install
}

Offline

#5 2008-06-08 08:30:10

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: Compiling nvidia driver for custom kernel

Boot, using your new kernel and see if you get output from this:

zcat /proc/config.gz

if so, these are the steps:

zcat /proc/config.gz > /usr/src/linux-2.6.25-tablet/.config
make prepare

You should now be ready to compile drivers.

If you don't get output, see if you still have the .config you used to build the kernel on your desktop, copy it over and skip step 1 tongue

If you don't have the config anymore, use make menuconfig to regenerate it (make sure you have all the options the same!) and make prepare, or build a new kernel just to be sure

edit:
In your PKGBUILD you use "make SYSSRC=/usr/src/linux module || return 1"
I would leave it as "make SYSSRC=/lib/${_kernver}/build module || return 1"
That way, this package always uses the kernel-source it was intended to use and you don't need a /usr/src/linux symlink anymore. What would happen when you change the symlink and have to rebuild the package?

Last edited by klixon (2008-06-08 08:35:51)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#6 2008-06-08 09:43:48

shazeal
Member
From: New Zealand
Registered: 2007-06-05
Posts: 341

Re: Compiling nvidia driver for custom kernel

shepheb wrote:

@shazeal:
I believe this is a subset of the problem I describe above?

Unless what klixon says works then no it isnt, If you dont have the right kernel makefiles in your usr/src/linux tree the NVIDIA driver has no idea what kernel its looking at.

And for reference it makes no difference what machine you build the kernel on only what files you have in the kernel package, I build my girlfriends kernel in my 32 bit chroot on my x86_64 machine.

Last edited by shazeal (2008-06-08 09:46:10)

Offline

#7 2008-06-08 10:05:07

shepheb
Member
Registered: 2008-06-08
Posts: 12

Re: Compiling nvidia driver for custom kernel

I did get output from 'zcat /proc/config.gz' so I followed both of the steps. However, when I ran make prepare:

# make prepare
Makefile:514: /usr/src/linux-2.6.25-tablet/arch/x86/Makefile: No such file or directory
make: *** No rule to make target '/usr/src/linux-2.6.25-tablet/arch/x86/Makefile'. Stop.

Just to give it a shot, I did

touch arch/x86/Makefile

and ran make prepare again. This time I get

# make prepare
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/kxgettext.o
  HOSTCC  scripts/kconfig/zconf.tab.o
scripts/kconfig/lex.zconf.c:1647: warning: =input= defined but not used
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf -s arch/x86/Kconfig
  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
ERROR: the symlink include/asm points to asm-i386 but asm-x86 was expected
       set ARCH or save .config and run 'make mrproper' to fix it
make: *** [include/asm] Error 1

If, again for the sake of it, I change that symlink and make prepare again, I get:

# make prepare
  CHK     include/linux/version.h
  CHK     include/linux/utsrelease.h
make[1]: *** No rule to make target 'missing-syscalls'. Stop.
make: *** [prepare0] Error 2

I'm going to try building it on my desktop. Both machines have nvidia cards. The desktop obviously doesn't need the tablet patch in the kernel, but it shouldn't hurt.

Oh, I've been running 'make prepare' in /usr/src/linux-2.6.25-tablet, I assume that's the right place.

Offline

#8 2008-06-08 10:17:15

shepheb
Member
Registered: 2008-06-08
Posts: 12

Re: Compiling nvidia driver for custom kernel

@shazeal:

I tried copying Makefile and Makefile_32 from the build dir's arch/x86 to the /usr/src/linux.../arch/x86, but it ended up with the same output as my second run in my post just above. Adjusting the symlink gave the same as my third run from my post just above.

So it seems that was necessary, but not the whole problem.

Offline

#9 2008-06-08 10:29:28

shepheb
Member
Registered: 2008-06-08
Posts: 12

Re: Compiling nvidia driver for custom kernel

For the record, I get the same result trying to install on my desktop.

Edit: By which I mean, I installed the custom kernel and tried to build the nvidia ABS, with the same result as on the tablet.

Last edited by shepheb (2008-06-08 10:50:49)

Offline

#10 2008-06-10 14:49:12

shepheb
Member
Registered: 2008-06-08
Posts: 12

Re: Compiling nvidia driver for custom kernel

This is part bump, part sub-question.

It occurred to me today that I could perhaps compile the nvidia driver right in with the kernel. But it's closed source and evil and all, so I don't know if that's possible. Hopefully that would solve the "where's your kernel source" problems. Is that a reasonable line of attack?

Whether it is or not, it seems like this thread was closing on a solution before it died. Any further help from my information above?

Thanks

Offline

#11 2008-06-10 14:58:21

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: Compiling nvidia driver for custom kernel

Rats... i completely forgot about this, sorry *hides in the corner, ashamed*

If i understand correctly, you didn't modify the source-tree on your desktop (the one used to build the kernel, no "make clean", no "make mrproper"), you installed the kernel (and did a "make modules_install", which is crucial) and still it doesn't want to build?


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#12 2008-06-10 15:25:45

shepheb
Member
Registered: 2008-06-08
Posts: 12

Re: Compiling nvidia driver for custom kernel

I'm using the kernel26 ABS PKGBUILD. To my untrained eye, it does make {x,g,menu,old}config, clean, bzImage, modules, modules_install, in that order. The exact lines in question are:

make gconfig
make clean bzImage modules
make INSTALL_MOD_PATH=$startdir/pkg modules_install

It runs install a couple of times to move various files (.config, .kernelrelease, etc.) into the /usr/src/linux-*/ directory. Everything looks good based on the above advice in the thread, so I don't know where it's going wrong.

Offline

#13 2008-06-10 17:42:07

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: Compiling nvidia driver for custom kernel

Can you email me all related files in a tarball? there's an email-link under my name if i'm not mistaken. Since there's no way to attach files, send me an email and i'll reply to it, so you can send the files (might include those nvidia-PKGBUILDS as well)

If i find something i'll post in this thread again (hopefully with a solution *grins*)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#14 2008-06-13 12:18:16

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: Compiling nvidia driver for custom kernel

I finally found some time to having a look. Sorry it took so long

The PKGBUILD you were using for the kernel was fairly out of date. If you remember where you got it from, it might be a good idea to send a signal there with what needs to be changed...

The i386 and x86-64 architectures where merged in the recent kernels and this is what caused most of the problems. The PKGBUILD could not find the Makefiles as it was searching in the old directories in the source-tree. So Shazeal was right wink
I also made sure some headers were included so you will be able to rebuild standard arch-packages for your custom kernel.
Thank god you can look up the PKGBUILD for arch's kernel, otherwise i'd have been lost there as well...

Made sure the mkinitcpio-preset for the default kernel doesn't conflict with the one in this package, by giving it the same name as the package. Updated kernel26.install to incorporate this change.

Updated nvidia PKGBUILD so you no longer need a /usr/src/linux symlink

I think that's about it

Oh yeah, the kernel-PKGBUILD uses the config you mailed to me... You might want to think about customizing it a bit to not include all drivers, but only the  ones you actually need. It took me about 2 hours to build the behemoth, whereas my kernel-builds usually take about 10 to 15 minutes wink
It takes a bit of time the first few times, but eventually you'll get the hang of it...

Last edited by klixon (2008-06-13 12:18:52)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#15 2008-06-13 14:00:56

shepheb
Member
Registered: 2008-06-08
Posts: 12

Re: Compiling nvidia driver for custom kernel

Well, I'm confused about the kernel PKGBUILD, since I copied it (I think, it was over a week ago) from /var/abs/core/kernel26 which I thought would be Arch's kernel and therefore the easiest to modify and make correct. I might have been wrong, or I might've had an out-of-date one.

Anyway, I went through and stripped down the config with many modules for things I don't need, yielding a quicker compile (~20 minutes on a single core of my C2D 2.8) and much quicker bootup (12-15 seconds? I was impressed). I'm sure there's more I could cut, but it's hard to know what I do and don't need with certainty when I'm new to it.

So I compiled and installed the nvidia drivers while running the new kernel, and then startx worked. And, a great relief after these troubles, the ultimate goal was achieved: the kernel patches do indeed fix the problems with the Wacom serial tablet not reinitializing after a suspend or hibernate. Now I can take my laptop to class and actually use the tablet when I get there. (Hibernate, alas, still doesn't work, but that seems to be a problem with the nvidia drivers in general)

Thanks very much for all your help, klixon.

Offline

#16 2008-06-13 14:47:34

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: Compiling nvidia driver for custom kernel

That's weird... Compare the old and new PKGBUILD for the kernel with each other. The changes are significant.
Did you update the abs-tree before copying?

Ah yes... configuring your kernel can be a bit daunting the first few times and is not really necessary. Still, i find it fun to strip out all reduncency.
If you're interested, i think the gentoo wiki has some nice articles about configuring the kernel. Takes a while to get right, but you learn along the way

Anyways, glad it all works now. Have fun tinkering wink


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#17 2008-12-10 16:27:51

jyro215
Member
Registered: 2008-10-29
Posts: 5

Re: Compiling nvidia driver for custom kernel

Hi, I'm having the same problem trying to install nvidia with 2.6.26.8 vanilla.  I'm using the pkgbuild from the custom kernel compilation wiki which I'm pretty sure is out of date.  I changed i386 to x86 throughout the pkgbuild, but it might need other changes.  Can someone post an updated pkgbuild for both the kernel and nvidia?  It would be much appreciated.

Offline

Board footer

Powered by FluxBB