Connected PC (host) on USB B cannot be found in Colibri iMX6ULL (device mode)

Dear all,

Currently I face a problem where the connected PC through a USB A to USB B cable cannot be found using operations like lsusb or usb-devices. What am I missing?

SoM: Colibri iMX6ULL 512MB IT V1.1A
Carrier: Colibri Evaluation Board V3.2B
OS: Toradex Embedded Linux Reference Multimedia Image (Toradex Easy Installer)

Host PC: Arch Linux

Hi @rjjong1 ,

could you please share more details of your setup?

Which carrier are you using? And what version?

The command lsusb does not work where? On the module? Or on the host?

Best Regards
Kevin

Hi @kevin.tx,

I edited my first post. It now contains the details. Further details about the problem are below.

The lsusb command in the iMX6ULL gives a list of all devices connected, but not the connected PC, which is actually a host in this case. It seems to only exclude one of the ‘Linux Foundation 2.0 root hubs’ when it is connected compared to when the USB cable is not connected.

Remo

The Colibri Evaluation board has two USB B connectors. Which one you are using?

I’m using the one next to the other USB ports and next to the Reset button.

Hi @rjjong1

did you follow the article about USB Device Mode?

USB Device Mode Linux

Best Regards
Kevin

Hello Kevin,

I followed the tutorial, but now I cannot seem to enable the configuration by echo ci_hdrc.1 > g2/UDC. It returns: write error: No such device. ci_hdrc.1 is the only controller in /sys/class/udc/. Could it be due to the functionfs function? I followed the guide thorougly, the only changes were made in the function lines where I replace ecm for ffs and in the idProduct (x0402c). Also the functionfs was mounted on /dev/ffs_usb. It has the ep0 endpoint.

Thank you.

Hi @rjjong1 ,

thanks for letting us know about your progress.

Could you share a bit more about your project? What are you trying to achieve at the very end?

Best Regards
Kevin

Hi @kevin.tx ,

We want to transfer files from a PC to the SoM via USB, the SoM will then communicate to a seperate FPGA over the parallel EIM interface. Now I am trying to setup a (usb) gadget with filesystem functionality, so that I am able to read and write to the endpoints.

Best regards,

Remo

The lsusb command in the iMX6ULL gives a list of all devices connected, but not the connected PC,

Hm, are you sure lsusb should list connected PC? Perhaps it should with dr_mode = "otg" in DT, but I think it shouldn’t when you have dr_mode = "peripheral". Anyway gadget is working though lsusb doesn’t list PC.

I followed the tutorial, but now I cannot seem to enable the configuration by echo ci_hdrc.1 > g2/UDC . It returns: write error: No such device. ci_hdrc.1 is the only controller in /sys/class/udc/.

Tutorial is fully working for i.MX6ULL, except for what you found. It should be echo ci_hdrc.1 > g2/UDC, not ci_hdrc.0. Since there are some command snippets with text block in between, perhaps you missed some cd command? It could be something wrong as well with your custom gadget config. Just try reproducing tutorial first, ffs gadget is another question.

Edward

Hi Edward,

The issue seems to come up when I choose functionfs (ffs) as a function, since I was able to enable the configuration (echo ci_hdrc.1 > UDC) after initialising the filesystem with a compiled binary from the kernel (linux/ffs-test.c at master · torvalds/linux · GitHub), which is executed from the ffs mountpoint. Although now I am not able to read the output that I wrote to ep1 using libusb.

ffs-test running in the background reports: bad OUT byte [NUMBER], expected 00 got [non nul byte]. Consequently it only outputs this error when I write non nul bytes during the bulk transfer. Another simple script that uses open() and read() to read the mounpoint/ep1 only outputs floating gibberish. Is there a complete guide that you can recommend me to read and write to the endpoints? As I have the feeling that I am skipping important steps that are hidden somewhere on the web.

Remo

Hi @rjjong1 ,

I was reproducing it on my end. I followed the guide I sent above, plus additionally, I followed a link on the article that led to the kernel documentation.

Kernel Documentation

There are some steps under Point 8 that you can try to follow.

On my end I now see the device on my host as follows:

lsusb on host

Bus 001 Device 004: ID 1b67:4028 Toradex Colibri iMX6ULL

Do you see the Module when you enter “lsusb” on your host as well?

Let me know if it worked.

Best Regards
Kevin

Hi @kevin.tx ,

Thank you for your reply.

I was able to find the device using lsusb and even with my Libusb (on host). Therefore my initial question is actually solved. However, I am still facing this other problem, where I am not able to write nor read to endpoints 1 or 2. The code that I tried was ffs-test.c (mentioned and referenced above) and this one: simple_usb_chat/device_schat.c at master · kopasiak/simple_usb_chat · GitHub. For some reason the program freezes (in the background) as the host writes some char array to endpoint 1 (out) using a bulk transfer (part of libusb). After that I am still able to find the device, but not able to write. Therefore I assume this is the part where it goes wrong, although I don’t see why.

Remo

Hi @rjjong1 ,

what software do you use to read the bytes on the device side?

If you do not have one, this might be the cause of why the host gets blocked from sending bytes.

Best Regards
Kevin

I was able to receive bytes on the module after rewriting aio_simple.c from the kernel. Other than writing the descriptors to ep0, which ffs-test and simple_schat also did, it used the following code to enable the endpoints for data streams:

FD_ZERO(&rfds);
		FD_SET(ep0, &rfds);
		FD_SET(evfd, &rfds);

		ret = select(((ep0 > evfd) ? ep0 : evfd)+1,
			     &rfds, NULL, NULL, NULL);
		if (ret < 0) {
			if (errno == EINTR)
				continue;
			perror("select");
			break;
		}

		if (FD_ISSET(ep0, &rfds))
			handle_ep0(ep0, &ready);

		/* we are waiting for function ENABLE */
		if (!ready)
			continue;

                while (1) {
                         your_code_here();
                }

I will close the ticket, thank you!

Hi @rjjong1 ,

thank you for sharing.

Best Regards
Kevin