1

I selected a Ralink 5572 based USB dongle to enable creating a 5 GHz access point on a Raspberry Pi 2.

I have found from trial and error that hostapd cannot use 5 GHz frequencies, unless first run in the 2.4 GHz band.

Here's the hostapd.conf file:

interface=wlan0
driver=nl80211
country_code=US
ssid=**********
ieee80211n=1
hw_mode=a
channel=44
wpa=3
wpa_passphrase=**********
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
beacon_int=100
auth_algs=3
macaddr_acl=0
wmm_enabled=1
eap_reauth_period=360000000

With hostapd.conf settings of hw_mode=a, and channel=44, hostapd gives this output:

sudo hostapd -d /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: interface wlan0 in phy phy0
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Add own interface ifindex 3
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Create interface iftype 6 (MONITOR)
nl80211: New interface mon.wlan0 created: ifindex=4
nl80211: Add own interface ifindex 4
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz
nl80211: 2457-2482 @ 40 MHz
nl80211: 2474-2494 @ 20 MHz
nl80211: 5170-5250 @ 80 MHz
nl80211: 5250-5330 @ 80 MHz
nl80211: 5490-5730 @ 160 MHz
nl80211: 5735-5835 @ 80 MHz
nl80211: 57240-63720 @ 2160 MHz
nl80211: Added 802.11b mode based on 802.11g information
channel [4] (44) is disabled for use in AP mode, flags: 0x77
wlan0: IEEE 802.11 Configured channel (44) not found from the channel list of current mode (2) IEEE 802.11a
wlan0: IEEE 802.11 Hardware does not support configured channel
Could not select hw_mode and channel. (-4)
wlan0: Unable to setup interface.

Next I change to hw_mode=g, channel=6, and run hostapd again:

sudo hostapd -d /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: interface wlan0 in phy phy0
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Add own interface ifindex 3
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Create interface iftype 6 (MONITOR)
nl80211: New interface mon.wlan0 created: ifindex=5
nl80211: Add own interface ifindex 5
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=US
nl80211: 2402-2472 @ 40 MHz
nl80211: 5170-5250 @ 80 MHz
nl80211: 5250-5330 @ 80 MHz
nl80211: 5735-5835 @ 80 MHz
nl80211: 57240-63720 @ 2160 MHz
nl80211: Added 802.11b mode based on 802.11g information
Completing interface initialization
Mode: IEEE 802.11g  Channel: 6  Frequency: 2437 MHz

Finally I change hostapd.conf back to hw_mode=a, channel=44, and run hostapd again:

sudo hostapd -d /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: interface wlan0 in phy phy0
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Add own interface ifindex 3
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Create interface iftype 6 (MONITOR)
nl80211: New interface mon.wlan0 created: ifindex=6
nl80211: Add own interface ifindex 6
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=US
nl80211: 2402-2472 @ 40 MHz
nl80211: 5170-5250 @ 80 MHz
nl80211: 5250-5330 @ 80 MHz
nl80211: 5735-5835 @ 80 MHz
nl80211: 57240-63720 @ 2160 MHz
nl80211: Added 802.11b mode based on 802.11g information
Completing interface initialization
Mode: IEEE 802.11a  Channel: 44  Frequency: 5220 MHz
nl80211: Set freq 5220 (ht_enabled=1 sec_channel_offset=0)

At this point, I can connect to the AP, perform WPA authentication, and receive an IP address.

As I compare the output, I notice the first run says "Regulatory information - country=00", even though the hostapd.conf file contains "country_code=US" After changing to the 2.4 GHz band, hostapd reports "Regulatory information - country=US", and then remains set to US after restoring to channel 44.

Does anyone know what is happening on the first run, and how to get the country code properly recognized the first time?

1 Answer 1

2

I came back for another try a year later, and was successful. Following these steps will enable RT5572 dongle as an AP in 5 GHz band (as proved by seeing beacon and associating)

This time I started with a Raspberry Pi 3, with a clean install of Jessie Lite 2016-11-25.

The Rosewill RNX-N600UB (containing RT5572 chipset) was recognized:

sudo lsusb

    Bus 001 Device 008: ID 148f:5572 Ralink Technology, Corp. RT5572 Wireless Adapter    

The kernel supports the RT5572 as part of rt2800usb:

sudo lsmod

    Module                  Size  Used by
    arc4                    1958  2
    rt2800usb              17554  0
    rt2800lib              71894  1 rt2800usb
    rt2x00usb               8943  1 rt2800usb
    rt2x00lib              37529  3 rt2x00usb,rt2800lib,rt2800usb
    mac80211              532098  3 rt2x00lib,rt2x00usb,rt2800lib
    crc_ccitt               1278  1 rt2800lib

See this page for more information on rt2800usb

Install basic Wi-Fi AP Support (from this page):

  sudo apt-get install rfkill
  sudo apt-get install udhcpd
  sudo apt-get install hostapd 

As of today, this will install hostapd v2.3, which does not work with this chipset.

Based on the footnote in this article, (Access point, hostapd 2.4 with rtl driver: Hostapd-rtl8188), I learned is necessary to build hostapd v2.4 for Realtek rtl871xdrv from source:

sudo apt-get install git
git clone https://github.com/lostincynicism/hostapd-rtl8188.git
cd hostapd-rtl8188/hostapd

Additional required prerequisites before make:

sudo apt-get install libnl-3-dev
sudo apt-get install libssl-dev
sudo apt-get install libnl-genl-3-dev

After installing these, you should be able to perform a clean make from the folder:

pi@raspberrypi3:~/hostapd-rtl8188/hostapd $  make

Then

pi@raspberrypi3:~/hostapd-rtl8188/hostapd $  make install

to update default to version to "hostapd v2.4 for Realtek rtl871xdrv"

Verify from the home directory with:

pi@raspberrypi3:~ $ hostapd -v
hostapd v2.4 for Realtek rtl871xdrv

The /etc/hostapd/hostapd.conf file is finicky about enabling 5 GHz operation. Many attempts resulted in errors like this:

Hardware does not support configured mode
wlan1: IEEE 802.11 Hardware does not support configured mode (2) (hw_mode in hostapd.conf)
Could not select hw_mode and channel. (-2)

After many trials, I found the following parameters worked (for a US location):

interface=wlan1
driver=nl80211
country_code=US
ssid=*********
hw_mode=a
channel=44
ieee80211d=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=*********
wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP  # You better do not use this weak encryption (only used by old client devices)
rsn_pairwise=CCMP
beacon_int=100
auth_algs=3
#ieee80211n=1          # 802.11n support
wmm_enabled=1         # QoS support
#ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
eap_reauth_period=360000000

This solves the problem reported initially. The 5 GHz operation is available immediately on startup, without having to initially operate at 2.4 GHz.

1
  • Note: Although I started out using the elinux hotspot guide <elinux.org/RPI-Wireless-Hotspot>, it turns out there are some issues with the networking changes in Jessie and beyond. It doesn't adequately address the issues of network/interfaces vs dhcpcd, and recommends udhcpd, which further complicates matters. I was unable to get the DHCP server working until I uninstalled udhcpd, and followed the guidelines in this article <frillip.com/…>. It uses dnsmasq, and explicitly shows how to fix the dhcpcd issues.
    – tim11g
    Dec 31, 2016 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.