Toybrick EN

中文 / EN
Toybrick EN Wiki TB-RK3399ProD How to support a new PCI-E device
How to support a new PCI-E device

Of course you need to write a new driver for a device whic is not supported in kernel, it can be complex.

We use Quectel EC20 4G module as example here, which is quite simple using the USB serial port interface to communicate with userspace application and application can use Hayes command set to control this modem.

Driver

The PCI-E USB hub has already been supported at kernel, so you don't need to worry about that part. And there is already a driver for its USB serial protocol. We just modify the simple drive to support this new product.

  1. drivers/usb/serial/option.c
     
    /* Quectel products using Quectel vendor ID */
    { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21),
      .driver_info = RSVD(4) },
    { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC25),
      .driver_info = RSVD(4) },
    { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_BG96),
      .driver_info = RSVD(4) },
    { USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EP06),
      .driver_info = RSVD(4) | RSVD(5) },

How to verify

After the kernel is proper built and boot, you would fine the following node at /dev directory:

  1. /dev/ttyUSB0 
    /dev/ttyUSB1 
    /dev/ttyUSB2
    /dev/ttyUSB3

The AT port for EC20 would be /dev/ttyUSB2 here, you can use the following commend to confirm

  1. #cat /dev/ttyUSB2 &
    #echo -e “AT\r\n” > /dev/ttyUSB2
    #AT

Dial-up


We need to proper a number of files for pppd or it won't know how to dial up this device. We offer some sample files here.

  1. /etc/ppp/peers/quectel-ppp

1.png

  1. /etc/ppp/peers/quectel-chat-connect

1.png

  1. /etc/ppp/peers/quectel-chat-disconnect

1.png

Then we can start pppd to verfiy whether it work

  1. # pppd call quectel-ppp &

You may get a log from the pppd, we know we get an access to Internet here

  1. pppd options in effect:
    debug           # (from /etc/ppp/peers/quectel-ppp)
    nodetach                # (from /etc/ppp/peers/quectel-ppp)
    dump            # (from /etc/ppp/peers/quectel-ppp)
    noauth          # (from /etc/ppp/peers/quectel-ppp)
    user test               # (from /etc/ppp/peers/quectel-ppp)
    password ??????         # (from /etc/ppp/peers/quectel-ppp)
    remotename 3gppp                # (from /etc/ppp/peers/quectel-ppp)
    /dev/ttyUSB3            # (from /etc/ppp/peers/quectel-ppp)
    115200          # (from /etc/ppp/peers/quectel-ppp)
    lock            # (from /etc/ppp/peers/quectel-ppp)
    connect chat ---/etc/ppp/peers/quectel-chat-connect               # (from /etc/ppp/peers/quectel-ppp)
    disconnect chat ---/etc/ppp/peers/quectel-chat-disconnect         # (from /etc/ppp/peers/quectel-ppp)
    nocrtscts               # (from /etc/ppp/peers/quectel-ppp)
    modem           # (from /etc/ppp/peers/quectel-ppp)
    hide-password           # (from /etc/ppp/peers/quectel-ppp)
    novj            # (from /etc/ppp/peers/quectel-ppp)
    novjccomp               # (from /etc/ppp/peers/quectel-ppp)
    ipcp-accept-local               # (from /etc/ppp/peers/quectel-ppp)
    ipcp-accept-remote              # (from /etc/ppp/peers/quectel-ppp)
    ipparam 3gppp           # (from /etc/ppp/peers/quectel-ppp)
    noipdefault             # (from /etc/ppp/peers/quectel-ppp)
    ipcp-max-failure 30             # (from /etc/ppp/peers/quectel-ppp)
    defaultroute            # (from /etc/ppp/peers/quectel-ppp)
    usepeerdns              # (from /etc/ppp/peers/quectel-ppp)
    noccp           # (from /etc/ppp/peers/quectel-ppp)
    abort on (BUSY)
    abort on (NO CARRIER)
    abort on (NO DIALTONE)
    abort on (ERROR)
    abort on (NO ANSWER)
    timeout set to 30 seconds
    send (AT^M)
    expect (OK)
    AT^M^M
    OK
     -- got it
     
    send (ATE0^M)
    expect (OK)
    ^M
    ATE0^M^M
    OK
     -- got it
     
    send (ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2^M)
    expect (OK)
    ^M
    ^M
    Quectel^M
    EC20F^M
    Revision: EC20CEFDR02A09M4G^M
    ^M
    SubEdition: V04^M
    ^M
    +CSQ: 14,99^M
    ^M
    +CPIN: READY^M
    ^M
    +COPS: 0^M
    ^M
    +CGREG: 0,0^M
    ^M
    OK
     -- got it
     
    send (AT+CGDCONT=1,"IP","3gnet",,0,0^M)
    expect (OK)
    ^M
    ^M
    OK
     -- got it
     
    send (ATD*99#^M)
    expect (CONNECT)
    ^M
    ^M
    CONNECT
     -- got it
     
    Script chat ---/etc/ppp/peers/quectel-chat-connect finished (pid 785), status = 0x0
    Serial connection established.
    using channel 1
    Using interface ppp0
    Connect: ppp0 <--> /dev/ttyUSB3
    sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x1f2b413> <pcomp> <accomp>]
    rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0xd11eadc2> <pcomp> <accomp>]
    sent [LCP ConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0xd11eadc2> <pcomp> <accomp>]
    rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x1f2b413> <pcomp> <accomp>]
    rcvd [LCP DiscReq id=0x1 magic=0xd11eadc2]
    rcvd [CHAP Challenge id=0x1 <40aedf97298706e7675d614c0cea9175>, name = "UMTS_CHAP_SRVR"]
    sent [CHAP Response id=0x1 <1bf312e7aa43615e474c49c28fbbaca5>, name = "test"]
    rcvd [CHAP Success id=0x1 ""]
    CHAP authentication succeeded
    CHAP authentication succeeded
    sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns2 0.0.0.0>]
    rcvd [IPCP ConfReq id=0x0]
    sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
    rcvd [IPCP ConfNak id=0x1 <addr 10.35.149.45> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
    sent [IPCP ConfReq id=0x2 <addr 10.35.149.45> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
    rcvd [IPCP ConfReq id=0x1]
    sent [IPCP ConfAck id=0x1]
    rcvd [IPCP ConfAck id=0x2 <addr 10.35.149.45> <ms-dns1 218.4.4.4> <ms-dns2 218.2.2.2>]
    Could not determine remote IP address: defaulting to 10.64.64.64
    local  IP address 10.35.149.45
    remote IP address 10.64.64.64
    primary   DNS address 218.4.4.4
    secondary DNS address 218.2.2.


Products Store Community Wiki Download About TB


To Top