Project

General

Profile

USB-OTG as a peripheral and a host

Added by Preejith S P almost 11 years ago

Hello,
I am using a MityDSP L138F with a custom board. This board has provision for a USB 1.1 Host and an USB 2 OTG port. I am trying to configure the USB-OTG port as a peripheral and get it detected through a Windows as well as a Linux PC and then to transfer data to the PC.

I have modified the /linux-davinci/arch/arm/mach-davinci/baseboard-industrialio.c as:
mityomapl138_usb_init(MUSB_PERIPHERAL);
After this, I rebuilt the kernel and created the uImage and loaded the kernel.
However, the Linux host PC running on Ubuntu 10.04 LTS was not able to detect it. Nothing was listed inside the /dev folder.
The Windows PC gave a message saying "Unidentified USB Device".
However, when I connected the OTG port to the HOST port in the custom board, the following was displayed:

root@mityomapl138:~# usb 1-1: new full-speed USB device number 2 using ohci
usb 1-1: New USB device found, idVendor=0525, idProduct=a4a0
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: Gadget Zero
usb 1-1: Manufacturer: Linux 3.2.0+ with musb-hdrc
usb 1-1: SerialNumber: 0123456789.0123456789.0123456789
gadget: full-speed config #3: source/sink

Can you guide me on how I can get the board detected and have data transferred to/from a Linux and Windows PC??

Also, when the /linux-davinci/arch/arm/mach-davinci/baseboard-industrialio.c was configured as a host:
mityomapl138_usb_init(MUSB_HOST);

In this case, a memory device (pen drive) was successfully detected by the OTG port. But I was not able to access the files within the device.
Is there any configuration that I am missing out on? Please guide me.

Thank you


Replies (11)

RE: USB-OTG as a peripheral and a host - Added by Michael Williamson almost 11 years ago

Hello,

It looks like you have selected the "gadget zero" device as your peripheral device. This is a USB test device setup.

You need to go back to your kernel configuration deselect the gadget zero device and select the RNDIS device, which will make your USB port look like a network device to a windows or linux machine when you plug it in. There are other device options (gadgetfs, mass storage, etc), but you will need to configure the drivers accordingly. This wiki page on our support site has a simple example of getting this compiled and setting it up.

The gadget drivers can be compiled in at startup (allowing only one configuration) or as modules (allowing different configurations). There is in option in the menuconfig for this. I would recommend compiling them right into the kernel. If you load it as a module, you must make sure that you install and insmod or modprobe the module to actually get the desired behavior.

I would recommend searching the web for linux gadget device configuration for further assistance on setting up USB in peripheral mode. And can probably leave the port in MUSB_OTG mode if you like, though forcing it to peripheral is OK.

-Mike

RE: USB-OTG as a peripheral and a host - Added by Preejith S P almost 11 years ago

Hello Mike,

As per your suggestion, I have made the changes to the kernel configuration and I have also followed the instructions given in the wiki page.
I have chosen the RNDIS device and compiled it into the kernel. The port is in the MUSB_OTG mode. I was able to successfully compile the kernel and get the uImage.

These are the steps I followed from the host terminal:
htic@htic->. /usr/local/oecore-i686/environment-setup-armv5te-angstrom-linux-gnueabi
htic@htic->cd linux-davinci
htic@htic->make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- industrialio_defconfig
htic@htic->make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- menuconfig
htic@htic->make ARCH=arm CROSS_COMPILE=arm-angstrom-linux-gnueabi- uImage

After this step, I obtained the uImage without any errors in the /linux-davinci/arch/arm/boot/ folder.

However, as mentioned in the wiki page, I am unable to see an Ethernet device (usb0) created by the RNDIS gadget driver and therefore I am not able to proceed further. My host PC runs on Ubuntu 12.04 LTS.
Could you help me with this?

Thank You

RE: USB-OTG as a peripheral and a host - Added by Jonathan Cormier almost 11 years ago

On the L138, if you run ifconfig -a is a usb0 listed?

-Jonathan

RE: USB-OTG as a peripheral and a host - Added by Michael Williamson almost 11 years ago

When you plug the USB in, the kernel should also dump out some information about the connection.

Attaching the results of dmesg might help as well.

-Mike

RE: USB-OTG as a peripheral and a host - Added by Preejith S P almost 11 years ago

Hello Jonathan, Mike

Thank you for your replies.

I have been able to find the usb0 device after executing the ifconfig -a command. I carried out the steps as given in the RNDIS wiki page. However, the PC failed to get an IP address. Instead, I used the same command (ifconfig usb0 IPADDR netmask 255.255.255.0 up) in the host PC with a different ip address to complete the setup. This procedure was listed in http://www.cypress.com/?docID=31404 and it works. I was able to ping from the host PC to the gadget successfully.
In a linux host PC, the -ifconfig command listed this usb0 device with the configured IP address and even lsusb listed this device as a RNDIS device.
In a Windows 8 host PC, the drivers were installed automatically and I could see the device listed as a Network Adapter in Device Manager.
However, all this works only if the port is set to MUSB_PERIPHERAL and not MUSB_OTG.

Now I am interested in knowing how to transfer data between my board and the host PC in both a Linux and a Windows environment. Could you please help me with this?
Also, could you throw some light on how I can transfer real time data (say, output from a transducer) from the board to the PC using this configuration?

Thank You

RE: USB-OTG as a peripheral and a host - Added by Jonathan Cormier almost 11 years ago

The connection setup can be treated like any normal network connection.

You can use ssh to transfer files to and from the board. Or you can setup an nfs mount.

For transferring real-time data, you will likely have to create a custom application on either end to send and receive the data. Unless your storing your real time data into files
then you could use nfs.

RE: USB-OTG as a peripheral and a host - Added by Preejith S P almost 11 years ago

Thank You Jonathan.
I will try them out.

RE: USB-OTG as a peripheral and a host - Added by Preejith S P almost 11 years ago

Hello,

I have used RNDIS and have been able to transfer data.
However, I would also like to know how to use either the USB host port or the OTG port to transfer data without setting up RNDIS.
I am trying to send data from my board to an Android phone. This data will just be displayed in a graph.
Can you tell me how I go about this without using RNDIS?

Thank You

RE: USB-OTG as a peripheral and a host - Added by Jonathan Cormier almost 11 years ago

Unfortunately I don't have any experience with interfacing with Android phones. If your Android phone supports rndis this may be the best way to go.

RE: USB-OTG as a peripheral and a host - Added by Michael Williamson almost 11 years ago

Probably the best solution would be to load in the USB OTG file storage gadget. This will make the L138 look like a thumb drive.

This link talks about it a bit (for AM335X, but is generally a "linux" thing and should work with L138).

http://processors.wiki.ti.com/index.php/USB_File_Storage_Gadget

Basically, when you compile and load in the g_file_storage.ko you can tell it to share a file system with the host.

CL doesn't have a lot of experience doing this, but if you google you should probably be able to find further examples.

-Mike

RE: USB-OTG as a peripheral and a host - Added by Preejith S P almost 11 years ago

Hello Jonathan and Mike,

Thank you for your quick replies.

@Mike
Thank you for your suggestion. I could use it as a file system, but I am interested in transmitting data in real time continuously. In such cases, I will not be able to write to and then read from a file. So is there any other alternative suggestion that you can give me?

Thanks in advance

    (1-11/11)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)