CDC: Configure USB to Gadget serial device

Source: Internet
Author: User
Tags types of functions

Linux supports the connection of various USB slave devices while also supporting itself as a device into other hosts. The most typical example is the Android OS phone, which plugs into a computer that can be identified as a USB stick device.

For the SOC, this part directly corresponds to the operation of the USB device section.

To avoid confusion with the word "device driver (USB device Driver)", which is supported as a host, Linux has named this part of the implementation "Gadget" (small toy). The kernel source directory is \drivers\usb\gadget, which contains the different types of USB Device Controller (UDC)-driven implementations supported by the kernel, as well as frameworks and different gadget implementations.

Taking AT91 ARM9 as an example, the lowest driver is at91_udc.c (for a SOC that supports high-speed USB 2.0 is ATMEL_USBA_UDC.C), it implements a unified interface defined by Gadget.h, and then the various gadget on the upper level Driver (such as SERIAL.C, etc.) call this set of unified interface to implement different types of functions, such as USB serial port, u disk, USB ethernet and so on.

The Atmel USB port frame diagram:

Configure kernel configure with the following command Supportgadget serial

1 Copy kernel Configure file to the obj directory in the current directory

2 Configuring the Configure file under the obj directory

3 Save the configured configure file as a. config

4 copy. config file to the CONIFG directory of Linux kernel

Make Mtxxxx_smp_mod_dbg_defconfig arch=arm o=obj/mtxxxx_smp_mod_dbg_defconfig

Make Menuconfig arch=arm o=obj/mtxxxx_smp_mod_dbg_defconfig

CP Obj/mtxxxx_smp_mod_dbg_defconfig/.config Arch/arm/configs/mtxxxx_smp_mod_dbg_defconfig

You need to select when configuring configure

Device Drivers--->

USB Support--->

USB Gadget Support--->

USB Gadget Drivers (Serial Gadget (with CDC Acmand CDC OBEX Support))--->

The final configure file needs to contain the following:

Config_usb_mtk_musb=y

Config_usb_mtk_musb_peripheral=y

Config_usb_gadget=y

Config_usb_libcomposite=y

Config_usb_f_acm=y

Config_usb_u_serial=y

Config_usb_f_serial=y

Config_usb_g_serial=y

Conifg_configs_fs=y

After USB is configured with device mode, the PC detects the gadget serial device via USB calbe access to the PC. The corresponding driver can be obtained from Linux open source.

The platform can see the correct data output by cat/dev/ttygs0 on the platform side and writing the data in the PC-side string.

(Please confirm driver boundrate/primary and secondary device number setting, primary and secondary device number can be specified in U_SERIAL.C gserial_setup () function gs_tty_driver->major = 0x000 c_ispeed = 9600, etc.; )

To use the Windows acmdriver you must has the "Linux-cdc-acm.inf" file (Driver is opensource, get it from the link) whic H supports all recent versions of Windows.

http://lxr.free-electrons.com/source/Documentation/usb/

After you install driver correctly, you can see a new COM port in the ports (COM & LPT) directory through Device Manager.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.