美文网首页NVIDIA Jetson working
Jetson Nano Running Samples

Jetson Nano Running Samples

作者: 童年雅趣 | 来源:发表于2019-03-28 11:11 被阅读253次
    1. 如何下载镜像软件到Jetson Nano

    Step1. 进入Recovery mode

    1. 找到J40和J48 跳PIN, 将J48跳线帽接起,再将J40 3和4Pin接起,这样Nano在上电后就会进入Force Recovery Mode
      2.Jetson Nano核心板插入micro-SD卡,插入micro-USB线,再接上电源
    2. 运行sdkmanager 或 Linux_for_Tegra
    image.png

    Step2. Flash 全部镜像文件

    Step3. Flash DTB文件
    Jetson Nano DTS 文件存储在:
    <install>/nvidia_sdk/JetPack_4.2_Linux_P3448/Linux_for_Tegra/sources/hardware/nvidia/platform/t210/porg/kernel-dts
    Nano 采用的DTS 文件:tegra210-p3448-0000-p3449-0000-a02.dts

    Modify that file and the files it includes (DTSI). When you build the kernel it will build the DTS files into DTB files. The resulting DTB file is located here (assuming you use the build directory above)
    <install>/nvidia_sdk/JetPack_4.2_Linux_P3448/Linux_for_Tegra/sources/kernel/kernel-4.9/build/arch/arm64/boot/dts

    Now comes the hard part. The DTB file needs to be placed into a partition header and signed/encrypted. The only way I've found to do this is to copy the DTB file here:
    <install>/nvidia_sdk/JetPack_4.2_Linux_P3448/Linux_for_Tegra/kernel/dtb
    Then run:

    sudo ./create-jetson-nano-sd-card-image.sh -o sd-blob.img -s 4G -r 200
    

    This will create an IMG file that can be programmed into an SD card or the internale MMC on the actual SOM. In the process of creating the IMG file it will take the DTB file and place the signed copy here:
    <install>/nvidia_sdk/JetPack_4.2_Linux_P3448/Linux_for_Tegra/bootloader/signed/tegra210-p3448-0000-p3449-0000-a02.dtb.encryptQ

    Pull the SD card out of the Nano and put into your Linux machine (share the USB into the VM). Now the following in the bootloader/signed directory.

    sudo dd if=tegra210-p3448-0000-p3449-0000-a02.dtb.encrypt of=/dev/sdx10
    

    This will program the DTB file into the partition. Put the SD card back in the
    Nano and reboot.

    2. 如下Samples 软件运行在32GB SanDisk UHS-I/U3 MicroSD Card上

    CUDA 10(路径:/usr/local/cuda/,默认系统未加入到环境变量)
    运行如下命令添加环境变量:
    export PATH=${PATH}:/usr/local/cuda/bin
    export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64
    Tegra Multimedia API :
    tegra_multimedia_api(路径:/usr/src/nvidia/tegra_multimedia_api)
    $sudo make -j4 (编译)

    高频运行模式
    $sudo nvpmodel -m 0 (5V 2A Mode)
    $sudo nvpmodel -m 1 (5V 1A Mode)
    $sudo tegrastats (CPU/GPU/EMC/Temperature Status)

    安装的三方工具或软件列表
    sudo apt-get update
    sudo apt-get install samba
    sudo apt-get install python3-pip
    
    Tensorflow 1.13.1
    pip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.3 --user
    安装过程若报错hdf5,请安装:
    sudo apt-get install libhdf5-serial-dev
    

    2. GPIO for Nano

    Jetson.GPIO库 已经预装在Nano,无需再安装其他GPIO Python库,如果安装了其他GPIO库需先卸载方可以正常适用Jetson.GPIO, 预安装路径:

    /opt/nvidia/jetson-gpio

    运行Jetson.GPIO前需运行以下步骤,建立GPIO 运行环境
    步骤一 - 设置运行权限Setup permissions

    $sudo groupadd -f -r gpio
    $sudo usermod -a -G gpio $USER
    $sudo cp /opt/nvidia/jetson-gpio/etc/99-gpio.rules /etc/udev/rules.d/
    $sudo udevadm control --reload-rules && sudo udevadm trigger
    
    $sudo reboot now
    

    步骤二 - Python 代码引用
    添加如下Python 代码后,才可以调用 import the RPi.GPIO (或者 motorhat library等)

    import sys
    sys.path.append('/opt/nvidia/jetson-gpio/lib/python/')
    sys.path.append('/opt/nvidia/jetson-gpio/lib/python/Jetson/GPIO')
    
    import Jetson.GPIO
    

    import RPi.GPIO
    

    Jetson.GPIO doesn't support PWM.
    However, the following I2C controlled board can generate PWM signals up to ~1.6kHz and should have Python libraries available.
    https://www.adafruit.com/product/815
    You could potentially connect this to whatever H-Bridge meets the power requirements of your application. The motor driver we used for JetBot actually combines this chip and multiple H-bridge on the same board.
    https://www.adafruit.com/product/2927


    3. MXNET for Nano

    Python2.7
    下载Wheel file here.

    sudo apt-get install -y git build-essential libatlas-base-dev libopencv-dev graphviz python-pip
    sudo pip install mxnet-1.4.0-cp27-cp27mu-linux_aarch64.whl

    Python3.7
    下载Wheel file here.

    sudo apt-get install -y git build-essential libatlas-base-dev libopencv-dev graphviz python3-pip
    sudo pip install mxnet-1.4.0-cp36-cp36m-linux_aarch64.whl

    4. Nano 运行Darknet (本案例采用 Alexey_Darknet)

    下载源码:
    $git clone https://github.com/AlexeyAB/darknet.git

    编译源码:
    修改Makefile内容,添加GPU/CUDNN/OPENCV 支持:
    GPU=1
    CUDNN=1
    CUDNN_HALF=1
    OPENCV=1
    $make -j4

    Darknet运行时Nano 电流较大,实测5V 瞬间电流有达到2.5A,也就是说普通的5V-2A MicroUSB 供电是无法满足的,此时需要提供5V-2A AC Adapter或者5V-4.5A MicroUSB 供电,以满足正常运行Darknet Yolo。
    下载对应weight就可以运行了, 比如自带的
    compute_capability = 530, cudnn_half = 0

    
    

    5. Nano 运行 Camera (案例采用 Raspberry Pi Camera v2)**

    Nano 已支持Camera列表

    相机安装后,以RAW 格式打开并预览:
    $nvgstcapture-1.0 -m 2

    附录 代码及终端信息

    $nvgstcapture-1.0 -m 2

    nvidia@tw-Nano:~$ nvgstcapture-1.0 -m 2
    Encoder null, cannot set bitrate!
    Encoder Profile = High
    Supported resolutions in case of ARGUS Camera
      (2) : 640x480
      (3) : 1280x720
      (4) : 1920x1080
      (5) : 2104x1560
      (6) : 2592x1944
      (7) : 2616x1472
      (8) : 3840x2160
      (9) : 3896x2192
      (10): 4208x3120
      (11): 5632x3168
      (12): 5632x4224
    
    Runtime ARGUS Camera Commands:
    
      Help : 'h'
      Quit : 'q'
      Set Capture Mode:
          mo:<val>
              (1): image
              (2): video
      Get Capture Mode:
          gmo
      Set sensor orientation:
          so:<val>
              (0): none
              (1): Rotate counter-clockwise 90 degrees
              (2): Rotate 180 degrees
              (3): Rotate clockwise 90 degrees
      Get sensor orientation:
          gso
      Set Whitebalance Mode:
          wb:<val>
              (0): off
              (1): auto
              (2): incandescent
              (3): fluorescent
              (4): warm-fluorescent
              (5): daylight
              (6): cloudy-daylight
              (7): twilight
              (8): shade
              (9): manual
      Get Whitebalance Mode:
          gwb
      Set Saturation (0 to 2):
          st:<val> e.g., st:1.25
      Get Saturation:
          gst
      Set Exposure Compensation (-2 to 2):
          ec:<val> e.g., ec:-2
      Get Exposure Compensation:
          gec
      Set Auto Whitebalance Lock:
          awbl:<val> e.g., awbl:0
      Get Auto Whitebalance Lock:
          awbl
      Set Auto Exposure Lock:
          ael:<val> e.g., ael:0
      Get Auto Exposure Lock:
          gael
      Set TNR Mode:
          tnrm:<val> e.g., tnrm:1
              (0): OFF
              (1): FAST
              (2): HIGH QUALITY
      Get TNR Mode:
          gtnrm
      Set TNR Strength (-1 to 1):
          tnrs:<val> e.g., tnrs:0.5
      Get TNR Strength:
          gtnrs
      Set EE Mode:
          eem:<val> e.g., eem:1
              (0): OFF
              (1): FAST
              (2): HIGH QUALITY
      Get EE Mode:
          geem
      Set EE Strength (-1 to 1):
          ees:<val> e.g., ees:0.5
      Get EE Strength:
          gees
      Set Auto Exposure Anti-Banding (0 to 3):
          aeab:<val> e.g., aeab:2
              (0): OFF
              (1): MODE AUTO
              (2): MODE 50HZ
              (3): MODE 60HZ
      Get Auto Exposure Anti-Banding:
          gaeab
      Set Gain Range:
          gr:<val><space><val> e.g., gr:1 16
      Get Gain Range:
          ggr
      Set Exposure Time Range:
          etr:<val><space><val> e.g., etr:34000 35000
      Get Exposure Time Range:
          getr
      Set ISP Digital Gain Range:
          dgr:<val><space><val> e.g., dgr:2 152
      Get ISP Digital Gain Range:
          gdgr
      Capture: enter 'j' OR
               followed by a timer (e.g., jx5000, capture after 5 seconds) OR
               followed by multishot count (e.g., j:6, capture 6 images)
               timer/multihot values are optional, capture defaults to single shot with timer=0s
      Start Recording : enter '1'
      Stop Recording  : enter '0'
      Video snapshot  : enter '2' (While recording video)
      Get Preview Resolution:
          gpcr
      Get Image Capture Resolution:
          gicr
      Get Video Capture Resolution:
          gvcr
    
    
    Runtime encoder configuration options:
    
      Set Encoding Bit-rate(in bytes):
          br:<val> e.g., br:4000000
      Get Encoding Bit-rate(in bytes):
          gbr
      Set Encoding Profile(only for H.264):
          ep:<val> e.g., ep:1
              (0): Baseline
              (1): Main
              (2): High
      Get Encoding Profile(only for H.264):
          gep
      Force IDR Frame on video Encoder(only for H.264):
          Enter 'f' 
    
    
    bitrate = 4000000
    Encoder Profile = High
    Encoder control-rate = 1
    Encoder EnableTwopassCBR = 0
    ** Message: 15:36:22.464: <main:4564> iterating capture loop ....
    Framerate set to : 30 at NvxVideoEncoderSetParameterNvMMLiteOpen : Block : BlockType = 4 
    ===== NVMEDIA: NVENC =====
    NvMMLiteBlockCreate : Block : BlockType = 4 
    H264: Profile = 100, Level = 40 
    GST_ARGUS: Creating output stream
    CONSUMER: Waiting until producer is connected...
    GST_ARGUS: Available Sensor modes :
    GST_ARGUS: 3280 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
    
    GST_ARGUS: 3280 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
    
    GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
    
    GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
    
    GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
    
    GST_ARGUS: Running with following settings:
       Camera index = 0 
       Camera mode  = 4 
       Output Stream W = 1280 H = 720 
       seconds to Run    = 0 
       Frame Rate = 120.000005 
    GST_ARGUS: PowerService: requested_clock_Hz=2016000
    GST_ARGUS: Setup Complete, Starting captures for 0 seconds
    GST_ARGUS: Starting repeat capture requests.
    CONSUMER: Producer has connected; continuing.
    
    

    相关文章

      网友评论

        本文标题:Jetson Nano Running Samples

        本文链接:https://www.haomeiwen.com/subject/putzvqtx.html