Jetson/Busybox RootFS

= 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:
 * Latest stable version of Busybox: http://www.busybox.net/
 * Sample Linux for Tegra filesystem AND Jetson TK1 Driver Packages: https://developer.nvidia.com/linux-tegra

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:
 *  for the path to the sample filesystem
 *  for the path to the Linux_for_Tegra folder
 * 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 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=/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 /rootfs/ mkdir dev etc lib proc tmp sys

Setting up /dev
Copy the dev folder from the sample filesystem to your filesystem cp -dpR /dev/* /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.

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/fstab: needed to mount your filesystem at bootime
 * 1) sample fstab:


 * /etc/inittab: parameters for the init process
 * 1) sample inittab:
 * sysinit:/etc/init.d/rcS


 * 1) Start an "askfirst" shell on the console
 * askfirst:-/bin/sh

tty2::askfirst:-/bin/sh tty3::askfirst:-/bin/sh tty4::askfirst:-/bin/sh tty4::respawn:/sbin/getty 38400 tty5 tty5::respawn:/sbin/getty 38400 tty6
 * 1) Start an "askfirst" shell on /dev/tty2-4
 * 1) /sbin/getty invocations for selected ttys
 * 1) Stuff to do when restarting the init process
 * restart:/sbin/init


 * 1) Stuff to do before rebooting
 * ctrlaltdel:/sbin/reboot
 * shutdown:/bin/umount -a -r
 * shutdown:/sbin/swapoff -a

Simply insert a single line into this file, for example: tegra-busybox
 * /etc/hostname: set the hostname of the machine


 * /etc/init.d/: Create this directory to make your init shell and add the following files

/etc/init.d/rcS /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)
 * 1) sample rcS
 * 2) ! /bin/sh


 * /etc/init.d/rc.nv

This file should be based off of nv.conf. You can find nv.conf within the /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 /sbin/ldconfig* /rootfs/sbin/

/usr/bin/tegra
 * /etc/ld.so.conf.d/nvidia-tegra.conf
 * 1) This file should only contain the following line:

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 /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 /etc/ sudo cp hosts group host.conf passwd shadow nsswitch.conf profile resolv.conf services /rootfs/etc/ IMPORTANT: Make sure users listed in /rootfs/etc/passwd are using /bin/sh and not /bin/bash

Install NVIDIA Drivers and Binaries
To do this: cd  sudo ./applied_binaries.sh NOTE: This assumes you have been assembling your filesystem within /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 /rootfs/usr/ sudo mkdir share cd share sudo mkdir udhcpc sudo cp -dpR /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.