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.


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 */
      .driver_info = RSVD(4) },
      .driver_info = RSVD(4) },
      .driver_info = RSVD(4) },
      .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 

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


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. /etc/ppp/peers/quectel-chat-connect


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


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)
     -- got it
    send (ATE0^M)
    expect (OK)
     -- got it
    send (ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2^M)
    expect (OK)
    Revision: EC20CEFDR02A09M4G^M
    SubEdition: V04^M
    +CSQ: 14,99^M
    +COPS: 0^M
    +CGREG: 0,0^M
     -- got it
    send (AT+CGDCONT=1,"IP","3gnet",,0,0^M)
    expect (OK)
     -- got it
    send (ATD*99#^M)
    expect (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> <ms-dns1> <ms-dns2>]
    rcvd [IPCP ConfReq id=0x0]
    sent [IPCP ConfNak id=0x0 <addr>]
    rcvd [IPCP ConfNak id=0x1 <addr> <ms-dns1> <ms-dns2>]
    sent [IPCP ConfReq id=0x2 <addr> <ms-dns1> <ms-dns2>]
    rcvd [IPCP ConfReq id=0x1]
    sent [IPCP ConfAck id=0x1]
    rcvd [IPCP ConfAck id=0x2 <addr> <ms-dns1> <ms-dns2>]
    Could not determine remote IP address: defaulting to
    local  IP address
    remote IP address
    primary   DNS address
    secondary DNS address 218.2.2.

Products Store Community Wiki Download About TB

To Top