IMX6ULL usb mass storage using schema

Hi,

I have configured usb mass storage gadget device using schema, linked to SD card. Gadget is detected successfully in windows, however any changes made in SD card (target imx6ull) are not reflected in mass storage device in windows. Recovery is restart the usbg using systemctl

attrs : 
{
    bcdUSB = 0x200;
    bDeviceClass = 0x2;
    bDeviceSubClass = 0x0;
    bDeviceProtocol = 0x0;
    bMaxPacketSize0 = 0x40;
    idVendor = 0x1b67;
    bcdDevice = 0x401;
};
os_descs : 
{
    config_id = 1;
    use = 1;
    qw_sign = "MSFT100";
    b_vendor_code = 0xcd;
};
strings = (
    {
        lang = 0x409;
        manufacturer = "Toradex";
        product = "Toradex Colibri iMX6ULL";
        serialnumber = "00000000";
    } );
functions :
{
    mass_storage :
    {
       instance = "0";
       type = "mass_storage";
       lun = (
          {
              lun = 0;
              file = "/dev/mmcblk0p1";
          } );
    };
};

configs = (
    {
        id = 1;
        name = "c";
        attrs :
        {
            bmAttributes = 0xC0;
            bMaxPower = 0x1;
        };
        strings = (
            {
                lang = 0x409;
                configuration = "MASS Storage";
            } );
        functions = (
            {
                name = "mass_storage";
                function = "mass_storage";
            });
    } );

Welcome to the community.

Could you please provide your Hardware and Software version ?
How you are testing ?

iMX6ULL 512MB WB IT V1.1A SoM and custom hardware

We are using Toradex Angstrom BSP. The manifest is pointing to below commit

Author: Marcel Ziswiler
Date: Mon Apr 1 10:49:51 2019 +0200
manifest: freeze toradex repositories to latest rocko
Signed-off-by: Marcel Ziswiler marcel.ziswiler@toradex.com

Testing:
After configured udc gadget as mass storage, connect device to windows

Dear @sarsekar

First of all an additional question for our clarification: Do you want to change files on the target while the mass storage partition is mounted on your computer? I don’t think this is a good idea and I am not even sure if this is allowed. But if you would do that, then you have two independent computers, changing files in the same file system. That’s like two computers accessing the same external drive. What is the intention behind?


Your configuration didn’t work for me actually. I followed the example configuration in this article and derived a USB mass-storage configuration for your requirements, which looks like the following. After adding the schema (configuration) to the device, I disabled the existing configuration with echo "" > g1/UDC, imported the new one with gadget-import g2 /etc/usbg/g2.schema and activated it with echo "ci_hdrc.1" > g2/UDC. After that, all worked fine for me.

My /etc/usbg/g2.schema:

attrs : 
{
    bcdUSB = 0x200;
    bDeviceClass = 0x2;
    bDeviceSubClass = 0x0;
    bDeviceProtocol = 0x0;
    bMaxPacketSize0 = 0x40;
    idVendor = 0x1b67;
    bcdDevice = 0x401;
};
os_descs : 
{
    config_id = 1;
    use = 1;
    qw_sign = "MSFT100";
    b_vendor_code = 0xcd;
};
strings = (
    {
        lang = 0x409;
        manufacturer = "Toradex";
        product = "Toradex Colibri iMX6ULL";
        serialnumber = "00000000";
    } );
functions :
{
    mass_storage_1 : 
    {
        instance = "0";
        type = "mass_storage";
        attrs : 
        {
            stall = false;
            luns = ( 
                {
                    cdrom = false;
                    ro = false;
                    nofua = false;
                    removable = true;
                    file = "/dev/mmcblk0p1";
                } );
        };
        os_descs = ( );
    };
};

configs = (
    {
        id = 1;
        name = "c";
        attrs :
        {
            bmAttributes = 0xC0;
            bMaxPower = 0x1;
        };
        strings = (
            {
                lang = 0x409;
                configuration = "MASS Storage";
            } );
        functions = (
            {
                name = "mass_storage.1";
                function = "mass_storage_1";
            });
    } );

Best regards
Diego

1 Like