下载BSP包

当前版本 Jetson Linux R32.6.1

L4T Driver Package (BSP)


Host环境准备

Host : Ubuntu 18.04.6 VirtualBox

sudo apt update
sudo apt-get install --no-install-recommends qemu-user-static debootstrap binfmt-support coreutils parted gdisk e2fsprogs
sudo apt-get install libxml2-utils


创建rootfs

tar xvf jetson-210_linux_r32.6.1_aarch64.tbz2
cd Linux_for_Tegra

sudo debootstrap --verbose --arch=arm64 --foreign --variant=minbase --include=python3,python3-apt bionic rootfs

sudo cp /usr/bin/qemu-aarch64-static rootfs/usr/bin
sudo chroot rootfs /bin/bash -c "/debootstrap/debootstrap --second-stage --verbose"


target安装依赖

sudo chroot rootfs /bin/bash

apt-get install vim

vi /etc/apt/sources.list
deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ bionic universe
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates universe
deb http://ports.ubuntu.com/ubuntu-ports/ bionic multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-updates multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security universe
deb http://ports.ubuntu.com/ubuntu-ports/ bionic-security multiverse

apt update

apt-get install libx11-dev libgles2 libpangoft2-1.0-0 libharfbuzz0b libdatrie1 libxkbcommon0 libwayland-egl1 libwayland-cursor0 libunwind8 libpng16-16 libpixman-1-0 libjpeg-turbo8 libinput10 libgles2 libevdev2 libcairo2 device-tree-compiler iso-codes libffi6 libncursesw5 libpython3-stdlib libpython3.8-minimal libpython3.8-stdlib libreadline7 libtinfo5 python3-minimal python3.8 libglvnd0 libdrm-common libdrm2 libegl-mesa0 libegl1 libegl1-mesa libgtk-3-0 libgbm1 libglapi-mesa libwayland-server0 libx11-xcb1 libxcb-dri3-0 libxcb-present0 libxcb-sync1 libxcb-xfixes0 libxshmfence1 libgstreamer1.0-0 libgstreamer-plugins-bad1.0-0 libpangocairo-1.0-0 libasound2 libasound2-data libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python python-minimal python2.7 python2.7-minimal

apt-get install bash-completion btrfs-progs curl dnsutils htop iotop isc-dhcp-client iputils-ping kmod linux-firmware locales net-tools netplan.io pciutils python3.8 ssh systemd udev unzip usbutils wpasupplicant

apt-get install build-essential python3.8-dev

配置

vi /etc/netplan/netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true

netplan apply

vi /etc/locale.gen
en_US.UTF-8 UTF-8
zh_CN.UTF-8 UTF-8

locale-gen

apt-get install sudo
adduser <name>
vi /etc/sudoers

清理

apt clean

rm /dev/random
rm /dev/urandom

exit

rm rootfs/usr/bin/qemu-arm-static

收尾

安装nvidia-l4tnvidia-l4t-firmware,gpio

sudo ./apply_binaries.sh


生成镜像

  • jetson-nano: 100/200/300 for A01/A02/B00
cd tools
sudo ./jetson-disk-image-creator.sh -o jetson_4G.img -b jetson-nano -r 300
  • jetson-nano-2gb-devkit: default
cd tools
sudo ./jetson-disk-image-creator.sh -o jetson_2G.img -b jetson-nano-2gb-devkit
  • jetson-xavier-nx-devkit: default


烧录镜像

wget https://raw.githubusercontent.com/pythops/jetson-nano-image/master/flash-image.sh

chmod a+x flash-image.sh
sudo ./flash-image.sh jetson-nano-2gb-aipos.img /dev/sde


扩展swap

sudo dd if=/dev/zero of=/swapfile bs=1024 count=4100000
sudo mkswap /swapfile
sudo swapon /swapfile

cat /etc/fstab 
# <file system> <mount point>             <type>          <options>                               <dump> <pass>
/dev/root            /                     ext4           defaults                                     0 1
/swapfile            swap                  swap           defaults                                     0 0


补缺

sudo apt-get install nvidia-l4t-cuda nvidia-l4t-jetson-io nvidia-l4t-jetson-multimedia-api cuda-tools-10-2 libnuma1
# libnvvpi1 
# libvulkan1 vulkan-utils
# nvidia-tensorrt nvidia-cuda 
sudo ldconfig

sudo nvpmodel -m 0
# 之后jtop才可用

sudo apt-get install libcurand-10-2 libcudnn8 libcufft-10-2 libcublas10

sudo apt-get install nvidia-opencv

sudo apt-get install libturbojpeg

# 装完cuda后需要重新安装一下torch
python3 -m pip install torch-1.8.1-cp38-cp38-linux_aarch64.whl --force-reinstall


GPU问题处理

cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
./deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

cudaGetDeviceCount returned 100
-> no CUDA-capable device is detected
Result = FAIL

# 加入video组
sudo usermod -a -G video aipos
sudo reboot

python3 -m pip install python-multipart