Difference between revisions of "USB Gadget"

From ArmadeusWiki
Jump to: navigation, search
(No difference)

Revision as of 13:22, 19 September 2006

Instructions to use the USB port of your Armadeus board to communicate with your PC


You can connect your Armadeus board to a PC using its USB port and it can be enumerated as many USB devices (depending on the type of communication way you want to use):

  • serial device
  • net device
  • mass storage device


when you build your kernel image, then modify your configuration:

[user@toto]$ make xconfig

in Device Drivers->USB support->USB Gadget Support, choose Support for USB Gadgets and activate all USB Gadget Drivers Save your configuration and then rebuild your kernel image:

[user@toto]$ make

now you should have following drivers in your kernel source tree:

drivers/usb/gadget/gadgetfs.ko        For test
drivers/usb/gadget/g_ether.ko         Ethernet emulation on USB
drivers/usb/gadget/g_file_storage.ko  Mass storage
drivers/usb/gadget/g_serial.ko        Serial emulation on USB
drivers/usb/gadget/g_zero.ko          For test
drivers/usb/gadget/imx_udc.ko         i.MX USB device Core Controller 

Copy imx_udc.ko, g_file_storage.ko & g_serial.ko to your target root filessytem in /lib/modules/


First, load the core controller driver on your board:

# insmod /lib/modules/imx_udc.ko

To emulate a mass storage device:

  • create or get a "backing storage file", for example: [[1]]
  • copy this file (uncompressed) in the /tmp directory of your rootfs (see NetworkConfig if necessary)
  • load g_file_storage module:
# insmod /lib/modules/g_file_storage.ko file=/tmp/backing_file
  • connect target's USB cable to your PC and,

On Linux:

  • as root, launch dmesg and find the /dev/sdaX device assigned to your board
  • then mount the device and enjoy file sharing:
[root@toto]# mount /dev/sda1 /mnt/tmp
[root@toto]# cd /mnt/tmp
[root@toto]# showimage /mnt/tmp/test.jpg

To emulate a serial port:

# mknod /dev/ttygserial c 127 0   (only needed the first time you want to use it, if not already existing)
# insmod /lib/modules/g_serial.ko