Flashing the rootfs on a NVIDIA Jetson TK1

I some how managed to mess up the file system on my Jetson TK1 within 2 days of receiving it and decided to start afresh by flashing back to the original rootfs.

NVIDIA provides a quick start guide on how to do this here on its Linux for Tegra R19 webpage. I am essentially paraphrasing those instructions so that I can get this done quicker the next time. Since the instructions are specific to release version it is possible that they could change for the next release.


You will need:

  1. A Linux host PC with enough free space on which you will prepare the file system before flashing it to the eMMC on the TK1 board over USB.
  2. micro USB to USB cable (should be included with the Jetson TK1 kit)

Download the following two files into the same folder:

  1. Jetson TK1 board support package aka BSP (called Tegra124_Linux_R19.2.0_armhf.tbz2) from here.
  2. Sample file system file (called Tegra_Linux_Sample-Root-Filesystem_R19.2.0_armhf.tbz2) from here.
mkdir tk1_reflash
cd tk1_reflash
wget https://developer.nvidia.com/sites/default/files/akamai/mobile/files/L4T/Tegra124_Linux_R19.2.0_armhf.tbz2
wget https://developer.nvidia.com/sites/default/files/akamai/mobile/files/L4T/Tegra_Linux_Sample-Root-Filesystem_R19.2.0_armhf.tbz2

Extract the BSP tarball:

sudo tar xpf Tegra124_Linux_R19.2.0_armhf.tbz2

Extract the FS tarball into a particular sub directory:

cd Linux_for_Tegra/rootfs
sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R19.2.0_armhf.tbz2

Apply binaries:

cd ..
sudo ./apply_binaries.sh

The following output will be seen:

Using rootfs directory of: /home/you/tk1_reflash/Linux_for_Tegra/rootfs
Extracting the NVIDIA user space components to /home/you/tk1_reflash/Linux_for_Tegra/rootfs
Extracting the NVIDIA gst test applications to /home/you/tk1_reflash/Linux_for_Tegra/rootfs
Extracting the configuration files for the supplied root filesystem to /home/you/tk1_reflash/Linux_for_Tegra/rootfs
Creating a symbolic link nvgstplayer pointing to nvgstplayer-0.10
Adding symlink libcuda.so --> libcuda.so.1.1
Extracting the firmwares and kernel modules to /home/you/tk1_reflash/Linux_for_Tegra/rootfs
Installing the board *.dtb files into /home/you/tk1_reflash/Linux_for_Tegra/rootfs/boot

Write to eMMC over usb:

  1. Put your system into “reset recovery mode” by holding down the “RECOVERY” button and press “RESET” button once on the main board.
  2. Ensure your Linux host system is connected to the target device through the USB cable for flashing.

Verify that board was connected by running:

lsusb | grep -i nvidia

You should see the following:

Bus 002 Device 004: ID 0955:7140 NVidia Corp.

Next run the following command. I think the eMMC is supposed to the 16GiB, but I just used the exact command from the NVIDIA readme assuming that I should be able to resize it later.

sudo ./flash.sh -S 8GiB jetson-tk1 mmcblk0p1

UPDATE: The above command will leave space unused as pointed in the comments. To use all of the eMMC use “-S 14580MiB” (from: http://elinux.org/Jetson_TK1#If_you_need_more_disk_space_on_the_eMMC)

This should print something like the following and will take a loooong time:

copying dtbfile(/home/foobar/l4t/Linux_for_Tegra/kernel/dtb/tegra124-pm375.dtb) to tegra124-pm375.dtb... done.
Making system.img... 
 populating rootfs from /home/foobar/l4t/Linux_for_Tegra/rootfs... done.
 Sync'ing... done.
System.img built successfully. 
copying bctfile(/home/foobar/l4t/Linux_for_Tegra/bootloader/ardbeg/BCT/PM375_Hynix_2GB_H5TC4G63AFR_RDA_924MHz.cfg) to bct.cfg... done.
copying cfgfile(/home/foobar/l4t/Linux_for_Tegra/bootloader/ardbeg/cfg/gnu_linux_fastboot_emmc_full.cfg) to flash.cfg... done.
creating gpt(ppt.img)... 
*** GPT Parameters ***
device size -------------- 15766388736
bootpart size ------------ 8388608
userpart size ------------ 15758000128
Erase Block Size --------- 2097152
sector size -------------- 4096
Partition Config file ---- flash.cfg
Visible partition flag --- GP1
Primary GPT output ------- PPT->ppt.img
Secondary GPT output ----- GPT->gpt.img
Target device name ------- none
*** PARTITION LAYOUT(16 partitions) ***
[ BCT] BH 0 16383 8.0MiB 
[ PPT] UH 0 4095 2.0MiB ppt.img
[ PT] UH 4096 8191 2.0MiB 
[ EBT] UH 8192 16383 4.0MiB fastboot.bin
[ LNX] UH 16384 32767 8.0MiB boot.img
[ SOS] UH 32768 45055 6.0MiB 
[ GP1] UH 45056 49151 2.0MiB 
[ APP] UV 49152 16826367 8192.0MiB system.img
[ DTB] UV 16826368 16834559 4.0MiB tegra124-pm375.dtb
[ EFI] UV 16834560 16965631 64.0MiB 
[ USP] UV 16965632 16973823 4.0MiB 
[ TP1] UV 16973824 16982015 4.0MiB 
[ TP2] UV 16982016 16990207 4.0MiB 
[ TP3] UV 16990208 16998399 4.0MiB 
[ UDA] UV 16998400 30773247 6726.0MiB 
[ GPT] UH 30773248 30777343 2.0MiB gpt.img
copying bootloader(/home/foobar/l4t/Linux_for_Tegra/bootloader/ardbeg/fastboot.bin)... done.
Bootloader(/home/foobar/l4t/Linux_for_Tegra/bootloader/ardbeg/fastboot.bin) used as flasher.
Existing flash application(/home/foobar/l4t/Linux_for_Tegra/bootloader/nvflash) reused.
making zero initrd... 
Making Boot image... done
*** Flashing target device started. ***
./nvflash --bct bct.cfg --setbct --configfile flash.cfg --create --bl fastboot.bin --odmdata 0x6009C000 --go
Nvflash 4.13.0000 started
chip uid from BR is: 0x340010017408c1431c00000016018080
rcm version 0X400001
Skipping BoardID read at miniloader level
System Information:
 chip name: unknown
 chip id: 0x40 major: 1 minor: 1
 chip sku: 0x81
 chip uid: 0x000000017408c1431c00000016018080
 macrovision: disabled
 hdcp: enabled
 jtag: enabled
 sbk burned: false
 board id: 0
 warranty fuse: 0
 dk burned: true
 boot device: emmc
 operating mode: 3
 device config strap: 0
 device config fuse: 0
 sdram config strap: 3
RCM communication completed
BCT sent successfully
odm data: 0x6009c000
downloading bootloader -- load address: 0x80108000 entry point: 0x80108000
sending file: fastboot.bin
- 900492/900492 bytes sent
fastboot.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
ML execution and Cpu Handover took 1 Secs
Partition backup took 0 Secs
setting device: 2 3
deleting device partitions
creating partition: BCT
creating partition: PPT
creating partition: PT
creating partition: EBT
creating partition: LNX
creating partition: SOS
creating partition: GP1
creating partition: APP
creating partition: DTB
creating partition: EFI
creating partition: USP
creating partition: TP1
creating partition: TP2
creating partition: TP3
creating partition: UDA
creating partition: GPT
sending file: ppt.img
\ 2097152/2097152 bytes sent
ppt.img sent successfully
padded 4 bytes to bootloader
sending file: fastboot.bin
- 900496/900496 bytes sent
fastboot.bin sent successfully
sending file: boot.img
\ 5912576/5912576 bytes sent
boot.img sent successfully
sending file: system.img
/ 8589934592/8589934592 bytes sent
system.img sent successfully
sending file: tegra124-pm375.dtb
- 34723/34723 bytes sent
tegra124-pm375.dtb sent successfully
sending file: gpt.img
\ 2097152/2097152 bytes sent
gpt.img sent successfully
Create, format and download took 1515 Secs
Time taken for flashing 1516 Secs
*** The target ardbeg has been flashed successfully. ***
Reset the board to boot from internal eMMC.
~/l4t/Linux_for_Tegra >

And thats it, we are all done!
Reboot your board and try not to mess up the file system again.

UPDATE: Added a short list of things I like to do post-install.

# verify that start stop restart works
sudo poweroff
sudo reboot

#got net?
sudo ping google.com

# get correct time
sudo ntpdate pool.ntp.org

# setup timezone, select US/Pacific
sudo dpkg-reconfigure tzdata

# set sysclock, only if internet is down
#sudo date mmddhhmmyyyy.ss
#sudo date 050607002014

# check time on HW RTC
sudo hwclock --debug

# sync HW RTC to sysclock
sudo hwclock -w

# add automatic time update at startup and to crontab
sudo vi /etc/rc.local
# add the following lines
hwclock -w
# edit crontab for root
sudo crontab -e
# add following lines
5 * * * * ntpdate-debian
7 * * * * hwclock -w

# disable gui desktop and window manager
sudo mv /etc/init/lightdm.conf /etc/init/lightdm.conf.disabled
# from here: http://www.pathbreak.com/blog/ubuntu-startup-init-scripts-runlevels-upstart-jobs-explained

# enable universe in the apt source list
sudo vi /etc/apt/sources.list

# update and upgrade
sudo apt-get update && sudo apt-get upgrade

# install useful packages
sudo apt-get install git screen tree tcsh vim-gtk

# misc cleanup
sudo apt-get autoclean & sudo apt-get clean


RaspberryPi with SM5100b GSM GPRS cellular shield


I am going to try porting my PC python script for interfacing to the SM5100b directly to the RPi instead of converting it to an Arduino program.

UPDATE: Wow… it was easier than I thought it would be. I was able to quickly get to the same level of functionality as that previous post in less than an hour. Here is the push message posted to Prowl app using the cellular shield by a python script running on the Raspberry Pi.

Updates project files should show up on my github soon.


My RaspberryPi Config

Setup for first boot

I bought an 8GB micro SDHC card which came with a USB card reader and an SD adapter. I used the windows disk image writer for setting it up with the latest raspbian wheezy image.

Then I powered the card using a usb cable and used a ethernet cable to connect it to my router. I then setup my router to assign The RPi a reserved easy to remember IP address.

$ ssh pi@

On first login its best to setup the following config using your preferences.

pi@raspberrypi ~ $ sudo raspi-config

At this point I was using ~1.5GB of the card.

Please note that the following tidbits have been scraped from various parts of the internet and I did not really have to figure out any of this myself.

Here is a good index page from the embedded linux RPi wiki for quickly looking up information.


Installing Packages

Next I upgraded all the installed packages, this takes a while to finish.

$ sudo apt-get update ; sudo apt-get upgrade

The upgrade pushes the card upto ~1.6GB.

General packages

$ sudo apt-get install vim ctags tcsh screen tightvncserver python-setuptools git

Automatically Adjust Clock speeds – Save Power

$ sudo vi /boot/config.txt


Install the cpufrequtils package, which allows control over the CPU speed based on demand and reboot:

$ sudo apt-get install cpufrequtils
$ sudo cpufreq-set -g ondemand
$ cpufreq-info
  current CPU frequency is 100.0 MHz.

GPIO packages

$ sudo apt-get install python-dev
$ sudo apt-get install python-rpi.gpio

Packages for OS X screen and file sharing

$ sudo apt-get install netatalk avahi-daemon
$ sudo update-rc.d avahi-daemon defaults

Miscallaneous setup

OS X File and Screen sharing

$ sudo vim /etc/avahi/services/afpd.service
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
 <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 <name replace-wildcards="yes">%h</name>

$ sudo vim /etc/avahi/services/rfb.service
<?xml version="1.0" standalone='no'?>
 <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
 <name replace-wildcards="yes">%h</name>

Note that rfb port 5901 implies :1 display.

$ sudo /etc/init.d/avahi-daemon restart


sudo vim /etc/modules

and add these two lines to the end of the file:


Next for python support:

sudo apt-get install python-smbus
sudo apt-get install i2c-tools

And finally try the following to test:

sudo i2cdetect -y 1
sudo i2cdetect -y 0

Setup config files


 set expandtab "et"
 set sw=4 "shiftwidth"
 set smarttab "spaces for tabs ?"
 set ts=4 "tabstop
 set shiftround
 "Indentations and line numbers
 "set number "nu"
 set autoindent
 set cindent "ci"
 set incsearch "incremental search
 set hlsearch "highlight search
 "line break - causes word granularity wrapping
 set lbr
 set wrap
 syntax on
 syntax sync fromstart
 set foldmethod=indent
 filetype plugin indent on
 syntax enable
 "set invlist
 set showmatch "sm"
 set smartcase "scs no ignore case when pattern has uppercase
 set backspace=2 "bs how backspace works at start of line
 filetype on "filetype detection on
 "dont indent when pasting with middle clicks
 set paste
 " Make shift-insert work like in Xterm
 set nocompatible "dont emulate bugs
 " configure command line completion
 set wildmode=list:longest,full
 " setup status line
 set statusline=%F%m%r%h%w\ [%{&ff}]\ [%Y]\ [%07l,%07v][%p%%]\ [%L]
 set laststatus=2 " always show the status line


 set prompt="%~ %# "
 bindkey -v
 set history = 5000
 set savehist = (5000 merge)
 set histfile="$HOME/.tcsh_history"
 history -L
 # Make command history (arrow keys) use history search operations
 bindkey -k down history-search- forward
 bindkey -k up history-search-backward
 setenv MANPAGER less
 alias l ls -lh
 alias cls clear
 alias vi vim -p
 alias vim vim -p

Disable root ssh

$ sudo vi /etc/ssh/sshd_config

Change to following:

PermitRootLogin no

Measure Core Temperature

$ /opt/vc/bin/vcgencmd measure_temp

For other options possible with this command run:

$ /opt/vc/bin/vcgencmd commands

Serial port setup

Remove the following text from the /boot/cmdline.txt file:

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

And comment out the following from /etc/inittab file:
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

You also might want to install minicom for monitoring:

$ sudo apt-get install minicom

To setup the serial port packages required for use with python:

$ sudo easy_install pyserial

Reboot time

As per my rough measurement it takes around 90-120 seconds for the raspberry pi to be able to accept ssh connections after initiating a reboot. I suspect that this is partly because of my slowish class 4 memory card. I was getting much quicker boot times with the 45MBps UHS-I SD card from my camera.

Change hostname

Update it in the following files and reboot:

$ sudo vim /etc/hostname /etc/hosts

And lastly

Once you are happy with your config remember to make a backup img of your card which you can restore if anything goes wrong.
A useful suggestion I found here was to zero out the free space to get better compression.

# cat /dev/zero > /zeroes ; rm /zeroes

Kubuntu 12.04 broken with WUBI

WUBI or the Windows UBuntu Installer (rev 269) is not able to install Kubuntu 12.04 because the download link coded up in the app seems to be broken.

Looking at the output log file, C:\Users\<me>\AppData\Local\Temp\wubi-12.04-rev269.log I saw the following error:

09-03 16:30 ERROR CommonBackend: Cannot download metalink file http://releases.ubuntu.com/kubuntu/12.04/kubuntu-12.04-desktop-amd64.metalink err=[Errno 14] HTTP Error 404: Not Found

Searching around on google, it turns out that this is a known bug and the solution is to download the iso file and keep it in the same folder as the downloaded wubi.exe file.

I think the correct metalink file is meant to be the following:


I followed the instructions from the solution and got the kubuntu-12.04.1-desktop-amd64.iso file using the torrent and then the Kubuntu installation worked smoothly.