Tegra/Mainline SW/Nouveau

Nouveau Support on Jetson TK1
This page keeps track of Nouveau's status on Jetson TK1 and acts as a kind of tutorial to get things running.

Note that Nouveau requires an upstream kernel to work and cannot be used with the L4T kernel. Going through this document will replace your L4T kernel with an upstream one, which may impact your board's usability as upstream kernels are currently less-featured. Due to the current reduced functionality of using Nouveau on Jetson TK1, this should really only be followed by people intending to hack on Nouveau or test it.

Note that as of now, there is no X.org support (Xwayland does work though). All the instructions of this document are for setting up DRM, Mesa and Wayland.

The GPU in Jetson TK1 is called GK20A and will be referred as such throughout this document.

Update: L4T/Nouveau root image creation scripts
If you want to get started as easily as possible, follow the instructions on https://github.com/Gnurou/tegra-nouveau-rootfs. They are the official painless way to run Nouveau on your board. The instructions on this page remain for educational purpose, although looking at the scripts used above is probably better.

U-boot, Kernel and Nouveau Module
Although the goal is to eventually have all the necessary support in the upstream projects, a few patches are still on their way there and therefore you will need to use non-mainline U-boot, Linux kernel and Nouveau modules branches.

U-boot
Compile and install the master branch of git://git.denx.de/u-boot-tegra.git. An essential patch (df3443dfa4) is required for the GPU to initialize properly and it has not reached mainline yet.

Kernel
Most of the kernel patches have been merged for 3.17, but a few are still pending, hopefully not for too long. Checkout the drm branch of https://github.com/Gnurou/linux.git. It has just a handful of commits on top of the current -rc.

From the kernel root, create a build directory and go into it:

mkdir build-tegra cd build-tegra

Select the Tegra configuration and cross-compile the kernel and modules (adapt the CROSS_COMPILE parameter to match your cross-compiler):

make -j4 -C .. ARCH=arm O=`pwd` CROSS_COMPILE=arm-none-eabi- tegra_defconfig dtbs zImage modules

Now install the kernel and modules. Mount the root partition of your Jetson TK1 (if you are booting off eMMC, run "ums 0 mmc 0" from U-boot to make it appear as a USB storage device) and adapt the following lines so the mount directory matches:

cp arch/arm/boot/zImage arch/arm/boot/dts/tegra124-* /path/to/jetson/root/boot make -C .. ARCH=arm O=`pwd` CROSS_COMPILE=arm-none-eabi- INSTALL_MOD_PATH=/path/to/jetson/root modules_install

Until Tegra K1 SMMU support is merged, you will need CMA memory. Lots of it. Make sure to boot with at least cma=256M in your kernel command-line.

Nouveau Kernel Module
The version of Nouveau in the kernel still lacks a few patches to allow GK20A to be used.

Checkout the gk20a branch of https://github.com/Gnurou/nouveau.git. Then compile the modules against your Linux tree:

cd nouveau/drm make -j4 ARCH=arm CROSS_COMPILE=arm-none-eabi- O=/path/to/kernel/source/build-tegra M=$PWD -C /path/to/kernel/source modules

Mount your Jetson TK1 root partition again, and install the modules:

make ARCH=arm CROSS_COMPILE=arm-none-eabi- O=/path/to/kernel/source/build-tegra M=$PWD INSTALL_MOD_PATH=/path/to/jetson/root -C /path/to/kernel/source modules_install

NVIDIA GK20A Firmware
GK20A's firmware should eventually end in linux-firmware, but until it is the case you will need to find or extract the 4 firmware files nvea_fuc409c, nvea_fuc409d, nvea_fuc41ac and nvea_fuc41ad. These files are still not officially distributed.

Put the 4 firmware files into /lib/firmware/nouveau of your Jetson TK1 root.

After the kernel, Nouveau modules, and firmware have been installed, you can boot your Jetson: the nouveau module should load successfully despite a few errors in the kernel log. To confirm, check that /dev/dri/renderD128 exists. If it does, the Nouveau module is correctly loaded!

User-space
We will compile all the required projects on the Jetson board. It takes more time, but is easier to achieve than cross-compilation.

Here's a (partial?) list of packages you should have installed before continuing. These package names are from Ubuntu 14.04.

autoconf bison flex pkg-config libtool libpthread-stubs0-dev x11proto-gl-dev x11proto-dri2-dev x11proto-dri3-dev x11proto-present-dev x11proto-xf86vidmode-dev

We will install all needed programs and libraries into $HOME/usr to avoid overwriting anything on the system. So first let's create an environment file for when we want to use Nouveau stuff, in e.g. ~/nouveau-env.sh:

NVD=$HOME/usr LD_LIBRARY_PATH=$NVD/lib PKG_CONFIG_PATH=$NVD/lib/pkgconfig/:$NVD/share/pkgconfig/ ACLOCAL="aclocal -I $NVD/share/aclocal" export NVD LD_LIBRARY_PATH PKG_CONFIG_PATH ACLOCAL export PATH="$NVD/bin:$PATH"

You can source this file before doing Nouveau-related work, or better, add the following to your ~/.bashrc:

source ~/nouveau-env.sh

Now with this environment properly set up, let's compile all needed libraries and programs.

libdrm
Some patches on top of mainline are still needed. Get the gk20a branch of https://github.com/Gnurou/drm.git, then compile and install as follows:

./autogen.sh --prefix=$NVD --enable-tegra-experimental-api make -j4 make install

Wayland
Wayland must be installed prior to Mesa so its Wayland support can be included.

Checkout the master branch (commit 5bed9e46e7 is known to work) from git://anongit.freedesktop.org/wayland/wayland, then compile and install:

./autogen.sh --prefix=$NVD --disable-documentation make -j4 make install

Mesa
All the needed patches are already in upstream Mesa, horray! But they will not be released until Mesa 10.3. So by the meantime, you will need to compile Mesa from source.

Checkout the master branch (commit e9a4e7492 is known to work) of git://anongit.freedesktop.org/mesa/mesa, then compile as follows:

./autogen.sh --without-dri-drivers --with-gallium-drivers=nouveau --enable-gallium-egl --enable-gbm --enable-egl --with-egl-platforms=drm,wayland --enable-gles1 --enable-gles2 --enable-opengl --prefix=$NVD make -j4 make install

kmscube
At this point you should be able to quickly try your setup using kmscube. Get the master branch of git://gitorious.org/thierryreding/kmscube.git, compile and test:

./autogen.sh --prefix=$NVD make -j4 ./kmscube /dev/dri/card0 /dev/dri/renderD128

alternatively,

./kmscube /dev/dri/card0 /dev/dri/card1

Should also work.

You should see a fullscreen cube rotating seamlessly. This validates the accelerated path of the Nouveau driver and the passing of buffers between Nouveau and tegradrm for display.

Weston
Checkout the baserock/james/weston branch of git://git.baserock.org/delta/weston.git. Then:

mkdir m4 ./autogen.sh --prefix=$NVD make -j4 sudo make install

You should now be able to run Weston. Make sure you have a keyboard and mouse connected, as it won't run through serial, and start Weston:

weston-launch

You should now see the Weston desktop and be able to run programs!

X.org
No X.org support for now - sorry!

Xwayland
Xwayland can be used to run X applications in Wayland. The Xwayland source can be found in the git repository at git://anongit.freedesktop.org/xorg/xserver. You will need some additional dependencies: libepoxy, X protocol files, libxtrans. For instructions, see http://wayland.freedesktop.org/xserver.html. To build Xwayland, run

autoreconf -fi ./configure --prefix=$NVD \ --enable-xwayland \ --enable-dri \ --disable-xorg \ --disable-xwin \ --disable-xquartz \ --disable-xvfb \ --disable-xnest \ --disable-docs \ --disable-devel-docs make -j4 make install

After installing Xwayland, you need to configure weston to use it and make some symlinks so that it doesn't fail immediately. See http://wayland.freedesktop.org/xserver.html for instruction on doing this.

After installing Xwayland, X applications should just work. At least chromium-browser does.

Enabling Reclocking
Reclocking support is enabled in the kernel, but to support it from user-space the Nouveau module needs to be loaded with a parameter. Paste the following:

options nouveau pstate=1

into /etc/modprobe.d/nouveau.conf and reboot for effect. The pstate file should appear in /sys/devices/soc0/57000000.gpu/. Use cat to list the possible values, and echo 0f to it to max the GPU frequency if needed!