18
SIMCom_3G_Linux_Driver_Applica tion Note_V1.00

 · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Embed Size (px)

Citation preview

Page 1:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

SIMCom_3G_Linux_Driver_Application Note_V1.00

Page 2:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

2

Document Title: SIMCom_3G_Linux_Driver_Application Note

Version: 1.00

Date: 2013-12-25

Status: Release

Document Control ID: SIMCom_3G_Linux_Driver_Application Note_V1.00

General NotesSIMCom offers this information as a service to its customers, to support application andengineering efforts that use the products designed by SIMCom. The information provided is basedupon requirements specifically provided to SIMCom by the customers. SIMCom has notundertaken any independent search for additional relevant information, including any informationthat may be in the customer’s possession. Furthermore, system validation of this product designedby SIMCom within a larger electronic system remains the responsibility of the customer or thecustomer’s system integrator. All specifications supplied herein are subject to change.

CopyrightThis document contains proprietary technical information which is the property of SIMComLimited., copying of this document and giving it to others and the using or communication of thecontents thereof, are forbidden without express authority. Offenders are liable to the payment ofdamages. All rights reserved in the event of grant of a patent or the registration of a utility modelor design. All specification supplied herein are subject to change without notice at any time.

Copyright © Shanghai SIMCom Wireless Solutions Ltd. 2013

Page 3:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

3

Contents

1 Introduction............................................................................................................................... 5

2 Driver issued by Linux kernel..................................................................................................62.1 Modify the driver............................................................................................................ 6

2.1.1 Support system suspend/resume......................................................................... 62.1.2 Support low power mode....................................................................................72.1.3 Add short packet flag.......................................................................................... 8

2.2 Build the driver............................................................................................................... 92.3 Use the driver................................................................................................................ 13

2.3.1 Install the driver (driver as module only)......................................................... 132.3.2 Use the driver....................................................................................................132.3.3 Remove the driver.............................................................................................16

Appendix.......................................................................................................................................... 17A Related Documents...........................................................................................................17B Terms and Abbreviations..................................................................................................17

Page 4:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

4

Version History

Date Version Description of change Author

2013-12-25 V1.00 New version Aaron

Scope

This document presents a brief description about how to use SIMCOM 3G modules on OS Linux.This document can apply to SIMCom 3G modules, includingSIM5218/SIM5215/SIM5216/SIM5320/SIM5310/SIM6320/SIM6216 series modules.

Page 5:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

5

1 Introduction

This document is a brief description on:1. How to modify, build and use the driver on Linux issued by Linux kernel in order to useSIMCom 3G modules.

Page 6:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

6

2 Driver issued by Linux kernel

In fact the kernel with version of 2.6.20 and later has a common driver named usbserialwhich can be used by SIMCom device.

Succeeding sections will use the kernel code of 2.6.35 as an example to depict how to modify,build and use kernel driver for SIMCom device in fail detail.

2.1 Modify the driver

One needs to add the vendor ID and product ID of SIMCom to kernel driver in order tosupport SIMCom device.

drivers\usb\serial\option.c:.

2.1.1 Support system suspend/resume

Add .reset_resume call-back function if kernel support, for some USB HOST controller issuea bus reset to USB devices when system resume, USB port will be unloaded, and loaded later, thereset_resume call-back function will avoid the port unloading when system resume, for moredetail please refer to kernel USB driver documents.

Page 7:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

7

2.1.2 Support low power mode

For kernel 2.6.36, add the follow highlight code to end of option_probe function:

For kernel 2.6.38, add the follow highlight code to end of option_probe function:

Page 8:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

8

2.1.3 Add short packet flag

Since the max packet size of BULK endpoint on SIMCOM module in High USB speed is512 bytes, in Full USB speed is 64 bytes, in addition the USB protocol says:

So one needs to send an zero-length packet additional if one wants to transmit the data streamwith length exactly multiple of wMaxPacketSize.

Fortunately one needs not to send a zero packet manually; one only needs to modify a littledriver code:

drivers\usb\serial\usb_wwan.c:

NOTE: This modification is only for the driver option.ko

Page 9:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

9

2.2 Build the driver

One needs to setup the kernel development environment first which include kernel sourcecode and cross compiler environment.

Following is a step-by-step instruction on how to build the driver into kernel.1) Use “sudo make menuconfig” to configure the kernel.

2) Enter into menu “Device Drivers”

3) Continue enter into menu “USB support”

Page 10:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

10

4) Continue enter into menu “USB Serial Converter support”

5) Type “y” to select menu “USB driver for GSM and CDMAmodems”, of course one can type“m” to compile the driver as a module.

Page 11:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

11

6) Some other options need to be configured, so please enter into menu “Device Drivers ->Generic Driver Options”

7) Type “y” to select the following two options.

Page 12:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

12

8) Exit and save the configuration.

After configuration, these items will be configured:CONFIG_USB = yCONFIG_USB_SERIAL=yCONFIG_USB_SERIAL_OPTION=y

Page 13:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

13

CONFIG_DEVTMPFS=yCONFIG_DEVTMPFS_MOUNT=y

1) Use “sudo make” to compile the kernel or use “sudo make modules” to compile the driver asa module

2.3 Use the driver

As you move through this chapter new kernel firmware or new driver: option.ko(compiled asmodule) is ready.

2.3.1 Install the driver (driver as module only)

If one compiles the driver as a module one needs to install it first.One can use the following command to install the driver:

modprobe option.koThis command will install all the needed drivers.

If all right the driver will be installed to the system, one can use the following command toquery the result:

lsmod |grep option

Note: this installation procedure is invalid when rebooting the system, so if one wants to installthe driver automatically when starting the system, one should better put the installationinstruction to the startup script.

2.3.2 Use the driver

After the driver installed one can use SIMCom device via the driver, now plug the SIMCom

Page 14:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

14

device to the host device via USB connector, and if the device is identified by the driver, 5 devicefiles named ttyUSB0, ttyUSB1, ttyUSB2, ttyUSB3 and ttyUSB4 will be created in directory /dev

The relationship between the device files and SIMCom composite device is like this:Device file SIMCom composite devicettyUSB0 DIAG interfacettyUSB1 NMEA interfacettyUSB2 ATCOM interfacettyUSB3 MODEM interfacettyUSB4 Wireless Ethernet Adapter interface

SIMCom device is plugged in:

Device files are created:

NOTE:1. In some composite devices of SIMCom not all of the interfaces are existed, so the relationshipis dynamic.2. Only the NMEA, ATCOM and MODEM interface can be worked correctly with this driver.

If one gets the device files ready one can use tools such as minicom, wvdial etc to use thedevice。

Page 15:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

15

ATCOM interface

NMEA interface

Page 16:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

16

2.3.3 Remove the driver

One can use the following command to uninstall the driver:rmmod option

After the command executed one can use “lsmod |grep option” to check if the driver has beenremoved successfully.

Note: when removing the driver one must disconnect the device and close all the tools usingthe device first.

Page 17:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

17

Appendix

A Related Documents

SN Document name Remark

[1] SIMCOM_SIM5320_ATC_EN_V2.01.doc

B Terms andAbbreviations

Abbreviation Description

USB Universal Serial Bus

Page 18:  · 5 $ & 5 6 ' && !!< 6 & ' % * $ ') 6 & '% 2 % L Author: cheng.shi Created Date: 2/3/2015 5:26:34 PM

Smart Machine Smart Decision

SIMCom_3G_Linux_Driver_Application Note _V1.00 2013-12-25

18

Contact us:Shanghai SIMComWireless Solutions Co.,Ltd.Address: Building A, SIM Technology Building, No. 633, Jinzhong Road, Shanghai,P. R. China 200335Tel: +86 21 3252 3300Fax: +86 21 3252 2030URL: www.sim.com/wm