Difference between revisions of "How to use mass storage gadget"

From RidgeRun Developer Connection
Jump to: navigation, search
 
(Mass storage gadget)
Line 1: Line 1:
 
=Mass storage gadget=
 
=Mass storage gadget=
Enable the following modules of the kernel:
+
1. Enable the following modules of the kernel:
 
<pre>
 
<pre>
 
-> Kernel configuration                                                                                                                       
 
-> Kernel configuration                                                                                                                       
Line 9: Line 9:
 
</pre>
 
</pre>
  
In order to expose a sd card partition as backing storage for the mass storage gadget  
+
2. In order to expose a sd card partition as backing storage for the mass storage gadget, you need to leave some available space
 +
in the sd card, for this, you can limit the space taken by the file system here:
 +
<pre>
 +
-> Installer Configuration
 +
  -> Minimal size of rootfs (MB)
 +
</pre>
 +
Then you can create a fat partition on the available space in the sd card, in order to be used as backing storage.
 +
 
 +
3. Build and install the kernel in the target board.
 +
 
 +
4. Now in the board command line, load the module and set the parameters, file should point to the fat partition created in step 2.
 +
<pre>
 +
modprobe g_mass_storage file=/dev/mmcblk3p3 stall=0
 +
</pre>
  
Build and install the kernel in the target board. Now in the target board command line:
+
An alternative way is to use the parameter removable and specify the file parameter later through sysfs:
 +
<pre>
 +
modprobe g_mass_storage removable=y  stall=0
 +
</pre>
  
 +
To specify the file parameter:
 
<pre>
 
<pre>
 +
echo "/dev/mmcblk3p3" > sys/devices/soc0/soc.0/2100000.aips-bus/2184000.usb/ci_hdrc.0/gadget/lun0/file
 +
</pre>
  
 +
To free the backing storage (No host should have the mass storage mounted):
 +
<pre>
 +
echo "" > sys/devices/soc0/soc.0/2100000.aips-bus/2184000.usb/ci_hdrc.0/gadget/lun0/file
 
</pre>
 
</pre>
  
Under construction...
+
If the gadget was mounted on the host, you may get a message like:
 +
<pre>
 +
Minimal size of rootfs (MB)
 +
</pre>

Revision as of 17:27, 15 November 2016

Mass storage gadget

1. Enable the following modules of the kernel:

-> Kernel configuration                                                                                                                       
  -> Device Drivers                                                                                                                          
    -> USB support (USB_SUPPORT [=y])                                                                                                       
      -> USB Gadget Support (USB_GADGET [=y])                                                                                                                      
        -> Mass Storage Gadget ( USB_MASS_STORAGE [=m])

2. In order to expose a sd card partition as backing storage for the mass storage gadget, you need to leave some available space in the sd card, for this, you can limit the space taken by the file system here:

-> Installer Configuration
  -> Minimal size of rootfs (MB)
Then you can create a fat partition on the available space in the sd card, in order to be used as backing storage.

3. Build and install the kernel in the target board.

4. Now in the board command line, load the module and set the parameters, file should point to the fat partition created in step 2.

modprobe g_mass_storage file=/dev/mmcblk3p3 stall=0

An alternative way is to use the parameter removable and specify the file parameter later through sysfs:

modprobe g_mass_storage removable=y  stall=0

To specify the file parameter:

echo "/dev/mmcblk3p3" > sys/devices/soc0/soc.0/2100000.aips-bus/2184000.usb/ci_hdrc.0/gadget/lun0/file

To free the backing storage (No host should have the mass storage mounted):

echo "" > sys/devices/soc0/soc.0/2100000.aips-bus/2184000.usb/ci_hdrc.0/gadget/lun0/file

If the gadget was mounted on the host, you may get a message like:

Minimal size of rootfs (MB)