Tegra/Mainline SW/Gentoo From SD Card

This article assumes you are running on a host Gentoo system, and have already got a cross compiler set up as armv7a-hardfloat-linux-gnueabi-

Preparing repos and SD card
mkdir -p ~/jetson cd ~/jetson mkdir tegra-uboot-flasher cd tegra-uboot-flasher curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo chmod a+x repo /usr/bin/python2 ./repo init -u git://github.com/NVIDIA/tegra-uboot-flasher-manifests.git -g default,-bootloader /usr/bin/python2 ./repo sync sudo emerge crypto++ libusb dtc cd tegrarcm ./autogen.sh ./configure make -j $(grep -c processor /proc/cpuinfo) cd ../cbootimage ./autogen.sh ./configure make -j $(grep -c processor /proc/cpuinfo) cd .. git clone https://github.com/swarren/u-boot cd scripts CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- PATH=${PATH}:~/jetson/tegra-uboot-flasher/tegrarcm/src/:~/jetson/tegra-uboot-flasher/cbootimage/src/ /usr/bin/python2 ./build --boards jetson-tk1 build





NOTE: This currently EXECUTES the u-boot bootloader, it DOES NOT flash it to the board, so you can make changes as you want/need and they don't stick around. If you would like them to stick around, then change the 'exec' in this next line to 'flash'

sudo PATH=${PATH}:~/jetson/tegra-uboot-flasher/tegrarcm/src/:~/jetson/tegra-uboot-flasher/cbootimage/src/ ./tegra-uboot-flasher --debug exec jetson-tk1

On serial port, you should see u-boot attempt to boot.

Now we prepare an sdcard.

sudo parted /dev/sdb --script -- mklabel msdos sudo parted /dev/sdb --script -- mkpart primary ext2 2048s 264191s sudo parted /dev/sdb --script -- mkpart primary ext4 264192s 100% sudo mkfs.ext2 /dev/sdb1 sudo mkfs.ext4 /dev/sdb2 sudo mkdir -p /mnt/gentoo sudo mount /dev/sdb2 /mnt/gentoo sudo mkdir /mnt/gentoo/boot sudo mount /dev/sdb1 /mnt/gentoo/boot cd /mnt/gentoo sudo  sudo tar -xpf stage3tarball-name

Set the password to gentoo (all LOWERCASE)

sudo $EDITOR /mnt/gentoo/etc/shadow root:$6$I9Q9AyTL$Z76H7wD8mT9JAyrp/vaYyFwyA5wRVN0tze8pvM.MqScC7BBm2PU7pLL0h5nSxueqUpYAlZTox4Ag2Dp5vchjJ0:14698:0:::::

Set up serial console so we can login via serial console.

sudo $EDITOR /mnt/gentoo/etc/inittab s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100

Kernel
Let's build a kernel - so many to choose from... I chose Thierry Reding's tree.


 * swarren: https://github.com/swarren/linux-tegra.git (tegra_dev branch)
 * treding: http://cgit.freedesktop.org/~tagr/linux/log/?h=staging/work (staging/master should be fine or staging/work with reverted WIP commit). Note: for nouveau to work you'll also need to supply firmware. As of 15th July 2014, it's still not in linux-firmware git master and can be fetched from Gnurou sources, gk20a branch: https://github.com/Gnurou/linux/tree/gk20a/firmware/nouveau (all files are needed), otherwise you'll need to disable nouveau in your kernel or you'll get OOPS on boot.
 * linux-next: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (master should be fine - constantly in flux - may or may not build)
 * linux: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git (only partial support so far, 3.16 merge window at time of writing)

Be sure to check http://patchwork.ozlabs.org/project/linux-tegra/list/ for possible patches you may want/need. Some patch sets will rely on others being there as well! (Treding kernel tree has if not all but most of patches that are still pending)

emerge bc cd ~/jetson git clone git://people.freedesktop.org/~tagr/linux -b staging/master cd linux make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- tegra_defconfig make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- -j $(grep -c processor /proc/cpuinfo) sudo cp arch/arm/boot/zImage /mnt/gentoo/boot/ sudo cp arch/arm/boot/dts/tegra124-jetson-tk1.dtb /mnt/gentoo/boot/ sudo make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- INSTALL_MOD_PATH=/mnt/gentoo modules_install

To get a boot.scr file: cd ~/jetson git clone https://github.com/NVIDIA/tegra-uboot-scripts/ cd tegra-uboot-scripts/

Because we use a separate boot partition, apply this patch so it knows where to find the files.

diff --git a/gen-uboot-script.py b/gen-uboot-script.py index 46847e5..374db49 100755 --- a/gen-uboot-script.py +++ b/gen-uboot-script.py @@ -107,7 +107,7 @@ if args.type == 'net': prefix='' else: load='load ${devtype} ${devnum}:${rootpart}' -   prefix='/boot/' +   prefix='/' f.write(load + ' ${kernel_addr_r} ' + prefix + 'zImage\n')

Now we create the boot.scr file. sudo /usr/bin/python2 ./part-uuid.py /dev/sdb 2 /usr/bin/python2 ./gen-uboot-script.py --partuuid  sudo cp boot.scr /mnt/gentoo/boot sudo sync sudo umount /mnt/gentoo/boot sudo umount /mnt/gentoo

Pop sdcard into the Jetson TK1 and type boot on the serial console, and it should attempt to boot from the sdcard.

After a bit, you should see a login prompt on the serial console, and if HDMI is enabled, you should actually see OpenRC starting up on the screen and once it's booted, the login prompt will show up there.

Some notes on Nouveau
As of 15th July 2014, Nouveau works only with patched Wayland (http://lists.freedesktop.org/archives/wayland-devel/2014-June/015537.html) and with libdrm-git and mesa-git. So be prepared for a lot of work. If you want to get OpenGL working, you still need to stick with nVidia's official kernel 3.10 form Linux4Tegra R19.3