OpenWrt Forum Archive

Topic: Compiling GobiSerial 3000 for Mipsel (MT7620)

The content of this topic has been archived on 30 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi guys...,
I am trying to compile the kernel module for the GobiSerial 3000 in order to use a Simcom 7100E module on  my OpenWrt router.

The router is based on MT7620 board. Although I can find instructions on how to cross compile packages, I cannot compile the module using the cross compiler toolchain for my board. The Makefile is really simple:

obj-m := GobiSerial.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

all: clean
    $(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
    rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions Module.* modules.order

but it fails on the cross compiler. I believe it is because the KDIR variable this way points to my host machine folder.
Can someone please point me how to resolve this?

In order to compile a kernel module for OpenWrt, you will need to create a specific OpenWrt Makefile.

See here https://wiki.openwrt.org/doc/devel/pack … el_modules

Typically, KDIR would be added to the MAKE_VAR or MAKE_OPTS variable in the Makefile which will then pass it through to the module makefile. If you have a look at any package in the OpenWrt source tree that has the name kmod-<name> you will see an example of how to do this.

Below is an example of a Makefile I created for the rtl8812au USB wifi dongle. In this Makefile, KSRC is the equivalent of your KDIR variable.

#
# Copyright (C) 2013-2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=rtl8812au
PKG_VERSION:=2016-09-23
PKG_RELEASE:=$(PKG_SOURCE_VERSION)

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/diederikdehaas/rtl8812AU.git
PKG_SOURCE_VERSION:=5a81815a672e51b0d0d205f5f37903805235f005
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MAINTAINER:=DL <dl12345@github.com>
PKG_LICENSE:=GPLv2


include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk

USER_EXTRA_CFLAGS = -DBACKPORT

ifneq ($(LINUX_KARCH), x86)
USER_EXTRA_CFLAGS += -DCONFIG_MINIMAL_MEMORY_USAGE 
endif

#
# Debugging trace flags
#
# USER_EXTRA_CFLAGS += -DCONFIG_DEBUG
# USER_EXTRA_CFLAGS += -DCONFIG_DEBUG_RTL871X
# USER_EXTRA_CFLAGS += -DCONFIG_DEBUG_CFG80211
# USER_EXTRA_CFLAGS += -DCONFIG_PROC_DEBUG
# USER_EXTRA_CFLAGS += -DDBG_MEM_ALLOC

MAKE_FEATURES:= \
    CONFIG_POWER_SAVING="n"

NOSTDINC_FLAGS = \
    -I$(STAGING_DIR)/usr/include/mac80211 \
    -I$(STAGING_DIR)/usr/include/mac80211/uapi \
    -I$(STAGING_DIR)/usr/include/mac80211-backport \
    -include backport/backport.h 

MAKE_OPTS:= \
    ARCH="$(LINUX_KARCH)" \
    CROSS_COMPILE="$(KERNEL_CROSS)" \
    KSRC="$(LINUX_DIR)" \
    KVER="$(LINUX_VERSION)" \
    M="$(PKG_BUILD_DIR)" \
    MODULE_NAME="8812au" \
    USER_EXTRA_CFLAGS="$(USER_EXTRA_CFLAGS)" \
    NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
    KBUILD_EXTRA_SYMBOLS="${STAGING_DIR}/usr/include/mac80211/Module.symvers" \
    $(MAKE_FEATURES)



define KernelPackage/$(PKG_NAME)
  SUBMENU:=Network Devices
  TITLE:=Realtek RTL8812AU wireless USB 802.11ac driver
  DEPENDS:=@USB_SUPPORT +kmod-mac80211 +kmod-usb-core
  FILES:=$(PKG_BUILD_DIR)/8812au.ko
endef

define KernelPackage/$(PKG_NAME)/description
 Kernel modules for the Realtek 8812AU and 8821A USB 802.11ac
 wireless USB adapters
endef

define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_OPTS)
endef

$(eval $(call KernelPackage,$(PKG_NAME)))

@dl12345 Thank you for your response!
I will give it a try and post results!

The discussion might have continued from here.