NVIDIA Jetson TX1のご紹介
https://gyazo.com/3a593d49eafb1c3d42e6e2f48ac7c5cc
https://gyazo.com/6eb46c49dba4d52b07b2b3583c5d892a
2018年6月9日(土) 関西*BSDユーザ会 研究会
むとうたけし@関西*BSDユーザ会 (@610t)
http://scrapbox.io/BSD/NVIDIA Jetson TX1のご紹介
まずは使ってみてください
IP: 192.168.xxx.xxx 現地で埋めること
hostname: tegra-ubuntu.local
user: guest
passwd: guest610
sudo可 (ではなかったけど、その場で直したorz)
NVIDIA Tegra
ARM系の省電力統合型プロセッサ(SoC): Wikipedia
ARM CPUとGPU、2Dエンジン、HD動画のエンコーダ・デコーダ、オーディオ処理、画像処理など
不要な機能は個別に停止して、消費電力を抑える
組み込み用途 (スマホ,タブレット,車載など)
Nintendo Switch (Tegra X1改)
FreeBSDのコード使ってるとか
リカバリーモードで既にLinux動いてる
Nintendo Switchのチップ解剖から考えるデグレード版Tegra X1を選んだ理由
NVIDIAのTegraを採用する任天堂の新ゲーム機「Nintendo Switch」
GameFace Labs Head Mounted Console (Tegra X2)
Android VRもSteamVRも動く「Jetson TX2」搭載スタンドアロンVR HMD
Tegra X1
NVIDIA Tegra X1
ARM 64bit(A57 x 4 + A53 x 4)とCUDAコア(256)、2Dエンジン、HD動画のエンコーダ・デコーダ、オーディオ処理、画像処理のSoC
table: Tegra X1 spec
機能 詳細
GPU NVIDIA Maxwell 256コア GPU DX-12, OpenGL 4.5, NVIDIA CUDA®, OpenGL ES 3.1, AEP, Vulkan
CPU 64bit ARM® 4x A57 2MB L2 + 4x A53
VIDEO H.265, VP9 4K 60 fps ビデオ 4k H.265, 4k VP9, 4k H.264
POWER 20 nm SoC - TSMC 分離パワーレイル, 第4世代のクラスタスイッチング
ディスプレイ 4K x 2K @60 Hz, 1080p @120 Hz HDMI 2.0 60 fps, HDCP 2.2
評価ボードJetson TX1
https://gyazo.com/3a593d49eafb1c3d42e6e2f48ac7c5cc
Tegra X1用評価ボード (NVIDIA JETSON)
Jetson TX1 spec
table: Jetson TX1 spec
機能 詳細
SoC NVIDIA Tegra X1(4 x A57)+4 x A53, Maxwell(256 CUDAコア)
ビデオ 4K x 2K 30 Hz Encode (HEVC) 4K x 2K 60 Hz Decode (10bit Support)
メモリ 4 GB 64 bit LPDDR4 25.6 GB/s
Display 2x DSI, 1x eDP 1.4 / DP 1.2 / HDMI
カメラ 最大6カメラ (2 Lane) CSI2 D-PHY 1.1 (1.5 Gbps/Lane)
PCIe Gen 2 | 1x4 + 1x1
Storage 16 GB eMMC, SDIO(SD), SATA, USB
その他I/O UART, SPI, I2C, I2S, GPIO
USB USB 3.0 A, USB 2.0 micro-B
ネットワーク GbE, 802.11ac WLAN, Bluetooth
外形 50 mm x 87 mm (400pin Compatible Board-to-Board Connector)
電源 19V AC付属
評価ボードの価格
2018/05現在
NVIDIA 開発者向け限定キャンペーン: 25,900円!!(NVIDIA Jetson TX1 開発者キット SE)
NVIDIA開発者に対して、ひとり1台限り
NVIDIA Jetson アカデミックプログラム: 38,600円
教育機関向けに、1台限り
amazon.co.jp: 75,979円
Linux for TX1
リソース: Jetson Download Center
Linux for Tegra(L4T): Ubuntu 16.04 LTS aarch64
aptで入るソフトウエアは、若干少なめか?
eMMCへのOSインストールには (Ubuntu 64bit) Linux の母艦が必要
仮想マシンでも良い (VirtualBox+拡張パック(USB 2.0対応) on macOSなど)
code: shell
$ uname -a
Linux tegra-ubuntu 4.4.38-tegra #1 SMP PREEMPT Thu Jul 20 00:41:06 PDT 2017 aarch64 aarch64 aarch64 GNU/Linux
Jetson Developer Kit
L4TをeMMCにインストールするのに利用
作業ディレクトリ: <top>/64_TX1/Linux_for_Tegra_64_tx1/
TX1をRecoveryモードにして使用
電源スイッチを押す
RECOVERY FORCE ボタンを押し続ける
RECOVERY FORCEボタンを押したままで、RESETボタンを押して離す
2秒待って、RECOVERY FORCEボタンを離す
flash.sh で、bootloaderだけの書き換えなども可
-L bootloader: bootloaderを書き込む
bootloader for TX1
標準u-boot bootloader
コレのどれか?: <l4t_top>/bootloader/t210ref/p2371-2180/u-boot*
code: shell
% cd <l4t_top>/bootloader/t210ref/p2371-2180/
% file *.bin
u-boot-dtb.bin: PCX ver. 2.5 image data bounding box 8223, 54531 - 0, 32776, 20-bit uncompressed
u-boot.bin: PCX ver. 2.5 image data bounding box 8223, 54531 - 0, 32776, 20-bit uncompressed
NetBSD pkgsrc/sysutils/u-boot-jetson-tx1
code: shell
% cd /usr/pkg/share/u-boot/jetson-tx1/
% file u-boot*
u-boot: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, with debug_info, not stripped
u-boot-dtb.bin: PCX ver. 2.5 image data bounding box 8223, 54531 - 0, 32785, 20-bit uncompressed
標準u-boot bootloader
U-Boot User Guide
設定ファイルは/boot/extlinux/extlinux.conf
設定例: <l4t_top>/bootloader/t210ref/p2371-2180/extlinux.conf*
ブート時の様子
http://sacraya.610t.org/scrapbox/BSD/TX1/tx1-serial.20180530.txt
code: u-boot
U-Boot 2016.07-g0ce7ca2 (Jul 20 2017 - 00:37:03 -0700)
TEGRA210
Model: NVIDIA P2371-2180
Board: NVIDIA P2371-2180
DRAM: 4 GiB
MC: Tegra SD/MMC: 0, Tegra SD/MMC: 1
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 2 1 0
MMC: no card present
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
223 bytes read in 86 ms (2 KiB/s)
p2371-2180 eMMC boot options
1: primary kernel
Enter choice: 1: primary kernel
Retrieving file: /boot/initrd
0 bytes read in 46 ms (0 Bytes/s)
Retrieving file: /boot/Image
20984368 bytes read in 528 ms (37.9 MiB/s)
append: root=/dev/mmcblk0p1 rw rootwait console=ttyS0,115200n8 console=tty0 OS=l4t fbcon=map:0 net.ifnames=0 androidboot.modem=none androidboot.serialno=03223160898180008106 androidboot.security=non-secure tegraid=21.1.2.0.0 ddr_die=2048M@2048M ddr_die=2048M@4096M section=256M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 debug_uartport=lsport,0 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff2bf000 nvdumper_reserved=0xff23f000 core_edp_mv=1125 core_edp_ma=4000 gpt android.kerneltype=normal androidboot.touch_vendor_id=0 androidboot.touch_panel_id=63 androidboot.touch_feature=0 androidboot.bootloader=00.00.2014.50-t210-fadd1be5 androidboot.verifiedbootstate=orange root=/dev/mmcblk0p1 rw rootwait
## Flattened Device Tree blob at 83100000
Booting using the fdt blob at 0x83100000
reserving fdt memory region: addr=80000000 size=20000
Using Device Tree in place at 0000000083100000, end 00000000831aee90
Starting kernel ...
標準u-boot bootloaderの 環境変数(抜粋)
設定の利用順
起動デバイス: mmc1, mmc0, usb0, pxe, dhcp
(主な)設定ファイル:{/,/boot}/extlinux/extlinux.conf, {/,/boot}/boot.scr
設定ファイルは、起動デバイスから順に読みこまれる
DTB: / /dtb/ /dtb/current/
http://sacraya.610t.org/scrapbox/BSD/TX1/tx1-serial.20180605.txt
code: shell
Tegra210 (P2371-2180) # printenv 
### 順番を並べ替えたり、削除したり編集済
# ボード基本情報
cpu=armv8
arch=arm
soc=tegra210
vendor=nvidia
board=p2371-2180
board_name=p2371-2180
# u-boot 入出力
stderr=serial
stdin=serial
stdout=serial
baudrate=115200
bootdelay=2
# ブートデバイス/設定関連
boot_targets=mmc1 mmc0 usb0 pxe dhcp
boot_prefixes=/ /boot/
boot_scripts=boot.scr.uimg boot.scr
boot_script_dhcp=boot.scr.uimg
bootcmd=run distro_bootcmd
efi_dtb_prefixes=/ /dtb/ /dtb/current/
# アドレス関連
kernel_addr_r=0x80080000
loadaddr=0x80080000
initrd_high=ffffffffffffffff
scriptaddr=0x90000000
fdt_addr=83100000
fdt_addr_r=0x82000000
fdt_high=ffffffffffffffff
fdtcontroladdr=fc82bba0
# ブートコマンド
cbootargs=root=/dev/mmcblk0p1 rw rootwait console=ttyS0,115200n8 console=tty0 OS=l4t fbcon=map:0 net.i12/1683 androidboot.modem=none androidboot.serialno=03223160898180008106 androidboot.security=non-secure tegraid=21.1.2.0.0 ddr_die=2048M@2048M ddr_die=2048M@4096M section=256M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 debug_uartport=lsport,0 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff2bf000 nvdumper_reserved=0xff23f000 core_edp_mv=1125 core_edp_ma=4000 gpt android.kerneltype=normal androidboot.touch_vendor_id=0 androidboot.touch_panel_id=63 androidboot.touch_feature=0 androidboot.bootloader=00.00.2014.50-t210-fadd1be5 androidboot.verifiedbootstate=orange
Jetson TX1 Graphic demo
https://github.com/NVIDIAGameWorks/GraphicsSamples
ドキュメント: GraphicsSamples/blob/master/doc/
README.md のリンクは切れてるorz
Binary: GraphicsSamples/samples/bin/linux-aarch64/
NVIDIAGameWorks/GraphicsSamplesデモ一覧
build
code: shell
$ cd GraphicsSamples/samples/build/linux-aarch64
$ make
https://gyazo.com/c2342627065581dc8f2b02eeed991134
面白そうなもの
TerrainTessellation: 山並みを飛行する
SkinningApp: 手を振り走るおっさん
ThreadedRenderingGL: 魚の群れ
Bloom: 宇宙船
ComputeParticles: 炎のようなパーティクル拡散
おまけ:SD用にL4T環境を構築する
参考: Jetson TX1 でUSB3.0につないだSSDからUbuntuをBootしてみる。
必要なファイル (2018/05/30現在) from Jetson Download Center
L4T Jetson TX1 Driver Package: Tegra210_Linux_R28.2.0_aarch64.tbz2
L4T Sample Root Filesystem: Tegra_Linux_Sample-Root-Filesystem_R28.2.0_aarch64.tbz2
SDにファイルシステムを構築
code: shell
$ sudo fdisk /dev/mmcblk1
Command (m for help): p
Disk /dev/mmcblk1: 29.7 GiB, 31914983424 bytes, 62333952 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/mmcblk1p1 2048 62333951 62331904 29.7G 83 Linux
$ sudo mkfs.ext4 /dev/mmcblk1p1
rootfsを作成
code: shell
$ tar jzxvf ~/Tegra210_Linux_R28.2.0_aarch64.tbz2
$ sudo mount /dev/mmcblk1p1 Linux_for_Tegra/rootfs
$ cd Linux_for_Tegra/rootfs
$ sudo tar jzxvf ~/Tegra_Linux_Sample-Root-Filesystem_R28.2.0_aarch64.tbz2
$ cd ..
$ sudo ./apply_binaries.sh
extlinux.confを修正、または追加
code: /boot/extlinux/extlinux.conf
LABEL SD
MENU LABEL SD kernel
LINUX /boot/Image
INITRD /boot/initrd
APPEND ${cbootargs} root=/dev/mmcblk1p1 rw rootwait
むとうの起こしたトラブル at L4T
工場出荷環境でapt upgradeしたら、立ち上がらなくなった
→再インストール
VirtualBoxのUSBが1.0だったので、システム初期化に死ぬほど時間がかかった
→USB 2.0にするには拡張パックが必要
adduserや設定GUIでユーザ足したら、Xが使えない
とりあえずnvidiaユーザを使う
extlinux.confの書き間違いでブートしない
→バックアップから起動
BluetoothキーボードがCUI設定でつながらない
→設定GUI使ったらいけた
SD環境では無線LANが使えない
→eMMCの環境全部コピーしたらOK
BSD for Tegra
NetBSD
8.0から: NetBSD/evbarm on NVIDIA Tegra
Tegra X1(64bit), K1(32bit)
framebufferのXまで動くらしい
簡単インストール: http://www.invisible.ca/arm/
FreeBSD
11Rから: What's new for FreeBSD 11
Tegra K1 (FreeBSD on Jetson TK1)
NetBSD for Jetson TX1
むとうは、動かせてませんorz
@jmcwhatever's tweet
1) Flash U-Boot from pkgsrc using Linux4Tegra tools (flash.sh)
2) Build release from https://github.com/ryo/netbsd-src branch rpi64wip .
rpi64wipからNetBSD currentにマージ済み (aarch64 support added)
3) dd arm64.img to SD card.
4) Power on board.
NeBSDを動かせていない、 むとうのいいわけ
オリジナルのL4Tはすぐ使える状況で残したい
NetBSDでは、多分、まだCUDAとか使えない
XでGPUを使うことはできるみたい
NetBSD用のU-bootで、L4Tブートできる?
今日のプレゼン用のマシンが無いと困るじゃん?
u-bootを書き換えたい気持ちをぐっと我慢
とりあえず、invisible SD挿してみた
標準u-bootのままで、の Generic 64-bit image (Tegra X1, Raspberry Pi 3用) NetBSD SDイメージ (201805291230Z) を挿してみたら…
boot環境まわり全く変えてないのに、勝手にNetBSDがbootしようとしてる!!
dtb: /dtb/tegra210-p2371-2180.dtb
boot.scrは使わないで/extlinux/extlinux.confを使う
https://drive.google.com/open?id=1YUyBoVIh2lcTVmDxfm4wOKwbmGzupwsw
code: shell
U-Boot 2016.07-g0ce7ca2 (Jul 20 2017 - 00:37:03 -0700)
TEGRA210
Model: NVIDIA P2371-2180
Board: NVIDIA P2371-2180
DRAM: 4 GiB
MC: Tegra SD/MMC: 0, Tegra SD/MMC: 1
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: No ethernet found.
Hit any key to stop autoboot: 2 1 0
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /extlinux/extlinux.conf
Retrieving file: /extlinux/extlinux.conf
reading /extlinux/extlinux.conf
243 bytes read in 15 ms (15.6 KiB/s)
NetBSD/arm64 boot options
1: NetBSD/arm64
Enter choice: 1: NetBSD/arm64
Retrieving file: /netbsd.img
reading /netbsd.img
8547460 bytes read in 389 ms (21 MiB/s)
append: root=ld0a console=fb
Retrieving file: /dtb/tegra210-p2371-2180.dtb
reading /dtb/tegra210-p2371-2180.dtb
59239 bytes read in 22 ms (2.6 MiB/s)
## Flattened Device Tree blob at 82000000
Booting using the fdt blob at 0x82000000
Using Device Tree in place at 0000000082000000, end 0000000082011766
Starting kernel ...
1.0000000 ok
1.0000000 uboot: args 0x82000000, 0, 0, 0
1.0000000 NetBSD/evbarm (fdt) booting ...
1.0000000 FDT /memory 0 @ 0x80000000 size 0x7ee00000
1.0000000 FDT /memory 1 @ 0x100000000 size 0x80000000
1.0000000 MEM: add 80000000-fee00000
1.0000000 MEM: add 100000000-180000000
1.0000000 MEM: res 82000000-8200f000
1.0000000 Usable memory:
1.0000000 80000000 - 81ffffff
1.0000000 8200f000 - fedfffff
1.0000000 100000000 - 17fffffff
1.0000000 initarm: kernel phys start 80000000 end 80827000
1.0000000 MEM: res 80000000-80827000
1.0000000 bootargs: root=ld0a console=fb
1.0000000 80827000 - 81ffffff
1.0000000 8200f000 - fedfffff
1.0000000 100000000 - 17fffffff
1.0000000 ------------------------------------------
1.0000000 kern_vtopdiff = 0xffffffbf80000000
1.0000000 physical_start = 0x0000000080000000
1.0000000 kernel_start_phys = 0x0000000080000000
1.0000000 kernel_end_phys = 0x0000000080827000
1.0000000 physical_end = 0x0000000081fff000
1.0000000 VM_MIN_KERNEL_ADDRESS = 0xffffffc000000000
1.0000000 kernel_start_l2 = 0xffffffc000000000
1.0000000 kernel_start = 0xffffffc000000000
1.0000000 kernel_end = 0xffffffc000827000
1.0000000 kernel_end_l2 = 0xffffffc000a00000
1.0000000 (kernel va area)
1.0000000 (devmap va area)
1.0000000 VM_MAX_KERNEL_ADDRESS = 0xffffffffffe00000
1.0000000 ------------------------------------------
1.0000000 panic: kernel debugging assertion "bootconfig.dramblocks <= DRAM_BLOCKS" failed: file "/home/source/ab/HEAD/src/sys/arch/aarch64/aarch64/aarch64_machdep.c", line 198
1.0000000 cpu0: Begin traceback...
1.0000000 trace fp ffffffc00000ab80
address 0xffffffc00000ab80 is invalid
address 0xffffffc00000ab88 is invalid
1.0000000 cpu0: End traceback...
Stopped in pid 0.1 (system) at ffffffc0000553a4: address 0xffffffc0000553
a4 is invalid
.insn 0x00000000 # undefined
db>
code: sys/arch/aarch64/aarch64/aarch64_machdep.c
% cat -n sys/arch/aarch64/aarch64/aarch64_machdep.c|head -205|tail -15
191 memsize_total = 0;
192 kstartp = atop(kernstart_phys);
193 kendp = atop(kernend_phys);
194
195 KASSERT(bp != NULL || nbp == 0);
196 KASSERT(bp == NULL || nbp != 0);
197
198 KDASSERT(bootconfig.dramblocks <= DRAM_BLOCKS);
199 for (i = 0; i < bootconfig.dramblocks; i++) {
200 paddr_t start, end;
201
202 /* empty is end */
203 if (bootconfig.drami.address == 0 &&
204 bootconfig.drami.pages == 0)
205 break;
ブートしない状態の起動スクリプト
症状は全く同じ
code: /extlinux/extlinux.conf
menu title Jetson TX1 boot options
timeout 30
label NetBSD/arm64
kernel /netbsd.img
fdtdir /dtb
append root=ld0a console=fb
code: /boot.txt
setenv bootargs root=ld0a
fatload mmc 1:1 0x90000000 netbsd.img
fatload mmc 1:1 ${fdt_addr_r} dtb/tegra210-p2371-2180.dtb
fdt addr ${fdt_addr_r}
booti 0x90000000 - ${fdt_addr_r}
NetBSDがブートしない原因はなに?
現状、invisibleのイメージをSDに書いて入れると、kernelを読み込んでbootするけどpanic
u-boot周りに原因?
設定が足りない?
/extlinux/extlinux.confと/boot.scr、どちらを使っても症状は一緒
TIP: /boot.scrを使うときは、起動スクリプトの検索パスからextlinux.confを外す
NetBSDのu-bootで無いとbootできない?
思いあまってSDにu-bootを書き込んだら、kernelブートすらしなくなった
このkernelで、TX1はブートできるの?
Rapberry Pi 3(同じSDイメージ)やNanoPi NEO2ではブートできてる
TODO
NetBSD for TX1
ARM 64 bit (aarch64) でXorgまでちゃんと動かす
Squeak/Scratch動かす
L4T
3軸加速度センサー付きのColdfire基板で、OpenGLグルグル
Deep LearningのcuDNNでなんかする
Q&Aとか、補足とか
結構大きくない?
Tegra X1 SoC自体はそれほど大きくない
別の拡張ボードJ120などを使えば、Raspberry Piよりコンパクトに (高さは別)
FreeBSDのpciconf的なものは、Linuxではなんになるんだろうか?
/sys/, /proc/, /dev/とか眺めたけど、よくわかんない
とりあえず、dmesg眺めて、所望の情報を得る
L4Tでの開発言語は?
CとかC++。多分、Pythonとかも使えると思う
CUDA、TensorRT、cuDNNとか、GPUを使えるライブラリは色々ある
#KBUG #FreeBSD #NetBSD #TX1