This version (20 Aug 2021 10:50) was approved by Michael Hennerich.

IIO System Considerations Tips & Tricks

IIO context timeout (libiio)

  • May be triggered by low sample rates and large buffers
  • Long blocking calls (some calibration, profile load, etc.)
Increase iio_context_set_timeout() timeout parameter or set to 0 to disables the timeout

Buffer handling, sizes and counts

Typically set to a frame or chunk size suitable for signal processing (e.g. N x FFT_size)

  • Small buffers → less latency but more overhead
  • Large buffers → less overhead but more latency

Number of discrete buffers are configurable, default is 4.
Can change this using iio_device_set_kernel_buffers_count()
Capturing starts as soon as the buffer is created!
FIFO like behavior new data is dropped in case it's not consumed fast enough!

IIO buffer DMA max block size

Max buffer size is limited by the max_block_size parameter

  • Default 16M
  • Can be adjusted

There are two ways to adjust the max block size


Set via /sys/module/industrialio_buffer_dma/parameters/max_block_size in bytes

This specifies any shell prompt running on the target

root@analog:~# echo 67108864 > /sys/module/industrialio_buffer_dma/parameters/max_block_size
root@analog:~# cat /sys/module/industrialio_buffer_dma/parameters/max_block_size

Kernel command line

Append the following to your kernel command line

  • industrialio_buffer_dma.max_block_size=size_in_bytes

Linux Contiguous Memory Allocator (or CMA)

  • Allocation of big, physically-contiguous memory blocks
  • Reserve memory early at boot time
  • Kconfig menu “Device Drivers” → “Generic Driver Options”→ “Contiguous Memory Allocator”
  • Kernel command line option cma=size_in_bytes
  • PlutoSDR default 256M
Depending on your IIO buffer DMA max block size and number of kernel buffer count you may need to CMA size

Capturing large contiguous buffers

  1. Set kernel buffer count to 1
  2. Increase IIO buffer DMA max block size parameter to at least the size of your desired contiguous buffer
  3. Make sure your CMA size is significantly bigger (CMA is used by various other DMA capable devices in your Linux system)
  4. AXI_DMAC controller limits length of the transfers to 2**DMA_LENGTH_WIDTH. The default is 24 so your max transfer size is 16777216 bytes. You may need to increase that and rebuild your design. Please see here: Synthesis Configuration Parameters
resources/tools-software/linux-software/libiio_tips_tricks.txt · Last modified: 20 Aug 2021 10:49 by Michael Hennerich