原以为so easy的小事情:从官网下载相应的驱动编译,安装,配置一下就好了。

事实上还是有2个坑的,首先是编译一大串的错误。


make[2]: *** [/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.o] Error 1
make[1]: *** [_module_/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
make: *** [modules] Error 2
##################################################
Compile make driver error: 2
Please check error Mesg
##################################################
 

/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:92:13: error: ‘IEEE80211_BAND_2GHZ’ undeclared here (not in a function)
   .band   = IEEE80211_BAND_2GHZ,  \
             ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:150:2: note: in expansion of macro ‘CHAN2G’
  CHAN2G(1, 2412, 0),
  ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:101:13: error: ‘IEEE80211_BAND_5GHZ’ undeclared here (not in a function)
   .band   = IEEE80211_BAND_5GHZ,  \
             ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:167:2: note: in expansion of macro ‘CHAN5G’
  CHAN5G(34, 0),  CHAN5G(36, 0),
  ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:167:2: error: initializer element is not constant
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:167:2: error: (near initialization for ‘rtw_5ghz_a_channels[0].band’)
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:167:2: error: initializer element is not constant
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:167:2: error: (near initialization for ‘rtw_5ghz_a_channels[1].band’)
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:168:2: error: initializer element is not constant
  CHAN5G(38, 0),  CHAN5G(40, 0),
...

/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:659:2: error: too few arguments to function ‘cfg80211_ibss_joined’
  cfg80211_ibss_joined(padapter->pnetdev, cur_network->network.MacAddress, GFP_ATOMIC);
  ^
...
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:757:45: error: ‘struct wireless_dev’ has no member named ‘sme_state’
   RTW_INFO("pwdev->sme_state(b)=%d\n", pwdev->sme_state);
                                             ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/include/rtw_debug.h:137:34: note: in definition of macro ‘RTW_INFO’
    _dbgdump(DRIVER_PREFIX fmt, ##arg);\
                                  ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:757:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘struct ieee80211_channel *’ [-Wformat=]
   RTW_INFO("pwdev->sme_state(b)=%d\n", pwdev->sme_state);
   ^
In file included from /root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/include/drv_types.h:65:0,
                 from /root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:22:
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:766:45: error: ‘struct wireless_dev’ has no member named ‘sme_state’
   RTW_INFO("pwdev->sme_state(a)=%d\n", pwdev->sme_state);
...
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:820:12: error: ‘struct wireless_dev’ has no member named ‘sme_state’
   if (pwdev->sme_state == CFG80211_SME_CONNECTING)
            ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:820:27: error: ‘CFG80211_SME_CONNECTING’ undeclared (first use in this function)
   if (pwdev->sme_state == CFG80211_SME_CONNECTING)
                           ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:820:27: note: each undeclared identifier is reported only once for each function it appears in
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:823:17: error: ‘struct wireless_dev’ has no member named ‘sme_state’
   else if (pwdev->sme_state == CFG80211_SME_CONNECTED) {
                 ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:823:32: error: ‘CFG80211_SME_CONNECTED’ undeclared (first use in this function)
   else if (pwdev->sme_state == CFG80211_SME_CONNECTED) {
                                ^
/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.c:827:4: error: too few arguments to function ‘cfg80211_disconnected’
    cfg80211_disconnected(padapter->pnetdev, 0, NULL, 0, GFP_ATOMIC);
    ^
...
make[2]: *** [/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046/os_dep/linux/ioctl_cfg80211.o] Error 1
make[1]: *** [_module_/root/ws/RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615/driver/rtl8192EU_WiFi_linux_v5.2.7_22739.20170615_COEX20170113-0046] Error 2
make[1]: Leaving directory `/usr/src/kernels/3.10.0-957.el7.x86_64'
make: *** [modules] Error 2
##################################################
Compile make driver error: 2
Please check error Mesg
##################################################
[root@localhost RTL8192EU_linux_v5.2.7_22739_COEX20170113-0046.20170615]#

恩,可能是驱动的问题,换了一个https://github.com/Mange/rtl8192eu-linux-driver,编译的错误差不多。按驱动文档应该是支持3.10的内核,这就奇怪了。

先说小结论:centos7.6 1810用的kernel比较老旧3.10 。它是把wifi的网络驱动子系统更新了,至少是更新到kernel4.7以上的版本。

这操作够风骚,反过来想也合理。毕竟这样容易支持更多的新硬件。

分析:怎么发现的?线索是ioctl_cfg80211.c:659:2: error:: too few arguments to function ‘cfg80211_ibss_joined’
  cfg80211_ibss_joined(padapter->pnetdev, cur_network->network.MacAddress, GFP_ATOMIC);这个函数参数会少?查看了下声明net/cfg80211.h文件,发现真的参数不匹配,然后在LXR上查看原版的,发现和centos7.6的真不一样。

再进到C文件中一看。

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
        notify_channel = ieee80211_get_channel(wiphy, freq);
        cfg80211_ibss_joined(padapter->pnetdev, cur_network->network.MacAddress, notify_channel, GFP_ATOMIC);
#else
        cfg80211_ibss_joined(padapter->pnetdev, cur_network->network.MacAddress, GFP_ATOMIC);
#endif

这样明白了,说明centos7.6是要用kernel3.15以上版本的分支。这就是问题所在,类似的还有几处同类问题就不说了。

还要在os_dep/linux/ioctl_cfg80211.c文件里定义 enum station_info_flags。改完这类问题就能编译通过。

其次是加载驱动dmesg有dump_stack错误信息。加载有依赖关系,注意下就好了。

结论:假消息。

一开始吓了一跳,难道是没改好?只是编译过了而已。事实是不用管这个,直接用UI配置wifi就能连接上,速度也不错,稳定性也没有问题。

分析 :仔细看了出错信息,只是个regulatory调节器。以多年的驱动经验,应该只是个可忽略的信息。直接试下看能不能用,果然能用,开心。

   4.168980] ------------[ cut here ]------------
[    4.168991] WARNING: CPU: 0 PID: 681 at net/wireless/reg.c:2287 wiphy_apply_custom_regulatory+0xb5/0xe0 [cfg80211]
[    4.168992] wiphy should have REGULATORY_CUSTOM_REG
[    4.168992] Modules linked in: snd_hda_codec_hdmi(+) intel_pmc_core intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel 8192eu(OE+) kvm snd_hda_codec_realtek snd_hda_codec_generic cfg80211 snd_hda_intel irqbypass iTCO_wdt iTCO_vendor_support crc32_pclmul ghash_clmulni_intel snd_hda_codec aesni_intel lrw gf128mul glue_helper ablk_helper snd_hda_core cryptd rfkill sg snd_hwdep snd_seq pcspkr snd_seq_device snd_pcm snd_timer mei_me acpi_pad snd mei soundcore i2c_i801 ip_tables xfs libcrc32c sd_mod crc_t10dif crct10dif_generic nouveau i2c_algo_bit drm_kms_helper mxm_wmi syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm ahci libahci libata crct10dif_pclmul crct10dif_common crc32c_intel r8169 serio_raw mii drm_panel_orientation_quirks wmi video i2c_hid dm_mirror dm_region_hash dm_log dm_mod
[    4.169018] CPU: 0 PID: 681 Comm: systemd-udevd Tainted: G           OE  ------------   3.10.0 #1
[    4.169019] Hardware name: Micro-Star International Co., Ltd. MS-7C31/B365M PRO-VH (MS-7C31), BIOS 1.10 04/02/2019
[    4.169020] Call Trace:
[    4.169024]  [<ffffffffafd61dc1>] dump_stack+0x19/0x1b
[    4.169027]  [<ffffffffaf697648>] __warn+0xd8/0x100
[    4.169028]  [<ffffffffaf6976cf>] warn_slowpath_fmt+0x5f/0x80
[    4.169034]  [<ffffffffc08ce625>] wiphy_apply_custom_regulatory+0xb5/0xe0 [cfg80211]
[    4.169056]  [<ffffffffc0a66110>] rtw_regd_init+0x30/0x40 [8192eu]
[    4.169074]  [<ffffffffc0a65f49>] rtw_cfg80211_ndev_res_register+0x19/0x30 [8192eu]
[    4.169109]  [<ffffffffc0a4d62f>] rtw_os_ndev_register+0x6f/0x130 [8192eu]
[    4.169142]  [<ffffffffc0a4e2b6>] rtw_os_ndevs_register+0xa6/0x140 [8192eu]
[    4.169172]  [<ffffffffc0a4e3d0>] rtw_os_ndevs_init+0x30/0x50 [8192eu]
[    4.169189]  [<ffffffffc0a4fa4a>] rtw_drv_init+0x2ca/0x3d0 [8192eu]
[    4.169192]  [<ffffffffafb03c4d>] usb_probe_interface+0x11d/0x320
[    4.169195]  [<ffffffffafaa8285>] driver_probe_device+0xc5/0x3e0
[    4.169196]  [<ffffffffafaa8683>] __driver_attach+0x93/0xa0
[    4.169198]  [<ffffffffafaa85f0>] ? __device_attach+0x50/0x50
[    4.169199]  [<ffffffffafaa5e25>] bus_for_each_dev+0x75/0xc0
[    4.169201]  [<ffffffffafaa7bfe>] driver_attach+0x1e/0x20
[    4.169202]  [<ffffffffafaa76a0>] bus_add_driver+0x200/0x2d0

-开机自动加载

生成加载依赖

# cp 8192eu.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless
# depmod -a

创建加载脚本

 /etc/sysconfig/modules/8192eu.mod

#! /bin/sh

/sbin/modinfo -F filename 8192eu > /dev/null 2>&1
if [ $? -eq 0 ]; then
    /sbin/modprobe 8192eu
fi

自动连接wlan,图形设置一下更方便。

 

---------假装是分割线-----------

修改后的代码上传了github,仅供参考:

git clone https://github.com/chuanjinpang/rtl8192eu-linux-driver.git

git branch -a
git checkout -b centos7 remotes/origin/centos7

 

Logo

更多推荐