12
N720/N720V5 USB Driver Application Note Issue 1.0 Date 2019-03-25 Neoway Product Document

USB Driver Application Note · 2020. 9. 28. · USB serial driver might be loaded to RNDIS/RMNET/ECM NIC port. The host enumerates NIC card port as ttyUSB devices, resulting in failure

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

  • N720/N720V5

    USB Driver Application Note

    Issue 1.0

    Date 2019-03-25

    Neoway Product Document

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd i

    Copyright © Neoway Technology Co., Ltd 2019. All rights reserved.

    No part of this document may be reproduced or transmitted in any form or by any means without prior written

    consent of Neoway Technology Co., Ltd.

    is the trademark of Neoway Technology Co., Ltd.

    All other trademarks and trade names mentioned in this document are the property of their respective

    holders.

    Notice

    This document provides guide for users to use N720/N720V5.

    This document is intended for system engineers (SEs), development engineers, and test engineers.

    THIS GUIDE PROVIDES INSTRUCTIONS FOR CUSTOMERS TO DESIGN THEIR APPLICATIONS.

    PLEASE FOLLOW THE RULES AND PARAMETERS IN THIS GUIDE TO DESIGN AND COMMISSION.

    NEOWAY WILL NOT TAKE ANY RESPONSIBILITY OF BODILY HURT OR ASSET LOSS CAUSED BY

    IMPROPER OPERATIONS.

    THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE DUE TO

    PRODUCT VERSION UPDATE OR OTHER REASONS.

    EVERY EFFORT HAS BEEN MADE IN PREPARATION OF THIS DOCUMENT TO ENSURE ACCURACY

    OF THE CONTENTS, BUT ALL STATEMENTS, INFORMATION, AND RECOMMENDATIONS IN THIS

    DOCUMENT DO NOT CONSTITUTE A WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.

    Neoway provides customers complete technical support. If you have any question, please contact your

    account manager or email to the following email addresses:

    [email protected]

    [email protected]

    Website: http://www.neoway.com

    http://www.neoway.com/

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd ii

    Contents

    1 Port Configurations .................................................................................... 1

    2 Linux USB Driver ....................................................................................... 2 2.1 USB Serial Driver ......................................................................................................................... 2

    2.1.1 Modifying Source Code ....................................................................................................... 2

    2.1.2 Modifying Kernel .................................................................................................................. 4

    2.2 CDC ACM Driver .......................................................................................................................... 4

    2.2.1 Modifying Source Code ....................................................................................................... 4

    2.2.2 Modifying Kernel .................................................................................................................. 5

    3 Test ............................................................................................................ 6

    4 FAQ ........................................................................................................... 7 4.1 ttyUSB is not generated ............................................................................................................... 7

    4.2 Failed to dial up to network access .............................................................................................. 8

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd iii

    About This Document

    Scope

    This document is applicable to N720/N720V5.

    Audience

    This document is intended for system engineers (SEs), development engineers, and test engineers.

    Change History

    Issue Date Change Changed By

    1.0 2019-02 Initial draft Tina

    Conventions

    Symbol Indication

    This warning symbol means danger. You are in a situation that could cause fatal

    device damage or even bodily damage.

    Means reader be careful. In this situation, you might perform an action that

    could result in module or product damages.

    Means note or tips for readers to use the module

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 1

    1 Port Configurations

    Table 1-1 Port configurations

    Model VID/PID Driver Device Port Function

    N720V5 0x2949/0x8700 CDC ACM

    usb0 RNDIS NIC card port

    ttyACM0 Diagnostic port

    ttyACM1 AT port

    ttyACM2 Private data service port

    N720 0x2949/0x8247 USB Serial

    ttyUSB0 Private data service port

    ttyUSB1 GPS

    ttyUSB2 AT port

    ttyUSB3 Diagnostic port

    RMNET RMNET NIC card

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 2

    2 Linux USB Driver

    Figure 2-1 USB driver architecture

    On the host, USB driver consists of USB host controller hardware at the bottom, USB host controller

    driver, USB core, and the USB device driver on the top. Driver modules for 4G devices include USB

    ACM, Option, etc.

    For N720 V5, configure ACM driver in cdc-acm.c.

    For N720, configure Option driver in option.c.

    On the device, USB driver consists of UDC driver program, Gadget Function API and Gadget Function

    driver program.

    2.1 USB Serial Driver

    To configure USB serial driver for N720, follow process below.

    2.1.1 Modifying Source Code

    1. Add the VID/PID of the module.

    Open the drivers/usb/serial/option.c file and add VID and PID to the option_ids[] data set.

    The following code is added:

    USB Device Driver Mass storage/CDC/HID

    USB core

    USB host control driver

    HOCI/EHCI/UHCI

    USB host control Device Controller

    UDC driver

    (omap/pxa2xx…)

    Gadget Function API

    Gadget Driver

    (mass storage/serial…)

    USB bus

    Host Device

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 3

    static const struct usb_device_id option_ids[] = {

    { USB_DEVICE(0x2949, 0x8247)}, /**Neoway N720**/

    { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },

    { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },

    { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },

    2. Filter out ports.

    USB serial driver might be loaded to RNDIS/RMNET/ECM NIC port. The host enumerates NIC

    card port as ttyUSB devices, resulting in failure to dial up to network access. Therefore, filtering

    out NIC port is necessary.

    Filter out NIC ports based on kernel versions.

    Kernel version later than Linux-3.8

    Modify kernel/drivers/usb/serial/option.c

    static const struct option_blacklist_info telit_le920_blacklist = {

    .reserved = BIT(1) | BIT(5),

    };

    /**begin added by Neoway**/

    static const struct option_blacklist_info neoway_n720_8247_blacklist = {

    .reserved = BIT(4),

    };

    /**end added by Neoway**/

    static const struct usb_device_id option_ids[] = {

    /**begin added by Neoway**/

    { USB_DEVICE(0x2949,0x8247),

    .driver_info = (kernel_ulong_t)&neoway_n720_8247_blacklist},

    /**end added by Neoway**/

    Kernel version earlier than Linux-3.8

    Modify kernel/drivers/usb/serial/option.c

    #define SAMSUNG_VENDOR_ID 0x04e8

    /**begin added by Neoway**/

    #define NEOWAY_VENDOR_ID 0x2949

    #define NEOWAY_PRODUCT_8247 0x8247

    /**end added by Neoway**/

    #define SAMSUNG_PRODUCT_GT_B3730 0x6889

    static int option_probe(struct usb_serial *serial,const struct usb_device_id *id){

    /**begin added by Neoway**/

    if (dev_desc->idVendor == cpu_to_le16(NEOWAY_VENDOR_ID) &&

    dev_desc->idProduct == cpu_to_le16(NEOWAY_PRODUCT_8241) &&

    iface_desc->bInterfaceClass != 0&&

    iface_desc->bInterfaceClass != 6)

    return -ENODEV;

    if (dev_desc->idVendor == cpu_to_le16(NEOWAY_VENDOR_ID) &&

    dev_desc->idProduct == cpu_to_le16(NEOWAY_PRODUCT_8242) &&

    iface_desc->bInterfaceClass != 0)

    return -ENODEV;

    if (dev_desc->idVendor == cpu_to_le16(NEOWAY_VENDOR_ID) &&

    dev_desc->idProduct == cpu_to_le16(NEOWAY_PRODUCT_8243) &&

    iface_desc->bInterfaceClass != 0)

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 4

    return -ENODEV;

    if (dev_desc->idVendor == cpu_to_le16(NEOWAY_VENDOR_ID) &&

    dev_desc->idProduct == cpu_to_le16(NEOWAY_PRODUCT_8247) &&

    iface_desc->bInterfaceClass != 4)

    return -ENODEV;

    /**end added by Neoway**/

    /* Store device id so we can use it during attach. */

    usb_set_serial_data(serial, (void *)id);

    2.1.2 Modifying Kernel

    1. Navigate to the kernel directory.

    2. Execute make menuconfig.

    3. Configure kernel

    Device Drivers --->

    [*] USB support --->

    USB Serial Converter support --->

    USB driver for GSM and CDMA modems

    4. Save and recompile the kernel.

    2.2 CDC ACM Driver

    To configure CDC ACM driver for N720V5, follow process below.

    2.2.1 Modifying Source Code

    1. Add the VID/PID of the module.

    Open the /kernel/drivers/usb/class/cdc-acm.c file and add VID and PID to the acm_ids[] data

    set.

    static const struct usb_device_id acm_ids[] = {

    { USB_DEVICE(0x2949, 0x8700)}, //N720V5

    }

    2. Filter out ports.

    ACM driver might be loaded to RNDIS/RMNET/ECM NIC port. The host enumerates NIC port as

    ttyACM devices, resulting in failure to dial up to network access. Therefore, filtering out NIC port

    is necessary.

    Add the following content to the /kernel/drivers/usb/class/cdc-acm.c file.

    static void acm_tty_set_termios(struct tty_struct *tty,

    struct ktermios *termios_old);

    /*

    * Functions for ACM control messages.

    */

    #if 1 /*Added by Neoway*/

    #define true 1

    #define false 0

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 5

    #define NEOWAY_VENDOR_ID 0x2949

    #define NEOWAY_PRODUCT_N720V5 0x8700

    bool detected_neoway_product(struct usb_device *dev)

    {

    if (NULL == dev)

    return false;

    if (le16_to_cpu(dev->descriptor.idVendor) == NEOWAY_VENDOR_ID &&

    le16_to_cpu(dev->descriptor.idProduct) == NEOWAY_PRODUCT_N720V5 )

    {

    return true;

    }

    return false;

    }

    #endif

    static int acm_probe(struct usb_interface *intf,

    const struct usb_device_id *id)

    {

    struct usb_cdc_union_desc *union_header = NULL;

    ……

    int rv = -ENOMEM;

    #if 1 /*Added by Neoway*/

    struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;

    if (detected_neoway_product(usb_dev) && (desc->bInterfaceNumber == 0 ||

    desc->bInterfaceNumber == 1)) {

    dev_err(&intf->dev, "Neoway quirk, skipping interface 0x%x\n", desc->bInterfaceNumber);

    return -ENODEV;

    }

    #endif

    2.2.2 Modifying Kernel

    1. Navigate to the kernel directory.

    2. Execute make menuconfig.

    3. Configure kernel

    Device Drivers --->

    [*] USB support --->

    *** USB Device Class drivers *** --->

    USB Modem (CDC ACM) support (CONFIG_USB_ACM=y)

    4. Save and recompile the kernel.

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 6

    3 Test

    After the previous configuration, corresponding device nodes are generated in the /dev directory.

    N720

    root@root: ls /dev/ttyUSB*

    /dev/ttyUSB0 /dev/ttyUSB1 /dev/ttyUSB2 /dev/ttyUSB3

    N720V5

    root@root: ls /dev/ttyACM*

    /dev/ttyACM0 /dev/ttyACM1 /dev/ttyACM2

    Send commands to the AT or MODEM port.

    root@support:/dev# cat /dev/ttyUSB0&

    [1] 7178

    root@support:/dev# echo -en "AT\r\n" > ttyUSB0

    root@support:/dev# AT

    OK

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 7

    4 FAQ

    4.1 ttyUSB is not generated

    1. Check if the module is started and input lsusb to check if the module is identified.

    root@support:/dev# lsusb

    Bus 002 Device 002: ID 8087:8000 Intel Corp.

    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    Bus 001 Device 002: ID 8087:8008 Intel Corp.

    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

    Bus 003 Device 002: ID 2949:8247

    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

    2. Check if option driver is loaded successfully.

    Input lsmod | grep option.

    If the option driver is not loaded, check if the system contains the option module.

    − If the system does not contain the option module, port one.

    − Check if the following compilation options are enabled in the config file.

    CONFIG_USB_SERIAL=y

    CONFIG_USB_SERIAL_OPTION=y

    − The option module is not compiled into the system.

  • N720/N720V5

    USB Driver Application Note

    Copyright © Neoway Technology Co., Ltd 8

    − After the driver is added, ttyUSB* nodes are generated in the /dev directory.

    4.2 Failed to dial up to network access

    Use dmesg to capture kernel log and send it to Neoway FAE for analysis.

    About This Document1 Port Configurations2 Linux USB Driver2.1 USB Serial Driver2.1.1 Modifying Source Code1. Add the VID/PID of the module.2. Filter out ports.

    2.1.2 Modifying Kernel1. Navigate to the kernel directory.2. Execute make menuconfig.3. Configure kernel4. Save and recompile the kernel.

    2.2 CDC ACM Driver2.2.1 Modifying Source Code1. Add the VID/PID of the module.2. Filter out ports.

    2.2.2 Modifying Kernel1. Navigate to the kernel directory.2. Execute make menuconfig.3. Configure kernel4. Save and recompile the kernel.

    3 Test4 FAQ4.1 ttyUSB is not generated1. Check if the module is started and input lsusb to check if the module is identified.2. Check if option driver is loaded successfully.

    4.2 Failed to dial up to network access