Because of the macro is pretty complex, have to use a trick. The old version Makefile works fine, so we can use its macro define.
Grab the Makefile command line first:
mipsel-openwrt-linux-musl-gcc -Wp,-MD,/Volumes/OpenWrt18/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/mt7628-p4rev-120395/build/../src/embedded/os/linux/.rt_pci_rbus.o.d -nostdinc -isystem /Volumes/OpenWrt18/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/../lib/gcc/mipsel-openwrt-linux-musl/7.3.0/include -I./arch/mips/include -I./arch/mips/include/generated -I./include -I./arch/mips/include/uapi -I./arch/mips/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -DVMLINUX_LOAD_ADDRESS=0xffffffff80000000 -DLINKER_LOAD_ADDRESS=0x80000000 -DDATAOFFSET=0 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-check-zero-division -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -mno-branch-likely -msoft-float -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float -ffreestanding -fno-stack-check -march=mips32r2 -mtune=34kc -Wa,--trap -DTOOLCHAIN_SUPPORTS_VIRT -I./arch/mips/include/asm/mach-ralink -I./arch/mips/include/asm/mach-ralink/mt7620 -I./arch/mips/include/asm/mach-generic -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-int-in-bool-context -Os -fno-caller-saves --param=allow-store-data-races=0 -DCC_HAVE_ASM_GOTO -Wframe-larger-than=1024 -fstack-protector -Wno-unused-but-set-variable -Wno-unused-const-variable -fomit-frame-pointer -fno-var-tracking-assignments -g -femit-struct-debug-baseonly -fno-var-tracking -Wdeclaration-after-statement -Wno-pointer-sign -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-merge-all-constants -fmerge-constants -fno-stack-check -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -I/Volumes/OpenWrt18/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/mt7628-p4rev-120395/build/../src/include -I/Volumes/OpenWrt18/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/mt7628-p4rev-120395/build/../src/embedded/include -I/Volumes/OpenWrt18/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/mt7628-p4rev-120395/build/../src/ate/include -DCONFIG_SUPPORT_OPENWRT=y -DCONFIG_RALINK_MT7628=y -DNEW_RATE_ADAPT_SUPPORT -DUAPSD_SUPPORT -DUAPSD_DEBUG -DMT_PS -DWSC_INCLUDED -DWSC_SINGLE_TRIGGER -DWSC_AP_SUPPORT -DWSC_V2_SUPPORT -DDOT11W_PMF_SUPPORT -DSOFT_ENCRYPT -DMBSS_SUPPORT -DMT7628 -DMT_BBP -DMT_RF -DRTMP_RBUS_SUPPORT -DRTMP_RF_RW_SUPPORT -DMT_MAC -DRTMP_MAC_PCI -DRTMP_PCI_SUPPORT -DRTMP_FLASH_SUPPORT -DDMA_SCH_SUPPORT -DRTMP_EFUSE_SUPPORT -DCONFIG_ANDES_SUPPORT -DRESOURCE_PRE_ALLOC -DNEW_MBSSID_MODE -DENHANCE_NEW_MBSSID_MODE -DENHANCED_STAT_DISPLAY -DFIFO_EXT_SUPPORT -DMCS_LUT_SUPPORT -DUSE_BMC -DTHERMAL_PROTECT_SUPPORT -DCAL_FREE_IC_SUPPORT -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT -DLINUX -Wall -Wstrict-prototypes -Wno-trigraphs -DCONFIG_AP_SUPPORT -DSCAN_SUPPORT -DAP_SCAN_SUPPORT -DDOT11_N_SUPPORT -DDOT11N_DRAFT3 -DSTATS_COUNT_SUPPORT -DIAPP_SUPPORT -DDOT1X_SUPPORT -DCONFIG_RA_NAT_NONE -DDBG -DIP_ASSEMBLY -DMODULE -mno-long-calls -DKBUILD_BASENAME='"rt_pci_rbus"' -DKBUILD_MODNAME='"mt7628"' -c -o /Volumes/OpenWrt18/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/mt7628-p4rev-120395/build/../src/embedded/os/linux/rt_pci_rbus.o /Volumes/OpenWrt18/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/mt7628-p4rev-120395/build/../src/embedded/os/linux/rt_pci_rbus.c
Now we can find the define: -DCONFIG_SUPPORT_OPENWRT=y -DCONFIG_RALINK_MT7628=y -DNEW_RATE_ADAPT_SUPPORT -DUAPSD_SUPPORT -DUAPSD_DEBUG -DMT_PS -DWSC_INCLUDED -DWSC_SINGLE_TRIGGER -DWSC_AP_SUPPORT -DWSC_V2_SUPPORT -DDOT11W_PMF_SUPPORT -DSOFT_ENCRYPT -DMBSS_SUPPORT …
Compare Makefile, we can get the defines. Update Makefile…
PKG_CONFIG_DEPENDS:=\
CONFIG_MT7628_AP_SUPPORT=m \
CONFIG_SUPPORT_OPENWRT=y \
CONFIG_RALINK_MT7628=y \
CONFIG_MT7628_NEW_RATE_ADAPT_SUPPORT=y \
CONFIG_MT7628_UAPSD=y \
CONFIG_MT7628_MAC=y \
CONFIG_MT7628_WSC_INCLUDED=y \
CONFIG_MT7628_WSC_V2_SUPPORT=y \
CONFIG_MT7628_DOT11W_PMF_SUPPORT=y \
CONFIG_MT7628_MBSS_SUPPORT=y \
CONFIG_MT7628_WPA3_SUPPORT=y
Then call “make package/mt7628/compile V=s”
Because there is no patch, we will get a lot of errors…I find most of the problem is not critical…Like this:
/Volumes/OpenWrt/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/mt7628-wifi/mt7628_wifi_ap/../mt7628_wifi/embedded/common/wsc.c:9903:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if
The driver internal Makefile default has -Werror, so such warning from new compiler gcc are dealed as error. That can be removed. Rest problem is because of new Linux kernel modify, so final patch like this:
--- a/mt7628_wifi_ap/Makefile
+++ b/mt7628_wifi_ap/Makefile
@@ -533,7 +533,7 @@
# CFLAGS
##################
EXTRA_CFLAGS += -DAGGREGATION_SUPPORT -DPIGGYBACK_SUPPORT -DWMM_SUPPORT -DLINUX \
- -Wall -Wstrict-prototypes -Wno-trigraphs -Werror -Wframe-larger-than=4096
+ -Wall -Wstrict-prototypes -Wno-trigraphs -Wframe-larger-than=4096
#-DDBG_DIAGNOSE -DDBG_RX_MCS -DDBG_TX_MCS
EXTRA_CFLAGS += -DCONFIG_AP_SUPPORT -DSCAN_SUPPORT -DAP_SCAN_SUPPORT
--- a/mt7628_wifi/embedded/common/cmm_info.c
+++ b/mt7628_wifi/embedded/common/cmm_info.c
@@ -97,7 +97,6 @@
{
#ifdef CONFIG_AP_SUPPORT
IF_DEV_CONFIG_OPMODE_ON_AP(pAd)
- MTWF_LOG(DBG_CAT_ALL, DBG_SUBCAT_ALL, DBG_LVL_OFF, ("Driver version-%s %s %s\n", AP_DRIVER_VERSION, __DATE__, __TIME__));
#endif /* CONFIG_AP_SUPPORT */
#ifdef CONFIG_STA_SUPPORT
--- a/mt7628_wifi/embedded/os/linux/rt_profile.c
+++ b/mt7628_wifi/embedded/os/linux/rt_profile.c
@@ -236,7 +236,7 @@
{
#ifndef OS_ABL_SUPPORT
// TODO: need to roll back when convert into OSABL code
- fsize = (ULONG)srcf->f_dentry->d_inode->i_size;
+ fsize = (ULONG)srcf->f_path.dentry->d_inode->i_size;
if (buf_size < (fsize + 1))
buf_size = fsize + 1;
#endif /* OS_ABL_SUPPORT */
--- a/mt7628_wifi/embedded/common/wsc.c
+++ b/mt7628_wifi/embedded/common/wsc.c
@@ -9847,7 +9847,7 @@
//PWSC_UPNP_NODE_INFO pWscUPnPNodeInfo;
UCHAR apIdx;
-#ifdef LINUX
+#ifdef LINUX_SIG
#ifdef WSC_SINGLE_TRIGGER
/* +++ added by YYHuang@Ralink, 08/03/12 */
/*
--- a/mt7628_wifi/embedded/os/linux/rt_proc.c
+++ b/mt7628_wifi/embedded/os/linux/rt_proc.c
@@ -29,7 +29,7 @@
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/proc_fs.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
#include "rt_config.h"
Then we can successfully get the mt7628.ko file.