Gentoo Logo

Disclaimer : This document is a work in progress and should not be considered official yet.


Gentoo on the Nvidia Tegra 250 Developer Kit

Content:

1.  Overview

Installing Gentoo in the Nvidia Tegra 250 is pretty simple if you're already a Gentoo user. You can either use a sufficiently sized SD card (>=2GB for ease) or an USB HDD. If you are familar with the Gentoo Linux installation process, there is not much different here.

2.  Requirements

To be able to install Gentoo, you'll need the following:

  • An x86/amd64 based PC with Linux on it
  • A Nvidia Tegra 250 Developer Kit
  • The USB -> USB mini type B cable the board comes with
  • One USB HDD
  • A network connection

3.  Preparing to install your Nvidia Tegra

Overview

Before we start the installation process, we need to build a kernel for the Nvidia Tegra and the utility to flash it to our board on our computer.

The Nvidia Tegra comes without any Operating System on it. At the moment it uses the fastboot method for flashing a kernel in case of Linux(Windows CE/Android is another story), since U-Boot or any other sane bootloader doesn't work yet.

Obtaining/Building a kernel

For booting the Nvidia Tegra we need a kernel. The vanilla kernel.org kernel doesn't support the Nvidia Tegra yet, so we have to use the kernel available on Nvidia's GIT server. For doing so we need dev-vcs/git on our system.

Code Listing 3.1: Get the kernel source

(Emerge dev-vcs/git if you don't have it already)
# emerge dev-vcs/git

(Clone Nvidia Tegra kernel repository, may take a while)
# git clone git://nv-tegra.nvidia.com/linux-2.6.git

(Once cloned, change to the new directory created)
# cd linux-2.6

(The tegra-9.12.7 tag/branch is known to work)
# git checkout tegra-9.12.7

Now that we have the kernel source, we can build it. However since the Nvidia Tegra is an ARM device, we need to crosscompile the kernel to ARM. For doing so, on Gentoo we use sys-devel/crossdev, which provides us an easy way to create a cross-compiler.

Code Listing 3.2: Creating a cross-compiler

(Emerge sys-devel/crossdev first, if you don't have it already)
# emerge -v crossdev

(Create a crosscompiler for the armv7a-unknown-linux-gnueabi CHOST)
# crossdev -S armv7a-unkown-linux-gnueabi

Once we have our crosscompiler, we can crosscompile it finally. We'll use the default kernel config since it has all we need.

Code Listing 3.3: Cross-compiling the kernel

(We use the default config for this board)
# cp arch/arm/configs/tegra_harmony_gnu_linux_defconfig .config

(Replace 9 with the number of cores you have on your computer)
# make -j9 ARCH=arm CROSS_COMPILE="armv7a-unknown-linux-gnueabi-" zImage

Once it gets built, we'll now have a kernel image on arch/arm/boot/zImage.

Obtaining and building the fastboot loader

The bootloader we'll use is the one that gets used for Android, since U-Boot doesn't support the Nvidia Tegra yet. This bootloader, fastboot, is available on the Android SDK

Code Listing 3.4: Download and unpack Nvidia's Android SDK for Linux

# wget http://developer.download.nvidia.com/tegra/files/android_tegra_250_5421622.run.zip

(After having downloaded the SDK, we unzip it)
# unzip android_tegra_250_5421622.run.zip

(We set the execution mode on the resulting binary)
# chmod +x android_tegra_250_5421622.run

(We execute the binary)
# ./android_tegra_250_5421622.run

After accepting the license, the binary will extract a directory called android_tegra_250_5421622. In this directory you'll find the fastboot bootloader.

You also need to copy the previously built zImage into that directory

We'll enter into the new directory and download the following file which contains the partitions that will be created on the board's NAND.

Code Listing 3.5: Getting the NAND partition config file

# cd android_tegra_250_5421622

# wget http://dev.gentoo.org/~armin76/arm/tegra2/linux_fastboot_nand.cfg

Compile the fastboot utility on your PC

For flashing a kernel into the board, we need the fastboot utility on our PC. The flashing is done through the miniUSB port the board has.

For building such tool, we need, unfortunately, java.

Code Listing 3.6: Emerging required dependencies

# emerge -v =sun-jdk-1.5*

Then, we'll checkout the repositories that are needed for fastboot

Code Listing 3.7: Checking out fastboot repositories

# git clone git://nv-tegra.nvidia.com/android/platform/build.git build
# git clone git://nv-tegra.nvidia.com/android/platform/external/svox.git external/svox
# git clone git://nv-tegra.nvidia.com/android/platform/external/zlib.git external/zlib
# git clone git://nv-tegra.nvidia.com/android/platform/system/core.git system/core

# cd system/core

(Get the correct version)
# git checkout tegra-9.12.5
# cd ..

Now, we compile it.

Code Listing 3.8: Compiling fastboot

# make -f build/core/main.mk fastboot

Flashing the bootloader

Now we'll format the NAND and flash the bootloader into it.

Make sure you plug the power cable on the board, then connect the usb cable to the board and to your PC.

To power on the board, you need to press *BOTH* the Force Recovery and the Power on buttons until the LEDs power up. Then execute the following command to flash the bootloader.

Important: Remember to copy the previously zImage into the android_tegra_250_5421622 directory!

Code Listing 3.9: Recreating the partitions and flashing the bootloader

# LD_LIBRARY_PATH=. ./nvflash --bct tegra_250_333MHz_1GB.bct --setbct --bl fastboot.bin --configfile linux_fastboot_nand.cfg --odmdata 0x303d8011 --create --go

If everything went right, you should see the following output on the command line:
Nvflash started
rcm version 0X20001
System Information:
   chip name: t20
   chip id: 0x20 major: 1 minor: 2
   chip sku: 0x8
   chip uid: 0x1614308744607417
   macrovision: disabled
   hdcp: enabled
   sbk burned: false
   dk burned: false
   boot device: nand
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 0

sending file: tegra_250_333MHz_1GB.bct
- 4080/4080 bytes sent
tegra_250_333MHz_1GB.bct sent successfully
odm data: 0x303d8011
downloading bootloader -- load address: 0x108000 entry point: 0x108000
sending file: fastboot.bin
\ 888192/888192 bytes sent
fastboot.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
setting device: 1 0
creating partition: BCT
creating partition: PT
creating partition: EBT
creating partition: UIP
creating partition: USP
creating partition: SOS
creating partition: LNX
creating partition: MBR
creating partition: UBN
creating partition: MPT
Formatting partition 2 BCT please wait.. done!
Formatting partition 3 PT please wait.. done!
Formatting partition 4 EBT please wait.. done!
Formatting partition 5 UIP please wait.. done!
Formatting partition 6 USP please wait.. done!
Formatting partition 7 SOS please wait.. done!
Formatting partition 8 LNX please wait.. done!
Formatting partition 9 MBR please wait.. done!
Formatting partition 10 UBN please wait.. done!
Formatting partition 11 MPT please wait.. done!
done!
sending file: fastboot.bin
\ 888192/888192 bytes sent
fastboot.bin sent successfully
sending file: zImage
\ 2488384/2488384 bytes sent
zImage sent successfully

On the Nvidia Tegra board video output you should see:
"Entering NvFlash recovery mode / Nv3p Server"

"Starting Fastboot USB download protocol"

That means the flashing of the bootloader went correctly, we can now flash the kernel.

Code Listing 3.10: Flashing the kernel

(Replace sda1 with the partition of the disk where you will put Gentoo on)
(Replace PATH_TO_zImage with the path where the zImage you build is located)
# out/host/linux-x86/bin/fastboot -i 0x955 -p sda1 flash:raw boot PATH_TO_zImage

If everything went right, you should see the following output:
(Note: the bytes may change)
creating boot image...
creating boot image - 2492416 bytes
sending 'boot' (2434 KB)... OKAY
writing 'boot'... OKAY

Remember to save this command(and the binaries), since its the command you'll need to put a new kernel

That means our Nvidia Tegra is ready to boot, now you can turn it off, and let's focus on the Gentoo installation on our USB disk

4.  Installing Gentoo

Overview

The installation this device is a bit different, as we can't install Gentoo on it by booting an installation environment. For installing Gentoo(and any other distro, really) you need to put the USB disk or usb stick on your PC and prepare there the minimal installation.

I'd recommend reading the ARM handbook, for creating the partitions, extracting the stage, configure the networking, etc...until you're able to create a minimum filesystem.

So please read and follow the ARM Handbook from the beginning, just skip the 10th chapter, as its irrelevant for our machine. I'll just explain what we have to do differently. Please read below first so you know when you have to go back to this document during the installation.

Stages information

Here's some information about the stages.

  • Architecture: arm
  • Subarchitecture: armv7a
  • CHOST: armv7a-unknown-linux-gnueabi
  • Profile: default/linux/arm/10.0

We'll be using the new EABI, also called gnueabi, instead of the old ABI. That is armel on Debian. There's no exact reason for why we should use this EABI and not the old one, apart that this one is better than the old.

Therefore, we need an armv7a-unknown-linux-gnueabi stage3, available under the releases/arm/autobuilds directory in your favorite mirror

Setting the default root password

This is the most important part of the installation. As without the root password we won't be able to login!

For setting the password, we need to be able to run passwd. However thats not possible since our PC can't run ARM binaries. Therefore we need to modify the file that contains the passwords, /etc/shadow inside the chroot, so we can set a default root password.

Warning: Remember that this paths are relative to the chroot! So if you extracted the stage3 on /mnt/hdd/, then you should add /mnt/hdd everytime i mention a file or directory

Code Listing 4.1: Change the default root password to gentoo

(This would be /mnt/hdd/etc/shadow in the example above)
# nano -w /etc/shadow

(Replace the first line with the following line)
root:$6$I9Q9AyTL$Z76H7wD8mT9JAyrp/vaYyFwyA5wRVN0tze8pvM.MqScC7BBm2PU7pLL0h5nSxueqUpYAlZTox4Ag2Dp5vchjJ0:14698:0:::::

After saving the file, that means that on the installation, the password will be gentoo. You can change it once you boot your Nvidia Tegra board.

Enabling SSH access(optional)

We can add sshd to the startup of our system so we can access the Nvidia Tegra board using ssh.

Code Listing 4.2: Adding sshd to the startup

# rc-update add sshd default

Enabling serial console access(optional)

By default the ttyS0 port is configured at 9600bps. However,almost all the ARM devices run the serial port at 115200bps. So this should be added to the /etc/inittab file:

Code Listing 4.3: Configuring serial console

# nano -w /etc/inittab

(Replace 9600 with 115200 on the ttyS0 line)
s0:12345:respawn:/sbin/agetty 115200 ttyS0 vt100

Finishing the installation

This is pretty much all the installation, read all the recommendations of the handbook, and remember to change the root password and/or create some users.

5.  Booting to our new system

Once you've finished the installation of Gentoo into your Nvidia Tegra, you can simply push the reset button. Then it will boot from the external storage device.

6.  References

You may find more documentation about the device itself and Linux-related at the following links:



Print

Page updated March 27, 2010

Summary: This guide shows you how to install Gentoo on the Nvidia Tegra 250 Developer Kit.

Raúl Porcel
Author

Donate to support our development efforts.

Copyright 2001-2014 Gentoo Foundation, Inc. Questions, Comments? Contact us.