libgpiod 库中的 gpiomon 似乎行为不正确

libgpiod 库中的 gpiomon 似乎行为不正确

我正在尝试使用libgpiodarmbian linux 监控 GPIO 事件。根据我的设备的引脚排列(BananaPI Zero M2 /w H3 allwinner 芯片)CON2-P18在脉冲按钮上挂了别针,这样我就可以测试它。首先我要找到引脚所在的线:

# gpiofind "CON2-P18"
gpiochip0 68

然后我会尝试监控它,但gpiomon没有运气:

# gpiomon --rising-edge 0 68
gpiomon: error waiting for events: No such device

但是我可以确认gpioget实用程序可以识别它并在按钮事件上正常运行:

# gpioget --bias=pull-down 0 68
0
root@bananapim2zero:~# gpioget --bias=pull-down 0 68
1
root@bananapim2zero:~# gpioget --bias=pull-down 0 68
0

我还可以使用实用程序设置它gpioset

# gpioset -B pull-down gpiochip0 68=0

我已经验证了相同的监控过程CON2-P16,一切正常!当我尝试监视 pin 时,出现相同的错误和行为CON2-P18

简单地使用另一个引脚对我来说有点麻烦,因为我已经使用上述引脚/线路设计并制造了 PCB。我想使用gpiomon实用程序而不是无限循环gpioget

是我做错了什么还是lib有问题?

libgpiod v. 1.6.2-1

# uname -a
Linux bananapim2zero 6.1.11-sunxi #23.02.2 SMP Sat Feb 18 05:52:53 UTC 2023 armv7l GNU/Linux

谢谢!

编辑:

提供strace“错误”命令$ strace sudo gpiomon --bias=pull-down --rising-edge gpiochip0 68::

execve("/usr/bin/sudo", ["sudo", "gpiomon", "--bias=pull-down", "--rising-edge", "gpiochip0", "68"], 0xbed32684 /* 24 vars */) = 0
access("/etc/suid-debug", F_OK)         = -1 ENOENT (No such file or directory)
brk(NULL)                               = 0x192b000
fcntl64(0, F_GETFD)                     = 0
fcntl64(1, F_GETFD)                     = 0
fcntl64(2, F_GETFD)                     = 0
access("/etc/suid-debug", F_OK)         = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fd6000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/v7l/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/v7l", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/tls/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/tls", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/v7l/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/v7l", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/neon/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/neon/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/neon/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/neon", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/vfp/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo/vfp", 0xbea15a10) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/sudo/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat64("/usr/lib/sudo", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=24663, ...}) = 0
mmap2(NULL, 24663, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6fcf000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libaudit.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\364\"\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=107848, ...}) = 0
mmap2(NULL, 237700, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f74000
mprotect(0xb6f8d000, 65536, PROT_NONE)  = 0
mmap2(0xb6f9d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0xb6f9d000
mmap2(0xb6f9f000, 61572, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f9f000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/sudo/libselinux.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libselinux.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0@R\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=108036, ...}) = 0
mmap2(NULL, 179236, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f48000
mprotect(0xb6f61000, 65536, PROT_NONE)  = 0
mmap2(0xb6f71000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0xb6f71000
mmap2(0xb6f73000, 3108, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f73000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/sudo/libutil.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libutil.so.1", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\200\n\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9800, ...}) = 0
mmap2(NULL, 73908, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f35000
mprotect(0xb6f37000, 61440, PROT_NONE)  = 0
mmap2(0xb6f46000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb6f46000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/sudo/libsudo_util.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\320=\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=79628, ...}) = 0
mmap2(NULL, 145056, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f11000
mprotect(0xb6f24000, 61440, PROT_NONE)  = 0
mmap2(0xb6f33000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xb6f33000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/sudo/libpthread.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libpthread.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\25K\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=113596, ...}) = 0
mmap2(NULL, 152152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6eeb000
mprotect(0xb6efe000, 61440, PROT_NONE)  = 0
mmap2(0xb6f0d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0xb6f0d000
mmap2(0xb6f0f000, 4696, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f0f000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/sudo/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\331v\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=971712, ...}) = 0
mmap2(NULL, 1040988, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dec000
mprotect(0xb6ed6000, 61440, PROT_NONE)  = 0
mmap2(0xb6ee5000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe9000) = 0xb6ee5000
mmap2(0xb6ee8000, 8796, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6ee8000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libcap-ng.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0H\16\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=13860, ...}) = 0
mmap2(NULL, 78068, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dd8000
mprotect(0xb6ddb000, 61440, PROT_NONE)  = 0
mmap2(0xb6dea000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0xb6dea000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libpcre2-8.so.0", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\250\31\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=415588, ...}) = 0
mmap2(NULL, 479836, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6d62000
mprotect(0xb6dc7000, 61440, PROT_NONE)  = 0
mmap2(0xb6dd6000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x64000) = 0xb6dd6000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libdl.so.2", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0000\n\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9772, ...}) = 0
mmap2(NULL, 73924, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6d4f000
mprotect(0xb6d51000, 61440, PROT_NONE)  = 0
mmap2(0xb6d60000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0xb6d60000
close(3)                                = 0
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fcd000
set_tls(0xb6fcdbd0)                     = 0
mprotect(0xb6ee5000, 8192, PROT_READ)   = 0
mprotect(0xb6d60000, 4096, PROT_READ)   = 0
mprotect(0xb6f0d000, 4096, PROT_READ)   = 0
mprotect(0xb6dd6000, 4096, PROT_READ)   = 0
mprotect(0xb6dea000, 4096, PROT_READ)   = 0
mprotect(0xb6f33000, 4096, PROT_READ)   = 0
mprotect(0xb6f46000, 4096, PROT_READ)   = 0
mprotect(0xb6f71000, 4096, PROT_READ)   = 0
mprotect(0xb6f9d000, 4096, PROT_READ)   = 0
mprotect(0x43f000, 4096, PROT_READ)     = 0
mprotect(0xb6fd8000, 4096, PROT_READ)   = 0
munmap(0xb6fcf000, 24663)               = 0
set_tid_address(0xb6fcd778)             = 10974
set_robust_list(0xb6fcd780, 12)         = 0
rt_sigaction(SIGRTMIN, {sa_handler=0xb6eef66d, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0xb6e13841}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0xb6eef6f1, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0xb6e13841}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
statfs("/sys/fs/selinux", 0xbea1655c)   = -1 ENOENT (No such file or directory)
statfs("/selinux", {f_type=EXT2_SUPER_MAGIC, f_bsize=4096, f_blocks=7438627, f_bfree=6853088, f_bavail=6769594, f_files=1855392, f_ffree=1745592, f_fsid={val=[2118024466, 2550696797]}, f_namelen=255, f_frsize=4096, f_flags=ST_VALID|ST_NOATIME}) = 0
brk(NULL)                               = 0x192b000
brk(0x194c000)                          = 0x194c000
openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "nodev\tsysfs\nnodev\ttmpfs\nnodev\tbd"..., 1024) = 386
read(3, "", 1024)                       = 0
close(3)                                = 0
access("/etc/selinux/config", F_OK)     = -1 ENOENT (No such file or directory)
prlimit64(0, RLIMIT_AS, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_AS, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_CORE, NULL, {rlim_cur=0, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_CPU, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_CPU, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_DATA, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_DATA, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_FSIZE, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_FSIZE, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_LOCKS, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_MEMLOCK, NULL, {rlim_cur=65536*1024, rlim_max=65536*1024}) = 0
prlimit64(0, RLIMIT_NOFILE, NULL, {rlim_cur=1024, rlim_max=1024*1024}) = 0
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = -1 EPERM (Operation not permitted)
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=256, rlim_max=RLIM64_INFINITY}, NULL) = -1 EPERM (Operation not permitted)
prlimit64(0, RLIMIT_NOFILE, {rlim_cur=1024*1024, rlim_max=1024*1024}, NULL) = 0
prlimit64(0, RLIMIT_NPROC, NULL, {rlim_cur=2962, rlim_max=2962}) = 0
prlimit64(0, RLIMIT_NPROC, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = -1 EPERM (Operation not permitted)
prlimit64(0, RLIMIT_NPROC, {rlim_cur=2962, rlim_max=2962}, NULL) = 0
prlimit64(0, RLIMIT_RSS, NULL, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_RSS, {rlim_cur=RLIM64_INFINITY, rlim_max=RLIM64_INFINITY}, NULL) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
prlimit64(0, RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}, NULL) = 0
fcntl64(0, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(1, F_GETFL)                     = 0x2 (flags O_RDWR)
fcntl64(2, F_GETFL)                     = 0x2 (flags O_RDWR)
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3041456, ...}) = 0
mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6b4f000
mmap2(NULL, 2596864, PROT_READ, MAP_PRIVATE, 3, 0x6d000) = 0xb68d5000
close(3)                                = 0
openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2329, ...}) = 0
fstat64(3, {st_mode=S_IFREG|0644, st_size=2329, ...}) = 0
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\10\0\0\0\0"..., 4096) = 2329
_llseek(3, -1479, [850], SEEK_CUR)      = 0
read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t\0\0\0\t\0\0\0\0"..., 4096) = 1479
close(3)                                = 0
stat64("/etc/sudo.conf", {st_mode=S_IFREG|0644, st_size=3975, ...}) = 0
openat(AT_FDCWD, "/etc/sudo.conf", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=3975, ...}) = 0
read(3, "#\n# Default /etc/sudo.conf file\n"..., 4096) = 3975
read(3, "", 4096)                       = 0
close(3)                                = 0
geteuid32()                             = 1000
access("/usr/local/bin/sudo", X_OK)     = -1 ENOENT (No such file or directory)
access("/usr/bin/sudo", X_OK)           = 0
stat64("/usr/bin/sudo", {st_mode=S_IFREG|S_ISUID|0755, st_size=135928, ...}) = 0
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=2996, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2996
read(3, "", 4096)                       = 0
close(3)                                = 0
openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/sudo.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "sudo", 4sudo)                     = 4
write(2, ": ", 2: )                       = 2
write(2, "effective uid is not 0, is /usr/"..., 133effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?) = 133
ioctl(2, TCGETS, {B9600 opost isig icanon echo ...}) = 0
)                       = 1
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?
+++ exited with 1 +++

“工作”$ sudo strace gpiomon --bias=pull-down --rising-edge gpiochip0 15命令:

execve("/usr/bin/gpiomon", ["gpiomon", "--bias=pull-down", "--rising-edge", "gpiochip0", "15"], 0xbed83760 /* 16 vars */) = 0
brk(NULL)                               = 0x17ce000
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f11000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=24663, ...}) = 0
mmap2(NULL, 24663, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f0a000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libgpiod.so.2", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\260!\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=21952, ...}) = 0
mmap2(NULL, 86024, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6ed4000
mprotect(0xb6ed9000, 61440, PROT_NONE)  = 0
mmap2(0xb6ee8000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb6ee8000
close(3)                                = 0
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\331v\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=971712, ...}) = 0
mmap2(NULL, 1040988, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6dd5000
mprotect(0xb6ebf000, 61440, PROT_NONE)  = 0
mmap2(0xb6ece000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe9000) = 0xb6ece000
mmap2(0xb6ed1000, 8796, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6ed1000
close(3)                                = 0
set_tls(0xb6f12180)                     = 0
mprotect(0xb6ece000, 8192, PROT_READ)   = 0
mprotect(0xb6ee8000, 4096, PROT_READ)   = 0
mprotect(0x4a1000, 4096, PROT_READ)     = 0
mprotect(0xb6f13000, 4096, PROT_READ)   = 0
munmap(0xb6f0a000, 24663)               = 0
rt_sigprocmask(SIG_BLOCK, [INT TERM], NULL, 8) = 0
signalfd4(-1, [INT TERM], 8, 0)         = 3
openat(AT_FDCWD, "/dev", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 4
fstat64(4, {st_mode=S_IFDIR|0755, st_size=3300, ...}) = 0
brk(NULL)                               = 0x17ce000
brk(0x17ef000)                          = 0x17ef000
getdents64(4, 0x17ce1b0 /* 165 entries */, 32768) = 4896
getdents64(4, 0x17ce1b0 /* 0 entries */, 32768) = 0
close(4)                                = 0
openat(AT_FDCWD, "/dev/gpiochip0", O_RDWR|O_CLOEXEC) = 4
lstat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
stat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
access("/sys/bus/gpio/devices/gpiochip0/dev", R_OK) = 0
openat(AT_FDCWD, "/sys/bus/gpio/devices/gpiochip0/dev", O_RDONLY) = 5
read(5, "254:0\n", 15)                  = 6
close(5)                                = 0
ioctl(4, GPIO_GET_CHIPINFO_IOCTL, 0xbee98018) = 0
openat(AT_FDCWD, "/dev/gpiochip1", O_RDWR|O_CLOEXEC) = 5
lstat64("/dev/gpiochip1", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0x1), ...}) = 0
stat64("/dev/gpiochip1", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0x1), ...}) = 0
access("/sys/bus/gpio/devices/gpiochip1/dev", R_OK) = 0
openat(AT_FDCWD, "/sys/bus/gpio/devices/gpiochip1/dev", O_RDONLY) = 6
read(6, "254:1\n", 15)                  = 6
close(6)                                = 0
ioctl(5, GPIO_GET_CHIPINFO_IOCTL, 0xbee98018) = 0
close(4)                                = 0
close(5)                                = 0
openat(AT_FDCWD, "/dev/gpiochip0", O_RDWR|O_CLOEXEC) = 4
lstat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
stat64("/dev/gpiochip0", {st_mode=S_IFCHR|0600, st_rdev=makedev(0xfe, 0), ...}) = 0
access("/sys/bus/gpio/devices/gpiochip0/dev", R_OK) = 0
openat(AT_FDCWD, "/sys/bus/gpio/devices/gpiochip0/dev", O_RDONLY) = 5
read(5, "254:0\n", 15)                  = 6
close(5)                                = 0
ioctl(4, GPIO_GET_CHIPINFO_IOCTL, 0xbee98058) = 0
ioctl(4, GPIO_GET_LINEINFO_IOCTL, 0xbee9807c) = 0
ioctl(4, GPIO_GET_LINEEVENT_IOCTL, 0xbee9809c) = 0
ioctl(4, GPIO_GET_LINEINFO_IOCTL, 0xbee9803c) = 0
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 1 ([{fd=5, revents=POLLIN}])
read(5, "\233\\D\336\201\10\0\0\1\0\0\0\0\0\0\0", 16) = 16
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
write(1, "event:  RISING EDGE offset: 15 t"..., 63event:  RISING EDGE offset: 15 timestamp: [    9353.872825499]
) = 63
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 1 ([{fd=5, revents=POLLIN}])
read(5, "\213\273\312\6\203\10\0\0\1\0\0\0\0\0\0\0", 16) = 16
write(1, "event:  RISING EDGE offset: 15 t"..., 63event:  RISING EDGE offset: 15 timestamp: [    9358.847687563]
) = 63
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000) = 0 (Timeout)
poll([{fd=5, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN|POLLPRI}], 2, 10000^C) = 1 ([{fd=3, revents=POLLIN}])
strace: Process 10962 detached

答案1

按照 Allwinner_H3_Datasheet 第 3.3 节 ~pg80(通过底部的链接)香蕉派页面,只有EINT引脚支持中断。

根据相同的 Banana Pi 页面,CON2-P128对应于PC4,因此不是或引脚H3之一,因此不支持中断。PAPG EINT

软件(无论是内核 GPIO 驱动程序还是libgpiod)都无法使该线路提供中断。您唯一的选择是轮询该线路或切换到其中一个EINT引脚。

顺便说一句,其中一条评论建议使用 的libgpiod v2 gpioset交互模式来获取行值作为性能优化。作为该模式的作者,这是行不通的 -gpioset将保存线路输出,并且返回的值get是线路当前设置的值(以防您切换几次并失去跟踪)。所以不是你想要的。一般规则 - 不要gpioset在外部驱动的输入线上使用 - 这会让魔法消失。

答案2

我是 的作者libgpiod。您能否跑gpiomon过去strace并确保没有文件描述符引发任何轮询事件?如果没有,则内核没有报告中断,这意味着驱动程序行为不正确(不太可能),或者您的硬件没有生成这些中断(可能)。

你用的驱动是什么?您的主板是否使用上游设备树?

巴特

相关内容