Difference between revisions of "Tegra/Mainline SW/Gentoo From SD Card"

From eLinux.org
Jump to: navigation, search
m (Shervin.emami moved page GentooFromSDCard to Tegra/Mainline SW/Gentoo From SD Card: Moved to upstream Tegra location, and put spaces in the title)
(bc required to build kernel)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
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-  
 
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
 
  mkdir -p ~/jetson
Line 7: Line 9:
 
  curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo
 
  curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > repo
 
  chmod a+x repo
 
  chmod a+x repo
  ./repo init -u git://github.com/NVIDIA/tegra-uboot-flasher-manifests.git -g default,-bootloader
+
  /usr/bin/python2 ./repo init -u git://github.com/NVIDIA/tegra-uboot-flasher-manifests.git -g default,-bootloader
  ./repo sync
+
  /usr/bin/python2 ./repo sync
  sudo emerge crypto++ libusb
+
  sudo emerge crypto++ libusb dtc
 
  cd tegrarcm
 
  cd tegrarcm
 
  ./autogen.sh
 
  ./autogen.sh
Line 21: Line 23:
 
  git clone https://github.com/swarren/u-boot
 
  git clone https://github.com/swarren/u-boot
 
  cd scripts
 
  cd scripts
  CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- PATH=${PATH}:~/jetson/tegra-uboot-flasher/tegrarcm/src/:/home/steev/sandbox/jetson/tegra-uboot-flasher/cbootimage/src/ ./build  --boards jetson-tk1 build
+
  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
  
 
<put board into "fastboot" mode - hold down force recovery button and hit reset if it's on, power button otherwise, then release force reset)>
 
<put board into "fastboot" mode - hold down force recovery button and hit reset if it's on, power button otherwise, then release force reset)>
Line 59: Line 61:
 
  sudo $EDITOR /mnt/gentoo/etc/inittab
 
  sudo $EDITOR /mnt/gentoo/etc/inittab
 
  s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100
 
  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.
 
Let's build a kernel - so many to choose from... I chose Thierry Reding's tree.
Line 64: Line 68:
 
* swarren: https://github.com/swarren/linux-tegra.git (tegra_dev branch)
 
* swarren: https://github.com/swarren/linux-tegra.git (tegra_dev branch)
 
   
 
   
* treding: https://git.gitorious.org/thierryreding/linux.git (master should be fine)
+
* 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-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)
Line 70: Line 74:
 
* 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)
 
* 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!
+
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
 
  cd ~/jetson
  git clone https://git.gitorious.org/thierryreding/linux.git
+
  git clone git://people.freedesktop.org/~tagr/linux -b staging/master
 
  cd linux
 
  cd linux
 
  make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- tegra_defconfig
 
  make ARCH=arm CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- tegra_defconfig
  make -j $(grep -c processor /proc/cpuinfo)
+
  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/zImage /mnt/gentoo/boot/
 
  sudo cp arch/arm/boot/dts/tegra124-jetson-tk1.dtb /mnt/gentoo/boot/
 
  sudo cp arch/arm/boot/dts/tegra124-jetson-tk1.dtb /mnt/gentoo/boot/
Line 104: Line 109:
  
 
Now we create the boot.scr file.
 
Now we create the boot.scr file.
  sudo ./part-uuid.py /dev/sdb 2
+
  sudo /usr/bin/python2 ./part-uuid.py /dev/sdb 2
  ./gen-uboot-script.py --partuuid <uuid-output-from-part-uuid.py-command>
+
  /usr/bin/python2 ./gen-uboot-script.py --partuuid <uuid-output-from-part-uuid.py-command>
 
  sudo cp boot.scr /mnt/gentoo/boot
 
  sudo cp boot.scr /mnt/gentoo/boot
 
  sudo sync
 
  sudo sync
Line 114: Line 119:
  
 
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.
 
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

Latest revision as of 23:51, 29 June 2015

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

<put board into "fastboot" mode - hold down force recovery button and hit reset if it's on, power button otherwise, then release force reset)>

<connect serial port if it isn't already>


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 <wget latest hardfloat stage3 tarball>
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.

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 <uuid-output-from-part-uuid.py-command>
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