Difference between revisions of "Jetson/Porting Fedora"

From eLinux.org
Jump to: navigation, search
m (rephrasing)
m (removing unneeded header)
Line 95: Line 95:
  
 
<pre>
 
<pre>
##Location
 
##<path_to_L4T_rootfs>/etc/systemd/system/nvidia-tegra.service
 
 
 
[Unit]
 
[Unit]
 
Description=The NVIDIA tegra init script
 
Description=The NVIDIA tegra init script

Revision as of 14:05, 13 July 2015

Introduction

This guide will go over the steps needed to get the ARM version of Fedora 20 running on the Jetson-TK1, after installing the board support package (config, kernel, drivers, etc.) This guide will help you configure the corresponding NVIDIA driver packages and binaries needed to use the Fedora distribution.

The first step is to download the latest TK1 Driver Package: https://developer.nvidia.com/linux-tegra

Extract the Jetson TK1 Driver Packages, which should contain a top folder called "Linux_for_Tegra".

 sudo tar jxpf <latest_l4t_driver_package>.tbz2
 cd Linux_for_Tegra     # We will refer to this directory as <path_to_L4T_TOP_DIR>
 cd rootfs              # We will refer to this directory as <path_to_L4T_rootfs>

NOTE: This guide follows the steps for flashing and booting into a minimal Fedora image. After, we provide instructions to make needed environment changes for launching a desktop environment. If you choose to use a non-minimal Fedora image, you may have to make some of the environment changes before flashing.

Obtaining the Fedora Image

Now we need to obtain the image for Fedora in order to place it's contents in the "rootfs" folder of Linux_for_Tegra.

A Fedora mirror can be found here: http://mirror.sfo12.us.leaseweb.net/fedora/linux/releases/20/Images/armhfp/

NOTE: Make sure to select the Minimal 20 "armhfp" version, labeled "Fedora-Minimal-armhfp-20-1-sda.raw.xz" on the link above. The latest Fedora 21 version may not work with the existing Jetson-TK1 BSP due to incompatible versions of Xorg.

Extract the image and then mount it with kpartx:

xz -d Fedora-Minimal-armhfp-20-1-sda.raw.xz 
sudo kpartx -a Fedora-Minimal-armhfp-20-1-sda.raw

Locate the contents of the mounted filesystem in /media/<user_name>/__/ and copy only the contents from the root filesystem that appears here into a desired directory on your local machine. You will want to run cp while preserving Fedora's symbolic links.

sudo cp -av /media/<user_name>/__/* <path_to_L4T_rootfs>

Changes to the Apply Binaries script

As the apply binaries script (apply_binaries.sh) was written to work with Ubuntu, and Ubuntu stores some of its libraries differently than Fedora, the script will need to be updated to look in the correct place. Navigate to your Linux_for_Tegra folder and make these changes to the apply_binaries.sh file.

Find the section of the file that looks similar to the script below, and add the two lines indicated:

if [ -d "${LDK_ROOTFS_DIR}/usr/lib/arm-linux-gnueabihf/tegra" ]; then
	ARM_ABI_DIR="${LDK_ROOTFS_DIR}/usr/lib/arm-linux-gnueabihf"
elif [ -d "${LDK_ROOTFS_DIR}/usr/lib/arm-linux-gnueabi/tegra" ]; then
	ARM_ABI_DIR="${LDK_ROOTFS_DIR}/usr/lib/arm-linux-gnueabi"
elif [ -d "${LDK_ROOTFS_DIR}/usr/lib/aarch64-linux-gnu/tegra" ]; then
	ARM_ABI_DIR="${LDK_ROOTFS_DIR}/usr/lib/aarch64-linux-gnu"
elif [ -d "${LDK_ROOTFS_DIR}/usr/lib/tegra" ]; then                     # Add this line
        ARM_ABI_DIR="${LDK_ROOTFS_DIR}/usr/lib"                         # and this one.
else
	echo "Error: None of Hardfp/Softfp Tegra libs found"
	exit 4
fi

Next, you will need to add flags to several tar commands in order to preserve symbolic links, since Fedora uses these links for its /bin, /sbin, and /lib folders. There are 4 lines you need to change like this:

#Replace these
tar xpfm
#With these
tar --keep-directory-symlink -xpmf

Similarly, there are 4 more lines that need to change like this:

#Replace these 
sudo tar jxpfm
#With these
sudo tar --keep-directory-symlink -jxpmf

Configuration Changes

Compared to Ubuntu a few configuration changes are needed

In order to address these changes, we will need to make a few edits to the "nv_tegra" folder, found within Linux_for_Tegra.

  • 1. Navigate to Linux_for_Tegra/nv_tegra
  • 2. Extract the "nvidia_drivers.tbz2" file and an "nvidia_drivers" file should appear
  • 3. Navigate to nvidia_drivers/usr/lib/arm-linux-gnueabihf
  • 4. Move the "tegra" and "tegra-egl" folders found here up one directory into /nvidia_drivers/usr/lib/
  • 5. Remove the old nvidia_drivers.tbz2 in /nv_tegra/
  • 6. Repackage the contents of nvidia_drivers
cd <path_to_L4T_TOP_DIR>/nv_tegra
sudo mkdir nvidia_drivers
sudo tar -xpjf nvidia_drivers.tbz2 -C nvidia_drivers/
cd nvidia_drivers/usr/lib/arm-linux-gnueabihf
sudo mv tegra ../tegra
sudo mv tegra-egl ../tegra-egl
cd ../../..
sudo rm ../nvidia_drivers.tbz2 
sudo tar -cpjf ../nvidia_drivers.tbz2 *

Initialization Script

Because Fedora uses systemd rather than upstart, the init script will need to be converted into a systemd service. Information on systemd and how to create services can be found on the Arch Wiki page for systemd. The process is the same for Fedora.

To create the systemd service, we will need the service descriptor file, that tells systemd about the service. The one that I created is below.

[Unit]
Description=The NVIDIA tegra init script

[Service]
type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/nvidia-tegra-init-script

[Install]
WantedBy=multi-user.target

You can sudo <some-text-editor> <path_to_L4T_TOP_DIR>/rootfs/usr/lib/systemd/system/nvidia-tegra.service and place the contents above into this empty file.

fstab

Depending on the image you obtained, you may need to be updated before flashing. As the Fedora install / image is distributed as a raw disk image, it assumes you will flash that image directly to the target device, which is not the case here. The fstab has the UUID's of the partitions which are not the same when flashing to the Jetson.

A blank fstab will work fine.

sudo rm <path_to_L4T_rootfs>/etc/fstab
sudo touch <path_to_L4T_rootfs>/etc/fstab

Flashing Jetson TK1

The steps for flashing the Fedora image to the Jetson are no different than flashing the image for Ubuntu.

First, make sure the Jetson-TK1 is in recovery mode by holding down the 'Force Recovery' button and then tapping the 'Reset' button on the board. Run the following commands to apply the configuration, create the image, and flash it to the Jetson

cd <path_to_L4T_TOP_DIR>
# Apply the NVIDIA specific configuration, binaries, and the L4T kernel
sudo ./apply_binaries.sh

# Create the image from the contents of rootfs and flash the image to the Jetson
sudo ./flash.sh -S 14580MiB jetson-tk1 mmcblk0p1

NOTE: If flash fails, try rebooting your host machine to clear device nodes

After flashing successfully, your Jetson-TK1 should boot and prompt you to set a root password, user, and timezone.

X11 Support

First, we need to install the base x11 packages. You can do this easily by running the following group install command:

yum install @base-x

Then, you will need to make sure that X is using the libglx.so that nvidia provides, and not the default

cd /usr/lib/xorg/modules/extensions
rm libglx.so
ln -sf /usr/lib/tegra/libglx.so libglx.so

Desktop Environment

To run Fedora's GUI environment you will need to choose a desktop environment and install it. For simplicity, I used XFCE.

yum install @xfce

Depending on the desktop environment, you may need to configure xinitrc. XFCE, for example, will not do this for you. You can configure your xinitrc by modifying / creating the .xinitrc file in your home directory.

nano ~/.xinitrc

You can also copy the default from /etc/X11/xinit/xinitrc to your home directory and modify it accordingly.

The addition of

exec startxfce4

is needed to tell xinit to launch xfce. A minimal configuration file is below.

#!/bin/bash
#For those using XFCE
exec startxfce4

Finally launch your desktop environment:

startx