You are not logged in.

#1 2013-07-06 22:32:05

BGK
Member
From: France
Registered: 2013-07-06
Posts: 30

[SOLVED] Custom kernel & nvidia

Hello.

So i wanted to learn about kernel building for a while and finally decided to jump in. (also i am a new Archlinux user)
I read the wiki and wanted to try the "traditional" way first so i grabbed the 3.10.0 vanilla tarball and thanks to the wiki, successully compiled and booted it. (i didn't bother trying to start X at this point).
Then i wanted to use the Arch "abs" way because i wanted to build my custom kernel from the same Arch stable kernel sources (nothing in the 3.10 gives me a boner and the stable arch sources are enough "bleeding edge" for me).

I followed the wiki procedure and built my linux-3.9.9-1-custom.tar.xz package, then i installed it without any issue. Finally i updated GRUB2 and booted this kernel to make sure it was working.
Well, it was.

At this point i knew i had to build a custom nvidia package to make X working so i followed the wiki procedure to build it.
Here is my PKGBUILD:

# $Id: PKGBUILD 189199 2013-06-29 10:08:46Z foutrelis $
# Maintainer : Thomas Baechler <thomas@archlinux.org>

pkgname=nvidia-custom
pkgver=319.32
_extramodules=extramodules-3.9-custom
pkgrel=2
pkgdesc="NVIDIA drivers for linux"
arch=('i686' 'x86_64')
url="http://www.nvidia.com/"
depends=('linux>=3.9' 'linux<3.10' "nvidia-libgl" "nvidia-utils=${pkgver}")
makedepends=('linux-headers>=3.9' 'linux-headers<3.10')
conflicts=('nvidia-96xx' 'nvidia-173xx')
license=('custom')
install=nvidia.install
options=(!strip)

if [ "$CARCH" = "i686" ]; then
    _arch='x86'
    _pkg="NVIDIA-Linux-${_arch}-${pkgver}"
    source=("ftp://download.nvidia.com/XFree86/Linux-${_arch}/${pkgver}/${_pkg}.run")
    md5sums=('978339ff37c3207f3a39d3952721dcdb')
elif [ "$CARCH" = "x86_64" ]; then
    _arch='x86_64'
   _pkg="NVIDIA-Linux-${_arch}-${pkgver}-no-compat32"
    source=("ftp://download.nvidia.com/XFree86/Linux-${_arch}/${pkgver}/${_pkg}.run")
    md5sums=('d181d856768868823df3bda4607a5315')
fi

build() {
    _kernver="$(cat /usr/lib/modules/${_extramodules}/version)"
    echo $_kernver
    cd "${srcdir}"
    sh "${_pkg}.run" --extract-only
    cd "${_pkg}/kernel"
    make SYSSRC=/usr/lib/modules/"${_kernver}/build" module
}

package() {
    install -D -m644 "${srcdir}/${_pkg}/kernel/nvidia.ko" \
        "${pkgdir}/usr/lib/modules/${_extramodules}/nvidia.ko"
    install -d -m755 "${pkgdir}/usr/lib/modprobe.d"
    #echo "blacklist nouveau" >> "${pkgdir}/usr/lib/modprobe.d/nvidia.conf"
    sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${_extramodules}'/" "${startdir}/nvidia.install"
    gzip "${pkgdir}/usr/lib/modules/${_extramodules}/nvidia.ko"
}

However when i tried to run makepkg, i got the following error:

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. *** 

After messing around for quite some time, i discovered nvidia was expecting stuff in the follwing directory:

/usr/lib/modules/3.9.9-1-custom/build/

But the build dir did not exist. I looked into the 3.9.9-1-ARCH and found that the build dir was indeed present in the stock kernel directory.

Since i was stuck i tried the following:

ln -s /usr/lib/modules/3.9.9-1-ARCH/build /usr/lib/modules/3.9.9-1-custom/build

and ran makepkg again: it built the package with no issue, so I installed the package.
I rebooted my machine thinking this ugly hack solved my problem.
I was wrong...

When i tried to start X i got this error (using the custom kernel):

modprobe: ERROR: could not insert 'nvidia': Exec format error

Here's the full output:

X.Org X Server 1.14.2
Release Date: 2013-06-25
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.9.7-1-ARCH x86_64 
Current Operating System: Linux msytux666 3.9.9-1-custom #2 SMP PREEMPT Sat Jul 6 21:52:16 CEST 2013 x86_64
Kernel command line: BOOT_IMAGE=/boot/vmlinuz-linux-custom root=UUID=a6b3e912-4bd4-47dc-810e-4d69667b21f9 ro quiet
Build Date: 01 July 2013  10:48:42AM
 
Current version of pixman: 0.30.0
        Before reporting problems, check http://wiki.x.org
        to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
        (++) from command line, (!!) notice, (II) informational,
        (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sat Jul  6 23:02:47 2013
(==) Using config file: "/etc/X11/xorg.conf"
(==) Using config directory: "/etc/X11/xorg.conf.d"
Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension SECURITY
Initializing built-in extension XINERAMA
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in extension DOUBLE-BUFFER
Initializing built-in extension RECORD
nitializing built-in extension DPMS
Initializing built-in extension X-Resource
Initializing built-in extension XVideo
Initializing built-in extension XVideo-MotionCompensation
Initializing built-in extension XFree86-VidModeExtension
Initializing built-in extension XFree86-DGA
Initializing built-in extension XFree86-DRI
Initializing built-in extension DRI2
Loading extension GLX
modprobe: ERROR: could not insert 'nvidia': Exec format error
(EE) 
Fatal server error:
(EE) no screens found(EE) 
(EE) 
Please consult the The X.Org Foundation support 
         at http://wiki.x.org
 for help. 
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE) 
(EE) Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error

Not sure what to do next.

Thank you for reading

PS: my stock kernel is still fine and running X with no issue (did not break anything, that's one good thing at least!)

Last edited by BGK (2013-07-06 23:12:54)

Offline

#2 2013-07-06 22:48:26

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Custom kernel & nvidia

Did you install the kernel headers when you build the custom package?  You need something to build against, and that /usr/modules/3.9.9-1-ARCH/build is a symlink that is owned by linux-headers.  It points to /usr/src/linux-3.9.9-1-ARCH.  So by symlinking that "build" from ARCH to custom, you are effectively building the module against the wrong headers. 

Check to make sure that you have installed the headers as well as the kernel.  The PKGBUILD for linux will build multiple packages (linux, linux-headers, and linux-docs).  I like to have all three, since the docs package contains some amazing information and is totally worth the ~16MB of space.  Do you have a directory set for storing built packages?  It is probably a good idea, so that you can keep them around.


BTW, installing headers using the "traditional method" would include issuing the "make headers-install" command as root (from the source directory of course).  Did you do that?

Last edited by WonderWoofy (2013-07-06 22:49:30)

Offline

#3 2013-07-06 23:12:36

BGK
Member
From: France
Registered: 2013-07-06
Posts: 30

Re: [SOLVED] Custom kernel & nvidia

You were indeed right, i did not install the headers nor the docs pakages generated by makepkg. What a stupid mistake!!
Thank you for your quick and quality answer.

PS: I didn't "make headers-install" either during the traditional way, it was not an issue because i did't needed those at this point, it was just a quick test, but I wouldn't think to run this command if i needed these headers, so thank you for this bonus knowledge smile

Last edited by BGK (2013-07-06 23:16:34)

Offline

Board footer

Powered by FluxBB