Difference between revisions of "Tegra/Mainline SW/Nouveau"

From eLinux.org
Jump to: navigation, search
(Some formatting)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Nouveau Support on Jetson TK1 ==
+
= 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.
+
This page keeps track of Nouveau's status on [[Jetson TK1]] and acts as a information hub for people wanting to run it on their boards.
  
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.
+
Nouveau requires an upstream kernel and cannot be used with the L4T kernel. It also requires an up-to-date upstream version of U-boot. Setting up both is a somehow involved process ; but fortunately a couple of helper scripts greatly simplify the process.
  
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.
+
Before proceeding, be aware that upstream Linux is less featured than L4T, and that things like video acceleration does not work at the moment. '''There is also no accelerated X driver''' (but Wayland works fine). Therefore, this procedure should really only be followed by people intending to hack on Nouveau or test it.
  
The GPU in Jetson TK1 is called GK20A and will be referred as such throughout this document.
+
== Flashing Upstream U-boot ==
 +
Tegra's boot is a quite complex process, and flashing a bootloader is equally complicated task that involves many different tools. People interested in all the gory details can read the first 3 documents of ftp://download.nvidia.com/tegra-public-appnotes/index.html. For our purpose, which is to just get things to work, we will use the Tegra U-boot Flasher Scripts.
  
== U-boot ==
+
https://github.com/NVIDIA/tegra-uboot-flasher-scripts/blob/master/README-developer.txt contains all the instructions needed to flash an upstream U-boot on your board. Once U-boot is flashed, you will be able to access its shell by pressing a key on the serial console during the initial countdown. If you let it go, it will attempt to boot the L4T kernel that is likely still on your board, which will fail because of L4T-specific kernel options that U-boot does not provide. However, it will have no problem with upstream kernel and user-space we will be building in the next section.
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 and Nouveau Module ==
+
== Building and Flashing a Nouveau User-space ==
Although the goal is to have all the necessary support in the upstream kernel, a few patches are still on their way there and therefore you will need to use custom Linux kernel and Nouveau modules branches.
+
We need to replace L4T with an upstream kernel, up-to-date Nouveau kernel modules, and user-space that includes the latest Free graphics stack. Again, this looks like a lot of work, but again scripts will help us.
  
=== Kernel ===
+
https://github.com/NVIDIA/tegra-nouveau-rootfs will assist us with the task of cross-compiling all the components we need and putting them together into a bootable system. It takes an Ubuntu 14.04 system image (the same basis than used for L4T), cross-compiles the Linux kernel, Nouveau modules, Free graphics stack (libdrm, Wayland, Mesa) as well as a couple of programs for us to play with (kmscube and weston). Instructions to write the system to either a SD card or the board's eMMC are also included. Just follow this page and you should be running a completely Free graphics stack on your Jetson TK1 board!
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:
+
== Tegra and U-boot Boot Process ==
 +
As explained above, the Tegra boot process is rather complex, and with U-boot on top of it, there is no shame in not understanding how one came up to that shiny Linux prompt. This section will attempt to quickly (and roughly) demystify what happens. For plenty of details, please read ftp://download.nvidia.com/tegra-public-appnotes/index.html.
  
mkdir build-tegra
+
When a Tegra board is powered on, code on its boot ROM is first executed. This code includes a recovery mode (that you enter by pressing the '''RECOVERY''' and '''RESET''' buttons on your Jetson TK1) that can receive a program through USB and execute it. This program can be for instance U-boot. Since this feature is in the boot ROM, it guarantees that your board can never be bricked: you will always retain the ability to load and execute a program through that mean.
cd build-tegra
 
  
Select the Tegra configuration and cross-compile the kernel and modules (adapt the CROSS_COMPILE parameter to match your cross-compiler):
+
When we "flash U-boot", what happens is that U-boot is loaded into the device's memory through recovery mode, and flashes itself to the eMMC memory where the boot ROM will find it.
  
make -j4 -C .. ARCH=arm O=`pwd` CROSS_COMPILE=arm-none-eabi- tegra_defconfig dtbs zImage modules
+
If recovery mode is not requested, the boot ROM will look for the bootloader on the eMMC, load it and execute it. This is when U-boot is running and displays its countdown on the serial console. You can interrupt it and use its shell, but if you just let it go it will run the '''bootcmd''' macro (which you can see as well as all other defined macros by typing ''printenv'' in the U-boot shell). This macro goes through all the different boot targets that Jetson TK1 support: SD card (mmc1), eMMC (mmc0), USB storage, network boot. If booting from a MMC device, ''the scan_dev_for_boot'' macro will look for a U-boot script image in ''/boot/boot.scr''. This script contains more U-boot commands that will load the kernel image and device tree binary, set the kernel boot arguments, and jump to the kernel entry point. From there the kernel boots as usual, by mounting the root filesystem specified in its boot arguments, and calling the ''init'' program.
 
 
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
 
 
 
=== 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!
 

Latest revision as of 01:57, 5 November 2014

Nouveau Support on Jetson TK1

This page keeps track of Nouveau's status on Jetson TK1 and acts as a information hub for people wanting to run it on their boards.

Nouveau requires an upstream kernel and cannot be used with the L4T kernel. It also requires an up-to-date upstream version of U-boot. Setting up both is a somehow involved process ; but fortunately a couple of helper scripts greatly simplify the process.

Before proceeding, be aware that upstream Linux is less featured than L4T, and that things like video acceleration does not work at the moment. There is also no accelerated X driver (but Wayland works fine). Therefore, this procedure should really only be followed by people intending to hack on Nouveau or test it.

Flashing Upstream U-boot

Tegra's boot is a quite complex process, and flashing a bootloader is equally complicated task that involves many different tools. People interested in all the gory details can read the first 3 documents of ftp://download.nvidia.com/tegra-public-appnotes/index.html. For our purpose, which is to just get things to work, we will use the Tegra U-boot Flasher Scripts.

https://github.com/NVIDIA/tegra-uboot-flasher-scripts/blob/master/README-developer.txt contains all the instructions needed to flash an upstream U-boot on your board. Once U-boot is flashed, you will be able to access its shell by pressing a key on the serial console during the initial countdown. If you let it go, it will attempt to boot the L4T kernel that is likely still on your board, which will fail because of L4T-specific kernel options that U-boot does not provide. However, it will have no problem with upstream kernel and user-space we will be building in the next section.

Building and Flashing a Nouveau User-space

We need to replace L4T with an upstream kernel, up-to-date Nouveau kernel modules, and user-space that includes the latest Free graphics stack. Again, this looks like a lot of work, but again scripts will help us.

https://github.com/NVIDIA/tegra-nouveau-rootfs will assist us with the task of cross-compiling all the components we need and putting them together into a bootable system. It takes an Ubuntu 14.04 system image (the same basis than used for L4T), cross-compiles the Linux kernel, Nouveau modules, Free graphics stack (libdrm, Wayland, Mesa) as well as a couple of programs for us to play with (kmscube and weston). Instructions to write the system to either a SD card or the board's eMMC are also included. Just follow this page and you should be running a completely Free graphics stack on your Jetson TK1 board!

Tegra and U-boot Boot Process

As explained above, the Tegra boot process is rather complex, and with U-boot on top of it, there is no shame in not understanding how one came up to that shiny Linux prompt. This section will attempt to quickly (and roughly) demystify what happens. For plenty of details, please read ftp://download.nvidia.com/tegra-public-appnotes/index.html.

When a Tegra board is powered on, code on its boot ROM is first executed. This code includes a recovery mode (that you enter by pressing the RECOVERY and RESET buttons on your Jetson TK1) that can receive a program through USB and execute it. This program can be for instance U-boot. Since this feature is in the boot ROM, it guarantees that your board can never be bricked: you will always retain the ability to load and execute a program through that mean.

When we "flash U-boot", what happens is that U-boot is loaded into the device's memory through recovery mode, and flashes itself to the eMMC memory where the boot ROM will find it.

If recovery mode is not requested, the boot ROM will look for the bootloader on the eMMC, load it and execute it. This is when U-boot is running and displays its countdown on the serial console. You can interrupt it and use its shell, but if you just let it go it will run the bootcmd macro (which you can see as well as all other defined macros by typing printenv in the U-boot shell). This macro goes through all the different boot targets that Jetson TK1 support: SD card (mmc1), eMMC (mmc0), USB storage, network boot. If booting from a MMC device, the scan_dev_for_boot macro will look for a U-boot script image in /boot/boot.scr. This script contains more U-boot commands that will load the kernel image and device tree binary, set the kernel boot arguments, and jump to the kernel entry point. From there the kernel boots as usual, by mounting the root filesystem specified in its boot arguments, and calling the init program.