I have created a custom Yocto image for use with the DE10-Nano and CN0540. The AD7768-1's buffer does not work, however the rest of its functions seem to work correctly. I have confirmed it's not a hardware issue by using the Kuiper image provided.
If I try to use the buffer by doing:
> echo 1 > scan_elements/in_voltage0_en
> echo 1 > buffer/enable
> cat /dev/iio:device0 | hexdump
the device will crash and reboot, unless I set the length of the buffer to one with:
> echo 1 > buffer/length
then the device will still crash, but instead of rebooting it repeatedly outputs:
[ 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
every ~20 seconds.
If I try to use:
> iio_readdev ad7768-1
I get the error:
> Unable to refill buffer: Connection timed out (110)
The output of
> iio_info
is:
Library version: 0.23 (git tag: 92d6a35) Compiled with backends: local xml ip usb serial IIO context created with local backend. Backend version: 0.23 (git tag: 92d6a35) Backend description string: Linux VibMonProto 5.15.0-yocto-standard-adi #1 SMP Thu Apr 27 16:34:06 UTC 2023 armv7l IIO context has 2 attributes: local,kernel: 5.15.0-yocto-standard-adi uri: local: IIO context has 5 devices: iio:device0: ad7768-1 (buffer capable) 1 channels found: voltage0: (input, index: 0, format: le:s24/32>>8) 3 channel-specific attributes found: attr 0: label value: (null) attr 1: raw value: -2246463 attr 2: scale value: 0.000488281 4 device-specific attributes found: attr 0: common_mode_voltage value: (AVDD1-AVSS)/2 attr 1: common_mode_voltage_available value: (AVDD1-AVSS)/2 2V5 2V05 1V9 1V65 1V1 0V9 OFF attr 2: sampling_frequency value: 256000 attr 3: sampling_frequency_available value: 256000 128000 64000 32000 16000 8000 4000 2000 1000 3 buffer-specific attributes found: attr 0: data_available value: 0 attr 1: length_align_bytes value: 16 attr 2: watermark value: 2048 1 debug attributes found: debug attr 0: direct_reg_access value: 0x0 No trigger on this device iio:device1: ltc2308 8 channels found: voltage6: (input) 2 channel-specific attributes found: attr 0: raw value: 175 attr 1: scale value: 1.000000000 voltage3: (input) 2 channel-specific attributes found: attr 0: raw value: 163 attr 1: scale value: 1.000000000 voltage7: (input) 2 channel-specific attributes found: attr 0: raw value: 166 attr 1: scale value: 1.000000000 voltage0: (input) 2 channel-specific attributes found: attr 0: raw value: 162 attr 1: scale value: 1.000000000 voltage4: (input) 2 channel-specific attributes found: attr 0: raw value: 169 attr 1: scale value: 1.000000000 voltage1: (input) 2 channel-specific attributes found: attr 0: raw value: 165 attr 1: scale value: 1.000000000 voltage5: (input) 2 channel-specific attributes found: attr 0: raw value: 168 attr 1: scale value: 1.000000000 voltage2: (input) 2 channel-specific attributes found: attr 0: raw value: 161 attr 1: scale value: 1.000000000 2 device-specific attributes found: attr 0: sleep_mode value: DISABLED attr 1: sleep_mode_available value: DISABLED ENABLED No trigger on this device iio:device2: one-bit-adc-dac 8 channels found: voltage0: (input) 2 channel-specific attributes found: attr 0: label value: cn0540_sw_ff_gpio attr 1: raw value: 0 voltage1: (output) 2 channel-specific attributes found: attr 0: label value: cn0540_red_led attr 1: raw value: 0 voltage5: (output) 2 channel-specific attributes found: attr 0: label value: cn0540_FDA_DIS attr 1: raw value: 0 voltage0: (output) 2 channel-specific attributes found: attr 0: label value: cn0540_blue_led attr 1: raw value: 0 voltage3: (output) 2 channel-specific attributes found: attr 0: label value: cn0540_ad7768-1-gpio0 attr 1: raw value: 0 voltage6: (output) 2 channel-specific attributes found: attr 0: label value: cn0540_FDA_MODE attr 1: raw value: 0 voltage2: (output) 2 channel-specific attributes found: attr 0: label value: cn0540_shutdown_gpio attr 1: raw value: 0 voltage4: (output) 2 channel-specific attributes found: attr 0: label value: cn0540_ad7768-1-gpio1 attr 1: raw value: 0 No trigger on this device iio:device3: ltc2606 1 channels found: voltage0: (output) 5 channel-specific attributes found: attr 0: powerdown value: 0 attr 1: powerdown_mode value: 90kohm_to_gnd attr 2: powerdown_mode_available value: 90kohm_to_gnd attr 3: raw value: 32768 attr 4: scale value: 0.062500000 No trigger on this device iio_sysfs_trigger: 0 channels found: 2 device-specific attributes found: attr 0: add_trigger ERROR: Permission denied (13) attr 1: remove_trigger ERROR: Permission denied (13) No trigger on this device
The custom image uses the adi kernel fork for its kernel, u-boot-socfpga for its u-boot by utilizing meta-altera, and CN0540 HDL to program the FPGA.
The HDL is compiled and converted to rbf FPPx16, then loaded onto the FPGA by modifying the U-boot bootcmd to include:
fatload mmc 0:1 0x2000000 fpga_design.rbf; fpga load 0 0x2000000 0x700000; bridge enable;
The socfpga_cyclone5_de10_nano_cn0540.dts device tree, and socfpga_adi_defconfig are used to configure the kernel.
sysvinit is changed to systemd as well.
Is there a step I'm missing to use this device with a custom image?