2015年7月25日 星期六

How to re-flash your Jetson TK1 Development Kit

since: 2015/07/25
update: 2015/10/19

reference:
1. Jetson TK1 - eLinux.org
2. Jetson TK1 User Guide - Flashing Jetson
3. How to Reinstall the Original File System on Jetson TK1
4. Linux For Tegra Archive
5. Debian -- Package Search Results -- firmware-iwlwifi

A. 說明:

    1. 需要重新再安裝 Jetson TK1 檔案系統的原因:
        a.  Jetson TK1 原本的檔案系統被弄亂了(甚至開機後, 無法進入系統 ---> 我啦)
        b. 想要提升 Jetson TK1 在 eMMC(Embedded MultiMediaCard:嵌入式多媒體卡)
            的可用空間. 16GB 的容量預設只能使用 8GB 或 12 GB.

            備註: 見上篇的結果:

    2. 需要有一台主機是跑 Linux 系統, 用來製作要給 Jetson TK1 的檔案系統.
        我是在 Mac 上的 Parallels 安裝 Ubuntu Linux.

    3. 重新安裝 Jetson TK1 的檔案系統, 大約需要一小時的時間來寫入 eMMC,
        並且會清除 Jetson TK1 上所有的資料.

-----------------------------------------------------------------------------------------------

B. 在 Mac 上安裝 Ubuntu Linux:
     1. 目前使用的版本: ubuntu-14.04.2-desktop-amd64.iso    

     2. Parallels 上的設定:
         a. 硬體 > USB 與藍牙 > USB 連結偏好設定...

         b. 設備 > 當檢測到新的外部設備時: 連接到運行的虛擬機器

         c. 配置完成 > 繼續

     3. 登入 Ubuntu (pass: pipixxxx)後, 打開 Terminal

-----------------------------------------------------------------------------------------------

C. 在 Ubuntu 上製作要給 Jetson TK1 使用的檔案系統

     接續 B 的步驟:

     1. 建立工作目錄:
         $ mkdir tk1_reflash
         $ cd tk1_reflash 

     2. Linux For Tegra Archive 下載 Linux For Tegra R21.4 檔案:

         a. Jetson TK1:
             $ wget http://developer.download.nvidia.com/embedded/L4T/r21_Release_v4.0/Tegra124_Linux_R21.4.0_armhf.tbz2

         b. Sample File System:
             $ wget http://developer.download.nvidia.com/embedded/L4T/r21_Release_v4.0/Tegra_Linux_Sample-Root-Filesystem_R21.4.0_armhf.tbz2

     3. 解壓縮檔案:
         a. $ sudo tar xpf Tegra124_Linux_R21.4.0_armhf.tbz2
         b. $ cd Linux_for_Tegra/rootfs
         c. $ sudo tar xpf ../../Tegra_Linux_Sample-Root-Filesystem_R21.4.0_armhf.tbz2

     4. Apply binaries:
         a. $ cd ..
         b. $ sudo ./apply_binaries.sh

-----------------------------------------------------------------------------------------------

D. Write to eMMC over USB:
     1. 將 USB Micro-B 線一端連接 Jetson TK1, 另一端連接 Ubuntu Linux

     2. Puts  Jetson TK1 in recovery mode:
         在  Jetson TK1 上先按住 "RECOVERY" 鈕不放, 接著按一次 "RESET" 鈕,
         約 2 秒後放開"RECOVERY" 鈕.

     3. Verify board is connected by running:
         $ lsusb | grep -i nvidia

         You should see the following:  

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

     4. flash the Jetson TK1:
         $ sudo ./flash.sh -S 14580MiB jetson-tk1 mmcblk0p1


         說明: 完成後, Jetson TK1 會自動重新開機

     5. 開機完成後, 登入 Jetson TK1, 檢查可用容量:
         $ df -h

     6. 其它請參考上一篇: Get Started On NVIDIA Jetson TK1C, D, EF
-----------------------------------------------------------------------------------------------

E.
some post-install housekeeping
    1. check internet
        $
sudo ping google.com -c 4

    2. get correct time
        $
date       
        $
sudo ntpdate pool.ntp.org       
        $
date

    3. setup timezone
       
$ sudo dpkg-reconfigure tzdata

       Current default time zone: 'Asia/Taipei'
       Local time is now:      Sat Aug  1 18:25:50 CST 2015.
       Universal Time is now:  Sat Aug  1 10:25:50 UTC 2015.


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

    5.
check time on HW RTC
        $
sudo hwclock --debug

    6.
sync HW RTC to sysclock
        $
sudo hwclock -w

    7.
add automatic time update at startup
        $
sudo vi /etc/rc.local....
# By default this script does nothing.

# add automatic time update at startup

ntpdate-debian
hwclock -w


exit 0


    8.
add automatic time update to crontab
        $
sudo crontab -e
....
# m h  dom mon dow   command

5 * * * * ntpdate-debian
7 * * * * hwclock -w


    9. update and upgrade
        $ sudo apt-get update && sudo apt-get upgrade


   10. install useful packages
         $ sudo apt-get install git screen tree tcsh vim-gtk

   11. misc cleanup
         $ sudo apt-get autoclean
         $ sudo apt-get clean


-----------------------------------------------------------------------------------------------

F.
Installing Wireless Intel 7260 Adapter(Mini-PCIe)    
    1. 到
Debian -- Package Search Results -- firmware-iwlwifi        
        下載:
Binary firmware for Intel Wireless cards 0.43 (stable)     
                  ===>  檔名: firmware-iwlwifi_0.43_all.deb
                  ===>  直接在
Jetson TK1 上點二下安裝, 安裝好重新開機.

     2.新增 Wi-Fi 網路 


     3. 設定 SSID 與選取網卡的 MAC address

     4. 設定安全模式與連線密碼


-----------------------------------------------------------------------------------------------

G. Add CUDA bin Environment Variables    
    1. $ vi ~/.bashrc
....
# Add CUDA bin paths:
export CUDA_HOME=/usr/local/cuda-6.5
PATH=${CUDA_HOME}/bin:${PATH}
export PATH

# or: export PATH=/usr/local/cuda-6.5/bin:$PATH


    2. $ source ~/.bashrc

2015年7月23日 星期四

How to fix: Java(TM) Platform SE binary has stopped working

since: 2015/07/23
update: 2015/07/23

reference:
1. stack vs heap:執行時期儲存兩大要角
2. memory - Java default stack size - Stack Overflow
3. -X Command-line Options

A. 查詢目前 Java VM 的 stack 與 heap memory 的 space:
     1. stack memory:
         Thread stacks are memory areas allocated for each Java thread for their internal
         use. This is where the thread stores its local execution state.



     2. heap memory:
         The Java heap (the “heap”) is the part of the memory where blocks of memory
         are allocated to objects and freed during garbage collection.


         > java -XshowSettings:vm

-----------------------------------------------------------------------------------------------

B. 設定 stack 與 heap memory 的 space:
 
     1. 查詢設定參數:
         > java -X

         -Xms<size> 設定 Java 堆集(heap)大小上限
         -Xss<size> 設定 Java 執行緒堆疊(stack)大小

   2. 電腦 > 內容 > 進階系統設定:
       系統內容 > 進階 > 環境變數:

     3. 系統變數 > 新增:
         變數名稱: _JAVA_OPTIONS
         變數值: -Xss1M -Xmx2560M
         > 確定

         說明: 此處將 stack 設為 1 MB, max heap 設為 2560 MB

     4. 重新開機後, 檢查設定值:
         > java -XshowSettings:vm


2015年7月22日 星期三

Get Started On NVIDIA Jetson TK1

since: 2015/07/22
update: 2015/07/22

reference:
1. Getting Started with Jetson
2. Jetson TK1 - eLinux.org

A. Login Credentials

     Username:  ubuntu
     Password:  ubuntu

-----------------------------------------------------------------------------------------------

B. Installing the Linux Driver Binary
     1. Change directories into the NVIDIA installation directory:
         $ cd ${HOME}/NVIDIA-INSTALLER

     2. Run the installer script to extract and install the Linux drive r binary release:
         $ sudo ./installer.sh

     3. Reboot the system
         $ shutdown -h now

     NOTE: the installer.sh should only be run once.

-----------------------------------------------------------------------------------------------

C. An important step before connecting the Jetson to Internet
     It is really important to tell "apt" not to overwrite the file "libglx.so" if you
     upgrade the system. "libglx.so" is a specific file in NVIDIA's graphics driver
     that might get replaced by an incorrect version from Ubuntu that stops you
     from being able to boot into the graphical environment! So please execute
     this command on your Jetson before you connect it to Internet or perform
     an update:


     $ sudo apt-mark hold xserver-xorg-core

-----------------------------------------------------------------------------------------------

D. Recommended first steps now that your board has internet access
     1. Add the Universe package repositories, since you will often need packages
         from Universe for code development:


         $ sudo apt-add-repository universe
         $ sudo apt-get update

     2. If you will use the shell command-line a lot
         Install "bash-completion" (it allows you to hit the "Tab" key to auto-complete
         your shell commands) and "command-not-found" (it shows which package
         you probably need to install if you run an unavailable command).

         $ sudo apt-get install bash-completion command-not-found
         $ exit

     3. If you will use the graphical environment (Unity) a lot

         You might want to turn off the desktop shopping suggestions that are enabled
         by default in Ubuntu 14.04 (despite the spyware concerns discussed by huge
         numbers of people) by running this:

$ gsettings set com.canonical.Unity.Lenses disabled-scopes "['more_suggestions-amazon.scope', \
    'more_suggestions-u1ms.scope', 'more_suggestions-populartracks.scope', 'music-musicstore.scope', \
    'more_suggestions-ebay.scope', 'more_suggestions-ubuntushop.scope', 'more_suggestions-skimlinks.scope']"


-----------------------------------------------------------------------------------------------

E. Shutting down Jetson TK1 safely

    $ sudo shutdown -h now
-----------------------------------------------------------------------------------------------

F. 備註:
    1. 從 Ubuntu 的視窗模式開啟 Terminal

    2. 查詢 TK1IP:
        $ ifconfig


    3. 遠端 SSH 登入 TK1:
        $ ssh ubuntu@192.168.1.6

    4. 查詢 TK1 的容量記憶體:
        $ df -h
        $ free -h