Nouveau DRM modules, the Nouveau kernel tree
The kernel modules required by Nouveau (drm.ko, drm_kms_helper.ko, ttm.ko and nouveau.ko) are built from a Linux kernel tree. You have several alternatives (marked with Alt) on how to download the source code and how to compile it. See also KernelModeSetting for important KMS notes. Please, read carefully.
The Nouveau kernel git repository contains one usable branch: master. You may not be able to compile the DRM modules against your current kernel, if it is too old (might need an -rc kernel or even Linus' git kernel). The possible errors include build failure and kernel modules that cannot be loaded. It is recommended to build your whole kernel from this branch.
master-compat now contains only the out-of-tree build Makefile and a couple of documents for those who insist on using an existing kernel. You cannot build a kernel or the DRM modules from master-compat.
1. Downloading the source
The alternatives are:
- cloning the Nouveau kernel repository in full
- If you intend to do development, this is the recommended option (also consider having Linus' tree, too).
- cloning the Nouveau kernel repository without history
- If you want to update often, this is probably the easiest.
- adding the Nouveau kernel repository as a new remote
- Only if you already have a full git kernel tree cloned, Linus' or whatever, and you are familiar with git remotes and branches. This option downloads the least amount of data. Cloning Linus' tree is possibly faster than cloning the Nouveau kernel tree.
- updating the repository from git
- Only if you already have the Nouveau kernel repository.
downloading a snapshot from http://cgit.freedesktop.org/nouveau/linux-2.6/ (browse for the package links)
- If you update only once a year...
- downloading a snapshot of only the directories needed for Nouveau kernel modules (not a full kernel)
The daily snapshots: http://people.freedesktop.org/~pq/nouveau-drm/ (the timestamp is in PDT) are named by the branch.
The archives are overwritten daily, so do not delete the file you downloaded. The command zcat master.tar.gz | git get-tar-commit-id will show the revision id of the package. The developers need to know the id, if you want to report bugs. Just download, unpack, and move on to the compiling instructions. Btw. here is the Makefile.
The snapshot cases are trivial, other cases are explained in the following. Take your pick.
NOTE: If you clone, you only need to do that once. Afterwards always use the update procedure. Cloning means a full copy of the remote repository including all branches.
1.1. Alt: Cloning the full Nouveau kernel repository
For anonymous access use
git clone git://anongit.freedesktop.org/nouveau/linux-2.6
It will create a directory called linux-2.6. If you want another name, use e.g.
git clone git://anongit.freedesktop.org/nouveau/linux-2.6 nouveau-linux
This will contain the full Linux development history from 2.6.12 onwards.
June 24th, 2009, this created a directory of approximately 700MB.
1.2. Alt: Cloning the Nouveau kernel repository without history
git clone --depth 1 git://anongit.freedesktop.org/nouveau/linux-2.6
Does not download any history, otherwise see above. You are still able to get updates using the normal git commands.
June 24th, 2009, this command created a directory of approximately 480MB and downloaded perhaps in half or one third of the time of the full clone.
1.3. Alt: Adding the Nouveau kernel repository as a new remote
Chdir into your Linux kernel git repository. For instance, if you have Linus' tree as a remote called "linus", git config -l will probably show something like
remote.linus.url=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git remote.linus.fetch=+refs/heads/*:refs/remotes/linus/*
To add Nouveau, do
git remote add nouveau git://anongit.freedesktop.org/nouveau/linux-2.6
and check with git config -l, you should have
remote.nouveau.url=git://anongit.freedesktop.org/git/nouveau/linux-2.6 remote.nouveau.fetch=+refs/heads/*:refs/remotes/nouveau/*
To actually download the Nouveau repository, do git remote update or git fetch nouveau or pass -f to the adding command in the first place. For more information, see git help remote.
In the other instructions, when you encounter origin in the commands, replace it with the remote name you selected (nouveau in this example).
1.4. Alt: Updating the Nouveau kernel git repository
git remote update
fetches all remote repositories and branches. Then, assuming you are working based on Nouveau's master branch,
git rebase origin/master
to move your current local branch on top the new head of origin/master.
2. Compiling the modules
The alternatives for building the Nouveau kernel modules are:
- out-of-tree build
- You compile the modules without touching your current kernel, assuming the kernel is compatible.
- kernel rebuild with updated DRM code
- After updating your existing kernel sources to the latest Nouveau code, you build a new kernel as usual. Allows built-in DRM and Nouveau.
RECOMMENDED: building a complete kernel from Nouveau sources
- The Nouveau kernel tree is a full kernel source, following Linus' tree. Linus' tree is occasionally merged into the Nouveau tree to get updates from upstream. Just build and use this kernel as usual. This option is not considered here because there is nothing special about it.
If you are not building a complete kernel from the Nouveau kernel sources, but you take only the DRM modules, your kernel version should be at least the version that is currently merged into the Nouveau kernel tree. You can check the required (recommended) kernel version from the Nouveau kernel tree upstream Makefile, the variables VERSION, PATCHLEVEL, SUBLEVEL and EXTRAVERSION at the top of the file.
2.1. Alt: Completely out-of-tree build for your existing kernel
The first thing to check is that the configuration of your currently running kernel (or the target kernel) is compatible. The usual requirements are listed in file DEPENDS. There are other requirements, too, but it is hard to miss them. You have to check the requirements yourself, or you may get mysterious compile errors, or the modules may simply fail to load.
The out-of-tree build is done using this Makefile, download it. It is recommended to save it under a new directory nouveau in your checkout of the Nouveau kernel tree. The following assumes you did exactly that.
The build itself:
cd nouveau make make install
By default it will build the modules for your currently running kernel. If you want to build for another kernel, use
make LINUXDIR=/path/to/system/kernel/source make LINUXDIR=/path/to/system/kernel/source install
The Makefile assumes that the Nouveau kernel tree is found in the parent directory of the current working directory of make. If that is not the case, you can specify the Nouveau kernel tree location with
make NOUVEAUROOTDIR=/path/to/nouveau/linux-2.6 make NOUVEAUROOTDIR=/path/to/nouveau/linux-2.6 install
You can also specify both LINUXDIR and NOUVEAUROOTDIR, if needed.
2.2. Alt: Rebuilding your existing kernel with new DRM and Nouveau parts
Go to your kernel source directory and replace two directories with symlinks into the Nouveau kernel tree as follows:
cd /usr/src/linux mv include/drm include/drm_orig ln -s /path/to/nouveau/linux-2.6/include/drm include/drm mv drivers/gpu/drm drivers/gpu/drm_orig ln -s /path/to/nouveau/linux-2.6/drivers/gpu/drm drivers/gpu/drm
Then configure, build and install your kernel as usual:
make oldconfig make menuconfig make make modules_install make install
Enable Nouveau in the kernel config.
Device drivers -> Graphics support ->
Direct Rendering Manager (CONFIG_DRM) ->
Nouveau (CONFIG_DRM_NOUVEAU)If you want KMS support and a fancy framebuffer console, enable
Device drivers -> Graphics support ->
Support for framebuffer devices (CONFIG_FB)
Console display driver support ->
Framebuffer Console support (CONFIG_FRAMEBUFFER_CONSOLE)CONFIG_FRAMEBUFFER_CONSOLE is recommended to have as a built-in. Laptop owners may need also Backlight & LCD device support. Maybe also Display device support?
If you need TV-out and you have one of the external encoder chips on your card (that is nv0x-nv2x, nv17-nv19 excluded), you also need to enable a matching encoder driver. If you're lucky you'll find it under:
Device drivers -> Graphics support ->
Direct Rendering Manager (CONFIG_DRM) ->
I2C encoder or helper chipsIf you have doubts about what encoder do you have, build them all as modules, they will only be used if they're suitable.
3. Installation notes
The out-of-tree build's make install step will install the modules into /lib/modules/<version>/extra. If your kernel already had drm.ko, ttm.ko or nouveau.ko in some other directory, they will conflict and should be removed. When the installation is done properly, all you need to do to load the modules is modprobe nouveau. Depending on your system, the modules may even be automatically loaded on boot, but starting X will load them, too. If nvidia.ko loads automatically on boot, you may want to remove it.

