Technical Application Note (TAN2012007): Understanding USB-FS on Linux
This application note describes how USB-FS affects Linux users and why proper settings impact performance.
Before you use your camera, we recommend that you are aware of the following resources available from our downloads page:
When the camera captures an image, it automatically transfers it to the PC to be stored in the PC's RAM. This is buffering. The amount of space in RAM assigned to store these images is called a stream buffer. It is important to understand what factors impact buffer allocation to ensure optimal performance and mitigate negative effects such as dropped images or corrupt files.
Buffer size depends on two parameters: image size and number of stream buffers.
The image size is calculated by the resolution and bit-depth.
Image Size = Resolution X Bit-depth
By default, Spinnaker automatically allocates the number of buffers based on the camera's frame rate. This is how many images can be buffered in RAM.
An image that is 1920 x 1080 at 8-bit pixel format is
1920 X 1080 X 8 = 16,588,800 bits (2,073,600 bytes)
If 100 stream buffers are allocated then 200 MB needs to be available.
Note: For more information on buffers, see our TAN Understanding Buffer Handling.
By default Linux Ubuntu sets the buffer size to 16 MB for USB devices. This is not sufficient for many cameras and may not even be enough for one image from a high resolution camera.
The USB-FS allows you to modify the Linux default to gain access to a higher amount of RAM for buffering. FLIR recommends you modify USB-FS to >1000 MB to ensure a sufficient amount of RAM is allocated to buffer incoming images. This helps to prevent crash issues associated with attempted buffer allocation.
For multiple cameras, USB-FS will need to be scaled up to account for additional bandwidth. This can be calculated via Resolution x Bit-depth x Number of Cameras.
To permanently modify the USB-FS memory limit:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.usbfs_memory_mb=1000"
$ sudo update-grub
If this fails to set the memory limit, run the following command:
$ sudo sh -c 'echo 1000 > /sys/module/usbcore/parameters/usbfs_memory_mb'
To confirm you have successfully updated the memory limit, run the following command:
Note: This method applies to Ubuntu 16.04/18.04 standard installations. For ARM boards, see our TAN Using Spinnaker on ARM and Embedded Systems.