我用 Yocto 制作了一个自定义 Linux 映像,以供使用CN0540和DE10-纳米。 CN0540(Analog Devices)的制造商提供了一个评价图像对于主板,它可以正常工作,但是在我的自定义映像中使用相同的内核分支(ADI Linux 分支),据我所知,相同的 defconfig (socfpga_adi_defconfig),以及相同的设备树(CN0540 dts),并且同样的 HDL 也加载到 FPGA 上(CN0540 高密度脂蛋白)我无法使用 CN0540 (AD7768-1) 上 ADC 的缓冲区。我可以使用 libiio 的iio_info
命令或使用设备文件从 ADC 读取单个值sys/bus/iio/devices/iio:device0/in_voltage0_raw
,但我无法从设备的缓冲区中读取例如iio_readdev ad7768-1
returns Unable to refill buffer: Connection timed out (110)
,或执行
> echo 1 > scan_elements/in_voltage0_en
> echo 1 > buffer/enable
> cat /dev/iio:device0 | hexdump
这会导致设备崩溃,除非我将缓冲区的长度设置为 1,echo 1 > buffer/length
这会导致设备输出
[ 441.310599] rcu: INFO: rcu_sched self-detected stall on CPU
[ 441.316258] rcu: 0-....: (2099 ticks this GP) idle=10f/1/0x40000002 softirq=2509/2509 fqs=1033
[ 441.325163] (t=2100 jiffies g=497 q=7)
[ 441.329057] NMI backtrace for cpu 0
[ 441.332592] CPU: 0 PID: 163 Comm: cat Not tainted 5.15.0-yocto-standard-adi #1
[ 441.339927] Hardware name: Altera SOCFPGA
[ 441.343988] Backtrace:
[ 441.346453] [<c0d914b0>] (dump_backtrace) from [<c0d916fc>] (show_stack+0x20/0x24)
[ 441.354073] r7:c010edfc r6:00000000 r5:60070193 r4:c143b218
[ 441.359801] [<c0d916dc>] (show_stack) from [<c0d94ecc>] (dump_stack_lvl+0x48/0x54)
[ 441.367360] [<c0d94e84>] (dump_stack_lvl) from [<c0d94ef0>] (dump_stack+0x18/0x1c)
[ 441.374907] r5:00000000 r4:20070193
[ 441.378525] [<c0d94ed8>] (dump_stack) from [<c05850fc>] (nmi_cpu_backtrace+0xe0/0x114)
[ 441.386424] [<c058501c>] (nmi_cpu_backtrace) from [<c0585218>] (nmi_trigger_cpumask_backtrace+0xe8/0x134)
[ 441.395965] r7:c010edfc r6:c0e01ee4 r5:c170469c r4:00000000
[ 441.401597] [<c0585130>] (nmi_trigger_cpumask_backtrace) from [<c010fd68>] (arch_trigger_cpumask_backtrace+0x20/0x24)
[ 441.412180] r9:c1703f10 r8:c0e01ee0 r7:c1835438 r6:00000000 r5:c1703fa4 r4:c171e840
[ 441.419886] [<c010fd48>] (arch_trigger_cpumask_backtrace) from [<c0d9340c>] (rcu_dump_cpu_stacks+0x144/0x174)
[ 441.429922] [<c0d932c8>] (rcu_dump_cpu_stacks) from [<c0198490>] (rcu_sched_clock_irq+0x6a8/0xa58)
[ 441.438860] r10:2e138000 r9:c1702d00 r8:c1693f40 r7:c18361a0 r6:00000000 r5:ef7cbf40
[ 441.446784] r4:c171e840
[ 441.449304] [<c0197de8>] (rcu_sched_clock_irq) from [<c01a354c>] (update_process_times+0x98/0xc4)
[ 441.458174] r10:c1702d80 r9:c1702d40 r8:c184fd40 r7:2e138000 r6:c1702d00 r5:00000000
[ 441.465969] r4:ef7c5540
[ 441.468524] [<c01a34b4>] (update_process_times) from [<c01b74e0>] (tick_sched_timer+0x88/0x2d8)
[ 441.477198] r7:c1ea9dc0 r6:00000066 r5:bf87a4da r4:ef7c6128
[ 441.482830] [<c01b7458>] (tick_sched_timer) from [<c01a4260>] (__hrtimer_run_queues+0x1fc/0x36c)
[ 441.491730] r10:ef7c5e14 r9:ef7c6128 r8:20070193 r7:00000000 r6:c01b7458 r5:ef7c5dc0
[ 441.499645] r4:ef7c5e00
[ 441.502183] [<c01a4064>] (__hrtimer_run_queues) from [<c01a5158>] (hrtimer_interrupt+0x13c/0x2c8)
[ 441.511041] r10:ef7c5e98 r9:ef7c5e70 r8:ef7c5e48 r7:ef7c5dcc r6:00000003 r5:20070193
[ 441.518836] r4:ef7c5dc0
[ 441.521357] [<c01a501c>] (hrtimer_interrupt) from [<c0110744>] (twd_handler+0x44/0x4c)
[ 441.529394] r10:c1ea8000 r9:c1ea9dc0 r8:f080210c r7:c1d08240 r6:00000018 r5:c17046b4
[ 441.537301] r4:00000001
[ 441.539821] [<c0110700>] (twd_handler) from [<c01838c8>] (handle_percpu_devid_irq+0x9c/0x200)
[ 441.548321] r5:c17046b4 r4:c1d09000
[ 441.551888] [<c018382c>] (handle_percpu_devid_irq) from [<c017ced4>] (handle_domain_irq+0x6c/0x88)
[ 441.560961] r7:0000001d r6:00000000 r5:00000000 r4:c1692a14
[ 441.566593] [<c017ce68>] (handle_domain_irq) from [<c0101300>] (gic_handle_irq+0x88/0x9c)
[ 441.574767] r7:c1692a20 r6:f0802100 r5:c177a344 r4:c17046b4
[ 441.580494] [<c0101278>] (gic_handle_irq) from [<c0100afc>] (__irq_svc+0x5c/0x78)
[ 441.587952] Exception stack(0xc1ea9dc0 to 0xc1ea9e08)
[ 441.593047] 9dc0: c28b3700 00000000 00000000 00000003 00001000 c28b3700 c2b47f40 befe9c04
[ 441.601193] 9de0: c28b3774 befe9c04 c1ea8000 c1ea9e24 c1ea9e28 c1ea9e10 c0a95530 c0a949ac
[ 441.609342] 9e00: 20070013 ffffffff
[ 441.612863] r9:c1ea8000 r8:c28b3774 r7:c1ea9df4 r6:ffffffff r5:20070013 r4:c0a949ac
[ 441.620699] [<c0a949a0>] (iio_dma_buffer_dequeue) from [<c0a95530>] (iio_dma_buffer_read+0x148/0x19c)
[ 441.629894] r5:c28b3700 r4:00001000
[ 441.633452] [<c0a953e8>] (iio_dma_buffer_read) from [<c0952618>] (iio_buffer_read+0x178/0x228)
[ 441.642168] r10:c1ea8000 r9:befe9c04 r8:00001000 r7:00000400 r6:00000002 r5:c1e43000
[ 441.649962] r4:c28b3700
[ 441.652483] [<c09524a0>] (iio_buffer_read) from [<c0954b24>] (iio_buffer_read_wrapper+0x2c/0x38)
[ 441.661248] r10:00000003 r9:c0954af8 r8:00001000 r7:00000001 r6:c1ea8000 r5:c1ea9f60
[ 441.669050] r4:c2b28540
[ 441.671571] [<c0954af8>] (iio_buffer_read_wrapper) from [<c02b2da8>] (vfs_read+0xc4/0x320)
[ 441.679817] [<c02b2ce4>] (vfs_read) from [<c02b348c>] (ksys_read+0x74/0xec)
[ 441.686766] r10:00000003 r9:00000000 r8:00000000 r7:befe9c04 r6:c1ea8000 r5:c2b28540
[ 441.694560] r4:c2b28540
[ 441.697081] [<c02b3418>] (ksys_read) from [<c02b351c>] (sys_read+0x18/0x1c)
[ 441.704027] r9:c1ea8000 r8:c0100244 r7:00000003 r6:b6f681a0 r5:befe9c04 r4:00001000
[ 441.711733] [<c02b3504>] (sys_read) from [<c0100060>] (ret_fast_syscall+0x0/0x48)
[ 441.719310] Exception stack(0xc1ea9fa8 to 0xc1ea9ff0)
[ 441.724344] 9fa0: 00001000 befe9c04 00000003 befe9c04 00001000 00000000
[ 441.732488] 9fc0: 00001000 befe9c04 b6f681a0 00000003 00000000 01000000 00000003 befe9c04
[ 441.740769] 9fe0: 00000003 befe9bb8 b6e6070f b6de1ae6
该输出每约 20 秒重复一次。
当缓冲区准备好时,设备应该向操作系统发送中断,因此我用 MCU 探测设备的 DRDY 引脚(中断引脚),并且该引脚永远不会变高。
我还尝试将我使用的 libiio 版本切换为与评估图像相同的版本,从 0.23 更改为 0.21,运行时的错误iio_readdev ad7768-1
从 更改Unable to refill buffer: Connection timed out (110)
为
Unable to refill buffer: Connection timed out
ERROR: Error during buffer disable: No such file or directory
我很确定在功能上是相同的错误,所以我将 libiio 版本改回 0.23
我修补了设备驱动程序和 libiio 试图找到问题,发现调用iio_readdev ad7768-1
libiio 的问题行是这个 ret = poll(pollfd, 2, timeout_rel);
,设备驱动程序中的问题函数似乎是这个 hw_submit_block
。
导致超时错误的原因是什么?
答案1
最后找到了解决办法。
U-boot 需要生成一些切换文件。
$ python ./arch/arm/mach-socfpga/cv_bsp_generator/cv_bsp_generator.py \
-i <path_to_qpds_handoff>/hps_isw_handoff/soc_system_hps_0 \
-o board/altera/cyclone5-socdk/qts/
这方面的文档位于/doc/README.socfpga文件。