Increase usbfs memory permenantly

Hi

is there any possible way on how to increase the usbfs memory on the rock 5 or how to add the usbcore.usbfs_memory_mb somewhere on the radxa rock 5 ?

thank you very much

Hello everyone,
I have the same problem.
I am trying to capture the streaming of industrial cameras.
The vendor recommends increasing the usbfs memory to at least 256MB.
Connecting the cameras the first error I get is for the size of swiotlb.

I added the swiotlb=65535 directive to the kernel with these commands:
sudo nano /etc/kernel/cmdline
sudo u-boot-update

After the reboot the camera streaming no longer creates the error on dmesg but only a few frames are acquired then the camera no longer sends.

The camera drivers add a script run at startup that sets the value of /sys/module/usbcore/parameters/usbfs_memory_mb to 1000.
So if I run the command cat /sys/module/usbcore/parameters/usbfs_memory_mb the value returned is 1000.
But it doesn’t seem to have any effect.

I tried entering the directive usbcore.usbfs_memory_mb=1000 directly in the kernel but the only effect is that the Lan port stops working.

Hi @Nicola_Gasbarro,

Thank you for sharing your experience.

I am also trying to increase this because I am using industrial cameras also with the Rock5B.
The only solution that I have found yesterday is that to go to /boot/extlinux/extlinux.conf and add the usbcore.usb_memory_mb=2000 directly in there after quite splashfor instance.

I know this is not the solution to be done, but this was the only working solution and note that this is was working with one bus, meaning that only one of the usb 3 is able to have that amount of RAM.

The only USB3 that is working is the USB3 port that down and not the one that is up. It is stupid, but at least this is the only solution that is working, I am able to receive the feeds now from two cameras with out any major issues. Both of the cameras are connected to a USB 3 hub also which makes life a but easier. However, note that some of the frames are dropped from time to time and I am still investigating. At least you know you have 98 percent of frames are received with out any issue.

Note that when I try these settings on my PC, I have no problem at all, even though the usb memory is set up to 256 MB there and not even single frame is dropped.

I do not know what is swiotb, so I can not comment on that, looking at this gentoo article https://wiki.gentoo.org/wiki/IOMMU_SWIOTLB it looks like for Intel devices mainly so I do not know if this will work on the radxa.

It definitely worth investigating as well, let me know if this solution works with you

Hi @moverrock,
the solution you proposed “usbcore.usbfs_memory_mb=2000” alone does not work for me.
I also need to set swiotlb=524288 in the kernel otherwise I cannot capture a single frame.
This I think is due to the resolution of the cameras.
I am running my tests on an 8.9Mpx in MONO12 and a 6.4Mpx in BayerRG12:

  • I am only testing one camera at a time.
  • The camera is connected to the USB3.0 port as you described.
  • The 6.4 does not need the swiotlb directive, but the 8.9 in full resolution does.
  • The kernel I am testing is 5.10.110-29-rockchip on debian 11.
  • The board is a Rock 5b ver. 1.42 2022.08.29.

At the moment I can capture on the 8.9 about 6000 frames at 20fps without errors with a bandwidth of about 365MB/s, then the USB port freeze .
When this happens I have no warnings or errors in dmesg.
When I stop the acquisition I get error -2136(DMR_EXECUTION_FAILED)
If I restart the acquisition, everything works correctly for a while and then freezes again.

That’s interesting would you be able to tell what kind of industrial camera are you using ?

Isn’t it written there?

I do not think so

Here is the fragment

MONO12 is the image pixel format and the same for BayerRG12

am I missing something ?

You are not missing anything, I was just being stupid.

I am testing Sony IMX267 Sensor based cameras. I tested two different manufacturers.
I managed to get at most a continuous acquisition of about 2h but the error is random.
I have contacted the camera manufacturers to find out with them if the problem is the driver compatibility.
I have currently stopped the tests and am waiting for a reply.

UPDATE 23/02/2024
After updating via apt upgrade (kernel is the same - 5.10.110.29) everything seems to work fine.
I captured 1343700 frames without any errors at 20Fps with a bandwidth of 365MB/s.
That’s about 19 hours of continuous acquisition.