Multiple serial port usb gadget colibri vf61

Hello,

I would like to have multiple (2) serial links over composite usb at vf61. Is it even possible?

I tried to edit /etc/usbg/g1.schema copying blocks under function and configs - see below - but it doesn’t work, since usbg service fails during start with this message: Failed to start Load default USB gadget schema g1.schema, specifically at this line:

ExecStartPost=/bin/sh -c /bin/echo `ls /sys/class/udc/` > /sys/kernel/config/usb_gadget/g1/UDC (code=exited, status=1/FAILURE).

It fails at writing to /sys/kernel/config/usb_gadget/g1/UDC with this message (exactly same as when I try to write there anything else):

root@colibri-vf:~# echo “” > /sys/kernel/config/usb_gadget/g1/UDC
-sh: echo: write error: No such device

EDIT: I tried with port_num = 0 and port_num = 1 in acm_GS1, since I don’t know what this attribute is about - with the same result.

Could somebody please tell me what’s wrong or what’s the way to add secondary serial line over usb - if it even is possible? Thank you.


    root@colibri-vf:~# cat /etc/usbg/g1.schema 
        attrs :  
        {
                bcdUSB = 0x0;
                bDeviceClass = 0x0;
                bDeviceSubClass = 0x0;
                bDeviceProtocol = 0x0;
                bMaxPacketSize0 = 0x40;
                idVendor = 0x1d6b;
                idProduct = 0x0104;
                bcdDevice = 0x400; 
        }; 
        strings = ( 
                {
                    lang = 0x409;
                    manufacturer = "Toradex";
                    product = "Unknown";
                    serialnumber = "";
                } ); 
        functions :  {
                acm_GS0 : 
                {
                    instance = "GS0";
                    type = "acm";
                    attrs : 
                    {
                        port_num = 0;
                    };
                };
                acm_GS1 : 
                {
                    instance = "GS1";
                    type = "acm";
                    attrs : 
                    {
                        port_num = 0;
                    };
                };
                rndis_0 : 
                {
                    instance = "0";
                    type = "rndis";
                    attrs : 
                    {
                        dev_addr = "00:14:2d:ff:ff:ff";
                        host_addr = "00:14:2d:ff:ff:fe";
                        qmult = 5;
                    };
                }; 
        }; 
        configs = ( 
                {
                    id = 1;
                    name = "c";
                    attrs : 
                    {
                        bmAttributes = 0x80;
                        bMaxPower = 0x2;
                    };
                    strings = ( 
                        {
                            lang = 0x409;
                            configuration = "Conf 1";
                        } );       
                    functions = ( 
                        {
                            name = "acm.GS0";
                            function = "acm_GS0";
                        }, 
                        {
                            name = "acm.GS1";
                            function = "acm_GS1";
                        }, 
                        {
                            name = "rndis.0";
                            function = "rndis_0";
                        } );
                } );

Did you update the kernel? You probably have a missmatch between kernel and kernel modules. The system then is not able to load the necessary kernel modules. The modules need to be present in ls /lib/modules/$(uname -r).

Thanks for reply. I’m not sure if I understand, but I think it shouldn’t be a problem of mismatched modules - when I use this composite usb as is configured out of the box (one serial and one rndis) it works fine. The problem is with adding/configuring additional serial link.

Or do you need separate modules for every serial link?

These modules are loaded (regardless the number of serial links configured):

root@colibri-vf:~# lsmod|grep rndis
usb_f_rndis            15406  2
u_ether                11977  1 usb_f_rndis
libcomposite           43496  13 usb_f_acm,usb_f_rndis
configfs               23589  4 usb_f_acm,usb_f_rndis,libcomposite
root@colibri-vf:~# lsmod|grep serial
u_serial                9638  3 usb_f_acm

Ok, I found a workaround - kind of.

Someone else had this problem with different platform https://www.spinics.net/lists/linux-usb/msg163414.html - he was able to run the composite usb only with 2 functions.

So I tried setup with only 2 serials and it works - see working config below.

Does anyone know if this is some limitation of the usb on Colibri VF61 or what else could cause it? Or if there is some way to have more than 2 functions? It’s sufficient for us to have only 2 serials for now, but could be nice to have rndis too.

root@colibri-vf:~# cat /etc/usbg/g1.schema
attrs :
{
    bcdUSB = 0x0;
    bDeviceClass = 0x0;
    bDeviceSubClass = 0x0;
    bDeviceProtocol = 0x0;
    bMaxPacketSize0 = 0x40;
    idVendor = 0x1d6b;
    idProduct = 0x0104;
    bcdDevice = 0x400;
};
strings = (
    {
        lang = 0x409;
        manufacturer = "Toradex";
        product = "Unknown";
        serialnumber = "";
    } );
functions :
{
    acm_GS0 :
    {
        instance = "GS0";
        type = "acm";
        attrs :
        {
            port_num = 0;
        };
    };
    acm_GS1 :
    {
        instance = "GS1";
        type = "acm";
        attrs :
        {
            port_num = 1;
        };
    };
};
configs = (
    {
        id = 1;
        name = "c";
        attrs :
        {
            bmAttributes = 0x80;
            bMaxPower = 0x2;
        };
        strings = (
            {
                lang = 0x409;
                configuration = "Conf 1";
            } );
        functions = (
            {
                name = "acm.GS0";
                function = "acm_GS0";
            },
            {
                name = "acm.GS1";
                function = "acm_GS1";
            } );
    } );

Perfect, that you found a solution. Thanks for the feedback.
Did you try to add three functions to see if this works or not?