Linux USB Gadget Driver

Linux USB Gadget Driver

This driver has been tested and is working. This driver is in the master branch.

It has been tested with the File Backed Storage Gadget driver in Linux as a memory device.

This driver works with the XPS USB 2.0 Device core in the Xilinx EDK which is a pay core. It can be evaluated for free.


The SMSC Daughter Card: EVB-USB3300-XLX

Linux Gadget File Storage Driver

XApp997: Reference Design: LogiCore OPB USB 2.0 Device has more documentation about how to use a similar core (OPB vs XPS) and the daughter board. This driver was tested with the XPS USB Device core which is a newer core based on a newer bus rather than the OPB.

Driver Kernel Configuration

Enable USB, then enable USB Gadget Support. Enable the Xilinx USB Driver which is a USB Peripheral Controller.

ML405 Testing Setup

This test was ran with the SMSC daughter card that supports USB connected to the ML405 board. The daughter card is plugged on the header closest to the power switch on the board with the daughter card hanging off the edge of the ML405. The jumpers of the SMSC daughter card should be as follows: J6=on, J7=off, and no power is required for the SMSC daughter card.

Linux Host Setup

This test assumes that you are going to connect the ML405 board over USB to a Linux Host as the ML405 ram disk only has a Linux partition.

Connect a USB cable from the SMSC daughter card on the ML405 to the Linux Host USB connector.

File Backed Storage Gadget Driver

This driver can be used to test the Xilinx USB Gadget Driver as it runs on top of the gadget driver and emulates a USB memory stick.

Enable the File Backed Storage Gadget as a module in the kernel configuration. This driver requires parameters when it starts such that it’s easier to load it as a module.

Building the Module

The kernel is built as normal once the kernel has been configured to include the USB driver.

Since the File Backed Storage Gadget Driver as setup as a module in the kernel configuration, it must be built.
bash> make ARCH=powerpc modules

The module, g_file_storage.ko, is created in the drivers/usb/gadget directory. This file can be copied to a ram disk to be executed later.

Inserting the Module

Once the kernel is running on the ML405, you should be able to see the kernel module, g_file_storage.ko, in the directory of the root file system where you put it. The following command inserts the driver as a kernel module into the kernel.
bash> insmod ./g_file_storage.ko file=/dev/ram0

You should now see several lines of output as follows indicating the driver is working.

  • g_file_storage xilinx_udc: controller 'xilinx_udc' not recognized
  • g_file_storage xilinx_udc: File-backed Storage Gadget, version: 7 August 2007
  • g_file_storage xilinx_udc: Number of LUNs=1
  • g_file_storage xilinx_udc-lun0: ro=0, file: /dev/ram0

Mounting the ML405 as a USB Memory Stick

This requires root access or SUDO access on the Linux Host.

From the /proc/scsi directory of the Linux Host, you should be able to see a usb-storage directory created for the ML405. If not, you should make sure you can see this directory with a normal USB memory stick.

A device node should also exist for the device which appears as a SCSI device, /dev/sd*.

From the Linux Host, create a temporary directory and mount the ML405 which is now emulating a USB memory stick.
bash> mkdir temp
bash> mount /dev/sd<your drive letter> temp
bash> cd temp
If you do not know what your drive letter is, you can find out with the following command:
bash> sudo fdisk -l

You should now see the root file system of the ML405. You can copy files from the root file system but you can't write to the root file system from the Linux Host.

© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy