桌面系统
lightdm桌面系统比gdm3可以少用500m内存
优化L4T
https://www.codeinsideout.com/blog/jetson/linux-tegra/
开箱手册
https://gilberttanner.com/blog/jetson-nano-getting-started
https://elinux.org/Jetson_Zoo#ONNX_Runtime
(注意:tensorflow等版本有更新)
开发文档和JetPack包
https://docs.nvidia.com/jetson/archives/
https://developer.nvidia.com/embedded/jetpack
GPIO唤醒
https://forums.developer.nvidia.com/t/configuring-gpio-wake/59912/2
https://blog.csdn.net/weixin_30824121/article/details/112214371
usb电源重置(使用了几次之后,主板会无故重启,待考究)
usb端口号别名
https://www.clearpathrobotics.com/assets/guides/kinetic/ros/Udev%20Rules.html
- 依据
主板存在多个USB,每个USB注册在操作系统固定的设备树路径,可用如下命令查看,得到下图。
$ ls -l /sys/bus/usb-serial/devices

1)串口编号随设备插入USB的时间先后分配序号;
2)路径则相对操作系统固定
- 查询usb设备连接属性
得到ATTRS参数列表(见后图),从父子结构属性树的某一层,找出一组:
KERNELS,SUBSYSTEMS,DRIVERS
$ udevadm info --name=/dev/ttyUSB0 --attribute-walk

- 配置一个规则文件可以,独用或混合使用ATTRS,ENV
$ sudo vi /etc/udev/rules.d/99-usb-serial.rules
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", DRIVERS=="cp210x", KERNELS=="1-2.2:1.0", MODE="0666", SYMLINK+="wheeltec_base"
生效规则文件, 测试(验证是否和上面同样命令的执行结果相同)
$ sudo udevadm trigger
# 测试
$ udevadm info --name=/dev/wheeltec_base --attribute-walk


常用手册
https://github.com/jetsonhacks/jetsonUtilities
1)常用命令
- 先安装jetson_stats
https://github.com/rbonghi/jetson_stats
$ sudo jtop
$ jetpack版本
$ cat /etc/nv_tegra_release
- opencv版本
$ cd /usr/bin
$ ./opencv_version
* cuda版本
$ cd /usr/local/cuda/bin
$ nvcc -v
$ gst-inspect-1.0 --gst-version
排错
- Failed to fetch ubuntu bionic arm64 packages
https://github.com/tuna/issues/issues/595#issuecomment-613789709
$ sudo vi /etc/apt/source.list
...
deb https://mirrors.aliyun.com/ubuntu-ports xenial main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports xenial-security main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports xenial-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports xenial-proposed main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports xenial-backports main restricted universe multiverse
...
$ sudo apt-get update
- Package nvidia-l4t-xusb-firmware is not configured yet.
因将/usr/bin/python指向python3导致问题
https://forums.developer.nvidia.com/t/errors-on-nvidia-l4t-xusb-firmware-and-nvidia-l4t-initrd/159209
$ sudo vi /usr/sbin/l4t_payload_updater_t210
#!/usr/bin/python
to
#!/usr/bin/python2
安装 jetson-inference
参考
https://github.com/dusty-nv/jetson-inference
https://www.rs-online.com/designspark/hands-on-with-the-nvidia-jetson-nano
$ sudo apt update
$ sudo apt install git cmake libpython3-dev python3-numpy
$ git clone --recursive https://github.com/dusty-nv/jetson-inference
$ cd jetson-inference
$ mkdir build
$ cd build
$ cmake ../
$ make
$ sudo make install
$ sudo ldconfig
BLAS和LAPACK的openblas安装
http://jungle.webhop.me:81/admin/index.html#/posts/edit?postId=273
安装pcl
包括pcl的依赖,vtk/flann/glew/boost更新/等等
http://jungle.webhop.me:81/admin/index.html#/posts/edit?postId=143
安装opencv
opencv安装,包括ffmpeg,gstreamer等依赖库安装
http://jungle.webhop.me:81/admin/index.html#/posts/edit?postId=81
ffmpeg安装
参考
https://forums.developer.nvidia.com/t/hardware-accelerated-video-playback-with-l4t-ffmpeg/154019/7
- 删除老版本
$ sudo dpkg -l | grep ffmpeg #查看安装
$ sudo dpkg -r ffmpeg
$ sudo apt-get purge '*ffmpeg*'
# 下方删除要谨慎
$ sudo find /usr -name "*ffmpeg*" -exec rm -rf {} \;
- 安装
$ echo "deb https://repo.download.nvidia.com/jetson/ffmpeg main main" | sudo tee -a /etc/apt/sources.list
$ echo "deb-src https://repo.download.nvidia.com/jetson/ffmpeg main main" | sudo tee -a /etc/apt/sources.list
$ sudo apt update
$ sudo apt install ffmpeg
- 检查
$ ffmpeg -decoders | grep nvv4l2
安装TensorFlow.1.x
参考
https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform/index.html
https://docs.nvidia.com/deeplearning/frameworks/install-tf-jetson-platform-release-notes/tf-jetson-rel.html
# Install system packages required by TensorFlow:
$ sudo apt-get update
$ sudo apt-get install libhdf5-serial-dev hdf5-tools libhdf5-dev zlib1g-dev zip libjpeg8-dev liblapack-dev libblas-dev gfortran
# Install and upgrade pip3.
$ sudo apt-get install python3-pip
$ sudo pip3 install -U pip testresources setuptools==49.6.0
# Install the Python package dependencies.
$ sudo pip3 install -U numpy==1.19.4 future==0.18.2 mock==3.0.5 h5py==2.10.0 keras_preprocessing==1.1.1 keras_applications==1.0.8 gast==0.2.2 futures protobuf pybind11
$ sudo pip3 install --pre --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v45 'tensorflow<2'
- 测试
$python3
>>>import tensorflow as tf
g)测试cv2
$ workon pyenv_ros2
$ python
>>> import cv2
>>> print(cv2.__version__)
安装pytorch/LibTorch
手册
https://qengineering.eu/install-pytorch-on-jetson-nano.html(包括:pytorch/LibTorch/Caffe2/TorchVision)
https://forums.developer.nvidia.com/t/pytorch-for-jetson-version-1-9-0-now-available/72048(TODO,好像是CPU版本)
$ python
>> import torch
>> torch.__version__
>> torch.cuda.is_available()
True <- 检查
安装TorchVision
- 检查报错
$ python3
> import torchvision as tv
...
PIL.Image Has No Attribute Image
解决:
#删除在/usr/lib/python3/有个pillow 5x版本
$ sudo rm -rf /usr/lib/python3/dist-packages/Pillow-5.1.0.egg-info
$ sudo rm -rf /usr/lib/python3/dist-packages/PIL
# 新安装pillow
$ sudo pip3 install -U pillow
将安装与/usr/local/lib/python3.6/dist-packages
Torchvision is a collection of frequent used datasets, architectures and image algorithms.
编译onnxruntime
https://medium.com/vitrox-publication/build-onnxruntime-from-source-on-windows-10-e85ea5fe71db
https://elinux.org/Jetson_Zoo#ONNX_Runtime
http://article.docway.net/details?id=6046eea04da5fa50e15091ca
- 下载最新
$ git clone https://github.com/microsoft/onnxruntime.git -b v1.8.2
- 编译
$ cd onnxruntime
- 修改cmake/CMakeLists.txt
option(onnxruntime_BUILD_UNIT_TESTS "Build ONNXRuntime unit tests" OFF)
$ ./build.sh --config Release --skip_submodule_sync --build_shared_lib --build_wheel --parallel --use_openmp --use_cuda --skip_tests --cudnn_home "/usr/local/cuda-10.2" --cuda_home "/usr/local/cuda-10.2"
- 安装
$ cd build/Linux/Release/dist
$ sudo python -m pip install onnxruntime_gpu-1.8.2-cp36-cp36m-linux_aarch64.whl
- 验证
>> import onnxruntime as rt
>> rt.get_device()
'GPU'
安装vscode
1)下载
https://github.com/futurejones/code-oss-aarch64/releases
2)安装
https://code.visualstudio.com/docs/setup/linux
$sudo dpkg -i code-oss_1.44.2-1587955852_arm64_ubuntu-18.04.deb
安装arduino
https://www.instructables.com/To-Install-Arduino-Software-IDE-on-Jetson-Nano-Dev/
增加系统交换空间
https://www.jetsonhacks.com/2019/11/28/jetson-nano-even-more-swap/
$ git clone https://github.com/JetsonHacksNano/resizeSwapMemory
$ cd resizeSwapMemory
$ ./setSwapMemorySize.sh -g 8
深度学习起步
https://gilberttanner.com/blog/jetson-nano-getting-started
MPI Solutions for GPUs
https://developer.nvidia.com/mpi-solutions-gpus
https://www.open-mpi.org/faq/?category=buildcuda
配置opencv到pyenv_ros2(不需要,这个方法可以了解)
$ cd ~/.pyenvs/pyenv_ros2/lib/python3.6/site-packages
$ ln -s /usr/local/lib/python3.6/site-packages/cv2/python-3.6/cv2.cpython-36m-aarch64-linux-gnu.so cv2.so
从硬盘运行系统
1)准备
a)主要参考文章(视频)
https://www.jetsonhacks.com/2019/09/17/jetson-nano-run-from-usb-drive/
(老文章https://www.jetsonhacks.com/2019/04/25/jetson-nano-run-on-usb-drive/)
b)Linux内核主要相关的概念:
Jetson bootloaders|an initrd (initial ramdisk)|Linux kernel|USB driver|USB firmware
c)相关概念参考文章
https://blog.csdn.net/seek_0380/article/details/106563825
https://stackoverflow.com/questions/10603104/the-difference-between-initrd-and-initramfs
d)下载脚本
https://github.com/JetsonHacksNano/rootOnUSB
$ cd
$ git https://github.com/JetsonHacksNano/rootOnUSB.git
$ cd rootOnUSB
2)动手了,只需4步
///////////////////////////
网络配置
查看当前网络配置
$ ll ll /etc/NetworkManager/system-connections
重启网卡服务
$ sudo /etc/init.d/networking restart
桌面共享
https://www.fatalerrors.org/a/jetson-nano-configuration-vnc.html
https://github.com/overclock98/Jetson_Nano_true_Headless_setup_without_hdmi_display
- 安装
- 完善nano 4g一个bug(nano_2g_L4T 32.6.1正常)
$ vi /usr/share/glib-2.0/schemas/org.gnome.Vino.gschema.xml
# 添加(若缺少)
<key name='enabled' type='b'>
<summary>Enable remote access to the desktop</summary>
<description>
If true, allows remote access to the desktop via the RFB
protocol. Users on remote machines may then connect to the
desktop using a VNC viewer.
</description>
<default>true</default>
</key>
# 重新编译
$ sudo glib-compile-schemas /usr/share/glib-2.0/schemas
- 配置远程访问
选择vino-server(XRDP占用内存高)
- 通过命令行配置
# Disable encryption for the VNC server
$ gsettings set org.gnome.Vino require-encryption false
$ gsettings set org.gnome.Vino prompt-enabled false
# Find the UUIDs of your connections
$ nmcli connection show
# Replace UUID with yours as a comma separated list in the square brackets of the configuration line
$ dconf write /org/gnome/settings-daemon/plugins/sharing/vino-server/enabled-connections "['UUID']"
# 6-Enabling Automatic Login (otherwise cant start from ssh): steps
$ sudo nano /etc/gdm3/custom.conf
添加或启用
AutomaticLoginEnable = true
AutomaticLogin = yourname
# 配置/etc/X11/xorg.conf
$ vi /etc/X11/xorg.conf
在文件末尾添加
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Tegra0"
SubSection "Display"
Depth 24
Virtual 1920 1600 # Modify the resolution by editing these values
EndSubSection
EndSection
# 重启,启动vino server
$ sudo reboot
$ export DISPLAY=:0 && /usr/lib/vino/vino-server
若在有物理显示器的终端,则直接启动
$ /usr/lib/vino/vino-server
- 通过GUI配置(若有显示器)
1)打开窗口 : 系统设置 > desktop sharing

2) 设置控制参数
$ sudo apt-get install dconf-editor
$ dconf-editor

3)自动启动
- 打开设置程序: Start the application

去掉桌面环境GUI
https://lunar.computer/posts/nvidia-jetson-nano-headless/
连接PCA9685 PWM driver
1)更新GPIO库
1)本系统和树莓派的RPi.GPIO的API完全相同(开发的应用程序模块可兼容)
2)下载安装GPIO库
https://github.com/NVIDIA/jetson-gpio
...
3)安装PCA9685 servo library
pip3 install Adafruit_PCA9685
4)引脚连线(左侧为PCA9685模块)
VCC <-> 3.3v(1)
SDL <-> SDL(3)
SCL <-> SCL(5)
GND <-> GND(9)
图示见:http://docs.donkeycar.com/guide/build_hardware/#step-4-connect-servo-shield-to-raspberry-pi
