export JTX2=~/JetsonTx2/Linux_for_Tegra
mkdir $JTX2/myspace -p
cd $JTX2/myspace
mount_roofs ()
{
sudo mount -v --bind /dev base/dev
sudo mount -vt devpts devpts base/dev/pts -o gid=5,mode=620
sudo mount -vt proc proc base/proc
sudo mount -vt sysfs sysfs base/sys
sudo mount -vt tmpfs tmpfs base/run
}
umount_roofs ()
{
sudo umount base/dev/pts
sudo umount base/proc
sudo umount base/sys
sudo umount base/run
sudo umount base
}
## Alpine 不能用, 因为官方包是 deb 的
# git clone https://github.com/alpinelinux/alpine-chroot-install.git
# sudo ./alpine-chroot-install/alpine-chroot-install \
# -m http://mirrors.tuna.tsinghua.edu.cn/alpine \
# -d $JTX2/rootfs \
# -a aarch64 \
# -p openrc
wget http://cdimage.ubuntu.com/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.4-base-arm64.tar.gz
tar -pxvf ubuntu-base-20.04.4-base-arm64.tar.gz -C $JTX2/rootfs
sudo $JTX2/apply_binaries.sh
sudo rm $JTX2/rootfs/dev/random $JTX2/rootfs/dev/urandom
cd $JTX2/myspace
sudo cp /etc/resolv.conf $JTX2/rootfs/etc/
source tools.sh
mount_roofs
sudo chroot $JTX2/rootfs /usr/bin/bash
apt --fix-broken install
umount_roofs
sudo ./flash.sh jetson-tx2-devkit mmcblk0p1
setenv ipaddr 192.168.31.100
setenv serverip 192.168.31.111
kernel_addr_r=80280000
tftp 80280000 zImage
tftp 80000000 tegra186-quill-p3310-1000-c03-00-dsi-hdmi-hdmi-imx274-hdmiin.dtb
bootz 80280000 - 80000000
## 更新 kernel 分区,实际是 u-boot, linux kernel 在 /boot 分区中, 由 u-boot 引导
sudo ./flash.sh -k BMP \
--image myspace/logo_create/jw_boot_logo/bmp.blob jetson-tx2-devkit mmcblk0p1
grep -nr "eth0" ./
-H 显示文件名
-r 搜索子目录
-n 显示行号
-i 不区分大小写
-w 只匹配整个单词
////////////////// Ubuntu rootfs /////////////////////////
mkdir $LFS/ubuntu -p
cd $LFS/src
wget http://cdimage.ubuntu.com/ubuntu-base/releases/18.04/release/ubuntu-base-18.04.5-base-armhf.tar.gz
tar -pxf ubuntu-base-18.04.5-base-armhf.tar.gz -C $LFS/ubuntu
sudo cp /etc/resolv.conf $LFS/ubuntu/etc/
sudo mount -v --bind /dev $LFS/ubuntu/dev
sudo mount -vt devpts devpts $LFS/ubuntu/dev/pts -o gid=5,mode=620
sudo mount -vt proc proc $LFS/ubuntu/proc
sudo mount -vt sysfs sysfs $LFS/ubuntu/sys
sudo mount -vt tmpfs tmpfs $LFS/ubuntu/run
sudo chroot $LFS/ubuntu /bin/bash
////// IN CHROOT /////
apt-get update
apt-get upgrade
apt-get install net-tools dhcpcd5
apt-get install vim
apt-get install systemd
echo auto eth0 > /etc/network/interfaces
echo iface eth0 inet dhcp >> /etc/network/interfaces
////// OUT CHROOT ////
sudo umount $LFS/ubuntu/dev/pts
sudo umount $LFS/ubuntu/dev
sudo umount $LFS/ubuntu/proc
sudo umount $LFS/ubuntu/sys
sudo umount $LFS/ubuntu/run
dd if=/dev/zero of=$LFS/dst/rootfs.img bs=1G count=2
mkfs.ext4 $LFS/dst/rootfs.img
sudo mount -o loop $LFS/dst/rootfs.img /mnt
sudo cp $LFS/ubuntu/* /mnt -r
sudo umount /mnt
qemu-system-arm \
-M vexpress-a9 \
-m 512M \
-nographic \
-kernel $LFS/dst/zImage \
-net nic -net user,hostfwd=tcp::10021-:22 \
-dtb $LFS/dst/vexpress-v2p-ca9.dtb \
-sd $LFS/dst/rootfs.img \
-append "root=/dev/mmcblk0 rw console=ttyAMA0"
mount -t sysfs sys /sys
mount -t proc proc /proc
mount -t devtmpfs udev /dev
/sbin/init -> /lib/systemd/systemd
load mmc 1:1 80280000 zImage
load mmc 1:1 80000000 suniv-f1c100s-licheepi-nano.dtb
bootz 0x60008000 - 0x61000000
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
网友评论