Topic: Building the Nvidia module into the kernel
Madness I know, but I thought I'd try and compile the nVidia kernel module into the kernel itself instead of loading it at run time. It worked! Eventually ![]()
Inserting the module into the standard kernel build process is simple enough. Place the source and the kbuild Makefile with the source tree and add an entry to it in the top level Makefile. I put mine as nvidia/ after net/. Then it will automatically build and install nvidia.ko whenever you make the kernel. That's a pretty good idea so you don't have to recompile the driver every time. Lots of the Makefile is now redundant and you can tidy it up if you like.
Building it into the kernel isn't quite so easy. Obviously change nvidia-m to nvidia-y in the Makefile. You can also add a Kconfig entry to configure it if you like. It doesn't work! There is a -DMODULE lurking in there which forces certain internal defines and the final LD will fail. So remove that define and it will all be OK.
Now you have a kernel with the nVidia proprietary bits linked in. Perfect! It is surprisingly small, considering it has a 5+MB module added to it. Must compress very well. Just one final wrinkle. When you try to start X, nvidia_drv.so will try to modprobe nvidia.ko and die. You will have to tweak modprobe.conf or something in modprobe.d so that the modprobe appears to succeed. I added "install nvidia /bin/true", but an alias to null might also work.
Just remembered something else that might bite you: agpgart should be either built in to the kernel or configured off completely. If it is built as a module as seems to be standard, then nVidia will compile calls to it but won't find them when it is linked. I turned AGP off completely in the kernel because nVidias internal AGP works well on my hardware.
Last edited by iann (2011-01-27 11:56:43)