AD9361: Rx Sample Streaming on Zc702 and AD-FMCOMMS2-EBZ

I was wondering if there is an example project/step that allows user to stream complex baseband samples from ad9361 to DDR memory connected to zynq chip on Zc702 eval platform mated with AD-FMCOMMS2-EBZ board.

I would like to continuously stream samples (Let's say for 10 minutes at sampling frequency of 10Mhz).

The kernel notifies userspace after a buffer has been fully filled. What you can do is allocate multiple buffers, each the size large enough for the period after which you want to get the notification. Then submit all buffers and start the capture process. The DMA will make sure that the data captured by those buffers is still continuous. Once you have enough data you then stop the capture process again. The method to get notified is to run poll() on the iio file descriptor. The process will be woken up when a buffer is ready. As an example you can take a look at the iio_buffer_refill() function.

If you don't want to redo things from scratch you can also directly use this function. E.g.

We apologize for the delay in responding to your question, but it was not posted in the appropriate community, so we did not see it. I have moved your thread. Someone from tlili's team will look into this for you.

I assume that you are using our Linux image. In this case you can capture as many samples as you have storage available to save them. Please take a look over the following thread for more information: Re: Capturing large nr of IQ samples

We are using Analog Device's Linux image on Zc702 Evalution board. Your answer does provide us a way forward.

I do have a follow up question:

If we are reading substantial number of samples (let's say 5 minutes worth), Is there a way to get a notification from the Linux device driver every 30 seconds of sample collection?

Basically we want the Linux driver to keep collecting the samples, and get a notification (Interrupt or semaphore or some other method) from Linux driver so that the collected samples can be processed or consumed at the application level without a break in sample collection?

The kernel notifies userspace after a buffer has been fully filled. What you can do is allocate multiple buffers, each the size large enough for the period after which you want to get the notification. Then submit all buffers and start the capture process. The DMA will make sure that the data captured by those buffers is still continuous. Once you have enough data you then stop the capture process again. The method to get notified is to run poll() on the iio file descriptor. The process will be woken up when a buffer is ready. As an example you can take a look at the iio_buffer_refill() function.

If you don't want to redo things from scratch you can also directly use this function. E.g.

You only need to allocate one buffer, like in the original example. The maximum size can currently be up to 4MB.

You can use the iio_readdev tool as a functional example of how to continuously read data from the device.

If you want to capture data at 10MHz for multiple minutes, you'll need to have a strategy how to store this data as it will generate more data than what fits into the system memory RAM. The main options are either stream via the network to a different machine, store onto the SD card (this will require a SD card that allows sufficiently fast write transfers), or write to a external hard disk connected via USB.

Section High-Speed MMAP Interface. It has been mentioned that it is buffer swap rather the copy of IQ samples to IIO buffer. I would like to know as what triggers the DMA from Hardware device to Kernel memory. Will there be sufficient kernel buffers (filled with IQ data) before the 1st invoke of iio_buffer_refill() function. Does the DMA transfer to kernel buffer keeps happening irrespective of whether we call iio_buffer_refill () or not.

What the libiio does is it allocates 4 so called blocks. Each block has a associated memory buffer. Once the IIO buffer has been created it will pass these blocks to the DMA controller and the DMA controller will start to fill them one after one. What iio_buffer_refill() is do is to take the first block in the list of completed blocks and give it to the application for processing. If no block has been completed so far iio_buffer_refill() will wait until a block becomes available. The second time iio_buffer_refill() is called it will give back the block that was returned on the first invocation to the kernel and the kernel passes it to the DMA and the DMA will then start to refill it again. This will then continue for any consecutive call of iio_buffer_refill().

How do we determine the size of these 4 blocks. Is this defined by the iio_device_create_buffer(dev,SIZE_AFTER_WHICH_YOU_WANT_TO_BE_NOTIFIED, false);

I am trying to capture samples at 2.046MHZ sampling rate. The buffer has been allocated to capture 1 ms worth of data. We are seeing some samples being missed ,hence we are trying to understand the process.

We are invoking iio_device_create_buffer with the following parameters

We would like to understand the logic behind the allocation of the loop back code.

printf("* Creating non-cyclic IIO buffers with 1 MiS\n");

rxbuf = iio_device_create_buffer(rx, 1024*1024, false);

txbuf = iio_device_create_buffer(tx, 1024*1024, false);

The example configures 2MHz sampling rate and the buffers created are 1MByte in size. How does this map to 4 different buffers of kernel memory. I am referring to high speed mode of transfer.(About libiio [Analog Devices Wiki]) Section HIGH-SPEED MMAP INTERFACE. Will the 1MByte allocation is divided equally.