使用jetson xavier 运行jetson-io.py闪退

问题描述

在配置gpio的时候,运行/opt/nvidia/jetson-io/jetson-io.py时界面一闪而过,无法正常使用配置。

问题种类以及解决方法

通过less参数来查看报错

sudo /opt/nvidia/jetson-io/jetson-io.py | less

解决方法

1.RuntimeError: Multiple APP partitions mounted!

首先创建patch.diff文件,并写入下面内容:

diff --git a/jetson-io/Jetson/board.py b/jetson-io/Jetson/board.py
index 8d0eb86..aa540e2 100644
--- a/jetson-io/Jetson/board.py
+++ b/jetson-io/Jetson/board.py
@@ -117,6 +117,22 @@ def _board_get_dtb(compat, model, path):
     return dtbs[0]


+def _board_root_partition_is_block_device():
+    dev = syscall.call_out('mountpoint -q -d /')
+    if not dev or len(dev) != 1:
+        raise RuntimeError("Root partition not found!")
+    return os.path.exists("/dev/block/%s" % dev[0])
+
+
+def _board_root_partition_get_partlabel():
+    entries = syscall.call_out('lsblk -n -r -o mountpoint,partlabel')
+    for entry in entries:
+        mountpoint,label = entry.split(' ')
+        if mountpoint == '/':
+            return label
+    return None
+
+
 def _board_partition_exists(partlabel):
     numparts = 0
     partlabels = syscall.call_out('lsblk -n -r -o partlabel')
@@ -126,16 +142,12 @@ def _board_partition_exists(partlabel):
     return numparts


-def _board_partition_is_mounted(partlabel):
-    mountpoint = None
-    entries = syscall.call_out('lsblk -n -r -o mountpoint,partlabel')
-    for entry in entries:
-        mount,label = entry.split(' ')
-        if partlabel == label:
-            if mountpoint:
-                raise RuntimeError("Multiple %s partitions mounted!" % partlabel)
-            mountpoint = mount
-    return mountpoint
+def _board_partition_is_root_mountpoint(partlabel):
+    if not _board_root_partition_is_block_device():
+        return False
+    if _board_root_partition_get_partlabel() == 'APP':
+        return True
+    return False


 def _board_partition_mount(partlabel):
@@ -195,27 +207,22 @@ class Board(object):
     def __init__(self):
         self.appdir = None
         self.bootdir = '/boot'
+        self.extlinux = '/boot/extlinux/extlinux.conf'
+        dtbdir = os.path.join(self.bootdir, 'dtb')
         fio.is_rw(self.bootdir)

-        # The partition that needs to be updated by Jetson-IO is the APP
-        # partition. In certain cases, such as mounting the rootfs via
-        # NFS, the APP partition is not mounted by default and so needs
-        # to be mounted. Therefore, we first check to see if the APP
-        # partition is mounted and if so where it is mounted. If it is
-        # not mounted then it is necessary to find and mount the 'APP'
-        # partition and copy the generated files back to this partition.
-        mountpoint = _board_partition_is_mounted('APP')
-        if mountpoint:
-            if mountpoint != '/':
-                self.bootdir = mountpoint
-            dtbdir = os.path.join(self.bootdir, 'dtb')
-        else:
+        # When mounting the rootfs via NFS, the root partition is not a
+        # block device. Furthermore, when booting with NFS the partition
+        # that the bootloader reads to parse the extlinux.conf and load
+        # the kernel DTB may not be mounted. Therefore, if the rootfs is
+        # not mounted on a partition called 'APP', then it is necessary
+        # to find and mount the 'APP' partition and copy the generated
+        # files back to this partition.
+        if not _board_partition_is_root_mountpoint('APP'):
             self.appdir = _board_partition_mount('APP')
             dtbdir = os.path.join(self.appdir, 'boot/dtb')
             fio.is_rw(self.appdir)

-        self.extlinux = os.path.join(self.bootdir, 'extlinux/extlinux.conf')
-
         # Import platform specific data
         self.compat = dt.read_prop('compatible')
         self.model = dt.read_prop('model')

执行

patch /opt/nvidia/jetson-io/Jetson/board.py < patch.diff

接下来可正常使用jetson-io.py进行配置。

2.ImportError: cannot import name ‘board’!

执行

sudo find /opt/nvidia/jetson-io/ -mindepth 1 -maxdepth 1 -type d -exec touch {}/__init__.py \;

3.No DTB found for NVIDIA Jetson Nano Developer Kit!’

执行

sudo mkdir /boot/dtb

sudo cp -v /boot/tegra210-p3448-0000-p3449-0000-[ab]0[02].dtb /boot/dtb/

小结

后两种是由于版本的原因,第一种是挂了ssd导致的,都是比较常见的问题。

参考:

https://forums.developer.nvidia.com/t/jetson-io-py-in-r32-7-2/231472
https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-325/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/hw_setup_jetson_io.html