AP-5Ghz-ATH10K

新进了个杀手1535ac网卡..高通QCA6174
想把AP改成5Ghz.结果iw list显示5ghz全部no IR,意味着无法使用..
原因是高通跟开源作者们说: 千万别在软件层面实现这个啊。这是违法的
在网上找了很多资料.实现一下.

目前状态
$ iw reg get
global
country CN: DFS-FCC
	(2402 - 2482 @ 40), (N/A, 20), (N/A)
	(5170 - 5250 @ 80), (N/A, 23), (N/A), AUTO-BW
	(5250 - 5330 @ 80), (N/A, 23), (0 ms), DFS, AUTO-BW
	(5735 - 5835 @ 80), (N/A, 30), (N/A)
	(57240 - 59400 @ 2160), (N/A, 28), (N/A)
	(59400 - 63720 @ 2160), (N/A, 44), (N/A)
	(63720 - 65880 @ 2160), (N/A, 28), (N/A)

$ iw list | grep "Frequencies" -A 30

		Frequencies:
			* 2412 MHz [1] (20.0 dBm)
			* 2417 MHz [2] (20.0 dBm)
			* 2422 MHz [3] (20.0 dBm)
			* 2427 MHz [4] (20.0 dBm)
			* 2432 MHz [5] (20.0 dBm)
			* 2437 MHz [6] (20.0 dBm)
			* 2442 MHz [7] (20.0 dBm)
			* 2447 MHz [8] (20.0 dBm)
			* 2452 MHz [9] (20.0 dBm)
			* 2457 MHz [10] (20.0 dBm)
			* 2462 MHz [11] (20.0 dBm)
			* 2467 MHz [12] (20.0 dBm) (no IR)
			* 2472 MHz [13] (20.0 dBm) (no IR)
			* 2484 MHz [14] (disabled)
	Band 2:
		Frequencies:
			* 5180 MHz [36] (23.0 dBm) (no IR)
			* 5200 MHz [40] (23.0 dBm) (no IR)
			* 5220 MHz [44] (23.0 dBm) (no IR)
			* 5240 MHz [48] (23.0 dBm) (no IR)
			* 5260 MHz [52] (23.0 dBm) (no IR, radar detection)
			* 5280 MHz [56] (23.0 dBm) (no IR, radar detection)
			* 5300 MHz [60] (23.0 dBm) (no IR, radar detection)
			* 5320 MHz [64] (23.0 dBm) (no IR, radar detection)
			* 5500 MHz [100] (disabled)
			* 5520 MHz [104] (disabled)
			* 5540 MHz [108] (disabled)
			* 5560 MHz [112] (disabled)
			* 5580 MHz [116] (disabled)
			* 5600 MHz [120] (disabled)
			* 5620 MHz [124] (disabled)
			* 5640 MHz [128] (disabled)
			* 5660 MHz [132] (disabled)
			* 5680 MHz [136] (disabled)
			* 5700 MHz [140] (disabled)
			* 5720 MHz [144] (disabled)
			* 5745 MHz [149] (30.0 dBm) (no IR)
			* 5765 MHz [153] (30.0 dBm) (no IR)
			* 5785 MHz [157] (30.0 dBm) (no IR)
			* 5805 MHz [161] (30.0 dBm) (no IR)
			* 5825 MHz [165] (30.0 dBm) (no IR)
			* 5845 MHz [169] (disabled)

解决办法是编译内核模块..
uname -r
mkdir ~/kernelbuild
cd ~/kernelbuild
# https://www.kernel.org/ https://mirror.tuna.tsinghua.edu.cn/kernel/v4.x 从这里获取一个相同版本的内核
wget https://mirror.tuna.tsinghua.edu.cn/kernel/v4.x/linux-4.11.3.tar.xz
tar -xvJf linux-4.11.3.tar.xz
cd linux-4.11.3
vim drivers/net/wireless/ath/regd.c

修改drivers/net/wireless/ath/regd.c
+号部分添加

# 段1 
static void
ath_reg_apply_beaconing_flags(struct wiphy *wiphy,
                              struct ath_regulatory *reg,
                              enum nl80211_reg_initiator initiator)
{

        enum nl80211_band band;
        struct ieee80211_supported_band *sband;
        struct ieee80211_channel *ch;
        unsigned int i;
       
       +#ifdef CONFIG_ATH_USER_REGD
       +	return;
       +#endif

        for (band = 0; band < NUM_NL80211_BANDS; band++) {
                if (!wiphy->bands[band])
                        continue;
                sband = wiphy->bands[band];
                for (i = 0; i < sband->n_channels; i++) {
                        ch = &sband->channels[i];
                        __ath_reg_apply_beaconing_flags(wiphy, reg,
                                                        initiator, ch);
                }
        }
}
# 段2
static void
ath_reg_apply_ir_flags(struct wiphy *wiphy,
                       struct ath_regulatory *reg,
                       enum nl80211_reg_initiator initiator)
{
        struct ieee80211_supported_band *sband;
        
        +#ifdef CONFIG_ATH_USER_REGD
        +	return;
        +#endif

        sband = wiphy->bands[NL80211_BAND_2GHZ];
        if (!sband)
                return;

# 段3
static void ath_reg_apply_radar_flags(struct wiphy *wiphy)
{
        struct ieee80211_supported_band *sband;
        struct ieee80211_channel *ch;
        unsigned int i;

        +#ifdef CONFIG_ATH_USER_REGD
        +	return;
        +#endif

        if (!wiphy->bands[NL80211_BAND_5GHZ])
                return;

        sband = wiphy->bands[NL80211_BAND_5GHZ];
# 段4
static int
ath_regd_init_wiphy(struct ath_regulatory *reg,
                    struct wiphy *wiphy,
                    void (*reg_notifier)(struct wiphy *wiphy,
                                         struct regulatory_request *request))
{
        const struct ieee80211_regdomain *regd;

        wiphy->reg_notifier = reg_notifier;

        +#ifdef CONFIG_ATH_USER_REGD
        +	return 0;
        +#endif

        wiphy->regulatory_flags |= REGULATORY_STRICT_REG |
                                   REGULATORY_CUSTOM_REG;

        if (ath_is_world_regd(reg)) {

修改drivers/net/wireless/ath/Kconfig
+号部分添加

if WLAN_VENDOR_ATH

+config ATH_USER_REGD
+	bool "Do not enforce EEPROM regulatory restrictions"
+       default n

config ATH_DEBUG
        bool "Atheros wireless debugging"
        ---help---
          Say Y, if you want to debug atheros wireless drivers.
          Right now only ath9k makes use of this.

编译开始
pacman -Sy bc linux-headers
make clean && make mrproper
cp /usr/lib/modules/$(uname -r)/build/Module.symvers ./
# 导出正在运行的内核的 .config 配置文件
zcat /proc/config.gz > .config
make oldconfig && make prepare
Wireless LAN (WLAN) [Y/n/?] y
  ADMtek devices (WLAN_VENDOR_ADMTEK) [Y/n/?] y
    ADMtek ADM8211 support (ADM8211) [M/n/?] m
  Atheros/Qualcomm devices (WLAN_VENDOR_ATH) [Y/n/?] y
    Do not enforce EEPROM regulatory restrictions (ATH_USER_REGD) [N/y]

Y 直接回车

make scripts
make M=drivers/net/wireless/ath

N分钟以后

仅替换ath模块
gzip drivers/net/wireless/ath/ath.ko
cp -f drivers/net/wireless/ath/ath.ko.gz /lib/modules/$(uname -r)/kernel/drivers/net/wireless/ath/ath.ko.gz
sudo depmod -a

重启

iw reg set CN
iw list

	Band 2:
		Frequencies:
			* 5180 MHz [36] (23.0 dBm)
			* 5200 MHz [40] (23.0 dBm) 
			* 5220 MHz [44] (23.0 dBm) 
			* 5240 MHz [48] (23.0 dBm) 
			* 5260 MHz [52] (23.0 dBm) (radar detection)
			* 5280 MHz [56] (23.0 dBm) (radar detection)
			* 5300 MHz [60] (23.0 dBm) (radar detection)
			* 5320 MHz [64] (23.0 dBm) (radar detection)
			* 5500 MHz [100] (disabled)
			* 5520 MHz [104] (disabled)
			* 5540 MHz [108] (disabled)
			* 5560 MHz [112] (disabled)
			* 5580 MHz [116] (disabled)
			* 5600 MHz [120] (disabled)
			* 5620 MHz [124] (disabled)
			* 5640 MHz [128] (disabled)
			* 5660 MHz [132] (disabled)
			* 5680 MHz [136] (disabled)
			* 5700 MHz [140] (disabled)
			* 5720 MHz [144] (disabled)
			* 5745 MHz [149] (30.0 dBm)
			* 5765 MHz [153] (30.0 dBm)
			* 5785 MHz [157] (30.0 dBm) 
			* 5805 MHz [161] (30.0 dBm) 
			* 5825 MHz [165] (30.0 dBm)
			* 5845 MHz [169] (disabled)
Hostapd.conf AP 5Ghz 802.11a/n/ac with WPA2-PSK and CCMP
interface=wlan0
bridge=br0      
hw_mode=a           
channel=0           
ieee80211d=1         
country_code=CN     
ieee80211n=1        
ieee80211ac=1        
wmm_enabled=1      

ssid=somename        
auth_algs=1           
wpa=2                
wpa_key_mgmt=WPA-PSK 
rsn_pairwise=CCMP
wpa_passphrase=somepassword
# 如果需要当AP-WDS ,不开这个则路由器B就不会wds成功
wds_sta=1

参考:
http://www.jackyhe.com/?p=263
https://renaudcerrato.github.io/2016/05/30/build-your-homemade-router-part3/
Archlinux中文内核
Archlinux compile kernel module

Show Comments