1/17/2019

Nvidia 개발환경-Nsight Tools (JetPack 3.3)

1. Nvidia의 Nsight 기본소개  

Nsight는 NVIDIA에서 제공하는 IDE Development Tool로 손쉽게 개발환경을 구축하는것을 도와준다.
현재 EVM Jetson TX2의 JetPack을 설치를 진행했다면, 기본으로 설치가 되어있으며, 본인이 별도로 원한다면 별도 설치도 가능한 것 같다.


Nsight Eclipse Edition
  https://developer.nvidia.com/nsight-eclipse-edition

Nsight Eclipse Edition 관련 Manual
  https://docs.nvidia.com/cuda/nsight-eclipse-edition-getting-started-guide/index.html#introduction
  https://docs.nvidia.com/cuda/nsight-eclipse-plugins-guide/index.html


1.1 JetPack 3.3 기능확인  

JetPack은 3.3 과 4.1.1 이 존재하지만  JetPack 4.1.1 아직 설치를 해보지 못했으며, 현재 JetPack 3.3만 설치를 진행을 한 상태이다.
JetPack은 Nvidia사에서 제공해주는 Host Development Tool 과 각 Device의 SDK로 구성이 되어있으며, 각 기능을 구분해서 잘 알아두자.

NVIDIA에서 JetPack에서는 Jetson TX2 SDK를 다음과 같은 기능 제공해준다.
자세한 내용은 Download 사이트와 Manual 참조
  • OS : Ubuntu  (L4T28.2.1)
  • Libraries : TensorRT/cuDNN / VisionWorks/ OpenCV /MultiMedia API 
  • Developer Tools

CUDA Tools
  https://developer.nvidia.com/debugging-solutions

Nsight Systems
  https://developer.nvidia.com/nsight-systems

Nsight Graphics
  https://developer.nvidia.com/nsight-graphics

TensorRT
  https://docs.nvidia.com/deeplearning/sdk/tensorrt-sample-support-guide/index.html
 https://github.com/NVIDIA-AI-IOT/tf_to_trt_image_classification#convert

Deep Learning SDK
  https://docs.nvidia.com/deeplearning/sdk/index.html


  https://ngc.nvidia.com/catalog/landing

  • JetPack Download
JetPack의 기능 및 Version 그리고 해당 보드 관련사항 확인
  https://developer.nvidia.com/embedded/jetpack

  • JetPack Manual 
상위정보들이 자세히 설명되어있으니, 반드시 확인
  https://docs.nvidia.com/jetson/jetpack/index.html

  • JetPack Archive
각 개별 JetPack Version들을 알아보자
  https://developer.nvidia.com/embedded/jetpack-archive


1.2 CUDA Toolkit 

NVIDIA에서는 CUDA Toolkit을 배포하고 있으며, 이안에는 NVCC/CUDA-GDB 및 개발환경이 구성이 되어있다.
TI처럼 NVIDIA의 Compiler 및  관련 Binutil을 별도로 제공하고 있으며,  Cross GCC의 개념으로 이해하면 될 것 같다.

NVIDIA에서는 CUDA관련된 Version에 이름이 존재하는 것 같으며 각각 Maxwell, Pascal 이 존재하는 것 같다.

CUDA Toolkit Version 별 배포
  https://developer.nvidia.com/cuda-toolkit-archive

CUDA Toolkit 및 NVCC 관련정보
  https://docs.nvidia.com/cuda/index.html

CUDA NVCC(CUDA Compiler) GDB 관련정보
  https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html
  https://docs.nvidia.com/cuda/cuda-gdb/index.html

1.3 NVIDIA 기타 개발툴 정보 

아직 사용해보지 못했으며, 추후 기회가 있다면 다시 검토를 해보자.

NVIDIA에서 제공하는 Developer Tools
  https://developer.nvidia.com/tools-overview

Nsight Visual Studio Edition
  https://developer.nvidia.com/nsight-visual-studio-edition

1.4 Jetson TX2의 Gstreamer 관련 정보 

추후 이부분은 python or command로 간단히 테스트를 진행을 해봐야 할 것 같으며, 간단히 간단히 테스트 한 후
관련기능을 따로 분리하여 기술한다.

Jetson Tx2 Gstreamer 관련정보
  https://developer.download.nvidia.com/embedded/L4T/r28_Release_v1.0/Docs/Jetson_TX2_Accelerated_GStreamer_User_Guide.pdf?fyfql6tLeytPjeEWlf9cmzFMS-kKyNcs3JrYDhp9oRT4q2MrtQc6r_NvoeMQIvlwddGG0FEeRTX3gIVF_qITlT_BmK9C5TZCxnc0dd3sKEZj0v8sykAGEozzCQB28U_3kajqqA4Sybn6tIz5v0CMBMkIHigbgTkBdh15DJf207mYxn35u8euwDWBM6SYyyE-Lw

2. Nsight Eclipse Edition 

JestsonTX2 개발환경에서 JetPack3.3 설치하여 자동으로 Ubuntu 16.04에  Nsight가 설치되었으며, 별도의 설치를 진행하지 않았다.

$ which nsight       // nsight 설치 위치 
/usr/local/cuda-9.0/bin/nsight

$ ls /usr/local/cuda-9.0/bin/
bin2c        cuda-gdb                     cuda-memcheck  cuobjdump            nsight                       nvcc.profile  nvprof   ptxas
computeprof  cuda-gdbserver               cudafe         fatbinary            nsight_ee_plugins_manage.sh  nvdisasm      nvprune
crt          cuda-install-samples-9.0.sh  cudafe++       gpu-library-advisor  nvcc                         nvlink        nvvp

$ nsight    // Nsight 실행 


별도의 설치를 한다면 상위 Nsight Eclipse Version 별도로 Download하여 설치를 추후 진행을 해보자.

Eclipse 기본사용법
  https://ahyuo.blogspot.com/search/label/IDE-Eclipse

Nsight Eclipse
  https://devblogs.nvidia.com/cuda-jetson-nvidia-nsight-eclipse-edition/


2.1 Nsight 의 TEST Program 작성 및 기본 TEST

현재 CUDA C/C++ Project는 문제가 없으므로, C/C++ 중심으로 테스트를 진행을 해본다.

File->New->C++ Project 실행













빌드 후 생성된 TEST ELF 파일을  sftp 이용하여 command 전송 후 테스트를 진행해 본다.


  • Host PC (Ubuntu 16.04) SFTP 전송 

$ cd ~/cuda-workspace/TEST/Debug/
$ ls 
TEST  makefile  objects.mk  sources.mk  src

$ readelf -a TEST | head    // ARM Version 인지 확인 
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AArch64
  Version:                           0x1


//SFTP 이용하여 TEST File 전송 

$ sftp nvidia@10.0.0.170   // JestonTx2 유선 연결 
or
$ sftp nvidia@192.168.55.2 // JetsonTx2 USB Ethernet 연결 

sftp> ls
Desktop                         Documents                       Downloads                       Music                           
NVIDIA_CUDA-9.0_Samples         Pictures                        Public                          Templates                       
Videos                          VisionWorks-SFM-0.90-Samples    examples.desktop                jetson_clocks.sh                
jhlee                           tegra_multimedia_api            tegrastats                      weston.ini  

sftp> put TEST 
Uploading TEST to /home/nvidia/TEST
TEST                                                                                           100%   67KB  67.4KB/s   00:00  

sftp> exit


  • HOST PC USB-ACM0 접속 

Host에서 USB ACM0 or USB CDC-ECM 으로 접속하여 Target에서 실행

$ sudo minicom -s   //ttyACM0 접속 

nvidia@tegra-ubuntu:~$ ./TEST
!!!Hello World!!!



2.2 SSH와  CUDA-GDB 이용하여 Debug 기능 설정  

Project Explorer창에서  TEST Project에서 우측 마우스 버튼을 클릭
  1. Run As->Run Configurations 선택  
  2. Debug As->Debug Configurations 선택 

  • Run Configuration 창 


Remote Connection의 우측 Manage 선택


Remote Connection 설정

이미 JetsonTx2의 usb0의 주소 192.168.55.2 설정됨
nvidia / ubuntu  두개의 ID 중 선택




상위 Remote toolkit을 아래와 같이 설정
/usr/local/cuda/bin




  • Run Configuration 설정확인




  • Run Configuration 의 CUDA-GDB -> Legacy Remote 변경 
현재 CUDA-GDB를 이용하고 있으며, 이를 일반적으로 변경을 원한다면  Run Configuration의 하단의

Using CUDA-GDB Remote Debugging Launcher- Select other 선택 


  • Debug Configuration 의 CUDA-GDB -> Legacy Remote 변경 
좀 더 다양한 기능을 제공하지만 현재 CUDA-GDB Remote Debugging Launcher만 작동
(일반 GDB와 통신지원이 되지 않는다)


GDB Remote
  http://sourceware.org/gdb/onlinedocs/gdb/Connecting.html
  https://sourceware.org/gdb/onlinedocs/gdb/Server.html
  https://www.hahwul.com/2015/11/debugging-gdb-using-gdb-for-remote.html


2.3  Remote Debug 및 BreakPoint 기능제공

상위에서 기본적으로 CUDA-GDB Remote 시스템으로 설정을 하면 아래와 같이 원격 Debug Mode가 작동이 되며,
Break Point 및 다양한 기능을 사용할 수 있다.

  • Break point 설정 
JTAG에서 제공하는 프로그램 처럼 GDB를 이용하여 프로그램의 Breakpoint를 사용하여 제어가 가능하다.




  • Debug Mode 실행확인 
  1. Project Explorer창에서  TEST Project에서 우측 마우스 버튼을 클릭
  2. Debug As->Remote C/C++ Application 선택 




아래의 영상은 CUDA C/C++를 이용하여 TEST를 진행을 하고 있으며, 이를 참조하여 Cuda도 적용해보자.
    https://www.youtube.com/watch?v=2Mi3MRKtg2M

예전에 GDB를 이용한 DDD처럼 각 기능을 Eclipse에서 사용할 수 있어 편했으며, Nsight의 기본기능확인이니,
세부기능인 Profiler / Memory Access / Disasemble/ Graph 기능 지원여부를 알아보도록하자.

TI에서 지원되는 것처럼 다 지원이 될 것 같은데, 다만 JTAG 대신 GDB을 이용하여 하기 때문에 기능제한이 있을 거라고 생각한다.

3. Tegra System Profiler (NVIDIA System Profiler)


$ cd ~/project/jetsonTX2   // Jetpack 3.3 설치장소 
$ cd  NVIDIA_System_Profiler
$ ls 
Host-x86_64  Target-arm  Target-arm-linux

$ cd Host-x86_64
$ ./SystemProfiler                // Tegra System Profiler  실행 

실행시 다음과 같이 실행

  • SSH를 이용하여 Jetson TX2 과 연결 



  • PID를 이용하여 Profile 진행 


상위에 지원되지 않는 Trace는 우측에 !로 표시되므로 관련부분은 미체크하고 실행


4.  NVIDIA Visual Profiler

Nsight Ecplise Edition에 포함되는 기능으로 개별적으로 실행이 가능하지만, 가급적 상위 Ecplise Edition으로 실행해서 사용하는 것이 좋다.


$ cd ~/project/jetsonTX2   // Jetpack 3.3 설치장소 
$ cd devtools_docs
$ ls 
NVIDIA System Profiler 4.0  Tegra Graphics Debugger 2.5     // 관련 Manual 참조 

  • 실행방법 
$ sudo /usr/local/cuda-9.0/bin/nvvp 



동일하게 SSH로 연결이 되지만 어떻게 사용하는 것인지는 매뉴얼을 자세히 봐야겠다.


관련메뉴얼
  https://docs.nvidia.com/cuda/profiler-users-guide/index.html#visual


5.  Tegra-Graphics-Debugger


  • 관련 설명서 참고 

$ cd ~/project/jetsonTX2   // Jetpack 3.3 설치장소 
$ cd devtools_docs
$ ls 
NVIDIA System Profiler 4.0  Tegra Graphics Debugger 2.5     // 관련 Manual 참조 

아직 필요성을 크게 느끼지 못해 사용하지 않고 있으며, 추후 자세한 기능을 알게된다면, 그때 다시 사용하도록 하자.


  • 실행방법 

$ sudo /usr/local/Tegra-Graphics-Debugger-2.5/nvidia-gfx-debugger 

//Error 
/usr/local/Tegra-Graphics-Debugger-2.5/nvidia-gfx-debugger.bin: error while loading shared libraries: libgstreamer-0.10.so.0: cannot open shared object file: No such file or directory

Ubuntu 16.04는 gstreamer 0.10을 현재 미지원
   https://github.com/toggl/toggldesktop/issues/1894

Gstreamer 0.10을 직접 Download
  https://devtalk.nvidia.com/default/topic/1026605/linux-graphics-debugger/error-loading-shared-libraries/

관련 메뉴얼
   https://developer.nvidia.com/tegra-graphics-debugger

1/16/2019

Jetson TX2 Jetpack3.3 설치 및 USB Device 관련사항

1. Jetson Tx2 Jetpack 설치 

회사일을 Jetson Tx2관련일을 하게되어 이에 관련된 일을 간단히 정리하고자 한다.
그리고, 인터넷에 오픈된 것만 관련하여 간단히 서술한다.

현재 Ubuntu는 16.04LTS이며, 아래와 같이 Jetpack 3.3 설치를 하며, 설치 방법도 EVM의 영문 매뉴얼을 참조하면 어느정도 이해를 할수 있다.

  • Jetson TX2 Jetpack 설치 정보 
현재 나의 경우는 JetPack L4T를 설치를 Force Recovery Mode를 이용하여 최종으로 설치한다음 아래와 같이 update와 upgrade를 진행했다.

$ sudo apt update && sudo apt upgrade -y 

아래의 부분은 Jetson TX2에서 진행을 했지만, 동작이 되지 않았다.

$ sudo ./jetson_clocks.sh
$ cd ~/tegra_multimedia_api/samples/backend
./backend 1 ../../data/Video/sample_outdoor_car_1080p_10fps.h264 H264 --trt-deployfile ../../data/Model/GoogleNet_one_class/GoogleNet_modified_oneClass_halfHD.prototxt --trt-modelfile ../../data/Model/GoogleNet_one_class/GoogleNet_modified_oneClass_halfHD.caffemodel --trt-forcefp32 0 --trt-proc-interval 1 -fps 10

관련정보
  https://judo0179.tistory.com/19


JetPack 3.3 Download
  https://developer.nvidia.com/embedded/jetpack

JetPack Manual
 https://docs.nvidia.com/jetson/jetpack/index.html
 https://docs.nvidia.com/jetson/jetpack/introduction/index.html
 https://docs.nvidia.com/jetson/jetpack/release-notes/index.html

  https://devblogs.nvidia.com/jetson-tx2-delivers-twice-intelligence-edge/

2. JetPack 설치 후 USB Device 정보 

Jetson TX2의 Jetpack 3.3 설치 후 아래와 같이 USB의 설정확인하였으며, 간단히 정리해본다.


일반적인 USB 정보 알아두자.
  https://ahyuo79.blogspot.com/2014/11/class-descriptor.html
  https://ahyuo79.blogspot.com/search/label/IF-USB

  • Host PC 확인  (JetsonTX2 USB 접속)
Jetpack 3.3 설치 후 아래와 같이 USB를 확인을 해보면 Nvidia 관련사항을 확인가능
좀더 자세히 분석하여 알아 보면 다음과 같다.

Jetson TX2의 USB Device Mode 일경우 지원사항
  1. USB Mass Storage :  USB CDC 관련 Manual 내용 
  2. USB CDC-ACM :  /dev/ttyACM0 으로 Serial로 쉽게 Login 가능 
  3. USB CDC-RNDIS:  USB를 통하여 Window의 RNDIS Ethernet 사용가능 
  4. USB CDC-ether:  USB CDC Ethernet이며 RNDIS와 같이 연동되는 것 같음  
결론적으로 USB Ethernet이 두개 지원가능하며, Serial도 지원가능 및 Mass Storage도 지원
Window에서는 Network는 상위 CDC-RNDIS만 지원될 것라고 생각함


USB CDC-Network Adapters (Kernel Config 사항) 
( Device Drivers - Network device support - USB Network Adapters)
CONFIG_USB_NET_CDCETHER
CONFIG_USB_NET_RNDIS_HOST
CONFIG_USB_NET_CDC_EEM
CONFIG_USB_NET_CDC_MBIM

USB CDC ACM (Kernel Config 사항)
( Device Drivers - USB support)
CONFIG_USB_ACM

**CDC-ACM은 Ethernet 기반의 Adapter가 아니므로 별도로 /dev/ttyACMx 존재하지만,
상위 Network Adapters들의 경우 별도의 /dev는 존재하지 않음 주의   

USB CDC 관련세부사항 
  https://en.wikipedia.org/wiki/Ethernet_over_USB
  http://processors.wiki.ti.com/index.php/Networking_over_USB


$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 007: ID 0955:7020 NVidia Corp. 
Bus 001 Device 003: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 001 Device 002: ID 045e:07f8 Microsoft Corp. Wired Keyboard 600 (model 1576)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

$ lsusb -t  // Host USB 와 Module 관련부분 확인 
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 9: Dev 7, If 0, Class=Communications, Driver=rndis_host, 480M
    |__ Port 9: Dev 7, If 1, Class=CDC Data, Driver=rndis_host, 480M
    |__ Port 9: Dev 7, If 2, Class=Communications, Driver=cdc_acm, 480M
    |__ Port 9: Dev 7, If 3, Class=CDC Data, Driver=cdc_acm, 480M
    |__ Port 9: Dev 7, If 4, Class=Mass Storage, Driver=usb-storage, 480M
    |__ Port 9: Dev 7, If 5, Class=Communications, Driver=cdc_ether, 480M
    |__ Port 9: Dev 7, If 6, Class=CDC Data, Driver=cdc_ether, 480M
    |__ Port 11: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 11: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 12: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M

$ lsusb -d 0955:7020 -v  // Jetson TX2 USB Descriptor 확인 

Bus 001 Device 004: ID 0955:7020 NVidia Corp. 
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.10
  bDeviceClass          239 Miscellaneous Device
  bDeviceSubClass         2 ?
  bDeviceProtocol         1 Interface Association
  bMaxPacketSize0        64
  idVendor           0x0955 NVidia Corp.
  idProduct          0x7020 
  bcdDevice            0.01
  iManufacturer           1 
  iProduct                2 
  iSerial                 3 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          248
    bNumInterfaces          7
    bConfigurationValue     1
    iConfiguration          4 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower                2mA
    Interface Association:
      bLength                 8
      bDescriptorType        11
      bFirstInterface         0
      bInterfaceCount         2
      bFunctionClass          2 Communications
      bFunctionSubClass       6 Ethernet Networking
      bFunctionProtocol       0 
      iFunction               7 
    Interface Descriptor:
....


  • Host PC에서 관련 Module Driver 확인 
사용되어지는 Module Driver를 알았으니, Depend를 알아보자.

$ lsmod        // Host PC Module 사용확인 
Module                  Size  Used by
rndis_wlan             57344  0
rndis_host             16384  1 rndis_wlan
cfg80211              622592  1 rndis_wlan
cdc_ether              16384  1 rndis_host
usbnet                 45056  3 rndis_wlan,rndis_host,cdc_ether
mii                    16384  1 usbnet
uas                    24576  0
usb_storage            69632  2 uas
cdc_acm                32768  2
pci_stub               16384  1
vboxpci                24576  0
vboxnetadp             28672  0
vboxnetflt             28672  0
vboxdrv               471040  3 vboxpci,vboxnetadp,vboxnetflt
binfmt_misc            20480  1
nls_iso8859_1          16384  2
snd_hda_codec_hdmi     49152  1
intel_rapl             20480  0
snd_hda_codec_realtek   106496  1
snd_hda_codec_generic    73728  1 snd_hda_codec_realtek
x86_pkg_temp_thermal    16384  0
intel_powerclamp       16384  0
coretemp               16384  0
kvm_intel             217088  0
kvm                   598016  1 kvm_intel
snd_hda_intel          40960  3
snd_hda_codec         126976  4 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec_realtek
irqbypass              16384  1 kvm
snd_hda_core           81920  5 snd_hda_codec_generic,snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek
snd_hwdep              20480  1 snd_hda_codec
snd_pcm                98304  4 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec,snd_hda_core
crct10dif_pclmul       16384  0
crc32_pclmul           16384  0
snd_seq_midi           16384  0
ghash_clmulni_intel    16384  0
snd_seq_midi_event     16384  1 snd_seq_midi
joydev                 24576  0
pcbc                   16384  0
input_leds             16384  0
aesni_intel           188416  0
aes_x86_64             20480  1 aesni_intel
snd_rawmidi            32768  1 snd_seq_midi
crypto_simd            16384  1 aesni_intel
snd_seq                65536  2 snd_seq_midi,snd_seq_midi_event
snd_seq_device         16384  3 snd_seq,snd_seq_midi,snd_rawmidi
glue_helper            16384  1 aesni_intel
snd_timer              32768  2 snd_seq,snd_pcm
cryptd                 24576  3 crypto_simd,ghash_clmulni_intel,aesni_intel
snd                    81920  17 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_pcm,snd_rawmidi
soundcore              16384  1 snd
intel_cstate           20480  0
intel_rapl_perf        16384  0
mei_me                 40960  0
shpchp                 36864  0
mei                    90112  1 mei_me
acpi_pad              180224  0
mac_hid                16384  0
parport_pc             36864  1
ppdev                  20480  0
lp                     20480  0
parport                49152  3 parport_pc,lp,ppdev
autofs4                40960  2
hid_generic            16384  0
usbhid                 49152  0
hid                   118784  2 usbhid,hid_generic
i915                 1630208  104
i2c_algo_bit           16384  1 i915
drm_kms_helper        172032  1 i915
syscopyarea            16384  1 drm_kms_helper
e1000e                249856  0
sysfillrect            16384  1 drm_kms_helper
sysimgblt              16384  1 drm_kms_helper
fb_sys_fops            16384  1 drm_kms_helper
ptp                    20480  1 e1000e
drm                   401408  6 drm_kms_helper,i915
pps_core               20480  1 ptp
ahci                   36864  3
libahci                32768  1 ahci
video                  45056  1 i915


  • Udev 관련부분 확인 
좀 더 자세히 알고 싶다면 USB와 같이 동작되는 Udev 관련부분을 찾아보자.
이 부분 까지 조사하지 않고 서술만 한다.

$ ls /lib/udev/rules.d/
39-usbmuxd.rules                     73-special-net-names.rules
40-crda.rules                        73-usb-net-by-mac.rules
40-usb-media-players.rules           75-net-description.rules
...

$ ls /sys/class/net/
enp0s20f0u9  enp0s20f0u9i5  enp0s31f6  lo

  https://wiki.archlinux.org/index.php/Android_tethering
  https://unix.stackexchange.com/questions/388300/udev-does-not-rename-usb-ethernet-device

Udev관련 Rule
  http://fewstreet.com/2015/06/09/ubuntu-udev-naming-rules.html


  • Jetson TX2의 USB-ACM Interface 
Jetson Manual을 읽어보면, 기본으로 nvidia/nvidia 로 id/pw로 제공을 하며, 두번째 id와 pw는 ubuntu/ubuntu를 제공해준다.


$ ls /dev/ttyACM0    // USB ACM  Interface 확인 
/dev/ttyACM0
$ minicom -s    // JetsonTx2 접속  nvidia:nvidia 


2.1 Jetson의 USB Ethernet 통신 설정 

Host PC와 Jetson Tx2 USB의 설정을하면 USB를 통하여 Internet 통신이 가능하다.
이를 이용하여 SSH 와 SFTP 및 추후 GDB까지 기능확장이 가능하다.
이 관련 Manual은 Mass Storage의 영문 Manual을 참조하자.

  • Host PC의 USB Host 의 Network 설정 
나의 경우 Host PC 아래와 같이  두 개의 USB Interface가 잡히며, 이를 설정해주자.
이 관련내용은 Mass Storage의 영문 매뉴얼을 참조하자.

직접설정

$ sudo ifconfig enp0s20f0u9 192.168.55.3 netmask 255.255.255.0 up
$ sudo ifconfig enp0s20f0u9i5 192.168.55.4 netmask 255.255.255.0 up

설정환경

$ sudo vi /etc/network/interfaces
auto lo
iface lo inet loopback

#allow-hotplug enp0s20f0u9
auto enp0s20f0u9
iface enp0s20f0u9 inet static
address 192.168.55.3
netmask 255.255.255.0
#gateway 192.168.55.1

$ sudo /etc/init.d/networking restart
$ sudo ifup enp0s20f0u9 

  https://wiki.debian.org/NetworkConfiguration

설정후 확인

$ ifconfig -a
enp0s20f0u9 Link encap:Ethernet  HWaddr 86:dd:47:07:ec:e4  
          inet addr:192.168.55.3  Bcast:192.168.55.255  Mask:255.255.255.0
          inet6 addr: fe80::84dd:47ff:fe07:ece4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:761 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1065 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:95357 (95.3 KB)  TX bytes:229667 (229.6 KB)

enp0s20f0u9i5 Link encap:Ethernet  HWaddr 16:bd:4f:fa:6a:df  
          inet addr:192.168.55.4  Bcast:192.168.55.255  Mask:255.255.255.0
          inet6 addr: fe80::14bd:4fff:fefa:6adf/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:800 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1017 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:98669 (98.6 KB)  TX bytes:178966 (178.9 KB)

enp0s31f6 Link encap:Ethernet  HWaddr 70:85:c2:3e:a8:2b  
          inet addr:10.0.0.107  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::725b:9a50:8ca0:81e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31853921 errors:0 dropped:0 overruns:0 frame:0
          TX packets:317267 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:46162303120 (46.1 GB)  TX bytes:35161467 (35.1 MB)
          Interrupt:16 Memory:df000000-df020000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:21308 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21308 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2903284 (2.9 MB)  TX bytes:2903284 (2.9 MB)



  • Jetson TX2의 USB Ethernet Device 설정 
상위의 Serial 프로그램(minicom)을 이용하여 ttyACM0 접속하여  Jetson TX2의 ethernet 환경을 살펴보자

Jetson Network 환경 확인

$ ifconfig -a                                              
docker0   Link encap:Ethernet  HWaddr 02:42:d0:89:67:5a                         
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0          
          UP BROADCAST MULTICAST  MTU:1500  Metric:1                            
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0                    
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0                  
          collisions:0 txqueuelen:0                                             
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)                                
                                                                                
dummy0    Link encap:Ethernet  HWaddr 16:34:65:bc:75:19                         
          BROADCAST NOARP  MTU:1500  Metric:1                                   
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0                    
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0                  
          collisions:0 txqueuelen:1000                                          
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)                                
                                                                                
eth0      Link encap:Ethernet  HWaddr 00:04:4b:c5:80:6f                         
          inet addr:10.0.0.170  Bcast:10.0.0.255  Mask:255.255.255.0            
          inet6 addr: fe80::9fdc:aa1b:faf4:9ad0/64 Scope:Link                   
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    
          RX packets:208078 errors:0 dropped:0 overruns:0 frame:0               
          TX packets:1925 errors:0 dropped:0 overruns:0 carrier:0               
          collisions:0 txqueuelen:1000                                          
          RX bytes:20077947 (20.0 MB)  TX bytes:354820 (354.8 KB)               
          Interrupt:42                                                          
                                                                                
l4tbr0    Link encap:Ethernet  HWaddr 7a:f3:26:af:7a:49                         
          inet addr:192.168.55.1  Bcast:192.168.55.255  Mask:255.255.255.0      
          inet6 addr: fe80::3851:d0ff:feaa:b4c4/64 Scope:Link                   
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    
          RX packets:10704 errors:0 dropped:0 overruns:0 frame:0                
          TX packets:101 errors:0 dropped:0 overruns:0 carrier:0                
          collisions:0 txqueuelen:1000                                          
          RX bytes:1739228 (1.7 MB)  TX bytes:10780 (10.7 KB)                   
                                                                                
lo        Link encap:Local Loopback                                             
          inet addr:127.0.0.1  Mask:255.0.0.0                                   
          inet6 addr: ::1/128 Scope:Host                                        
          UP LOOPBACK RUNNING  MTU:65536  Metric:1                              
          RX packets:219 errors:0 dropped:0 overruns:0 frame:0                  
          TX packets:219 errors:0 dropped:0 overruns:0 carrier:0                
          collisions:0 txqueuelen:1                                             
          RX bytes:16393 (16.3 KB)  TX bytes:16393 (16.3 KB)                    
                                                                                
tunl0     Link encap:IPIP Tunnel  HWaddr                                        
          NOARP  MTU:1480  Metric:1                                             
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0                    
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0                  
          collisions:0 txqueuelen:1                                             
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)                                
                                                                                
usb0      Link encap:Ethernet  HWaddr 9e:52:2b:63:ed:f2                         
          inet6 addr: fe80::9c52:2bff:fe63:edf2/64 Scope:Link                   
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    
          RX packets:5407 errors:5407 dropped:0 overruns:0 frame:5407           
          TX packets:4407 errors:0 dropped:0 overruns:0 carrier:0               
          collisions:0 txqueuelen:1000                                          
          RX bytes:874353 (874.3 KB)  TX bytes:813177 (813.1 KB)                
                                                                                
usb1      Link encap:Ethernet  HWaddr 7a:f3:26:af:7a:49                         
          inet6 addr: fe80::78f3:26ff:feaf:7a49/64 Scope:Link                   
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    
          RX packets:5297 errors:0 dropped:0 overruns:0 frame:0                 
          TX packets:4519 errors:0 dropped:0 overruns:0 carrier:0               
          collisions:0 txqueuelen:1000                                          
          RX bytes:864875 (864.8 KB)  TX bytes:633831 (633.8 KB)                
                                                                                
wlan0     Link encap:Ethernet  HWaddr 00:04:4b:c5:80:6d                         
          UP BROADCAST MULTICAST  MTU:1500  Metric:1                            
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0                    
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0                  
          collisions:0 txqueuelen:1000                                          
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)   

usb0 직접 설정 or DHCP 설정

$ sudo ifconfig usb0 192.168.55.2 netmask 255.255.255.0 up
or
$ udhcpc -i usb0   // DHCP Client로 설정 

network 환경설정

$ sudo vi /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto usb0
iface usb0 inet static
netmask 255.255.255.0
address 192.168.55.2


상위와 같이 설정후  Host PC에서 Jetson(192.168.55.2)로 접속가능.(SSH/SFTP/NFS)

$ ssh nvidia@192.168.55.2   // ID: ubuntu 가능 
$ sftp nvidia@192.168.55.2  // ID: ubuntu 가능 

  • Jetson 의 NFS지원 
아래와 같이 Kernel에서 NFS는 지원이 되지만, /sbin/mount의 NFS가 지원이 되지 않아 별도의 package 설치
 
$ cat /proc/filesystems | grep nfs  // Kernel의 NFS지원확인 
$ sudo apt-get install nfs-common   // mount nfs 지원 
$/sbin/mount  // mount 명령어 nfs 지원확인 
mountall                mount.ecryptfs_private  mount.lowntfs-3g        mount.nfs4              mount.ntfs-3g
mount.ecryptfs          mount.fuse              mount.nfs               mount.ntfs  

Host PC의 NFS Server 설정 후 아래와 같이 테스트

$ mount -t nfs -o nolock 192.168.5.3:/home/jhlee/test /home/nvidia/test 


2.2 USB Storage

이 부분은 추후 사용하기 위해 만든 것이며, 지금은 자료만 모음

USB Mass Storage Disable
  https://askubuntu.com/questions/888052/how-to-block-all-usb-storage-devices-in-ubuntu
  https://www.cyberciti.biz/faq/linux-disable-modprobe-loading-of-usb-storage-driver/
  https://help.ubuntu.com/community/Mount/USB

3.  Flash Jetson TX2

Host PC에서 USB를 통해 손쉽게 Flash하며, Backup 도 가능하기 때문에 관련 Command를 소개한다.


  • USB Force Recovery Mode



  • flash.sh 기본사용법 
Host PC와 Jetson의 microUSB 과 연결하여 USB를 통하여 Image를 Write or Read 할 수 있는 기능이다.





  • Host PC USB 연결확인 
만약 문제가 있다면, 상위 USB Force Recovery Mode로 진입하자.

$ lsusb  // Host 에서 USB 로 Jetson TX2 연결 후 Connection 확인
.....
Bus 001 Device 036: ID 0955:7020 NVidia Corp. 

  • Image Flash 방법  (USB 연결확인 후)
$  cd jetsonTX2/64_TX2/Linux_for_Tegra // JetPack 3.3 설치 위치  
$ sudo ./flash.sh  jetson-tx2 mmcblk0p1// For Jetson TX2 


  • Image Backup 및 Flash 방법 
$ sudo ./flash.sh -r -k APP -G clone.img jetson-tx2 mmcblk0p1    //기존에 사용하던 Image Backup
$ ls
clone.img  clone.img.raw
$ sudo cp clone.img.raw bootloader/system.img             // 실행전 반드시 bootloader/system.img bakcup  
$ sudo ./flash.sh -r -k APP jetson-tx2 mmcblk0p1                              // 적용된 이미지로 Flash


  • mount system.img.raw 방법 
system.img 는 mount가 되지 않으며, system.img.raw만 mount가 되었으며, mount 한 후에 NVIDIA에서 제공하는 SDK가 제대로 설치되었는지 확인하자.

$ mkdir test   //mount 할 장소 
$ sudo mount -t ext4 -o loop ./bootloader/system.img.raw ./test    // RAW File Mount

$ ls test/      // Target File System , APP 
README.txt  bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var // Target Filesystem 

$ ls ./test/usr/local/      //CUDA 설치확인 
bin  etc  games  include  lib  man  sbin  share  src    // 미설치 

$ ls ./test/usr/src/      //tensorrt 설치 확인  /usr/src/tensorrt/bin/   , /usr/src/tensorrt/samples/
linux-headers-4.4.38-tegra

$ sudo umount test   // 반드시 unmount

  • flash.sh 사용법
$ ./flash.sh -h

Usage: sudo ./flash.sh [options]  
  Where,
 target board: Valid target board name.
 rootdev: Proper root device.
    options:
        -b  --------- nvflash boot control table config file.
        -c  --------- nvflash partition table config file.
        -d  --------- device tree file.
        -e  ------- Target device's eMMC size.
        -f  -------- Path to flash application: nvflash or tegra-rcm.
        -h ------------------- print this message.
        -i ------------------- pass user kernel commandline as-is to kernel.
        -k  ---- partition name or number specified in flash.cfg.
        -m  ----- MTS preboot such as mts_preboot_si.
        -n  -------- Static nfs network assignments
                               :::
        -o  --------- ODM data.
        -p  --------- Total eMMC HW boot partition size.
        -r ------------------- skip building and reuse existing system.img.
        -s ----- PKC key used for signing and building bl_update_payload.
        -t  ------- tegraboot binary such as nvtboot.bin
        -u  -------- PKC server in @ format.
        -w  --------- warm boot binary such as nvtbootwb0.bin
        -x  --------- Tegra CHIPID. default = 0x18(jetson-tx2)
                               0x21(jetson-tx1), 0x40(jetson-tk1).
        -y  -------- PKC for secureboot, NS for non-secureboot.
        -z  -------------- Serial Number of target board.
        -B  --------- BoardId.
        -C  --------- Kernel commandline arguments.
                               WARNING:
                               Each option in this kernel commandline gets
                               higher preference over the same option from
                               fastboot. In case of NFS booting, this script
                               adds NFS booting related arguments, if -i option
                               is omitted.
        -F  --------- Flash server such as fastboot.bin.
        -G  ------- Read partition and save image to file.
        -I  ---------- initrd file. Null initrd is default.
        -K  ---------- Kernel image file such as zImage or Image.
        -L  ------ Bootloader such as cboot.bin or u-boot-dtb.bin.
        -M  -------- MTS boot file such as mts_si.
        -N  --------- i.e. :/my/exported/nfs/rootfs.
        -P  -- Primary GPT start address + size of PPT + 1.
        -R  ------ Sample rootfs directory.
        -S  ------------ Rootfs size in bytes. Valid only for internal
                               rootdev. KiB, MiB, GiB short hands are allowed,
                               for example, 1GiB means 1024 * 1024 * 1024 bytes.
        -T  -------- ITS file name. Valid only for u-boot.
        --no-flash ----------- perform all steps except physically flashing the board.
                               This will create a system.img.
        --bup ---------------- Generate bootloader update payload(BUP).
        --multi-spec---------- Enable support for building multi-spec BUP.
        --clean-up------------ Clean up BUP buffer when multi-spec is enabled.
        --usb-instance  -- Specify the USB instance to connect to; integer
                               ID (e.g. 0, 1), bus/dev (e.g. 003/091), or USB
                               port path (e.g. 3-14). The latter is best.



  • Jetson TX2 Partion 구조 (Jetson TX2 확인)
Jetson TX2에서 Terminal에 접속후에 MBR이 아닌 GPT 방식 이므로 아래와 같이 확인하자

$nvidia@tegra-ubuntu:~$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 29.1 GiB, 31268536320 bytes, 61071360 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: gpt
Disk identifier: 00000000-0000-0000-0000-000000000000

Device             Start      End  Sectors   Size Type
/dev/mmcblk0p1      4097 58724352 58720256    28G Microsoft basic data
/dev/mmcblk0p2  58724353 58732544     8192     4M Microsoft basic data
/dev/mmcblk0p3  58732545 58740736     8192     4M Microsoft basic data
/dev/mmcblk0p4  58740737 58741760     1024   512K Microsoft basic data
/dev/mmcblk0p5  58741761 58742784     1024   512K Microsoft basic data
/dev/mmcblk0p6  58742785 58743808     1024   512K Microsoft basic data
/dev/mmcblk0p7  58743809 58744832     1024   512K Microsoft basic data
/dev/mmcblk0p8  58744833 58750976     6144     3M Microsoft basic data
/dev/mmcblk0p9  58750977 58757120     6144     3M Microsoft basic data
/dev/mmcblk0p10 58757121 58761216     4096     2M Microsoft basic data
/dev/mmcblk0p11 58761217 58762424     1208   604K Microsoft basic data
/dev/mmcblk0p12 58762425 58763632     1208   604K Microsoft basic data
/dev/mmcblk0p13 58763633 58764632     1000   500K Microsoft basic data
/dev/mmcblk0p14 58764633 58765632     1000   500K Microsoft basic data
/dev/mmcblk0p15 58765633 58769728     4096     2M Microsoft basic data
/dev/mmcblk0p16 58769729 58773824     4096     2M Microsoft basic data
/dev/mmcblk0p17 58773825 58786112    12288     6M Microsoft basic data
/dev/mmcblk0p18 58786113 58798400    12288     6M Microsoft basic data
/dev/mmcblk0p19 58798401 58802496     4096     2M Microsoft basic data
/dev/mmcblk0p20 58802497 59064640   262144   128M Microsoft basic data
/dev/mmcblk0p21 59064641 59326784   262144   128M Microsoft basic data
/dev/mmcblk0p22 59326785 59392320    65536    32M Microsoft basic data
/dev/mmcblk0p23 59392321 59457856    65536    32M Microsoft basic data
/dev/mmcblk0p24 59457857 59588928   131072    64M Microsoft basic data
/dev/mmcblk0p25 59588929 59720000   131072    64M Microsoft basic data
/dev/mmcblk0p26 59720001 59721024     1024   512K Microsoft basic data
/dev/mmcblk0p27 59721025 59722048     1024   512K Microsoft basic data
/dev/mmcblk0p28 59722049 60246336   524288   256M Microsoft basic data
/dev/mmcblk0p29 60246337 61071326   824990 402.8M Microsoft basic data
 


$nvidia@tegra-ubuntu:~$ sudo gdisk -l /dev/mmcblk0
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/mmcblk0: 61071360 sectors, 29.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 00000000-0000-0000-0000-000000000000
Partition table holds up to 29 entries
First usable sector is 4097, last usable sector is 61071327
Partitions will be aligned on 1-sector boundaries
Total free space is 1 sectors (512 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            4097        58724352   28.0 GiB    0700  APP
   2        58724353        58732544   4.0 MiB     0700  mts-bootpack
   3        58732545        58740736   4.0 MiB     0700  mts-bootpack_b
   4        58740737        58741760   512.0 KiB   0700  cpu-bootloader
   5        58741761        58742784   512.0 KiB   0700  cpu-bootloader_b
   6        58742785        58743808   512.0 KiB   0700  bootloader-dtb
   7        58743809        58744832   512.0 KiB   0700  bootloader-dtb_b
   8        58744833        58750976   3.0 MiB     0700  secure-os
   9        58750977        58757120   3.0 MiB     0700  secure-os_b
  10        58757121        58761216   2.0 MiB     0700  eks
  11        58761217        58762424   604.0 KiB   0700  bpmp-fw
  12        58762425        58763632   604.0 KiB   0700  bpmp-fw_b
  13        58763633        58764632   500.0 KiB   0700  bpmp-fw-dtb
  14        58764633        58765632   500.0 KiB   0700  bpmp-fw-dtb_b
  15        58765633        58769728   2.0 MiB     0700  sce-fw
  16        58769729        58773824   2.0 MiB     0700  sce-fw_b
  17        58773825        58786112   6.0 MiB     0700  sc7
  18        58786113        58798400   6.0 MiB     0700  sc7_b
  19        58798401        58802496   2.0 MiB     0700  FBNAME
  20        58802497        59064640   128.0 MiB   0700  BMP
  21        59064641        59326784   128.0 MiB   0700  BMP_b
  22        59326785        59392320   32.0 MiB    0700  SOS
  23        59392321        59457856   32.0 MiB    0700  SOS_b
  24        59457857        59588928   64.0 MiB    0700  kernel
  25        59588929        59720000   64.0 MiB    0700  kernel_b
  26        59720001        59721024   512.0 KiB   0700  kernel-dtb
  27        59721025        59722048   512.0 KiB   0700  kernel-dtb_b
  28        59722049        60246336   256.0 MiB   0700  CAC
  29        60246337        61071326   402.8 MiB   0700  UDA
 



관련문서는 아래를 참조 혹은 설치시 Start_L4T_Docs.html 부분을 참조

Jetson_X2_Developer_Kit_User_Guide.pdf
  https://developer.nvidia.com/embedded/dlc/l4t-27-1-jetson-tx2-user-guide

1/15/2019

Ubuntu 16.04 LTS 기반 설치

1. Ubuntu 16.04 LTS 기본 OS설치 

기존처럼 Window에서 Virtual Box를 설치하여 Ubuntu를 설치하여 적용하는 것이 아니라 반대로 설치하는 경우에 필요한 Tool들을 간단히 정리해 본다.
현재 나의 OS를 Ubuntu 16.04 or 18.04 LTS로 설치하여 사용하고 Virtual Box를 이용하여 Window를 설치한다.

  • 기본 OS: Ubuntu 16.04 /18.04 LTS  ( Jetson 문제로 16.04변경)
  • Guest OS: Window 7 

1.1  USB 설치디스크 만들기

아래의 내용을 보고 간단하게 USB기반으로 Booting하는 Ubuntu OS 를 만들자.

  https://ahyuo.blogspot.com/2019/01/usb.html


2. Ubuntu 에서 사용할 프로그램들   


  • 썬더버드 
기본으로 설치되어 있으며, Window의 Outlook이라고 생각하면 되겠다.


  • 크롬설치방법
아래방법으로 설치함

$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - 
$ sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
$ sudo apt-get update
//크롬 설치
$ sudo apt-get install google-chrome-stable
$ sudo rm -rf /etc/apt/sources.list.d/google.list 


  http://snowdeer.github.io/linux/2018/02/02/ubuntu-16p04-install-chrome/
  https://webnautes.tistory.com/1079

  • VirtualBox 설치
아래의 내용들로 최신 버전을 설치를 해도 되지만, Ubuntu 16.04/18.04 LTS에서는 검색을 하면 쉽게 설치가 가능하다.

아래 내용들은 참고하고, 추후 최신버전으로 변경할 일이 있다면 시도를 다시 해보자.

  https://www.virtualbox.org/wiki/Linux_Downloads
  https://websiteforstudents.com/install-virtualbox-latest-on-ubuntu-16-04-lts-17-04-17-10/
  https://tecadmin.net/install-virtualbox-on-ubuntu-18-04/


해당 *.deb 파일 다운로드

$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -

$ vi /etc/apt/sources.list  // virtualbox repository 추가 
............
deb https://download.virtualbox.org/virtualbox/debian mydis> contrib
deb https://download.virtualbox.org/virtualbox/debian xenial contrib

$ sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/virtualbox.list'


//download Oracle public key and register  
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -

$ sudo apt-get update
$ sudo apt-get install virtualbox-6.0



  • Eclipse
Java용 Eclipse로 Ubuntu 소프트웨어에서 검색을 하면 쉽게 설치 가능



  • Eclipse CDT
C/C++ Eclipse용으로 Ubuntu 소프트웨어에서 검색을 해도 나오지 않아 강제로 아래와 같이 설치


  https://websiteforstudents.com/how-to-install-eclipse-oxygen-ide-on-ubuntu-167-04-17-10-18-04/
  https://agiantmind.tistory.com/182



  • 화면 캡쳐프로그램
원시적 방법으로는 간단하게 Print Screen Button을  이용하여 캡쳐를 하면되지만, Window 처럼
Ubuntu 16.04 /18.04 Version에서

  https://webnautes.tistory.com/513



  • Consol Program 및 SSH Program 
Serial Program을 보기위해 기존의 minicom 이나 putty가 지원이 되니 이를 설치해보자.
아직 Putty로 Serial을 보지 못했다.

$ sudo apt install putty
$ sudo apt install minicom 

$ minicom -s 
$ putty 

putty
  http://processors.wiki.ti.com/index.php/Setting_up_Minicom_in_Ubuntu

SFTP
  http://hongci.tistory.com/16



  • DNS Server 설정 
  http://wani.kr/posts/2017/03/22/ubuntu-resolvconf-settings-summary/



1/14/2019

USB 시동디스크 만들기 와 이해

1. PC의 USB Booting Disk만들기 

현재 기본 OS를 Window 7 or 10가 아닌 Linux ,즉 Ubuntu로 사용해야 하기때문에 아래와 같은 작업을 실행한다.

  1. USB 저장장치기반으로 시동디스크 생성 (ISO Image기반)
  2. BIOS에서 Booting 우선순위를 USB 변경 
  3. Linux(Ubuntu) 설치 진행   

현재 내가 사용하고 있는 OS가 Ubuntu 이므로 그 기준으로 관련 프로그램 설명한다.

기존생각은 Window에서 주로 임베디드에서 많이 사용하던 Win32DiskImager or Echer으로 사용하여 만들 생각이었다
하지만, Ubuntu의 Startup Disk Program 와 Window 에서는 Rufus 이용하여 사용하겠다.

  • Linux와 Window 와 USB Grub과 함께 설치 방법
아래에서 USB Boot Disk를 Grub과 함께 만드는 방법을 소개주셔서 감사하다.
추후 시간이 있다면 이부분을 한번 따라 해보겠다.
  https://bagjunggyu.blogspot.com/2013/10/linux-booting-usb-grub.html


1.1 Ubuntu 에서 Ubuntu USB 시동디스크 만들기

우선 현재 사용 중인 OS가 Ubuntu 일 경우 하도록 하며, 아래의 Startup Disk Program을 이용하여 만들어보자 
Ubuntu에 USB 시동디스크 설치프로그램은 기본설치
(Ubuntu 16.04 이후것은 확인)

  • 사용프로그램 (Ubuntu에 기본내장)
Startup Disk Program

  • Ubuntu에서 시동디스크 만들기 
  1. Startup or 시동디스크 검색 
  2. 시동디스크 설치 실행 
  3. Ubuntu Image 를 USB에 설치 

  • Ubuntu 실행 Startup Disk Program 찾기  

https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-ubuntu?_ga=2.105790597.76344796.1547599988-873301564.1547599988#0


  • Make Startup Disk 
USB Ubuntu Image 만들기 

https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-ubuntu?_ga=2.105790597.76344796.1547599988-873301564.1547599988#0


아래문서참고
  https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-ubuntu?_ga=2.105790597.76344796.1547599988-873301564.1547599988#0

  • 동작방식 
상위와 같이 Ubuntu Image를 생성하면, 내부에 EFI 와 boot 가  directory 존재하며, Ubunut를 설치시에, EFI System Parition을 이용한다. 


1.2 Window에서 Ubuntu/Window USB 시동디스크 만들기

우선 현재 사용 중인 OS가 Window 일 경우 하도록 하며, Echer이외에도  Rufus는 프로그램이 존재하는데, 파티션과 UEFI 설정가능
Image만 USB에 Write하면 될 줄 알았는데, 옵션이 다양하다

  • 사용프로그램 및 Download
Rufus Download 
  https://rufus.ie/

  • Rufus 설정포인트
  1. 파티션을 MBR or GPT로 설정
  2. 대상시스템 (BIOS 또는 UEFI or UEFI)




참고자료
  http://w3devlabs.net/wp/?p=24400
  https://webnautes.tistory.com/1146


1.3 Window에서 Window 10 Image 생성 

MS사에서 제공해주는 방법으로 상위 RUFUS 대신 이용해보도록 하자. 

Window 10 Image Download 및 USB Image 생성

Window USB 시동디스크 만들기 
  https://ahyuo79.blogspot.com/2019/08/lenovo-laptop.html


1.4 Window 에서 이외 Tool 

임베디드에서 많이 사용하는 Win32DiskImager or Echer 사용해도 상관은 없다. 
다만 BIOS에서 UEFI가 아닌 Legacy로 사용 

Download  Win32DiskImager

Download Etcher


2. PC의 BIOS와 UEFI 기본이해 

PC의 BIOS(Basic Input/Output System)는 이전처럼 간단하게 작동이 되지 않으며,
최신 UEFI(Unified Extensible Firmware Interface)을 적용하며 점점 변경되어 가고 있다고 한다

이전 BIOSLegacy BIOS라고 정의하며, 최신 BIOSUEFI이라고 명명한다고 한다. 
Laptop의 BIOS 설정에 가면 상위처럼 이름이 정해져 있다. 


2.1 Legacy BIOS 

Legacy BIOS의 경우는 
이전 부팅방식인 Boot Sector의 MBR 정보와 Bootcode를 가지고 Booting을 했으며, 기본방식으로 동작한다. 
하지만, HDD 용량제한과 BIOS의 기능제한이 문제가 되며, 결론적으로 GPT는 지원을 하지는 못한다. 

  • BIOS -> HDD의 MBR

https://en.wikipedia.org/wiki/BIOS


2.2 UEFI 지원 BIOS

UEFI(Unified Extensible Firmware Interface) 의 경우는  
기존 BIOS(Legacy BIOS)와 달리 BootSector(MBR)에만 지원하지 않고 GPT 지원하기되어 대용량 HDD를 지원가능하다.
UEFI Spec은  Boot Manager 라는 것 정의하고, Computer가 Power up이 되었을 때, 
Boot Manager는 이미 사용자가 설정된 Boot Configuration 체크하여 동작하고 Boot를 결정한다

UEFI의 경우 일반적으로 GPT(GUID Partition Table)을 이용한다고 한다.
  • UEFI -> HDD 의 EFI Partition -> EFI Bootloader
아래의 GRUB2의 GPT 부분을 보면, SDA1이 EFI Parition으로 FAT32
https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#Booting


결론적으로 UEFI는 BIOS에 부족한 부분을 외부저장장치에 EFI_SYSTEM_PARTITION이 별도 생성하여 BIOS를 확장하는 구조이다. 
기존의 BIOS에서 할 수 없었던 기능들을 이곳에 추가 확장을 하는 것이다. 

  • EFI system partition (약어, ESD)
외부저장장치 즉 Storage에 다양한 FAT Filesystem(FAT32, FAT16 , FAT12)으로 제공하여 구성되며, 
MBR과 GPT Partition을 기존과 동일하게 설정하기 때문에 이 부분을 이해한다. 
CD Disk는 보니 다르게 동작하니, 착각하지 말자.

ESD Wiki 자료
  https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#EFI_system_partition


  • EFI 관련파일의 구성과 PARTITION 
EFI_SYSTEM_PARTITION -- /EFI/BOOT/BOOT machine_type_short_name.EFI // 이런식으로 이름을 구성  
EFI_SYSTEM_PARTITION -- /efi/BOOT/BOOTX64.EFI   // x86-64 일 경우 (상위와 같이 적용)
EFI_SYSTEM_PARTITION -- /efi\boot\bootaa64.efi  // ARM64 일 경우  (상위와 같이 적용)

UEFI Interface
  https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface


  • EFI의 시스템의 이해 
인텔은 EFI(Extensible Firmware Interface)라는 스펙을 개발했지만, 이는 UEFI에 주요 기능이 포함되었다고 한다.
Hardware는 PC의 Mainboard와 CPU 및 기타 Device를 말할 것이며, Firmware와 EFI는 BIOS기능을 말한다.




  https://en.wikipedia.org/wiki/EFI_system_partition


  • Interaction between the EFI Boot manager and EFI drivers
상위에서 설명한 Boot Manager와 동작방식을 그림으로 표현을 해준다.
EFI BOOT Manager와 EFI Driver의 동작방법을 이해해보면, 아래의 Blue색은 EFI의 전체 시스템이며, OS Loader와 어떻게 작용하는지 이해해보자.



  1. 좌측그림 EFI Binaries 파일 
  2. 우측그림 Boot Manager
  https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#Applications


  • UEFI Booting 
UEFI booting은 Legacy BIOS와 다르게 boot sector에 의존하지 않으며, 상위 EFI 처럼 Boot Manager가 존재하여 이를 OS Loader를 실행을 해준다.
크게보면 아래 두가지 형태로 나누어 볼수 있을 것 같으며, 세부적인 Booting은 아래에서 참조하자.

  1. UEFI-GPT booting
  2. UEFI-MBR

  https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#Booting

UEFI를 보면서 Shell 제공뿐만 아니라 기존의 BIOS가 Logo 및 GUI가 지원이 되는 것을 보고 사실 많이 놀랐다.
너무 옛날버전의 BIOS만 봐서 그런지 최신 BIOS를 보니 낯설기만 해서 일단 상위처럼 이해만 하고 넘어가자.
다른 Booting 모드도 제공하는 것 같은데, 추후 사용할 일 있다면 그때 알아가자.

궁금한것은 UEFI로 확장하여, 상위 LOGO와 GUI 환경을 제공하는것인지가 궁금하다. 아직 이해가 되지 않아 이부분은 추후에 확인 


UEFI의 이해 참고자료
  https://namu.wiki/w/UEFI
  https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface
  https://ko.wikipedia.org/wiki/%ED%86%B5%EC%9D%BC_%ED%99%95%EC%9E%A5_%ED%8E%8C%EC%9B%A8%EC%96%B4_%EC%9D%B8%ED%84%B0%ED%8E%98%EC%9D%B4%EC%8A%A4
  https://msdn.microsoft.com/ko-kr/library/windows/hardware/dn898495(v=vs.85).aspx


3. MBR 와 GPT  이해 와 차이 

  • 기존 MBR(Master Boot Record) 
MBR(Master Boot Record)은 기존부터 사용한 방식이며, HDD Disk의 Sector 0 으로 BIOS가 이 부분으로 부팅하면서 Partition 체크하는 부분이다. 
역할은 Boot CodePartition Entry , 즉 Partition 정보이다. 
하지만, 용량이 제한되어 있다보니, 기능이 제한적일 수 밖에 없다. 

MBR(Master Boot Record)
BootCode 와 Partition Entry 들어감 
  https://en.wikipedia.org/wiki/Master_boot_record

  • GPT기반 변경 
GPT(Sector 1)하드디스크 용량증가로 인하여 MBR의 용량문제 개선하기 위해서, MBR(Sector 0) Partition 기능에 확장제공하는 방식이다. 
현재는 GPT는 MBR에 기존과 다른 구조로 사용하여 확장되어지는 구조이며, 이에 사용되는 툴도 둘다 다르다.


  • Bootloader(GRUB2) 비교
둘 다 Extend Partition에 GRUB을 넣으려고 하는 것이며, 각 차이를 알아두도록 하자. 
  1. boot.img: MBR에 저장되어지는 boot image로 core.img를 접근 
  2. core.img: GRUB의 core image로 /boot/grub을 접근 


  • MBR or GPT 일 경우, GRUB2 저장 

  https://en.wikipedia.org/wiki/Boot_sector


Sector Size,LBA 512 기준
  1. Example 1: MBR사용 
    1. Sector 0: MBR
    2. Sector 1~2047 
  2. Example 2: GPT(GUID Partition Table)사용 (아래 그림참조)
    1. Sector 0: MBR
    2. Sector 1: Primary GPT Header 
    3. Sector 2~33:  Partition Entry Array 128개  (128x128/512=32 Sector)
      1. GUID Partition Entry: 128byte 
        1. Partition type GUID: 아래 다시 설명 
        2. Unique Partition GUID
        3. ... 기타 등등 (상위 링크 참조)

    4. Empty Space:
    5. SDA1: EFI System Partition(FAT32)  (각 Partition GUID 참조)
    6. SDA2: BIOS boot Partition  (각 Partition GUID 참조)
    7. SDA3: Linux /  Root File system (각 Partition GUID 참조)
    8. SDA4: Linux /boot  File system (/boot/grub) (각 Partition GUID 참조)

Unix/Linux계열:  각 OS마다 조금씩 다르며, 링크를 참조하여 확인 
Window 32 bit :  UEFI 허용안하며, GPT도 미지원 
Window 64 bit :  Disk 당 GPT 128 Partition 까지 지원

GPT(GUID Partition Table) 사용할 경우 아래의 Globally unique identifier (GUID)는 공용으로 사용하는 ID이므로, 아래의 wiki에서 각각의 ID의 의미를 알아두고 이해하자.
  1. MBR partition scheme: 024DEE41-33E7-11D3-9D69-0008C781F39F
  2. EFI System partition: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
  3. BIOS boot partition: 21686148-6449-6E6F-744E-656564454649
  4. Sony boot partition: F4019732-066E-4E12-8273-346C5641494F
  5. Lenovo boot partition: BFBFAFE7-A34F-448A-9A5B-6213EB736C22
이외 OS 관련된 GUID 와 각 제조회사 GUID 아주 다양하다

세부사항 GUID 정보
Window/Linux/macOS/Android/QNX 등 각 OS GUID는 반드시 확인
  https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs



3.1 MBR 와 GPT의 Partition Tool 

기존에 MBR의 경우fdisk라는 것을 이용하여 MBR Parttion table을 설정하고 이를 진행했지만, GPTgdisk,gparted 라는 Tool을 사용한다.

아래와 같이 사용되어지는 Tool이 변경되어진다. 
  1. MBR : fdisk
  2. GPT :  gdisk gparted

3.2 MBR과 GPT의 내부구성 

위에서 설명했듯이 MBR과 GPT도 중요한것은 내부구성을 파악하고 Partition을 어떻게 구분하는지 이부분을 알아보자.
아래의 wiki를 보면 대충이해는 가지만, 세부적인것은 더 자세히 알아봐야할 것 같다.

  • MBR(Master Boot Record) 사용 
기존부터 사용하던 방식으로, 4개의 Primary Partition 4개를 제공하고 확장한다면, Logical로 분할하여 확장하는 방식인 걸로 기억한다. 
아래의 LBA0에 모든 정보를 넣는 구조이다. 

나도 너무 오래되어서 까먹으며, 추후 다시 한번 자세히 정독하자 
  https://en.wikipedia.org/wiki/Master_boot_record
  https://ko.wikipedia.org/wiki/%EB%A7%88%EC%8A%A4%ED%84%B0_%EB%B6%80%ED%8A%B8_%EB%A0%88%EC%BD%94%EB%93%9C
  https://en.wikipedia.org/wiki/Disk_partitioning
  https://en.wikipedia.org/wiki/Extended_boot_record


  • GPT(GUID Partition Table) 사용
MBR부분 즉, LBA0은 이전 호환성을 위해 그대로 사용하고, LBA1 부터 GPT를 사용하게되면 아래와 같이 Patition Entry 가 마음대로 더 확장가능하다. 
우선 Primary GPT 와 Secodary GPT 기반으로 아래와 같이 볼 수 있고, 그 안에 각 Patition Entry Point가 존재한다. 
GUID 방식은 나도 구조를 이전에도 본적이 없어 아래의 Wiki로 파악을 하고 있다.
지금 봐도 좀 혼동이 된다.
  https://en.wikipedia.org/wiki/GUID_Partition_Table
  https://ko.wikipedia.org/wiki/GUID_%ED%8C%8C%ED%8B%B0%EC%85%98_%ED%85%8C%EC%9D%B4%EB%B8%94