What to do with the Orin NX as a USB device?

I have modified the OrinNX USB device tree as USB peripheral.
I want to utilize USB for data communication with PC, so what do I need to write next for USB driver?

You might find this of interest:

I’ve tried the examples explained in the file, and the PC already recognizes the USB devices uart, tcp, Mass Storage driver, but these are not what I want, I want to realize that there are multiple ep’s of a USB device, and each ep transmits a different amount of data?

At the same time I understand the use of dynamic config gadget, but I do not know if this way can meet my requirements!

USB is just a data pipe. USB does not care how many devices use that pipe, but there are limitations and trying to exceed total bandwidth is a problem. Prior to hitting total bandwidth limitations you might start experiencing other issues, e.g., time required to switch which device has traffic could add latency.

USB is hot-plug. Each USB device announces what it is when it is plugged in to the USB. USB itself does not care, but it does broadcast the device information to a hot-plug layer. This layer then offers the device to the drivers, and a driver which is compatible will respond and take ownership at the host end. There are several generic “standard” classes of device, such as keyboard and mice being Human Interface Devices (HID), and devices which follow that standard will always have a driver due to USB shipping by default with that standard class driver. Make no mistake though, the HID driver itself is not a USB driver, it is a driver which ships with USB. The same is true for the USB Video class (UVC), and cameras which advertise their generic compatibility will work with that.

Custom devices won’t find any driver responds to it for ownership unless someone installed that custom driver. If the function you want is not standard, then you have to write your driver from scratch.

The Linux gadget framework is only a skeleton for “standard” class devices. You can make the Linux computer appear to be one of those devices by filling in the framework information. This is what happens with the virtual network device, and also with a mass storage device with the README file in it. The former is useful during flash (after flash completes it uses this by default for optional package installs), and the latter is merely a demo.

You can put as many devices as you want on that one connector up to a limit (I think something like 127 or 128 devices), but I suspect the system will fail for other reasons long before it reaches that limit.

Do you want your Jetson to appear as any particular kind of device? Is that device custom, or is it something which is standardized? If custom, you write it all from scratch. If standardized, then you could write it from scratch, but the gadget framework is far easier. If you want to keep what is already there, and add a couple of devices, then this too is not an issue unless we start reaching USB limitations or performance limitations.

If you are writing a driver from scratch, then it is no different on a Jetson than it is on a desktop Linux PC. The trick here is that most such documentation is for a hardware device, and not for virtual device. You could examine how the gadget framework is designed, and then extend it with your own custom device (this would be a non-trivial learning curve).

I know it’s a hard one. I’m trying gadget now, testing gadget zero. i’ve configured the USB using configfs, and the pc (windows, linux) recognizes the configured gadget USB. but now i don’t know how to operate the configured USB from orin NX side. I use libusb to send data to orin NX from pc side.

If the Linux (Jetson) side is in device mode, and if that device is custom, then you need to develop kernel code on both the Jetson and the other end for the custom device. If the Jetson side is in device mode, and is working as a “standard” device type (which the Gadget system works with), then it is a case of filling in all of the parameters in the Gadget template. Gadget is more closely described here:

More information for Gadget:

There is a learning curve, especially if you are not already familiar with USB devices (at the driver side). There is no reason you cannot implement each device individually without removing the other. For example, you could add a mass storage device and a virtual emulation of a keyboard and mouse. You could then implement a second mass storage device, or a second virtual keyboard.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.