Difference between revisions of "Jetson/Busybox RootFS"

From eLinux.org
Jump to: navigation, search
m (Added an extra line of padding)
(Added a comment about CUDA on Busybox)
 
Line 198: Line 198:
 
sudo ./flash.sh  jetson-tk1 mmcblk0p1
 
sudo ./flash.sh  jetson-tk1 mmcblk0p1
 
</pre>
 
</pre>
 +
 +
 +
= CUDA on Busybox =
 +
CUDA does work with Busybox, but probably not uclibc, so to run CUDA code on Busybox, you can statically link to libc.

Latest revision as of 22:39, 29 April 2015

Introduction

This wiki will take you through the steps required to create and flash a simple BusyBox filesystem for the Jetson TK1. A root filesystem must contain everything needed to support a BusyBox-based system. For this to run, it must include the minimum requirements:

  • Basic set of utilities: init sh, ls, cp, mv, etc. that are from BusyBox,
  • Minimum set of directories: /bin, /sbin, /usr, /dev, /proc, /etc, /lib, /tmp, /sys
  • Minimum set of config files: rc, inittab, fstab, etc.,
  • Devices: /dev/mmcblk*, /dev/tty*, /dev/fb0, etc.,
  • Runtime library to provide basic functions and applications.


Populating the Filesystem

Before we begin, you will need to have obtained three packages:

Extract the Driver Packages, and it should produce a folder called Linux_for_Tegra. Next, extract the sample filesystem and BusyBox into their own separate directories. From now on we will refer to these paths as:

  • <sampleFS path> for the path to the sample filesystem
  • <L4T path> for the path to the Linux_for_Tegra folder
  • <busybox path> for the path to the BusyBox folder

Busybox Utilities

To get Busybox to work we will need to make a static build and then install it to our rootfs, which will populate the /bin, /sbin, and /usr folders.

cd <busybox path>
make menuconfig

NOTE: You will need to have ncurses installed for menuconfig to work

After running "make menuconfig" select Busybox Settings --> Build Options. Within Build Options, check "Build BusyBox as a static binary" using the 'Y' key. Next, set "Cross Compiler prefix" to arm-linux-gnueabihf-

Exit the menu, and be sure to save your changes.

make
make install CONFIG_PREFIX=<L4T path>/rootfs/

Required Directories

A few directories are required for the system to work properly. Travel to the L4T rootfs folder and observe that /bin, /sbin, and /usr have already been made from the Busybox install. Now we need to make the rest of them.

cd <L4T path>/rootfs/
mkdir dev etc lib proc tmp sys

Setting up /dev

Copy the dev folder from the sample filesystem to your filesystem

cp -dpR <sampleFS path>/dev/* <L4T Path>/rootfs/dev/

OPTIONAL: If you have specific devices you wish to run on the BusyBox system, make a device node for it with mknod or add a udev rule.

Setting up /etc

In the etc directory of rootfs will need to assemble some required files.

  • /etc/fstab: needed to mount your filesystem at bootime
##sample fstab: 
proc  /proc proc  defaults  0 0
none  /tmp  ramfs defaults  0 0
mdev  /dev  ramfs defaults  0 0
sysfs /sys  sysfs defaults  0 0
  • /etc/inittab: parameters for the init process
##sample inittab: 
::sysinit:/etc/init.d/rcS
# Start an "askfirst" shell on the console
::askfirst:-/bin/sh
# Start an "askfirst" shell on /dev/tty2-4
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh
# /sbin/getty invocations for selected ttys
tty4::respawn:/sbin/getty 38400 tty5
tty5::respawn:/sbin/getty 38400 tty6
# Stuff to do when restarting the init process
::restart:/sbin/init
# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
  • /etc/hostname: set the hostname of the machine

Simply insert a single line into this file, for example:

tegra-busybox
  • /etc/init.d/: Create this directory to make your init shell and add the following files

/etc/init.d/rcS

##sample rcS
#! /bin/sh
/bin/hostname -F /etc/hostname
/bin/mount -a
/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug #enable udev
/sbin/mdev -s
/etc/init.d/rc.nv
/etc/init.d/rc.local #make your local init shell (optional line)
  • /etc/init.d/rc.nv

This file should be based off of nv.conf. You can find nv.conf within the <L4T path>/nv_tegra/config.tbz package at /etc/init/nv.conf

Copy all the contents in between (but not including) script and end script.

NOTE: Lines 90-97 of nv.conf - dpkg do not exist. Therefore, delete the lines:

ARCH=`/usr/bin/dpkg --print-architecture`
if [ "x${ARCH}" = "xarm64" ]; then
	LIB_DIR="/usr/lib/aarch64-linux-gnu/tegra"
elif [ "x${ARCH}" = "xarmhf" ]; then
	LIB_DIR="/usr/lib/arm-linux-gnueabihf/tegra"
else
	LIB_DIR="/usr/lib/arm-linux-gnueabi/tegra"
fi

And replace with only:

LIB_DIR="/usr/lib/arm-linux-gnueabihf/tegra"
  • /etc/init.d/rc.local: For creating your local init shell

This file can be completely empty.

  • /etc/ld.so.conf.d/: This folder can be used to make your lib config files

You can call "ldconfig" in your init shell to update ld.so.cache at first boot. In order to use the ldconfig tool you will need to copy it.

cp -dpR <sampleFS path>/sbin/ldconfig* <L4T path>/rootfs/sbin/
  • /etc/ld.so.conf.d/nvidia-tegra.conf
## This file should only contain the following line:
/usr/bin/tegra

IMPORTANT: Make sure all of the files you have created have execute permissions enabled so that they can be run upon init. For example:

chmod +x <L4T path>/rootfs/etc/rc.nv 

Setting User Information

Copy these files to set up user information, as well as some other required files from /etc

cd <sampleFS path>/etc/
sudo cp hosts group host.conf passwd shadow nsswitch.conf profile resolv.conf services <L4T path>/rootfs/etc/

IMPORTANT: Make sure users listed in <L4T path>/rootfs/etc/passwd are using /bin/sh and not /bin/bash

Install NVIDIA Drivers and Binaries

To do this:

cd <L4T path>
sudo ./applied_binaries.sh

NOTE: This assumes you have been assembling your filesystem within <L4T Path>/rootfs/, as indicated by the instructions above. If you have been doing this elsewhere, give applied_binaries a -r flag to indicate where your rootfs is.

Configure UDHCPC

Instantiate the udhcpc folder

cd <L4T Path>/rootfs/usr/
sudo mkdir share
cd share
sudo mkdir udhcpc
sudo cp -dpR <busybox path>/examples/udhcp/simple.script udhcpc/default.script

Assemble common_libs

To do this:

cd <L4T Path>/rootfs/lib/
sudo mkdir arm-linux-gnueabihf
sudo cp -dpR <sampleFS path>/lib/arm-linux-gnueabihf/* arm-linux-gnueabihf/

Assemble user_toolsr_libs

To do this:

sudo cp <sampleFS path>/usr/bin/ldd <L4T path>/rootfs/usr/bin/ 


Flashing the Jetson

Now that we have assembled the filesystem, the Jetson is ready to be flashed. Make sure your board is in recovery mode by holding down the Force Recovery button while clicking the Reset button on the Jetson. Finally:

cd <L4T Path>
sudo ./flash.sh  jetson-tk1 mmcblk0p1


CUDA on Busybox

CUDA does work with Busybox, but probably not uclibc, so to run CUDA code on Busybox, you can statically link to libc.