系统镜像6G,默认安装ubuntu desktop等桌面软件,体积非常大,如果项目开发完成,想要将工程文件直接集成到镜像里,进行批量烧录,那么可以通过自制镜像的方式来实现。以下针对Nano版整理的制作方法。
一、下载BSP并解压
使用的是L4T Jetson-210_Linux_R32.7.2_aarch64.tbz2
1 2 3 | tar xvf Jetson-210_Linux_R32.7.2_aarch64.tbz2 cd Linux_for_Tegra |
二、host安装依赖
apt-get update
apt-get install --no-install-recommends -y qemu-user-static debootstrap binfmt-support coreutils parted gdisk e2fsprogs
三、运行debootstrap创建基础rootfs
debootstrap --arch=arm64 --foreign --variant=minbase --include=python3,python3-apt bionic rootfs
tee rootfs/etc/apt/sources.list -'EOF'
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main universe restricted
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main universe restricted
EOF
tee rootfs/etc/netplan/netcfg.yaml -'EOF'
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
EOF
cp /usr/bin/qemu-aarch64-static rootfs/usr/bin
chroot rootfs /bin/bash -c "/debootstrap/debootstrap --second-stage"
四、target安装依赖
此时需要chroot到rootfs内
chroot rootfs /bin/bash
apt update
apt-get install python-pip python-pycurl g++ libpython-dev python-numpy gnuradio gnuradio-dev rtl-sdr librtlsdr-dev osmo-sdr libosmosdr-dev libosmocore libosmocore-dev libboost-all-dev libcppunit-dev swig doxygen liblog4cpp5-dev python-scipy ant libusb-1.0-0 libfftw3-dev python3-pip python3-numpy python3-scipy gr-air-modes pkg-config git libssl-dev libsdl2-dev libasound2 libxmu-dev libxi-dev freeglut3-dev libasound2-dev libjack-jackd2-dev libxrandr-dev libgee-0.8-dev libgtk-3-dev libgranite-dev libvte-2.91-dev libjson-glib-dev libunity-dev meson valac gpg python-psutil python-demjson python-requests python-serial python-poster bash-completion build-essential btrfs-progs cmake curl htop iotop iputils-ping kmod linux-firmware locales net-tools netplan.io pciutils python3-dev ssh systemd udev unzip usbutils gpsd gpsd-clients
rm /dev/random
rm /dev/urandom
exit
./apply_binaries.sh
五、删除缓存文件
sudo rm rootfs/var/cache/apt/archives/*.deb
六、编译镜像
cd tools
#4G版:
sudo ./jetson-disk-image-creator.sh -o jetson_4G.img -b jetson-nano -r 300
七、烧录镜像
cd bootload
sudo cp jetson_4G.img.raw system.img
sudo ./flash.sh -r jetson-nano-emmc mmcblk0p1