Verdin USB OTG Slave

Hi,
I have no experience with usb protocol but basically I would like to connect the Verdin over usb to a PC and see it as a mounted drive.
From the Dahlia datasheet on Verdin USB_1 Port:

I see that this should be possible, but just connecting a USB-C cable between my PC and Verdin X3 connector does nothing. On the other hand the port does work as a host. I can put in a usb stick and it is mounted in Linux and I can copy data onto it.

I see it depends on the CC Pin. Should I change anything or the PC handles handles this by itself?

Furthermore we are designing a USB Micro interface on our custom board with the same idea and the same USB_1 port of the Verdin. Is there something that we have to watch out for? This is the schematics:

Thanks in advance!

Hi @swiss !

Please refer to this USB Device Mode (Linux) | Toradex Developer Center article.

About the hardware for Verdin interfaces, please refer to the Verdin Carrier Board Design Guide.

Let us know if it helps you :slight_smile:

Best regards,

Hi @swiss !

Were you able to solve your issue?

Let us know :slight_smile:

Best regards,

Hi @henrique.tx ,
Sorry I am preoccupied with some other parts of the project right now. I will update you as soon as possible!

1 Like

Hi @henrique.tx ,
One month later I’m finally back on this topic.

After reading up on the links you sent me, I decided I want a to use the USB CDC ECM function.
I tried following the gadget example but I hit a problem as soon as:

# Mount configfs
mount -t configfs none /sys/kernel/config
cd /sys/kernel/config/usb_gadget/

# Create gadget
mkdir g2
cd g2

# Use Toradex vendor and product id
echo 0x1b67 > idVendor

I had to run most of the commands as sudo, but even with that, as soon as I change the idVendor file, (sudo vim idVendor and :wq! after to exit) I get a message:

WARNING: The file has been changed since reading it!!!

and the idVendor goes back to 0x0000.
The same happens for every step where I have to change a file in this example. I can’t change it and it goes back to it’s original value.

Also maybe worth mentioning just running the first step gives me this message:

mount -t configfs none /sys/kernel/config
mount: /sys/kernel/config: none already mounted on /sys/fs/bpf.

I have no idea if that is connected with the issue.

Btw I am using the TorizonCore image without Portainer

Hi @swiss !

Could you please share the following information:

  • Which exact module are you using? Please share its full name and version.
  • Which TorizonCore version are you using? Please share the output of cat /etc/os-release.
  • Have you done any customization on your TorizonCore image (either using TorizonCore Builder or building it using Yocto)?

This is expected as the default user in TorizonCore is torizon and you are dealing with system-related files in /sys/kernel therefore you need to give permission to torizon user to perform the modifications.

About your specific issue, we need to research and do some tests. We will get back to you as soon as we have some news.

Best regards,

Hi,

Verdin Mini v1.1 (with wifi), right now testing on Dahlia boad v1.1

ID=torizon
NAME=“TorizonCore”
VERSION=“5.7.0+build.17 (dunfell)”
VERSION_ID=5.7.0-build.17
PRETTY_NAME=“TorizonCore 5.7.0+build.17 (dunfell)”
DISTRO_CODENAME=“dunfell”
BUILD_ID=“17”
ANSI_COLOR=“1;34”
VARIANT=“Docker”

Only using TorizonCore to change the device tree overlay, I’m trying to aviod using Yocto (no experience). I just added my changes to the verdin-imx8mm_lt8912 overlay that was already applied. Pretty much just deactivating peripherals that I’m using form the M core and activating RPMSG. Here is the dto:

// Verdin DSI to HDMI Adapter orderable at Toradex.

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,verdin-imx8mm";
};

&gpu {
	status = "okay";
};


&pwm1 {
	status = "disabled";
};


/* Disable Verdin SPI */
&uart2 {
        status = "disabled";
        };
&uart3 {
	status = "disabled";
        };
&ecspi1 {
	status = "disabled";
        };

&ecspi2 {
	status = "disabled";
       	};

&gpio3 {
	status = "disabled";
	};

&flexspi {
	status = "disabled";
	};
&{/} {

    reserved-memory {

		#address-cells = <2>;
		#size-cells = <2>;
		ranges;
        
        vdev0vring0: vdev0vring0@B8000000 {
			compatible = "shared-dma-pool";
			reg = <0 0xB8000000 0 0x8000>;
			no-map;
		};

		vdev0vring1: vdev0vring1@B8008000 {
			compatible = "shared-dma-pool";
			reg = <0 0xB8008000 0 0x8000>;
			no-map;
		};

     		vdev1vring0: vdev1vring0@B8010000 {
			compatible = "shared-dma-pool";
			reg = <0 0xB8010000 0 0x8000>;
			no-map;
		};

		vdev1vring1: vdev1vring1@B8018000 {
			compatible = "shared-dma-pool";
			reg = <0 0xB8018000 0 0x08000>;
			no-map;
		};     

		vdevbuffer: vdevbuffer@b8400000 {
			compatible = "shared-dma-pool";
			reg = <0 0xb8400000 0 0x100000>;
			no-map;
		};
        
        rsc_table: rsc_table@B80FF000 {
			reg = <0 0xb80ff000 0 0x1000>;
			no-map;
		};
    };
};

&rpmsg {
	/*
	 * 64K for one rpmsg instance:
	 * --0xb8000000~0xb800ffff: pingpong
	 */
	vdev-nums = <2>;
	reg = <0x0 0xb8000000 0x0 0x20000>;
	 memory-region = <&vdevbuffer>, <&vdev0vring0>, <&vdev0vring1>, 
                   <&vdev1vring0>, <&vdev1vring1>, 
                   <&rsc_table>;
    status = "okay";
};

How do I change the permissions? I would suggest adding this information to the USB Device Mode (Linux) | Toradex Developer Center page since a lot of users probably use torizoncore with torizon user when trying this for the first time.
Sorry, I missunderstood, you meant adding sudo is expected, but my issue that the files keep their old values is a new issue.

Since you are looking into my specific issue, a bit more information:

My goal is to use the pins shown in my first post in this question, so USB 1 of the Verdin port for communication with the PC. The CDC ECM protocol looks like the best solution since it should be compatible with Windows, OSx and Linux as host computers. My priority right now is communicating with Windows though. Also the communication will be through a container later, but that shouldn’t pose any issues I hope, after I make it work from the torizoncore directly.

Thanks in advance!

Hello @swiss ,
Did you have a look at this thread too?

Best regards,
Josep

Hi @josep.tx ,

This did solve one part of the problem. I am able to change the idVendor and other files when outside of the g2 directory. I think you should change this in the tutorial USB Device Mode (Linux) | Toradex Developer Center

since it explicitly says “cd g2”.

The second part of the problem is: it’s not working :slight_smile:
After following the steps for cdc ecm and connecting it to my windows laptop, nothing happens.

Didn’t see the last paragraph, after enabling the new configuration in g2/UDC the device is mounted to windows, I can’t runt the gadget-export though.

gadget-export g2 /etc/usbg/g2.schema
-sh: gadget-export: command not found

Hello @swiss ,

According to @jeremias.tx answer in that thread:
One thing that is outdated is that there is no gadget-export or gadget-import command in the newer releases. However these commands are only to export/import an already existing schema. The commands the article had you do prior is what creates the schema. In this case you would only need export the schema if you want to transfer it to another system.

Best regards,
Josep

Hi @josep.tx ,
I saw that, but when I restart the device the configuration goes away. The next sentence in the tutorial states:
“To make sure the g2 Gadget configuration gets loaded automatically, alter the systemd service located at /lib/systemd/system/usbg.service or name the schema g1.schema.”

So I’m not sure how to keep this gadget on the board if I dont have the schema.

Apart from that, the device is being recognized by windows but it says that no driver is installed and I can’t find any to install.

I found this thread USB OTG Ethernet not working that explains pretty much the same issue and I doesn’t seem to be solved. I can also try the RNDIS, maybe it’s just windows that doesn’t like the ecm protocol.

I managed to make RNDIS protocol work following this extensive topic:

As I said in the beginning - no experience with any of these protocols that’s why it was a bit chaotic. I guess a need a composite device with the ecm and rndis protocol together where rndis is used by windows hosts and ecm by linux/osx hosts, but I’ll concentrate on using the rndis with windows for now.

The question of saving the configuration still stays kinda open, in the mentioned topic the solution was to write a small script that runs on linux start, is that the only solution? If yes I will just close the topic

Hello @swiss

I would say it is “one” solution, usually there are different ways to achieve the same result. So far it is what it has been tried.

Best regards,
Josep