Quantcast Technical Application Notes
 
Technical Application Notes
Click an item to read from the list below.

Technical Application Notes


 

 

Understanding USB-FS on Linux

Subject

Technical Application Note (TAN2012007): Understanding USB-FS on Linux

11233

Applicable products

  • All USB cameras

Application note description

This application note describes how USB-FS affects Linux users and why proper settings impact performance.

Preparing for use

Before you use your camera, we recommend that you are aware of the following resources available from our downloads page:

  • Getting Started Manual for the camera—provides information on installing components and software needed to run the camera.
  • Technical Reference for the camera—provides information on the camera’s specifications, features and operations, as well as imaging and acquisition controls.
  • Firmware updates—ensure you are using the most up-to-date firmware for the camera to take advantage of improvements and fixes.
  • Tech InsightsSubscribe to our bi-monthly email updates containing information on new knowledge base articles, new firmware and software releases, and Product Change Notices (PCN).

What are buffers?

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.

How are buffers allocated?

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.

Example:

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)

~2 MB

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.

Why configure USB-FS?

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.

Configuring USB-FS

To permanently modify the USB-FS memory limit:

    1. In a text editor, open the /etc/default/grub file.
    2. Find
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    1. Replace with
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.usbfs_memory_mb=1000"
    1. Update grub with these settings:
$ sudo update-grub
  1. Reboot and test a USB camera.

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:

cat /sys/module/usbcore/parameters/usbfs_memory_mb

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.