Problems with installing nvidia 340xx

Please, could you help me. I’m absolute newbie. I came into Linux due to its support for older machines to get my Asus UL80VT G210M working. I can’t upgrade it, nor throw it away. And I need working descrete card. No other distro users seemed to be able to launch nvidia340 or cared trying, not to mention Manjaro’s great community.
I installed Manjaro GNOME 21.2rc1, disabled Wayland to get past black screen, installed 5.4 kernel and removed 5.15. Then I followed these instructions:

and got white screen with an error.
Then I tried sudo nvidia-xconfig and was able to get into the text mode. My /etc/modprobe.d/ was empty and /etc/modules-load.d/ did not contain nvidia.conf. So i created them manually and also added the said commands to the modules.cong in /etc/modprobe.d/ with no visible effect.
Then i found a thread and added Option “IgnoreABI” to Section “ServerFlags” to generated xorg.conf and my keyboard or a text mode stopped working.

Hello @lotussuitekoln and welcome :wink:

I moved your post to a new topic, since your request was not related to the How-To content itself, but rather a support request.

Please share also your xorg.log, which should show what is going wrong.

Here a simple script which collects almost everything what could be needed (maybe more newbie friendly this way):

curl -s "https://gitlab.com/-/snippets/2174072/raw/main/gpu-report.sh" | sh

It is very big. Please upload it like that and share the link here:

curl -s https://gitlab.com/-/snippets/2174072/raw/main/gpu-report.sh | sh -s -- upload
2 Likes

Wow! I didn’t expect someone would address my question that fast :slightly_smiling_face: Thank you!

With every attempt I do clean reinstall. This time I installed kernel 5.10, followed the instructions and generated xorg.conf. Didn’t reboot so I could stay in a graphical mode.

Log contents:

https://0x0.st/-CGw.txt

@lotussuitekoln

You a have Hybrid-GPU and currently you use the open source drivers for both:

Graphics:
  Device-1: Intel Mobile 4 Series Integrated Graphics vendor: ASUSTeK
    driver: i915 v: kernel bus-ID: 00:02.0 chip-ID: 8086:2a42 class-ID: 0300
  Device-2: NVIDIA GT218M [GeForce G210M] vendor: ASUSTeK driver: nouveau
    v: kernel alternate: nvidia bus-ID: 01:00.0 chip-ID: 10de:0a74
    class-ID: 0300

So, actually, both are working. The iGPU Intel is there as Main and the dGPU as Sink.

Both are working KMS:

[    40.950] (II) modesetting: Driver for Modesetting Kernel Drivers: kms
[    40.950] (II) modeset(0): using drv /dev/dri/card0
[    40.951] (II) modeset(G0): using drv /dev/dri/card1

GLX should be switchable with:

glxinfo | grep "OpenGL renderer"
DRI_PRIME=1 glxinfo | grep "OpenGL renderer"

If your really need this driver then…

  1. install the driver again like described…
  2. Add the config to blacklist the nouveau driver for the nvidia card:

File: /etc/modprobe.d/blacklist.conf

blacklist nouveau
blacklist ttm
blacklist drm_kms_helper
blacklist drm

One line command:

sudo echo -e "blacklist nouveau\nblacklist ttm\nblacklist drm_kms_helper\nblacklist drm" > /etc/modprobe.d/blacklist.conf
  1. Add the config to load the nvidia driver:

File: /etc/modules-load.d/nvidia.conf

nvidia
nvidia-drm

One line command:

sudo echo -e "nvidia\nnvidia-drm" > /etc/modules-load.d/nvida.conf
  1. Reboot now. It should load the driver on the next boot.
    :warning: Before rebooting, keep sure there is no xorg config set for nvidia like this here:
sudo rm -f /etc/X11/xorg.conf

It would try to load the nvidia driver, but could possibly crash.

  1. So now the driver should be loaded. You should see now nvidia as driver instead of nouveau in inxi. Check it with:
inxi -Gazy
  1. I am not sure, but I guess 340xx also should be able to offload GLX to the nvidia gpu with:
glxinfo | grep "OpenGL renderer"
prime-run glxinfo | grep "OpenGL renderer"

(install it, if not done: pamac install nvidia-prime mesa-utils )

:notebook: To enable the GPU output for a second screen, a special xorg config is needed for the nvidia driver. But don’t know what you expect. So GPU offloading should be working this way, without a xorg config.

1 Like

Well, I groundlessly beleived this driver would help me run certain applications. I’m in a text mode again. Probably I should give up on nvidia after days of trying. Thank you for your help.

Did you remove the xorg.conf ?

Also: Stay on Kernel 5.4 for this driver… but possibly the nvidia driver does not support the X-Server at this Version. Idk :man_shrugging: Thats the reason, why I said to skip the xorg.conf of nvidia and stay with the intel opensource driver as main. So no xorg configs.

You will need the Ignore ABI trick for this old unsupported driver because of xorg update.

Section "ServerFlags"
  Option "IgnoreABI" "1"
EndSection
1 Like

I removed /etc/X11/xorg.conf
but where to should I add these lines

to /etc/X11/mhwd.d/nvidia.conf ?
If there is no such file should I create it?
Should it be the only contents of this file?
Should the value be “1” or “true”?

Sorry for that many questions.

Try to create /etc/X11/xorg.conf.d/30-nvidia-ignoreabi.conf

Failed to start GNOME.
No luck so far.

Hello,
Just a silly question, Have you uninstalled nouveau before installing nvidia driver or rebooting ??

Hello. No, how do I do that?

You could try with mhwd

 mhwd -li -d  # to list basic information of all the drivers currently installed on your system

sudo mhwd -r [pci or usb] [name of driver]  # to remove an installed driver

Example sudo mhwd -r pci video-nvidia to remove nvidia driver.

Or if its not problem to you, you could reinstall the system and we can start from beginning. I found an old tutorial that might help you, not sure though :man_shrugging:

1 Like

I have my GT9400 working with nvidia-340xx-dkms. Here my inxi:

~ >>> inxi -Fz                                                                 
System:
  Kernel: 5.10.84-1-MANJARO x86_64 bits: 64 Desktop: MATE 1.26.0
    Distro: Manjaro Linux
Machine:
  Type: Laptop System: Apple product: MacBookPro5,4 v: 1.0
    serial: <superuser required>
  Mobo: Apple model: Mac-F22587A1 v: MacBookPro5,4
    serial: <superuser required> UEFI: Apple v: MBP53.88Z.00AC.B03.0906151647
    date: 06/15/09
Battery:
  ID-1: BAT0 charge: 78.1 Wh (99.9%) condition: 78.2/77.8 Wh (100.5%)
CPU:
  Info: dual core model: Intel Core2 Duo P8700 bits: 64 type: MCP cache:
    L2: 3 MiB
  Speed (MHz): avg: 1190 min/max: 798/2527 cores: 1: 1468 2: 913
Graphics:
  Device-1: NVIDIA C79 [GeForce 9400M] driver: nvidia v: 340.108
  Device-2: Apple Built-in iSight type: USB driver: uvcvideo
  Display: x11 server: X.Org 1.21.1.2 driver: loaded: nvidia
    resolution: 1440x900~60Hz
  Message: Unable to show advanced data. Required tool glxinfo missing.
Audio:
  Device-1: NVIDIA MCP79 High Definition Audio driver: snd_hda_intel
  Sound Server-1: ALSA v: k5.10.84-1-MANJARO running: yes
  Sound Server-2: PipeWire v: 0.3.40 running: yes
Network:
  Device-1: NVIDIA MCP79 Ethernet driver: forcedeth
  IF: enp0s10 state: down mac: <filter>
  Device-2: Broadcom BCM4322 802.11a/b/g/n Wireless LAN
    driver: b43-pci-bridge
  IF-ID-1: wlan0 state: up mac: <filter>
Bluetooth:
  Device-1: Apple Bluetooth Host Controller type: USB driver: btusb
  Report: bt-adapter ID: hci0 rfk-id: 1 state: down
    bt-service: enabled,running rfk-block: hardware: no software: no
    address: <filter>
Drives:
  Local Storage: total: 111.79 GiB used: 64.66 GiB (57.8%)
  ID-1: /dev/sda vendor: Crucial model: CT120M500SSD3 size: 111.79 GiB
Partition:
  ID-1: / size: 85.92 GiB used: 64.65 GiB (75.2%) fs: ext4 dev: /dev/sda3
  ID-2: /boot/efi size: 511 MiB used: 3.7 MiB (0.7%) fs: vfat
    dev: /dev/sda1
Swap:
  ID-1: swap-1 type: partition size: 3.95 GiB used: 0 KiB (0.0%)
    dev: /dev/sda5
Sensors:
  System Temperatures: cpu: 60.0 C mobo: N/A gpu: nvidia temp: 62 C
  Fan Speeds (RPM): N/A
Info:
  Processes: 178 Uptime: 1d 8h 47m Memory: 3.59 GiB used: 2.09 GiB (58.2%)
  Shell: Zsh inxi: 3.3.11

To build the driver use pamac GUI. Hit ‘edit build files’ clear the PKGBUILD from the AUR and replace with:

and change line 9 pkgrel=1 to the appropriate version, currently 26.
Whenever there is a big update check if nvidia-340xx-dkms is part of it and do that first, then do the rest (with possible kernel updates) with pamac upgrade -a.

Stay on Kernel 5.4 for this driver

As you can see around line 20 there are patches for 5.7 -5.10, so the 5.10 is probably the only kernel you should try this with (The original PKGBUILD differs by offering patches up to 5.15. As soon as I’m back from hols I’ll try to build the driver using this adapted version of philm’s file; if that works I’ll try installing 5.15, if not don’t laugh, I’m no coder but I like trying things out… :sweat_smile::


# Maintainer: Jerry Xiao <aur@mail.jerryxiao.cc>
# Maintainer: graysky <graysky AT archlinux DOT us>
# Contributor: Giancarlo Razzolini <grazzolini@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgbase=nvidia-340xx
pkgname=(nvidia-340xx-dkms)
pkgver=340.108
pkgrel=1
pkgdesc="NVIDIA drivers for linux, 340xx legacy branch"
arch=('x86_64')
url="https://www.nvidia.com/"
makedepends=("nvidia-340xx-utils=${pkgver}" 'linux>=5.4' 'linux-headers>=5.4')
conflicts=('nvidia')
license=('custom')
options=(!strip)
source=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run"
  0001-kernel-5.7.patch
  0002-kernel-5.8.patch
  0003-kernel-5.9.patch
  0004-kernel-5.10.patch
  0005-kernel-5.11.patch
  0006-kernel-5.14.patch
  0007-kernel-5.15.patch
)
b2sums=('6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb21396cfd89ebc54c32f921ea17e3e47eaa95abcbc24ecbd144fb89028'
        '7150233df867a55f57aa5e798b9c7618329d98459fecc35c4acfad2e9772236cb229703c4fa072381c509279d0588173d65f46297231f4d3bfc65a1ef52e65b1'
        'b436095b89d6e294995651a3680ff18b5af5e91582c3f1ec9b7b63be9282497f54f9bf9be3997a5af30eec9b8548f25ec5235d969ac00a667a9cddece63d8896'
        '947cb1f149b2db9c3c4f973f285d389790f73fc8c8a6865fc5b78d6a782f49513aa565de5c82a81c07515f1164e0e222d26c8212a14cf016e387bcc523e3fcb1'
        '665bf0e1fa22119592e7c75ff40f265e919955f228a3e3e3ebd76e9dffa5226bece5eb032922eb2c009572b31b28e80cd89656f5d0a4ad592277edd98967e68f')
_pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"

prepare() {
  sh "${_pkg}.run" --extract-only

  cd "${_pkg}"
  patch -Np1 -i ../0001-kernel-5.7.patch
  patch -Np1 -i ../0002-kernel-5.8.patch
  patch -Np1 -i ../0003-kernel-5.9.patch
  patch -Np1 -i ../0004-kernel-5.10.patch
  patch -Np1 -i ../0005-kernel-5.11.patch   
  patch -Np1 -i ../0006-kernel-5.14.patch
  patch -Np1 -i ../0007-kernel-5.15.patch

  cp -a kernel kernel-dkms
}

package_nvidia-340xx-dkms() {
    pkgdesc="NVIDIA driver sources for linux, 340xx legacy branch"
    depends=('dkms' "nvidia-340xx-utils=$pkgver" 'libgl' 'linux>=5.4')
    optdepends=('linux-headers: Build the module for Manjaro kernel')
    provides=("nvidia-340xx=$pkgver")
    conflicts+=('nvidia-340xx')

    cd "${_pkg}"

    install -dm 755 "${pkgdir}"/usr/src
    cp -dr --no-preserve='ownership' kernel-dkms "${pkgdir}/usr/src/nvidia-${pkgver}"
    cat "${pkgdir}"/usr/src/nvidia-${pkgver}/uvm/dkms.conf.fragment >> "${pkgdir}"/usr/src/nvidia-${pkgver}/dkms.conf

    echo "blacklist nouveau" |
        install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modprobe.d/${pkgname}.conf"
}

# vim:set ts=2 sw=2 et:

the nvidia driver does not support the X-Server at this Version.

As the inxi shows, the latest x11 server 1.21.1.2 works with the nvidia-340xx-dkms driver.

Yes. Here is mine:

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 340.107  (buildmeister@swio-display-x64-rhel04-13)  Thu May 24 22:29:58 PDT 2018

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
	Option "NoLogo" "1"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Extensions"
    Option         "Composite" "Enable"
EndSection

 
Section "InputClass"
    Identifier          "Keyboard Defaults"
    MatchIsKeyboard        "yes"
    Option              "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection

Section "ServerFlags"
     Option "IgnoreABI" "1"
EndSection

I know your hardware is different but if i can help with more info on this just ask.

I also would like to thank all the people who came up with this solution, you have saved a lot of perfectly working hardware from the ever growing electronics scrap heap (I live in Nairobi, 5km from: dandora dump electronic at DuckDuckGo ).

As an afterthought; I’d recon package maintainers who keep old hardware alive would be eligible for funding through one of the environmental grants that most ‘western’ governments increasingly offer, I wonder if someone has ever tried applying, I’m a photographer and happy to provide high impact images from Dandora dump site for an application.

2 Likes

I’ve already reinstalled like dozens of times, so it’s not a problem :grinning:

Thank you.
So I did everything mentioned here

except for compiling packages, which I did as mentioned by you:
I found option to turn on AUR in a pamac manager preferences and to edit pkgbuild.
I built it on a 5.10 kernel.
Then I made some adjustments as was mentioned by @megavolt and you

but again I was only able to run Manjaro in a text mode

Ok, so start from scratch. Reinstall the system with free drivers option.

  1. Make sure you are on kernel 5.4 LTS or 5.10 LTS.
  2. Follow this tutorial.
    On step 1 of the tutorial uninstall the free drivers via mhwd DO NOT REBOOT!
    On step 2 install the nvidia drivers via
 git clone https://gitlab.manjaro.org/packages/extra/nvidia-340xx-utils.git
 git clone https://gitlab.manjaro.org/packages/multilib/lib32-nvidia-340xx-utils.git
 git clone https://github.com/philmmanjaro/nvidia-340xx-dkms.git

 cd nvidia-340xx-utils && makepkg -si
 cd ../lib32-nvidia-340xx-utils && makepkg -si
 cd ../nvidia-340xx-dkms && makepkg -si

Or via pamac AUR if you wish to be on kernel 5.10 LTS.(You mentioned you know how to do that)
DO NOT REBOOT!
3. Follow the rest of the tutorial as it says.
On step 5 where it says For GDM you will do only that, not the others. Since you mentioned you are on GNOME.
Again DO NOT REBOOT!

If you finished the tutorial you will have this file /etc/X11/xorg.conf.d/optimus.conf
Open the file and add this at the bottom

Section "ServerFlags"
     Option "IgnoreABI" "1"
EndSection

Now you can reboot… :crossed_fingers: hopefully it will work.

EDIT The tutorial is read and do.

It looks like it is possible to run Nvidia driver 340.108 with kernel 5.16.

Here’s what I did:

  1. Downloaded the Manjaro package nvidia-340xx-utils:
git clone https://gitlab.manjaro.org/packages/extra/nvidia-340xx-utils.git
  1. Created a text file 30-nvidia-ignoreabi.conf in the nvidia-340xx-utils folder:
Section "ServerFlags"
	Option "IgnoreABI" "true"
EndSection
  1. Patched PKGBUILD:
--- PKGBUILD	2022-01-04 13:27:57.211134866 +0100
+++ PKGBUILD	2022-01-03 19:40:08.142117341 +0100
@@ -10,12 +10,13 @@
 url="http://www.nvidia.com/"
 license=('custom')
 options=('!strip')
-source=('mhwd-nvidia' 'nvidia-drm-outputclass.conf' 'nvidia-utils.sysusers')
+source=('mhwd-nvidia' 'nvidia-drm-outputclass.conf' 'nvidia-utils.sysusers' '30-nvidia-ignoreabi.conf')
 source_i686=("https://us.download.nvidia.com/XFree86/Linux-x86/${pkgver}/NVIDIA-Linux-x86-${pkgver}.run")
 source_x86_64=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run")
 md5sums=('2f767e7d0c63e6f943edcb82ef09a389'
          '768a64259f7e8d8a46a13b876d6c443c'
-         '3d2894e71d81570bd00bce416d3e547d')
+         '3d2894e71d81570bd00bce416d3e547d'
+         '24f8ffd217e5f6f939f9113ff454c7c5')
 md5sums_i686=('ffa278e613337e638fd10de41dae3630')
 md5sums_x86_64=('e783e383bd4344d590ad429eb0883717')
 
@@ -82,6 +83,9 @@
     replaces=('nvidia-340xx-libgl')
     install="${pkgname}.install"
 
+    # Exceedingly hacky workaround for Xorg 1.21 until Nvidia updates the driver
+    install -D -m644 30-nvidia-ignoreabi.conf "${pkgdir}/etc/X11/xorg.conf.d/30-nvidia-ignoreabi.conf"
+
     cd "${srcdir}/${_pkg}"
 
     # X driver
  1. Installed the package:
$ makepkg -si
  1. Then, I downloaded the Manjaro nvidia-340xx package:
git clone https://gitlab.manjaro.org/packages/extra/linux50-extramodules/nvidia-340xx.git
  1. Next, I downloaded the kernel patches from AUR:
cd nvidia-340xx
wget -O 0001-kernel-5.7.patch https://aur.archlinux.org/cgit/aur.git/plain/0001-kernel-5.7.patch?h=nvidia-340xx
wget -O 0002-kernel-5.8.patch https://aur.archlinux.org/cgit/aur.git/plain/0002-kernel-5.8.patch?h=nvidia-340xx
wget -O 0003-kernel-5.9.patch https://aur.archlinux.org/cgit/aur.git/plain/0003-kernel-5.9.patch?h=nvidia-340xx
wget -O 0004-kernel-5.10.patch https://aur.archlinux.org/cgit/aur.git/plain/0004-kernel-5.10.patch?h=nvidia-340xx
wget -O 0005-kernel-5.11.patch https://aur.archlinux.org/cgit/aur.git/plain/0005-kernel-5.11.patch?h=nvidia-340xx
wget -O 0006-kernel-5.14.patch https://aur.archlinux.org/cgit/aur.git/plain/0006-kernel-5.14.patch?h=nvidia-340xx
wget -O 0007-kernel-5.15.patch https://aur.archlinux.org/cgit/aur.git/plain/0007-kernel-5.15.patch?h=nvidia-340xx
  1. The 0007-kernel-5.15.patch from the AUR package might throw an error due to incorrect (DOS) linebreaks used.
    To rectify, use the following command:
sed -i.bak 's/\r$//' 0007-kernel-5.15.patch 
  1. Edit PKGBUILD for the Manjaro nvidia-340xx package to look like this (the corrected patch is already considered):
# Based on the file created for Arch Linux by:
# Maintainer : Thomas Baechler <thomas@archlinux.org>

# Maintainer: Philip Müller <philm@manjaro.org>
# Maintainer: Roland Singer <roland@manjaro.org>

_linuxprefix=linux516
_extramodules=extramodules-5.16-MANJARO
pkgname=$_linuxprefix-nvidia-340xx
_pkgname=nvidia
pkgver=340.108
pkgrel=29
provides=("$_pkgname=$pkgver")
groups=("$_linuxprefix-extramodules")
pkgdesc="NVIDIA drivers for linux."
arch=('i686' 'x86_64')
url="http://www.nvidia.com/"
depends=(
         "$_linuxprefix"
         "nvidia-340xx-utils=${pkgver}"
         )
makedepends=("$_linuxprefix-headers")
conflicts=('nvidia-96xx' 'nvidia-183xx' "$_linuxprefix-nvidia" "$_linuxprefix-nvidia-304xx")
license=('custom')
install=nvidia.install
options=(!strip !ccache)
source=(
        '0001-kernel-5.7.patch'
        '0002-kernel-5.8.patch'
        '0003-kernel-5.9.patch'
        '0004-kernel-5.10.patch'
        '0005-kernel-5.11.patch'
        '0006-kernel-5.14.patch'
        '0007-kernel-5.15.patch'
        '0008-kernel-5.16.patch'
        )
source_i686=("https://us.download.nvidia.com/XFree86/Linux-x86/${pkgver}/NVIDIA-Linux-x86-${pkgver}.run")
source_x86_64=("https://us.download.nvidia.com/XFree86/Linux-x86_64/${pkgver}/NVIDIA-Linux-x86_64-${pkgver}-no-compat32.run")
md5sums=('4be5a196c4a0b095771179e820f5cc88'
         'e868ff40e412fae26b6a01929debdf04'
         '400ad257dcc26c607eb8c8c273693a01'
         'e4893414b629caaa0b3a31317ab484f2'
         '4d1a74da2f65db16066c26c7a9f7b4ab'
         '17f59396f6989283c1bd75aad57e48fd'
         '816ce6cb7626afc5c5daeef75e446890'
         'e219234af48fe6e158250115c4ef6c20'
         )
md5sums_i686=('9a4b382ef545d836033630224735d5dd')
md5sums_x86_64=('e783e383bd4344d590ad429eb0883717')

[[ "$CARCH" = "i686" ]] && _pkg="NVIDIA-Linux-x86-${pkgver}"
[[ "$CARCH" = "x86_64" ]] && _pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"

prepare() {
    # Remove previous builds
    [ -d "$_pkg" ] && rm -rf "$_pkg"
    sh "${_pkg}.run" --extract-only
    cd "${_pkg}"
    # patches here

    # Fix compile problem with 5.7
    echo "Patching for 5.7"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0001-kernel-5.7.patch)

    # Fix compile problem with 5.8
    echo "Patching for 5.8"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0002-kernel-5.8.patch)

    # Fix compile problem with 5.9
    echo "Patching for 5.9"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0003-kernel-5.9.patch)

    # Fix compile problem with 5.10
    echo "Patching for 5.10"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0004-kernel-5.10.patch)

    # Fix compile problem with 5.11
    echo "Patching for 5.11"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0005-kernel-5.11.patch)

    # Fix compile problem with 5.14
    echo "Patching for 5.14"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0006-kernel-5.14.patch)

    # Fix compile problem with 5.15
    echo "Patching for 5.15"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0007-kernel-5.15.patch)

    # Fix compile problem with 5.16
    echo "Patching for 5.16"
    (patch -p1 --no-backup-if-mismatch -i "$srcdir"/0008-kernel-5.16.patch)


    export DISTCC_DISABLE=1
    export CCACHE_DISABLE=1
}

build() {
    _kernver="$(cat /usr/lib/modules/${_extramodules}/version)"

    cd "${_pkg}"/kernel
    make SYSSRC=/usr/lib/modules/"${_kernver}/build" module

    cd uvm
    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 -m644 "${srcdir}/${_pkg}/kernel/uvm/nvidia-uvm.ko" \
        "${pkgdir}/usr/lib/modules/${_extramodules}/nvidia-uvm.ko"
    gzip "${pkgdir}/usr/lib/modules/${_extramodules}/"*.ko
    sed -i -e "s/EXTRAMODULES='.*'/EXTRAMODULES='${_extramodules}'/" "${startdir}/nvidia.install"
}
  1. Now, in the nvidia-340xx folder, execute
$ makepkg -si

a last time, and afterwards, reboot.
10. You are done - running the 340.108 legacy Nvidia driver on kernel 5.16!

3 Likes