DMA on Jetson TX2

Hi,

I am using the Jetson TX2 for an imaging application to capture a 5MP bmp image. However, I need to utilize the TX2’s DMA for acquiring the image buffer and sending it to a device through the USB port. Is it possible? Can we utilize the USB directly without storing the buffer in Tx2’s RAM?

Thanks,
Abhijeet

Hi,
Is your capture going through v4l2 or other interfaces?

We have tegra_multimedia_api and gstreamer implementations. You may check documents first.
https://developer.nvidia.com/embedded/dlc/l4t-documentation-28-2-ga
https://developer.nvidia.com/embedded/dlc/l4t-accelerated-gstreamer-guide-28-2-ga

Hi DaneLLL,

Thank you for sharing the docs.
The camera uses a v4l2 interface and a g-streamer library. We can use the accelerated g-streamer interface but do we need to handle the data transfer explicitly using some API or it is taken care of in the back-end?

Thanks,
Abhijeet

Hi,
We don’t know much about how to transfer data via USB to another device. Other users may share their experience.

For getting preview from v4l2src, you can run:

$ export DISPLAY=:0
$ gst-launch-1.0 v4l2src device=/dev/video1 ! videoconvert ! xvimagesink

You could use a USB hard drive or thumb drive. You could also use the gigabit ethernet. What do you expect to be the consumer of the data?

Hi linuxdev,

I need to transfer the captured image data to a windows system (which will act as a device) from TX2 (the host).

Thanks,
Abhijeet

Unless your Windows system is set up to act as mass storage (meaning it has a device port and not host port, plus it was configured to look like a hard drive) you will probably be better off using gigabit ethernet. USB is not bidirectional like ethernet…one end must be programmed to be a host, the other end must be programmed as a device. Two hosts cannot talk to each other. Only a host and device can talk to each other. If the device is not a “standard” device, then you need the user of the device to have a custom driver specific to that device.

The choices available change depending on the nature of how you use the data. If you want to act as a hard drive, then the other end just looks for files and copies files when found. If acting as RTSP streaming, then you have to do all of the usual setup, and then make the USB look like a network interface with one address (you already have ethernet though, and if you make USB look like a network device, then the Windows side will need to set up how to use this new NIC…then how to look at the RTSP stream). If you want this to appear as a continuous video stream, then the Jetson would need to be in isochronous mode…but the TX2 does not support isochronous mode (which is sort of what RTSP streaming does, but it isn’t over USB normally) on the micro-USB port, and so you’d need an add-on USB card. There are too many choices, most of which are difficult, unless you know of and can describe an exact use case of how the data must behave and be consumed.

Hi linuxdev,

Thank you for your prompt response. Apologies for the mistake, the TX2 should act as a device and the Windows as a host for the data transfer. Also, I am not considering Ethernet transfer as an option to fully utilize the USB3 data transfer speeds among others.

Thanks,
Abhijeet

See similar:
[url]usb 3.0 device mode RNDIS ethernet speed (12MB/s --18MB/s) - Jetson TX2 - NVIDIA Developer Forums

Sorry, you won’t be able to achieve USB3 as a device without a custom carrier. You can only use USB2.

Also, ethernet is a general data pipe, USB is not, and so setting it up is more complicated even in cases where it will work as you want. Device mode could be made to look like an ethernet NIC.

Okay.

Thank you.

Hi linuxdev,

I am referring to the below post for kernel customization on L4T-28.1.

https://devtalk.nvidia.com/default/topic/1014096/jetson-tx2/how-to-set-tx2-otg-usb-as-device-mode-/post/5205500/#5205500

I have patched the necessary changes and compiled-flashed the binaries on TX2. However, while running the script “configfs_msc_l4t.sh” on the TX2, I am getting the following error:
mkdir: cannot create directory ‘/config/usb_gadget/g1’ : cannot allocate memory

The script contains mounting of /config folder and L4T folder gets created but mkdir: usb_gadget fails.

What could be wrong with this?

Are you actually using R28.1? If using R28.2+, then you have some prebuilt example gadget set up (and the instructions for R28.1 might be interfered with when trying to run at the same time as the R28.2+ sample).

If you download the R28.2 driver package, and then unpack it, you will find this:

Linux_for_Tegra/nv_tegra/config.tbz2

If you unpack that in an empty directory somewhere you will specifically see content in this directory (or if you are running R28.2+ this will already exist on your TX2):

opt/nvidia/l4t-usb-device-mode/*

If you run the script “nv-l4t-usb-device-mode.sh” as root (e.g., sudo), then this will set up various sample devices. Keep in mind that the emulated hard drive depends on the filesystem.img being there. If you don’t want to create a fake ethernet device, then you can comment it out in “nv-l4t-usb-device-mode.sh”. Comments in the file should help understanding it even if you’re not using that file. You should be able to copy that content to an R28.1 TX2 and have it work (assumes gadget is configured in the kernel…which it might already be done even by default on R28.1).

Thank you linuxdev,
It works!