* On the Windows PC open the external media device, now you have access to the MMC card on your device.

* On the Windows PC open the external media device, now you have access to the MMC card on your device.

−

[[Category:Whitepaper]]

+

= Mass Storage Performance Test =

+

+

A 4GB file was created on the LeopardeBoard using "dd". The file was transmitted from a LeopardBoard to a Ubuntu PC using the USB composite driver. The transmitted file and the file at the LeopardBoard where compared using the sha1sum, both numbers where the same indicating that the USB file transfer didn't corrupted the data.

+

+

The average LeopardBoard-to-host transmission speed was approximately 3.5MB/s.

+

+

= Mass storage endurance test =

+

+

To keep from wearing out NAND or an SD card, we will use a VFAT file system contained in a file in tmpfs. Change VFAT_FILE to point to a file on NAND or SD card if that is your preference.

+

+

On the target, setup a 10Mbyte VFAT file system with some files and allow it to be mounted over USB:

* the host will calculate the sha1sum for the downloaded file and compare it to the sha1sum calculated by the target

+

* created files will be delete and the process repeated

+

+

Make sure you stop any applications running on the target that will interfere with USB serial communication. On target, update inittab and then have init reread the modified file to allow a shell to exist on USB ACM serial port.

+

+

<pre>

+

modprobe g_cdc_ms removable=y luns=1

+

echo 'ttyGS0::askfirst:-/bin/sh' >> /etc/inittab

+

kill -HUP 1 # causes init to reload /etc/inittab

+

</pre>

+

+

On the host side setup so it is easy to send commands the run on the target. To keep USB ACM from sending open / close indications to the shell running on ttyGS0, I just run picocom in another window. We can still send commands to the target using <tt>/dev/ttyACM0</tt>.

+

+

<pre>

+

sudo chmod ugo+rw /dev/ttyACM0

+

picocom /dev/ttyACM0

+

</pre>

+

+

Now open another terminal and send some commands to the shell running on the target. The responses to your commands will be displayed in picocom:

Introduction

This document explains the Communications Device Class (CDC) Abstract Control Model (ACM) +
Mass Storage (MS) composite Linux gadget driver and how to use it with a Linux host PC and
a Windows host PC.

CDC ACM + MS driver

The CDC ACM + MS driver is a USB composite gadget driver which implements the serial
communication and mass storage functions. This allows the device to be registered
on a host computer as a seral port (e.g. /dev/ttyACM0 or COM1:) and as a USB thumb
drive (e.g. /dev/sdf or E:). The composite driver allows for simultaneous
use of the serial and mass storage functions.

Driver support

The CDC ACM only driver that comes with the Linux kernel is supported on both Linux
and Windows. For Windows it is necessary the use of the following INF file:

Our experience shows the CDC ACM + MS composite USB driver is not well supported
on Windows with this INF file. We have tested with a propretary solutions from
Thesycon, with a demo version available at

The serial communication port has been registed as 'ttACM0', meaning it will show
up as '/dev/ttyACM0'. The mass storage device have been registered as 'sdf',
meaning it will show up as '/dev/sdf'.

How to test the serial driver in Linux

In order to test the serial function on Linux you should need to install picocom

sudo apt-get install picocom

and use the picocom terminal emulator to display data received over the USB serial
connection:

picocom /dev/ttyACM0

In order to send data from the target device we need to use the USB serial
gadget driver device file '/dev/ttyGS0'. We can echo command to send data from the
device to the Ubuntu host computer:

echo foo > /dev/ttyGS0

After that you should see the text foo on picocom's output.

In a similar way, if we want to send data from the host computer to the device we should
first send the data on the host by running

echo hello > /dev/ttyACM0

and read it on the device

cat /dev/ttyGS0

How to use the mass storage function in Linux

Once the driver has been installed correctly we just need to mount the SD card on the device
in order to get the mass storage device ready. In order to do that we just need to run the
following commands on the target device:

On the Ubuntu PC open the external media device, now you have access to the MMC card on your device.

Using CDC ACM + MS device with Windows 7 host

When using the device on Windows, you need to use a INF file in order to load the
appropriate driver. There is an INI file avaiable (see above), but it didn't work
for use on Windows 7 with a CDC ACM + MS device. Instead we used the proprietary
driver from Thesycon.

Thesycon provides a demo version of the driver
[1] that can be installed on Windows.
By default it creates a directory on C:\Thesycon\CdcAcm\V1.96.0_Demo\. There is
an INI file and a SYS driver in the idisk sub-directory you can use to exchange USB serial data
with the target device.

In order use the INF file provided it is necessary to add the VID (Vendor ID) and PID (Product ID)
of the target device to the file; look for the following piece of code into the file:

Replace the USB\VID_VVVV&PID_PPPP string with the corresponding VID and PID. In addition we
need to specify the interface on which the serial function is located since it is a composite device.
For example, the following uses the Linux Foundation (VID = 0x1D6B) device with a PID = 0x0104
(Multifunction Composite Gadget). We assume the serial interface is located in the interface 1,
so the piece of code shown above should be replaced by:

Once the edited INF file is read, just plug the device to the Windows host computer. Windows
will try to locate a usable driver. When it asks for the driver just point it to the folder where
the modified INF file resides and Windows will do the rest.

If Windows doesn't ask for it but still fails on the installation you can install the driver by:

Go to Start -> Control panel -> Devices and printers"

Right click on the composite device.

Properties -> Hardware.

Select the CDC ACM Data function.

Properties

Change configuration

Update firmware

Point it to the folder containing the INF file and then wait to the driver to be installed.

Once Windows announces the driver was installed correctly, the device is ready to use.

Using the Windows 7 serial port

In order to use the serial function you can install TeraTerm on your
Windows machine and launch the TeraTerm application. On first dialog TeraTerm will ask
for the connection properties as is shown on figure 1, be sure to select Serial and
the port corresponding to your composite device.

Figure 1. TeraTerm initial screen.

After selecting the appropriated port, TeraTerm will open the connection with the device.

To send data from the device to your host PC run the following command on the target device:

echo foo > /dev/ttyACM0

You should be able to see the text foo in the TeraTerm window.

To send data from Windows to the device write any word on your TeraTerm's window and press ENTER and then run the following command on the device:

cat /dev/ttyACM0

You should be able to see the string on your target device console.

How to use the mass storage function in Windows 7

Once the driver has been installed correctly we just need to mount the SD card on the device
in order to get the mass storage device ready. In order to do that we just need to run the
following commands on the target device:

On the Windows PC open the external media device, now you have access to the MMC card on your device.

Mass Storage Performance Test

A 4GB file was created on the LeopardeBoard using "dd". The file was transmitted from a LeopardBoard to a Ubuntu PC using the USB composite driver. The transmitted file and the file at the LeopardBoard where compared using the sha1sum, both numbers where the same indicating that the USB file transfer didn't corrupted the data.

The average LeopardBoard-to-host transmission speed was approximately 3.5MB/s.

Mass storage endurance test

To keep from wearing out NAND or an SD card, we will use a VFAT file system contained in a file in tmpfs. Change VFAT_FILE to point to a file on NAND or SD card if that is your preference.

On the target, setup a 10Mbyte VFAT file system with some files and allow it to be mounted over USB:

the host will calculate the sha1sum for the downloaded file and compare it to the sha1sum calculated by the target

created files will be delete and the process repeated

Make sure you stop any applications running on the target that will interfere with USB serial communication. On target, update inittab and then have init reread the modified file to allow a shell to exist on USB ACM serial port.

On the host side setup so it is easy to send commands the run on the target. To keep USB ACM from sending open / close indications to the shell running on ttyGS0, I just run picocom in another window. We can still send commands to the target using /dev/ttyACM0.

sudo chmod ugo+rw /dev/ttyACM0
picocom /dev/ttyACM0

Now open another terminal and send some commands to the shell running on the target. The responses to your commands will be displayed in picocom: