Wiki

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
resources:tools-software:linux-software:libiio_tips_tricks [20 Aug 2021 09:42] – created Michael Hennerichresources:tools-software:linux-software:libiio_tips_tricks [20 Aug 2021 10:30] – [Linux Contiguous Memory Allocator (or CMA)] Michael Hennerich
Line 9: Line 9:
 <note tip>Increase **iio_context_set_timeout()** timeout parameter or set to 0 to disables the timeout</note> <note tip>Increase **iio_context_set_timeout()** timeout parameter or set to 0 to disables the timeout</note>
  
 +===== 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
 +
 +{{ :resources:tools-software:linux-software:libiio:internals:libiio_highspeed_interface.png?400 |}}
 +
 +<note tip>**Number of discrete buffers are configurable, default is 4.**\\ 
 +Can change this using //**iio_device_set_kernel_buffers_count()**//</note>
 +
 +<note tip>**Capturing starts as soon as the buffer is created!**\\ //iio_device_create_buffer()//</note>
 +
 +<note tip>**FIFO like behavior new data is dropped in case it's not consumed fast enough!**</note>
 +
 +==== 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
 +
 +=== sysfs ===
 +
 +Set via **/sys/module/industrialio_buffer_dma/parameters/max_block_size** in bytes
 +
 +<WRAP box bggreen><wrap info>This specifies any shell prompt running on the target</wrap>
 +<xterm>
 +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**
 +67108864
 +root@analog:~# 
 +</xterm></WRAP>
 +
 +=== 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
 +
 +<note tip>Depending on your **IIO buffer DMA max block size** and **number of kernel buffer count** you may need to **CMA size**</note> 
 +
 +===== Capturing large contiguous buffers =====
 +
 +Set kernel buffer count to 1
  
resources/tools-software/linux-software/libiio_tips_tricks.txt · Last modified: 20 Aug 2021 10:49 by Michael Hennerich