I hope to have the freedom to choose to start the USB storage device/EMMC system when booting up

I hope to have some way to decide whether to boot the system from the emmc or from the USB drive when the Jetson TX2 NX starts up. Is this achievable? I switched the boot device now by modifying/boot/extLinux/extlinux.cn, but this requires modifying the file and restarting after booting. Is there any other way?

Debugging in the U-Boot Environment
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3274/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/uboot_guide.html
Changing Boot Order with U-Boot
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3274/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/flashing.html

Hello, I found the Boot Sequence section in the link, but it only mentions simple information and does not provide an actual method. I am UEFI Adaptation — Jetson Linux<br/>Developer Guide 34.1 documentation -UEFI was discovered in bootloader uefi, which mentioned ‘How to select boot device in UEFI’. This feature sounds like it meets my needs, but it seems that my Jetson TX2 NX (Jetpack 4.6.2) cannot perform the same operation. Is there any other way to achieve similar functionality?

開機的時候按鍵盤可以中斷U-Boot,進到U-Boot prompt
先用

printenv boot_targets

確認你現在的開機順序長怎樣,
再用

setenv boot_targets <new value>
saveenv

修改設定
這樣看得懂?

你貼的那個是rel-35以後用UEFI的方式,TX2不支援rel-35、也沒有UEFI可以用

TX2 cannot use L4T R34.x, it is limited to R32.x. This means there is no UEFI and you must use documents for the L4T R32.x release. Your release can be found with “head -n 1 /etc/nv_tegra_release”. Then find docs here for that exact release:
https://developer.nvidia.com/linux-tegra

我进到U-Boot后执行命令printenv boot_targets,查到的结果开机顺序是mmc1 mmc0 usb0 nvme0 pxe dhcp
然后我使用命令setenv boot_targets usb0 mmc1 mmc0 nvme0 pxe dhcp修改了启动顺序 ,saveenv后执行reset重启设备。

之后测试设置是否生效时首先将USB设备接入TX2 NX后开机,此时系统仍然从EMMC启动了,我断电重新查看U-Boot的启动顺序,发现启动顺序仍然是我修改后的结果。

U盘中的设备是使用如下命令从EMMC中复制到U盘中的:
sudo dd if=/dev/mmcblk0p1 of=/dev/sda1 bs=4M status=progress

麻煩你檢查一下USB disk上/boot/extlinux/extlinux.conf這個檔案裡root的值,把它改成你的USB disk
現在的情況大概是kernel確實是從USB disk讀,但是rootfs還是mount在eMMC

正規方法應該是要重燒,不是直接用dd複製…

我将USB disk中的 /boot/extlinux/extlinux.conf root值改为USB disk后仍然不能正常启动。
我尝试将系统烧录至USB Disk。

首先我在官网下载了4.6.2版本的系统包(Jetson_Linux_R32.7.2_aarch64.tbz2以及Tegra_Linux_Sample-Root-Filesystem_R32.7.2_aarch64.tbz2)

 tar xf  /path/Jetson_Linux_R32.7.2_aarch64.tbz2 #得到Linux_for_tegra文件夹。
进入Linux_for_tegra/rootfs下,将Tegra_Linux_Sample-Root-Filesystem_R32.7.2_aarch64.tbz2文件解压至此处(sudo tar xfp /path/Tegra_Linux_Sample-Root-Filesystem_R32.7.2_aarch64.tbz2)
cd ..
sudo ./apply_binaries.sh

接下来我使用这个文件夹进行了一次镜像烧录,sudo ./flash.sh jetson-xavier-nx-devkit-tx2-nx mmcblk0p1 ,该设备烧录完成可以正常进入系统。

下面我尝试进行USB Disk的系统烧录,在 Compiling Tegra Source Code | Jetson Tegra X1 and X2 | RidgeRun中我发现 Flashing the board部分有USB Disk的烧录流程。我尝试按照作者提供的流程进行烧录,下面是我执行过的命令:

#首先将USB Disk直接接入PC
mount #得到的输出中查找到USB Disk的位置/dev/sdc1

umount /dev/sdc1
sudo mkfs.ext4 /dev/sdc1

export DEVDIR=/path/Linux_for_Tegra
mkdir -p $DEVDIR/images/fs
sudo mount /dev/sdc1 $DEVDIR/images/fs 
cd $DEVDIR/rootfs/
sudo cp -a * $DEVDIR/images/fs  && sync

sudo umount $DEVDIR/images/fs
#在这里从PC移除USB DISK并将其接入TX2 NX,将设备设置为烧写模式,连接PC,进入到Linux_for_tagra后执行:
sudo ./flash.sh  jetson-xavier-nx-devkit-tx2-nx sda1

这时执行flash.sh会发现这个脚本执行耗时比正常烧录短,我将设备与PC断开并退出烧录模式、未移除USB设备的情况下开机最终未进入系统。屏幕上仅显示一个窗体内容为:
The installer encountered an unrecoverable error.A desktop session will now be run so that you may inverstigate the problem or try installing again.
点击下方的OK按钮后设备最终会黑屏。
这种烧录方法会导致emmc中原本存在的系统不能直接启动,我尝试将这个USB Disk插入到第二台tx2 nx中启动,第二台设备中的emmc搭载了系统并能正常启动,我在U-Boot中修改了启动顺序至usb0 mmc1 mmc0 nvme0 pxe dhcp
我在U-boot中再次确认启动顺序,仍然为usb0 mmc1 mmc0 nvme0 pxe dhcp ,如果执行
setenv bootdev usb 0 #尝试了两次,第二次在这里插入了一句usb start,但是有报错 #Tegra186 (P3636-0001) # usb start #starting USB... #No working controllers found boot
输入boot后会直接启动emmc中的系统

麻煩照我們官方文件上的步驟做
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3274/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/flashing.html#wwpID0E0HO0HA
請不要找一些第三方的教學拿來問我們為什麼這樣做不會動
這些教學不是我們寫的,我們也沒有驗證過…

我的烧录过程遇到些问题。
首先我的操作流程是:

#在Jetson Linux R32.7.2 Release Page下载secureboot_R32.7.2_aarch64.tbz2并解压至Linux_for_Tegra内
#将USB设备接入到Jetson
sudo gdisk /dev/sda1 #查询U Disk的sector_size和num_sectors

#将U Disk格式化为Ext格式并取消挂载
sudo umount /dev/sda1
sudo mkfs.ext4 /dev/sda1
#弹出并将U Disk接入TX2 NX,将TX2 NX置于恢复模式,将Host PC与其相连接。
gedit Linux_for_Tegra/tools/kernel_flash/flash_l4t_nvme.xml #将sector_size和num_sectors修改到与刚才查询的一致。
cd   Linux_for_Tegra/tools/kernel_flash
sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device sda1 -c ./tools/kernel_flash/flash_l4t_nvme.xml -S 16GiB --showlogs jetson-xavier-nx-devkit-tx2-nx nvme0n1p1
#这个命令来源于README_initrd_flash.txt中Workflow 3: How to flash to an external storage部分:
Example usage:
Flash USB-connected storage use APP partition on it as root filesystem
sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device sda1 -c ./tools/kernel_flash/flash_l4t_nvme.xml -S 8GiB  --showlogs  jetson-xavier mmcblk0p1

执行l4t_initrd_flash.sh的输出为:
Run command: if [ -f /qspi/l4t_flash_from_kernel.sh ]; then USER=root /qspi/l4t_flash_from_kernel.sh --no-reboot --qspi-only ; fi on root@fe80::1%enp0s20u3
4194304
[ 0]: l4t_flash_from_kernel: Starting to create gpt for emmc
Active index file is /home/mnv/Videos/Linux_for_Tegra/tools/kernel_flash/images/internal/flash.idx
Number of lines is 56
max_index=55
writing item=21, 1:3:primary_gpt, 512, 2097152, gpt_primary_1_3.bin, 16896, fixed--0, ab61274d922628fe13f4077aa144ef8841355e40
Writing primary_gpt partition with gpt_primary_1_3.bin
Offset is not aligned to K Bytes, no optimization is applied
dd if=/home/mnv/Videos/Linux_for_Tegra/tools/kernel_flash/images/internal/gpt_primary_1_3.bin of=/dev/sdc bs=1 skip=0 seek=512 count=16896
16896+0 records in
16896+0 records out
16896 bytes (17 kB, 16 KiB) copied, 0.0272283 s, 621 kB/s
Writing primary_gpt partition done
Error: Invalid argument during seek for read on /dev/sdc
[ 4]: l4t_flash_from_kernel: Error: partprobe failed. This indicates that:

  • the xml indicates the gpt is larger than the device storage
  • the xml might be invalid
  • the device might have a problem.
    Please make correction.
    Error flashing non-qspi storage
[flash.txt|attachment](upload://gkhjnXy6IvDBFSk4ku7Td6gJc6t.txt) (89.8 KB)
#文件中是全部的输出
我的设备是Jetson TX2 NX,U Disk设备大小是64GB

flash.txt (89.8 KB)

你確定你的flash command是對的?
為什麼最後是/dev/sdc

我确认我的命令是sda,这是否和我系统的分区有关。
我执行df -h的结果是:

Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  2.0M  1.6G   1% /run
/dev/sdb4       1.5T  174G  1.2T  13% /
tmpfs           7.8G     0  7.8G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/loop1       92M   92M     0 100% /snap/gtk-common-themes/1535
/dev/loop0      512K  512K     0 100% /snap/gnome-characters/795
/dev/loop3      640K  640K     0 100% /snap/gnome-logs/106
/dev/loop2       56M   56M     0 100% /snap/core18/2796
/dev/loop6      768K  768K     0 100% /snap/gnome-characters/726
/dev/loop5       74M   74M     0 100% /snap/core22/864
/dev/loop7      242M  242M     0 100% /snap/gnome-3-38-2004/70
/dev/loop4      497M  497M     0 100% /snap/gnome-42-2204/141
/dev/loop8      219M  219M     0 100% /snap/gnome-3-34-1804/93
/dev/loop9      1.7M  1.7M     0 100% /snap/gnome-system-monitor/186
/dev/loop10      66M   66M     0 100% /snap/gtk-common-themes/1515
/dev/loop16     128K  128K     0 100% /snap/bare/5
/dev/loop12     896K  896K     0 100% /snap/gnome-logs/121
/dev/loop15      64M   64M     0 100% /snap/core20/2182
/dev/loop11     2.3M  2.3M     0 100% /snap/gnome-calculator/953
/dev/loop13     1.5M  1.5M     0 100% /snap/gnome-system-monitor/184
/dev/loop14     505M  505M     0 100% /snap/gnome-42-2204/172
/dev/loop17     350M  350M     0 100% /snap/gnome-3-38-2004/143
/dev/loop19      40M   40M     0 100% /snap/snapd/21184
/dev/loop20      64M   64M     0 100% /snap/core20/2015
/dev/loop21     2.3M  2.3M     0 100% /snap/gnome-calculator/955
/dev/loop18      56M   56M     0 100% /snap/core18/2812
/dev/loop22      41M   41M     0 100% /snap/snapd/20290
/dev/loop23     219M  219M     0 100% /snap/gnome-3-34-1804/72
/dev/sda1        96M   31M   66M  32% /boot/efi
tmpfs           1.6G   20K  1.6G   1% /run/user/121
tmpfs           1.6G   44K  1.6G   1% /run/user/1000
/dev/loop24      16G  4.8G   11G  32% /home/mnv/Videos/Linux_for_Tegra/bootloader/mnt

系统中原本就已存在/dev/sda1,这是否会造成影响。

对于/dev/sdc,系统内原本无此分区。在执行l4t_initrd_flash.sh后才会出现。我使用sudo blkid查询到的结果是/dev/sdc: PTUUID=“5ddec359-3f1a-4cc1-8fcb-bdb5407a6adb” PTTYPE=“gpt”
在我断开Jetson与PC的连接后查询不到这个分区了。
我尝试将命令修改为:

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device sdc(在这里将sda换为sdc) -c ./tools/kernel_flash/flash_l4t_nvme.xml -S 16GiB --showlogs jetson-xavier-nx-devkit-tx2-nx nvme0n1p1

得到了同样的输出

現在討論的都是Jetson上的東西
跟你的host PC上有什麼storage完全沒關係…

我修改了方法后重新尝试了一次,完整的操作流程:

#在HOST PC上保证依赖已经全部安装:
 sudo apt install libxml2-utils simg2img network-manager abootimg sshpass device-tree-compiler

#在验证过能够正常烧录系统的Linux_for_Tegra同级目录执行
tar xjvf secureboot_R32.7.2_aarch64.tbz2

#在Jetson上
sudo blockdev --getbsz /dev/sda1     # 查看扇区大小4096
sudo blockdev --getsz /dev/sda1       # 查看分区总扇区数量1212395252
sudo umount /dev/sda1
sudo mkfs.ext4 /dev/sda1

#在Host PC上
systemctl stop udisks2.service
#将USB Disk插入TX2 NX,然后将设备设置为恢复模式,并使用数据线连接至Host PC

cd Linux_for_Tegra/
#编辑Linux_for_Tegra/tools/kernel_flash/flash_l4t_nvme.xml
    <device type="nvme" instance="0" sector_size="512" num_sectors="60604416">修改为
    <device type="nvme" instance="0" sector_size="4096" num_sectors="121239552">
#编辑Linux_for_Tegra/bootloader/t186ref/cfg/flash_l4t_t186.xml
    <device type="sdmmc_boot" instance="3" sector_size="4096" num_sectors="16384">修改为<device type="nvme_boot" instance="3" sector_size="4096" num_sectors="16384">
    <device type="sdmmc_user" instance="3" sector_size="4096" num_sectors="61071360">修改为<device type="nvme_user" instance="3" sector_size="4096" num_sectors="61071360">

sudo ./tools/kernel_flash/l4t_initrd_flash.sh --external-device sda1 -c ./tools/kernel_flash/flash_l4t_nvme.xml -S 16GiB  --showlogs   jetson-xavier-nx-devkit-tx2-nx mmcblk0p1

执行脚本报错
Error: Return value 4 Command tegraparser_v2 --generategpt --pt flash.xml.bin Error: /home/mnv/Videos/Linux_for_Tegra/bootloader/signed/flash.idx is not found Error: failed to relocate images to /home/mnv/Videos/Linux_for_Tegra/tools/kernel_flash/images Cleaning up...
请问我需要在哪个步骤修改以解决这个报错?

完整的l4t_initrd_flash.sh输出
failed_to_relocate_images.txt (13.3 KB)

看不懂你這裡在做什麼
我們的文件有那裡說要這樣改?

我在README_initrd_flash.txt中看到有写:
This tool does not support size discovery for internal emmc/sdcard. Therefore,
you might need to change the “num_sectors” field in the config file under
bootloader/t186ref/cfg if the default “num_sectors” is incompatible. You must
change “num_sectors” so that num_sectors * sector_size is equal to or smaller
the size of the internal emmc/sd card of your Jetson.
对于我的情况,这部分是不需要修改的吗?或者是我的修改方法不对?

你真的知道自己在做什麼嗎…
你要改也是改flash_l4t_nvme.xml 請不要動flash_l4t_t186.xml

所以flash_l4t_nvme.xml应该如何修改?
是否仅需要修改<device type="nvme" instance="0" sector_size="512" num_sectors="121239552"> 中的num_sectors即可? 我需要确认sector_size是固定为512还是需要使用USB设备实际的值?