Skip to content

Instantly share code, notes, and snippets.

@wicadmin
Last active December 25, 2018 19:31
Show Gist options
  • Save wicadmin/92568fe855ccad93a9e2c794cfd0f38e to your computer and use it in GitHub Desktop.
Save wicadmin/92568fe855ccad93a9e2c794cfd0f38e to your computer and use it in GitHub Desktop.
OpenWRT Gobinet Sierra 7455 Modem
https://forum.sierrawireless.com/t/compiling-gobi-drivers-under-rhel-6-9-x86-64/12414
https://blog.csdn.net/qq_22340085/article/details/51828854

Openwrt add USB NIC driver (SIERRA)

I got a 7455 LTE module from SIERRA and the corresponding DEVKIT. The DEVKIT interface is USB3.0. I can connect my other openwrt development board through USB3.0, and then openwrt development board loads the corresponding driver, virtual network card and serial port. The function of the USB network card, not much nonsense, the following are the steps to add:

Go to the Sierra website to find the 7455USB driver and download it at the following address: Imgur Imgur

Add a USB NIC driver:

  1. Create a gobinet directory under package/kernel, enter the gobinet directory, and create the Makefile and src directories. The contents of the Makefile are as follows:
# Copyright (C) 2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=gobinet
PKG_RELEASE:=1

include $(INCLUDE_DIR)/package.mk

define KernelPackage/gobinet
  SUBMENU:=Other modules
  TITLE:=gobinet for sierra
  DEPENDS:=+kmod-usb-core kmod-usb-net    //Remember to add dependencies
  FILES:=$(PKG_BUILD_DIR)/gobinet.ko
  KCONFIG:=
  AUTOLOAD:=$(call AutoLoad,50,gobinet)    //Automatic loading
endef

define KernelPackage/gobinet/description
  Kernel module for Sierra USB
endef

EXTRA_KCONFIG:= \
        CONFIG_GOBINET=m                

EXTRA_CFLAGS:= \
        $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
        $(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \

MAKE_OPTS:= \
        ARCH="$(LINUX_KARCH)" \
        CROSS_COMPILE="$(TARGET_CROSS)" \
        SUBDIRS="$(PKG_BUILD_DIR)" \
        EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
        $(EXTRA_KCONFIG)

define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
        $(MAKE) -C "$(LINUX_DIR)" \
                $(MAKE_OPTS) \
                modules
endef

$(eval $(call KernelPackage,gobinet))

  1. Enter the src directory, copy the source code GobiNet downloaded from the official website to the src directory, modify the contents of the Makefile as follows:
obj-${CONFIG_GOBINET}   += gobinet.o
gobinet-objs := GobiUSBNet.o QMIDevice.o QMI.o usbnet_2_6_32.o usbnet_3_0_6.o \
                    usbnet_2_6_35.o usbnet_3_10_21.o usbnet_3_12_xx.o usbnet_4_4_xx.o

Create a Kconfig file with the following contents:

config SIERRA-NET
        tristate "net for sierra USB"

Add USB serial port driver:

Add steps similar to NIC drivers, note that the Makefile dependency is changed to:

DEPENDS:=+kmod-usb-core kmod-usb-serial //Remember to add dependencies

  1. Return to the main directory, make menuconfig, choose the following:

Imgur

After saving make, you can find gobinet.ko and in the ./build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7621/gobinet/ipkg-ramips_24kec/kmod-gobinet/lib/modules/3.10.14/ directory. Gobiserial.ko driver file, copy the file to the development board, after the insmod work, after the 7455 module and the development board are successfully connected through usb3.0, dmesg can see:

Imgur

The representative was successfully mounted.

Then you can go through the webpage:

Imgur

See two more NICs, add the appropriate interface to use.

1. To compile a nids driver for the openwrt system, the source code is provided by the hardware vendor.

First compile under ubuntun to see if the compilation is normal, if there is an error, and the error is fixed.

Compilation in OpenWrt environment

  1. Enter the build directory of openwrt, which is the configuration of make menuconfig.
Under ./package/kernel/
mkdir gobinet 
touch gobinet/Makefile 
mkdir gobinet/src 

Copy the source code and related header files needed for compilation to gobinet/src

cd gobinet/src 
touch Makefile

Edit Makefile

obj-m := gobinet.o
gobinet-objs := GobiUSBNet.o QMIDevice.o QMI.o

Where gobinet.o is the name of the desired gobinet.ko GobiUSBNet.o QMIDevice.o QMI.o is the source file needed to generate gobinet

The Makefile provided by the hardware vendor is

obj-m := GobiNet.o
GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o
EXTRA_CFLAGS := -DSIMCOM_NETWORK_MANAGER
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
OUTPUTDIR=/lib/modules/`uname -r`/kernel/drivers/net/usb/

all: clean
  $(MAKE) -C $(KDIR) M=$(PWD) modules

install: all
  mkdir -p $(OUTPUTDIR)
  cp -f GobiNet.ko $(OUTPUTDIR)
  depmod

clean:
  rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions Module.* modules.order

cd .. Go to package/kernel/gobinet, edit the Makefile in this directory

      include $(TOPDIR)/rules.mk          #Must contain
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=gobinet                  #Package name, displayed in menuconfig
PKG_RELEASE:=2                     #version number

include $(INCLUDE_DIR)/package.mk

define KernelPackage/gobinet
  SUBMENU:=Other modules          #Subdirectory          
  TITLE:= GobiNet device          #Package description
  DEPENDS:=+kmod-usb-core         #The ko file that must be relied upon to compile this ko file must be added correctly
                                  #Plus, or not
  FILES:=$(PKG_BUILD_DIR)/gobinet.ko  #Generate file
  KCONFIG:=
endef

define KernelPackage/gobinet/description
 Kernel module for register a custom gobinet platform device.
endef

EXTRA_CFLAGS := -DSIMCOM_NETWORK_MANAGER   #Compile depend on the options, from the original    
                                            #In the Makefile, there must be

MAKE_OPTS:= \                            #fixed format
    ARCH="$(LINUX_KARCH)" \
    CROSS_COMPILE="$(TARGET_CROSS)" \
    SUBDIRS="$(PKG_BUILD_DIR)" \
    EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
    $(EXTRA_KCONFIG)

define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
    $(MAKE) -C "$(LINUX_DIR)" \
        $(MAKE_OPTS) \
        modules
endef

$(eval $(call KernelPackage,gobinet))

If an error occurs during compilation, you can check if EXTRA_CFLAGS is added correctly. appear Package kmod-gobinet is missing dependencies for the following libraries: usbcore.ko Module dependency problem You can check whether make menuconfig selects the relevant module and the configuration of the DEPENDS option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment