Post Go back to editing

PlutoSDR Local backend and High-speed mmap interface

I am trying to write a C program in Linux  to pull samples continuously from the receive buffer of PlutoSDR using the libiio library. I think the High-speed mmap interface should be utilized in order to move the received samples from the hardware to user space fast enough.

However, the High-speed mmap interface is only supported in local backend and I cannot create the context for my PlutoSDR with the local backend.

pi@pi2:~ $ iio_info -s
Library version: 0.23 (git tag: v0.23)
Compiled with backends: local xml ip usb
Unable to create Local IIO context : No such file or directory (2)
Available contexts:
    0: 0456:b673 (Analog Devices Inc. PlutoSDR (ADALM-PLUTO)), serial=10447396599300040f001c009d1128f249 [usb:1.3.5]
    1: (Analog Devices PlutoSDR Rev.B (Z7010-AD9363A)), serial=10447396599300040f001c009d1128f249 [ip:pluto.local]

I also tried to use the iio_create_local_context() function in my code but the return result is "assertion failed".

What should I do to create context for my PllutoSDR with local backend and then check my iio_buffer is using the high-speed interface?

Thank you.


Add the information about the programming language and OS.
[edited by: KhanhToan at 12:09 PM (GMT -4) on 25 Apr 2022]
  • I think there is a misunderstanding. The highspeed mmap interface being supported only by the local backend means that's where it's implemented. A local context means that the IIO sysfs is found locally (on the Pluto itself). If you are running iio_info on your host PC, then you are not seeing the local context because the pluto connects to your host PC via IP or USB.

    However Pluto implements an IIOD(IIO Daemon) locally which basically brokers IIO requests between remote clients and the local context. Once a context is created (either local, or remote by connecting to an IIOD) the way you configure/use any hardware attributes/buffers etc. should be the same.

    By simply using the examples provided with libiio - you can push/pull data from the Pluto. The speed at which you push pull data is limited by the USB2.0 link if you are using the USB or IP (since it's using an IP-over-USB protocol) which theoretically goes up to 480Mbps. If you are using the local context directly - you are limited by the memory throughput which is obviously a lot more.

    In order to have the program running on the Pluto locally besides configuring the local context, you need to crosscompile it for the pluto. This is usually not necessary to get started, unless you have a specific application in mind.

    To answer your question directly, just use the remote context the same way you would use the local context. The pluto will use the highspeed interface regardless. If the usb 2.0 link is not fast enough (the buffers are not continous), you can try acquiring and processing some data locally(on the pluto itself).


  • Hi Adrian,

    First of all, thank you very much for answering my question. I should have stated that I'm trying to write and run my C program on my Linux host computer.

    I actually took a look at the iio_buffer_refill function in the "buffer.c" source file in the libiio library and added some commands to it and then ran my program with the iio_buffer_refill function in a loop check if my Pluto was using the high-speed interface. Unfortunately, the result was not.

    #include "stdio.h"
    ssize_t iio_buffer_refill(struct iio_buffer *buffer)
    ssize_t read;
    const struct iio_device *dev = buffer->dev;
    ssize_t ret;

    if (buffer->dev_is_high_speed) {
    read = dev->ctx->ops->get_buffer(dev, &buffer->buffer,
    buffer->length, buffer->mask, dev->words);
    printf("\n\tRefilling Pluto Buffer with FAST interface!\n"); <<< I added this line.
    } else {
    read = iio_device_read_raw(dev, buffer->buffer, buffer->length,
    buffer->mask, dev->words);
    printf("\n\tRefilling Pluto Buffer with SLOW interface!\n"); <<< I added this line.

    if (read >= 0) {
    buffer->data_length = read;
    ret = iio_device_get_sample_size_mask(dev, buffer->mask, dev->words);
    if (ret < 0)
    return ret;
    buffer->sample_size = (unsigned int)ret;
    return read;

    The result was:

        Refilling Pluto Buffer with SLOW interface!

        Refilling Pluto Buffer with SLOW interface!

        Refilling Pluto Buffer with SLOW interface!

    Apparently, my Pluto is refilling the captured samples to my iio_buffer using the slow interface.

    I'm using libiio v0.23, Pluto firmware v0.33, and running the program with buffer length of 2^10 =1024 samples, low sampling rate 600kHz (using ad9361 library) to prevent overflow at receiver side.

    What should I do to enable high-speed interface for my receiving Pluto?


  • Hi Toan,

    You can only communicate with the Pluto with the regular interface (be it over USB, network or UART). There is no other interface available there.

    As Adrian said, the high-speed interface is only available on the local backend, which means for applications running on the Pluto itself, and not running from your PC.

    The Pluto runs IIOD, which is the server side of libiio. IIOD itself will use the local context of libiio, with the high-speed interface.