<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>my tech blog &#187; wifi</title>
	<atom:link href="http://billauer.se/blog/category/wifi/feed/" rel="self" type="application/rss+xml" />
	<link>https://billauer.se/blog</link>
	<description>Anything I found worthy to write down.</description>
	<lastBuildDate>Thu, 12 Mar 2026 11:36:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Linux: Atheros QCA6174&#8242;s Bluetooth disappearing after reboot</title>
		<link>https://billauer.se/blog/2019/07/qualcomm-atheros-qca6174-bluetooth/</link>
		<comments>https://billauer.se/blog/2019/07/qualcomm-atheros-qca6174-bluetooth/#comments</comments>
		<pubDate>Sun, 21 Jul 2019 10:26:17 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[bluetooth]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux kernel]]></category>
		<category><![CDATA[USB]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5773</guid>
		<description><![CDATA[When Bluetooth goes poof Having rebooted my computer after a few months of continuous operation, I suddenly failed to use my Bluetooth headphones. It took some time to figure out that the problem wasn&#8217;t with the Cinnamon 3.8.9 fancy stuff, nor the DBus interface, which produced error messages. There was simply no Bluetooth device in [...]]]></description>
			<content:encoded><![CDATA[<h3>When Bluetooth goes poof</h3>
<p>Having rebooted my computer after a few months of continuous operation, I suddenly failed to use my Bluetooth headphones. It took some time to figure out that the problem wasn&#8217;t with the Cinnamon 3.8.9 fancy stuff, nor the DBus interface, which produced error messages. There was simply no Bluetooth device in the system to talk to.</p>
<p>Prior to this mishap, my Atheros QCA6174 had worked flawlessly and reliably for several months, both as a Wifi adapter and a Bluetooth adapter.</p>
<p>For the record, I have a Linux Mint 19 Tara machine with 4.15.0-20-generic kernel on a X299 AORUS Gaming 7 motherboard, running in 64 bit mode of course.</p>
<p>I&#8217;ll jump to the spoiler: If you happen to have a Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter on your machine, never just reboot the machine: Shut down the computer completely, and disconnect main power for a minute or so with the power supply&#8217;s switch. Just powering off the computer the fine way isn&#8217;t enough. The device probably continues to get power from the motherboard when in computer is off by virtue of its own power control.</p>
<p>Powering off the computer this way is what solved it for me. However there are also some rumors on the web, which I can&#8217;t confirm, about Bluetooth coming back to life after loading Windows on the same computer. Or turning Bluetooth off and on again with the BIOS. My guess is that due to a bug, the chip sometimes needs some kind of tickle on shutdown or when starting, or Bluetooth is lost. Something that is worked around with a hush-hush fix in the driver for Windows,  but the Linux driver doesn&#8217;t do the same.</p>
<p>This post goes down to the gory details, partly for the sake of quick diagnostics in the future, and partly because Bluetooth tends to be a mystery thing. So I&#8217;m trying to give an idea on what&#8217;s going on.</p>
<h3>Why it&#8217;s confusing</h3>
<p>Here&#8217;s the thing: The Qualcomm QCA6174 connects to the motherboard as a PCIe device as a Wifi adapter, and to the USB bus as a Bluetooth device. Sounds weird, but that&#8217;s the way it is. Bluetooth has been wonky for 20 years, and that&#8217;s probably its destiny.</p>
<p>So there are wires going from the QCA6174 to the PCIe bus and other wires from the same device going to one of the ports of the motherboard&#8217;s USB root hub (see details below). On my specific motherboard, the Bluetooth interface of the QCA6174 is connected to port 13 of the root hub, that facilitates the motherboard&#8217;s physical USB connector at the back of the computer. So while designing the board, they wired some of the D+/D- wires to the physical ports at the back, and a couple of those go to the QCA6174. I&#8217;m saying this over and over again, because it&#8217;s so counterintuitive.</p>
<p>Counterintuituve, but it seems like it&#8217;s quite common. Intel&#8217;s AC 7260 Wifi / Bluetooth combo seems to do exactly the same thing.</p>
<p>As a PCIe device, QCA6174 has Vendor / Product IDs 168c:003e. As as USB device, it&#8217;s 0cf3:e300. Confusing? It won&#8217;t surprise me if the Wifi and Bluetooth interfaces are two independent units on the same chip, that happen to share an antenna.</p>
<p>Apparently, when the QCA6174 has a bad day, the PCIe interface wakes up properly, and USB doesn&#8217;t. The result is that the Wifi works fine, but the Bluetooth is absent.</p>
<p>To add some confusion,  the kernel source&#8217;s drivers/net/wireless/ath/ath10k/usb.c matches USB device 13b1:0042,  which is indeed a Linksys device (the comment in the code says Linksys  WUSB6100M). Not clear why it&#8217;s there.</p>
<p>On the other hand, drivers/bluetooth/btusb.c, matches a  whole range of Atheros USB devices, among others 0cf3:e300, calling it  &#8220;QCA ROME&#8221; in the comments. So it&#8217;s the btusb module that takes care of QCA6174&#8242;s Bluetooth interface, not anything in ath/ath10k. Cute, isn&#8217;t it?</p>
<h3>What it looks like when it works</h3>
<p>When trying to figure out what&#8217;s wrong, it helps knowing that it looks like when it&#8217;s OK. So below is a lot of info that was collected when I got the Bluetooth up and running.</p>
<p>When it failed, everything looked exactly the same in relation to the device&#8217;s PCIe interface, but there was absolutely nothing related to USB and Bluetooth: No entry for the device in lsusb, hcicontrol nor rfkill, as shown below.</p>
<p>Kernel log output on behalf of the device, as connected to the PCIe bus. Note that the exact same logs appeared when the Bluetooth device was absent. Exactly-exactly. Down to the single character, I&#8217;ve compared them. So this isn&#8217;t really relevant, but anyhow:</p>
<pre>[    0.126428] pci 0000:03:00.0: [168c:003e] type 00 class 0x028000
[    0.126456] pci 0000:03:00.0: reg 0x10: [mem 0x92800000-0x929fffff 64bit]
[    0.126555] pci 0000:03:00.0: PME# supported from D0 D3hot D3cold

<span style="color: #888888;"><em>[ ... ]</em></span>

[   17.616738] ath10k_pci 0000:03:00.0: enabling device (0000 -&gt; 0002)
[   17.617514] ath10k_pci 0000:03:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0

<span style="color: #888888;"><em>[ ... ]</em></span>

[   17.915091] ath10k_pci 0000:03:00.0: Direct firmware load for ath10k/pre-cal-pci-0000:03:00.0.bin failed with error -2
[   17.915109] ath10k_pci 0000:03:00.0: Direct firmware load for ath10k/cal-pci-0000:03:00.0.bin failed with error -2
[   17.926172] ath10k_pci 0000:03:00.0: qca6174 hw3.2 target 0x05030000 chip_id 0x00340aff sub 1a56:1535
[   17.926173] ath10k_pci 0000:03:00.0: kconfig debug 0 debugfs 1 tracing 1 dfs 0 testmode 0
[   17.926505] ath10k_pci 0000:03:00.0: firmware ver WLAN.RM.4.4.1-00124-QCARMSWPZ-1 api 6 features wowlan,ignore-otp crc32 d8fe1bac
[   18.078191] ath10k_pci 0000:03:00.0: board_file api 2 bmi_id N/A crc32 506ce037

<span style="color: #888888;"><em>[ ... ]</em></span>

[   18.642461] ath10k_pci 0000:03:00.0: Unknown eventid: 3
[   18.658195] ath10k_pci 0000:03:00.0: Unknown eventid: 118809
[   18.661096] ath10k_pci 0000:03:00.0: Unknown eventid: 90118
[   18.661772] ath10k_pci 0000:03:00.0: htt-ver 3.56 wmi-op 4 htt-op 3 cal otp max-sta 32 raw 0 hwcrypto 1</pre>
<p>Note that two attempts to load firmware failed, but apparently the third went OK. Don&#8217;t let these error messages mislead you: The kernel messages in this respect were the same when the Bluetooth appeared and when it didn&#8217;t.</p>
<p>The &#8220;Unknown eventid&#8221; may appear more than once.</p>
<p>Its entry with plain lspci (unrelated entries removed):</p>
<pre>$ lspci
03:00.0 Network controller: Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter (rev 32)</pre>
<p>And now to the parts that were missing completely when the Bluetooth device didn&#8217;t appear: The logs on behalf of the device, connected to the USB bus:</p>
<pre>[    3.764868] usb 1-13: new full-speed USB device number 12 using xhci_hcd
[    3.913930] usb 1-13: New USB device found, idVendor=0cf3, idProduct=e300
[    3.915610] usb 1-13: New USB device strings: Mfr=0, Product=0, SerialNumber=0</pre>
<p>Plain lsusb:</p>
<pre>$ lsusb
<em>[ ... ]</em>
Bus 001 Device 012: ID 0cf3:e300 Atheros Communications, Inc.
<em>[ ... ]</em></pre>
<p>lsusb, tree view (a lot of irrelevant stuff excluded):</p>
<pre>$ lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
    |__ Port 13: Dev 12, If 1, Class=Wireless, Driver=btusb, 12M
    |__ Port 13: Dev 12, If 0, Class=Wireless, Driver=btusb, 12M</pre>
<p>More in detail for the device:</p>
<pre># lsusb -v -d 0cf3:e300

Bus 001 Device 012: ID 0cf3:e300 Atheros Communications, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.01
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        64
  idVendor           0x0cf3 Atheros Communications, Inc.
  idProduct          0xe300
<em><span style="color: #888888;">[ ... ]</span></em></pre>
<p>Several modules appear in lsmod, but the point is that there are  dependencies on bluetooth module, in particular the btusb module.  Irrelevant modules deleted from list below:</p>
<pre>$ lsusb
rfcomm                 77824  16
bnep                   20480  2
btusb                  45056  0
btrtl                  16384  1 btusb
btbcm                  16384  1 btusb
btintel                16384  1 btusb
bluetooth             548864  43 btrtl,btintel,bnep,btbcm,rfcomm,btusb</pre>
<h3>How to check if a Bluetooth device is present</h3>
<p>There is no device file for Bluetooth interface, exactly as there&#8217;s none for network. Like there&#8217;s eth0 for Ethernet, there&#8217;s hci0 for Bluetooth.</p>
<p>hcicontrol grabs the info by opening a socket. As in the relevant strace:</p>
<pre>socket(PF_BLUETOOTH, SOCK_RAW, 1)</pre>
<p>So this is what it looked like with the Bluetooth device present (without it, hciconfig simply prints nothing):</p>
<pre>$ hciconfig
hci0:	Type: Primary  Bus: USB
	BD Address: xx:xx:xx:xx:xx:xx  ACL MTU: 1024:8  SCO MTU: 50:8
	UP RUNNING PSCAN ISCAN
	RX bytes:1386 acl:0 sco:0 events:94 errors:0
	TX bytes:5494 acl:0 sco:0 commands:94 errors:0</pre>
<p>Real hex numbers appear instead of the xx&#8217;s above. Use hciconfig -a for more verbose output.</p>
<p>And the device appears in the rfkill list, and shouldn&#8217;t be blocked.</p>
<pre>$ rfkill list
0: hci0: Bluetooth
	Soft blocked: no
	Hard blocked: no
1: phy0: Wireless LAN
	Soft blocked: no
	Hard blocked: no</pre>
<p>These two show that the kernel supplies a Bluetooth device to the higher software levels. If Bluetooth doesn&#8217;t work, there are other reasons&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2019/07/qualcomm-atheros-qca6174-bluetooth/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>5 GHz Wifi access point on Linux Mint 19 / Atheros</title>
		<link>https://billauer.se/blog/2018/12/tara-5-ghz-hostapd-atheros/</link>
		<comments>https://billauer.se/blog/2018/12/tara-5-ghz-hostapd-atheros/#comments</comments>
		<pubDate>Mon, 03 Dec 2018 06:40:56 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux kernel]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=5616</guid>
		<description><![CDATA[+ how to just compile an Ubuntu distribution kernel without too much messing around. Introduction It&#8217;s not a real computer installation if the Wifi works out of the box. So these are my notes to self for setting up an access point on a 5 GHz channel. I&#8217;ll need it somehow, because each kernel upgrade [...]]]></description>
			<content:encoded><![CDATA[<p>+ how to just compile an Ubuntu distribution kernel without too much messing around.</p>
<h3>Introduction</h3>
<p>It&#8217;s not a real computer installation if the Wifi works out of the box. So these are my notes to self for setting up an access point on a 5 GHz channel. I&#8217;ll need it somehow, because each kernel upgrade will require tweaking with the kernel module.</p>
<p>The machine is running Linux Mint 19 (Tara, based upon Ubuntu Bionic, with kernel 4.15.0-20-generic). The NIC is Qualcomm Atheros QCA6174 802.11ac Wireless Network Adapter, Vendor/Product IDs 168c:003e.</p>
<h3>Installing hostapd</h3>
<pre># apt install hostapd</pre>
<p>/etc/hostapd/hostapd.conf as follows:</p>
<pre>macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0

#Support older EAPOL authentication (version 1)
eapol_version=1

# Uncomment these for base WPA &amp; WPA2 support with a pre-shared key
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

wpa_passphrase=mysecret

# Customize these for your local configuration...
interface=wlan0
hw_mode=a
channel=52
ssid=mywifi
country_code=GD</pre>
<p>and /etc/default/hostapd as follows:</p>
<pre>DAEMON_CONF="/etc/hostapd/hostapd.conf"
DAEMON_OPTS=""</pre>
<p>Then unmask the service by deleting /etc/systemd/system/hostapd.service (it&#8217;s a symbolic link to /dev/null).attempting to start the service with</p>
<h3>5 GHz is not for plain people</h3>
<pre>Nov 27 21:14:04 hostapd[6793]: wlan0: IEEE 802.11 Configured channel (52) not found from the channel list of current mode (2) IEEE 802.11a
Nov 27 21:14:04 hostapd[6793]: wlan0: IEEE 802.11 Hardware does not support configured channel</pre>
<p>What do you mean it&#8217;s not supported? It&#8217;s on the list!</p>
<pre># iw list
<em>[ ... ]</em>
	Band 2:
<em>[ ... ]</em>
          Frequencies:
			* 5180 MHz [36] (17.0 dBm) (no IR)
			* 5200 MHz [40] (17.0 dBm) (no IR)
			* 5220 MHz [44] (17.0 dBm) (no IR)
			* 5240 MHz [48] (17.0 dBm) (no IR)
			* 5260 MHz [52] (24.0 dBm) (no IR, radar detection)
			* 5280 MHz [56] (24.0 dBm) (no IR, radar detection)
			* 5300 MHz [60] (24.0 dBm) (no IR, radar detection)
			* 5320 MHz [64] (24.0 dBm) (no IR, radar detection)
			* 5500 MHz [100] (24.0 dBm) (no IR, radar detection)
			* 5520 MHz [104] (24.0 dBm) (no IR, radar detection)
			* 5540 MHz [108] (24.0 dBm) (no IR, radar detection)
			* 5560 MHz [112] (24.0 dBm) (no IR, radar detection)
			* 5580 MHz [116] (24.0 dBm) (no IR, radar detection)
			* 5600 MHz [120] (24.0 dBm) (no IR, radar detection)
			* 5620 MHz [124] (24.0 dBm) (no IR, radar detection)
			* 5640 MHz [128] (24.0 dBm) (no IR, radar detection)
			* 5660 MHz [132] (24.0 dBm) (no IR, radar detection)
			* 5680 MHz [136] (24.0 dBm) (no IR, radar detection)
			* 5700 MHz [140] (24.0 dBm) (no IR, radar detection)
			* 5720 MHz [144] (24.0 dBm) (no IR, radar detection)
			* 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)
<em>[ ... ]</em></pre>
<p>The problem is evident when executing hostapd with the -dd flag (edit /etc/default/hostapd), in which case it lists the allowed channels. And none of the 5 GHz channels is listed. The underlying reason is the &#8220;no IR&#8221; part given in &#8220;iw list&#8221;, meaning no Initial Radiation, hence no access point allowed.</p>
<p>It&#8217;s very cute that the driver makes sure I won&#8217;t break the regulations, but it so happens that these frequencies are allowed for indoor use. My computer is indoors.</p>
<p>The way to work around this is to edit one of the driver&#8217;s sources, and use it instead.</p>
<p>Note that the typical error message when starting hostapd as a systemd service is quite misleading:</p>
<pre>hostapd[735]: wlan0: IEEE 802.11 Configured channel (52) not found from the channel list of current mode (2) IEEE 802.11a
hostapd[735]: wlan0: IEEE 802.11 Hardware does not support configured channel
hostapd[735]: wlan0: IEEE 802.11 Configured channel (52) not found from the channel list of current mode (2) IEEE 802.11a
hostapd[735]: Could not select hw_mode and channel. (-3)
hostapd[735]: wlan0: interface state UNINITIALIZED-&gt;DISABLED
hostapd[735]: wlan0: AP-DISABLED
hostapd[735]: wlan0: Unable to setup interface.
hostapd[735]: wlan0: interface state DISABLED-&gt;DISABLED
hostapd[735]: wlan0: AP-DISABLED
hostapd[735]: hostapd_free_hapd_data: Interface wlan0 wasn't started
hostapd[735]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
hostapd[735]: wlan0: IEEE 802.11 Hardware does not support configured channel

<span style="color: #888888;"><em>[ ... ]</em></span>

systemd[1]: hostapd.service: Control process exited, code=exited status=1
systemd[1]: hostapd.service: Failed with result 'exit-code'.
systemd[1]: <span style="color: #ff0000;"><strong>Failed to start Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator.</strong></span></pre>
<p>Not only is the message marked in red (as it also appears with journalctl itself) not related to the real reason, which is given a few rows earlier (configured channel not found), but these important  log lines don&#8217;t appear in the output of &#8220;systemctl status hostapd&#8221;, as they&#8217;re cut out.</p>
<h3>Preparing for kernel compilation</h3>
<p>In theory, I could have compiled the driver only, and replaced the files in the /lib/modules directory. But I&#8217;m in for a minimal change, and minimal brain effort. So the technique is to download the entire kernel, compile things that don&#8217;t really need compilation. Then pinpoint the correction, and recompile only that.</p>
<p>Unfortunately, Ubuntu&#8217;s view on kernel compilation seems to be that it can only be desired for preparing a deb package. After all, who wants to do anything else? So it gets a bit off the regular kernel compilation routine.</p>
<p>OK, so first I had to install some stuff:</p>
<pre># apt install libssl-dev
# apt install libelf-dev</pre>
<p><span style="text-decoration: line-through;"> </span></p>
<p>Download the kernel (took me 25 minutes):</p>
<pre>$ time git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git</pre>
<h3>Compilation</h3>
<p>The trick is to make the modules of a kernel that is identical to the running one (so there won&#8217;t be any bugs due to mismatches) and also match the kernel version string exactly (or the module won&#8217;t load).</p>
<p>Check out tag Ubuntu-4.15.0-20.21 (in my case, for 4.15.0-20-generic). This matches the kernel definition at the beginning of dmesg (and also the compilation date).</p>
<p><strong>Follow <a href="https://billauer.se/blog/2014/05/kernel-version-git/" target="_blank">this post</a> and to prevent the &#8220;+&#8221; at the end of the kernel version.</strong></p>
<p>Change directory to the kernel tree&#8217;s root, and copy the config file:</p>
<pre>$ cp /boot/config-`uname -r` .config</pre>
<p>Make sure the configuration is in sync:</p>
<pre>$ make oldconfig</pre>
<p>There will be some output, but no configuration question should be made &#8212; if that happens, it&#8217;s a sign that the wrong kernel revision has been checked out. In fact,</p>
<pre>$ diff /boot/config-`uname -r` .config</pre>
<p>should only output the difference in one comment line (the file&#8217;s header).</p>
<p>And then run the magic command:</p>
<pre>$ fakeroot debian/rules clean</pre>
<p style="padding-left: 30px;"><em>Don&#8217;t ask me what it&#8217;s for (I took it from <a href="https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel" target="_blank">this page</a>), but among others, it does</em></p>
<p><em> </em></p>
<pre style="padding-left: 30px;"><em>cp debian/scripts/retpoline-extract-one scripts/ubuntu-retpoline-extract-one</em></pre>
<p><em> </em></p>
<p style="padding-left: 30px;"><em>and without it one gets the following error:</em></p>
<p><em> </em></p>
<pre style="padding-left: 30px;"><em>/bin/sh: ./scripts/ubuntu-retpoline-extract-one: No such file or directory</em></pre>
<p>Ready to go, then. Compile only the modules. The kernel image itself is of no interest:</p>
<pre>$ time make KERNELVERSION=`uname -r` -j 12 modules &amp;&amp; echo Success</pre>
<p>The -j 12 flag means running 12 processes in parallel. Pick your own favorite, depending in the CPU&#8217;s core count. Took 13 minutes on my machine.</p>
<p>Alternatively, compile just the relevant subdirectory. Quicker, no reason it shouldn&#8217;t work, but this is not how I did it myself:</p>
<pre>
<pre>$ make prepare scripts
$ time make KERNELVERSION=`uname -r` -j 12 M=drivers/net/wireless/ath/ &amp;&amp; echo Success</pre>
</pre>
<p>And then use the same command when repeating the compilation below, of course.</p>
<h3>Modify the ath.c file</h3>
<p>Following <a href="https://www.kdaye.com/ap-5ghz-ath10k/" target="_blank">this post</a> (more or less) , edit drivers/net/wireless/ath/regd.c and neutralize the following functions with a &#8220;return&#8221; immediately after variable declarations. Or replace them with functions just returning immediately.</p>
<ul>
<li>ath_reg_apply_beaconing_flags()</li>
<li>ath_reg_apply_ir_flags()</li>
<li>ath_reg_apply_radar_flags()</li>
</ul>
<p>Also add a &#8220;return 0&#8243; in ath_regd_init_wiphy() just before the call to wiphy_apply_custom_regulatory(), so the three calls to apply-something functions are skipped. In the <a href="https://www.kdaye.com/ap-5ghz-ath10k/" target="_blank">said post</a>, the entire init function was disabled, but I found that unnecessarily aggressive (and probably breaks something).</p>
<p>Note that there&#8217;s e.g. __ath_reg_apply_beaconing_flags() functions. These are not the ones to edit.</p>
<p>And then recompile:</p>
<pre>$ make KERNELVERSION=`uname -r` modules &amp;&amp; echo Success</pre>
<p>This recompiles regd.c and ath.c, and the generates ath.ko. Never mind that the file is huge (2.6 MB) in comparison with the original one (40 kB). Once in the kernel, they occupy the same size.</p>
<p>As root, rename the existing ath.ko in /lib/modules/`uname -r`/kernel/drivers/net/wireless/ath/ to something else (with a non-ko extension, or it remains in the dependency files), and copy the new one (from drivers/net/wireless/ath/) to the same place.</p>
<p>Unload modules from kernel:</p>
<pre># rmmod ath10k_pci &amp;&amp; rmmod ath10k_core &amp;&amp; rmmod ath</pre>
<p>and reload:</p>
<pre># modprobe ath10k_pci</pre>
<p>And check the result (yay):</p>
<pre># iw list
<em><span style="color: #888888;">[ ... ]</span></em>
		Frequencies:
			* 5180 MHz [36] (30.0 dBm)
			* 5200 MHz [40] (30.0 dBm)
			* 5220 MHz [44] (30.0 dBm)
			* 5240 MHz [48] (30.0 dBm)
			* 5260 MHz [52] (30.0 dBm)
			* 5280 MHz [56] (30.0 dBm)
			* 5300 MHz [60] (30.0 dBm)
			* 5320 MHz [64] (30.0 dBm)
			* 5500 MHz [100] (30.0 dBm)
			* 5520 MHz [104] (30.0 dBm)
			* 5540 MHz [108] (30.0 dBm)
			* 5560 MHz [112] (30.0 dBm)
			* 5580 MHz [116] (30.0 dBm)
			* 5600 MHz [120] (30.0 dBm)
			* 5620 MHz [124] (30.0 dBm)
			* 5640 MHz [128] (30.0 dBm)
			* 5660 MHz [132] (30.0 dBm)
			* 5680 MHz [136] (30.0 dBm)
			* 5700 MHz [140] (30.0 dBm)
			* 5720 MHz [144] (30.0 dBm)
			* 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] (30.0 dBm)
<em><span style="color: #888888;">[ ... ]</span></em></pre>
<p>The no-IR marks are gone, and hostapd now happily uses these channels.</p>
<h3>Probably not: Upgrading firmware</h3>
<p>As I first through that the the problem was an old firmware version, as discussed on <a href="https://ubuntuforums.org/showthread.php?t=2325359&amp;page=2" target="_blank">this forum post</a>, I went for upgrading it. These are my notes on that. Spoiler: It was probably unnecessary, but I&#8217;ll never know, and neither will you.</p>
<p>From the dmesg output:</p>
<pre>[   16.152377] ath10k_pci 0000:03:00.0: Direct firmware load for ath10k/pre-cal-pci-0000:03:00.0.bin failed with error -2
[   16.152387] ath10k_pci 0000:03:00.0: Direct firmware load for ath10k/cal-pci-0000:03:00.0.bin failed with error -2
[   16.201636] ath10k_pci 0000:03:00.0: qca6174 hw3.2 target 0x05030000 chip_id 0x00340aff sub 1a56:1535
[   16.201638] ath10k_pci 0000:03:00.0: kconfig debug 0 debugfs 1 tracing 1 dfs 0 testmode 0
[   16.201968] ath10k_pci 0000:03:00.0: firmware ver WLAN.RM.4.4.1-00079-QCARMSWPZ-1 api 6 features wowlan,ignore-otp crc32 fd869beb
[   16.386440] ath10k_pci 0000:03:00.0: board_file api 2 bmi_id N/A crc32 20d869c3</pre>
<p>I was first mislead to think the firmware wasn&#8217;t loaded, but the later lines indicate it was acutally OK.</p>
<p>Listing the firmware files used by the kernel module:</p>
<pre>$ modinfo ath10k_pci
filename:       /lib/modules/4.15.0-20-generic/kernel/drivers/net/wireless/ath/ath10k/ath10k_pci.ko
firmware:       ath10k/QCA9377/hw1.0/board.bin
firmware:       ath10k/QCA9377/hw1.0/firmware-5.bin
<strong>firmware:       ath10k/QCA6174/hw3.0/board-2.bin
firmware:       ath10k/QCA6174/hw3.0/board.bin
firmware:       ath10k/QCA6174/hw3.0/firmware-6.bin
firmware:       ath10k/QCA6174/hw3.0/firmware-5.bin
firmware:       ath10k/QCA6174/hw3.0/firmware-4.bin
firmware:       ath10k/QCA6174/hw2.1/board-2.bin
firmware:       ath10k/QCA6174/hw2.1/board.bin
firmware:       ath10k/QCA6174/hw2.1/firmware-5.bin
firmware:       ath10k/QCA6174/hw2.1/firmware-4.bin
</strong>firmware:       ath10k/QCA9887/hw1.0/board-2.bin
firmware:       ath10k/QCA9887/hw1.0/board.bin
firmware:       ath10k/QCA9887/hw1.0/firmware-5.bin
firmware:       ath10k/QCA988X/hw2.0/board-2.bin
firmware:       ath10k/QCA988X/hw2.0/board.bin
firmware:       ath10k/QCA988X/hw2.0/firmware-5.bin
firmware:       ath10k/QCA988X/hw2.0/firmware-4.bin
firmware:       ath10k/QCA988X/hw2.0/firmware-3.bin
firmware:       ath10k/QCA988X/hw2.0/firmware-2.bin</pre>
<p>So which firmware file did it load?  Well, there&#8217;s a firmware git repo for Atheros 10k:</p>
<pre>$ git clone https://github.com/kvalo/ath10k-firmware.git</pre>
<p>I&#8217;m not very happy running firmware found just somewhere, but the   author of this Git repo is Kalle Valo, who works at Qualcomm. The Github   account is active since 2010, and the files included in the Linux  kernel are included there. So it looks legit.</p>
<p>Comparing files with the ones  in the Git repo, which states the full  version names, the files loaded were  hw3.0/firmware-6.bin and another  one (board-2.bin, I guess). The former  went into the repo on Decemeber  18, 2017, which is more than a year  after the problem in the forum post  was solved. My firmware is hence  fairly up to date.</p>
<p>Nevertheless, I upgraded to the ones added to the git firmware repo  on November 13, 2018, and re-generated initramfs (not that it should  matter &#8212; using lsinitramfs it&#8217;s clear that none of these firmware files  are there). Did it help? As expected, no. But hey, now I have the  latest and shiniest firmware:</p>
<pre>[   16.498706] ath10k_pci 0000:03:00.0: firmware ver WLAN.RM.4.4.1-00124-QCARMSWPZ-1 api 6 features wowlan,ignore-otp crc32 d8fe1bac
[   16.677095] ath10k_pci 0000:03:00.0: board_file api 2 bmi_id N/A crc32 506ce037</pre>
<p>Exciting! Not.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2018/12/tara-5-ghz-hostapd-atheros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SOLVED: Lenovo Yoga 2 13&#8243; with &#8220;hardware-disabled&#8221; Wifi</title>
		<link>https://billauer.se/blog/2014/08/linux-ubuntu-yoga-hardware-blocked-wireless-lan/</link>
		<comments>https://billauer.se/blog/2014/08/linux-ubuntu-yoga-hardware-blocked-wireless-lan/#comments</comments>
		<pubDate>Fri, 01 Aug 2014 15:13:35 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux kernel]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=4411</guid>
		<description><![CDATA[Overview Having a Lenovo Yoga 2 13&#8243; (non-pro) running Ubuntu 14.04.1, I couldn&#8217;t get Wireless LAN up and running, as the WLAN NIC appeared to be &#8220;hardware locked&#8221;. This is the summary of how I solved this issue. If you&#8217;re not interested in the gory details, you may jump right to bottom, where I offer [...]]]></description>
			<content:encoded><![CDATA[<h3>Overview</h3>
<p>Having a Lenovo Yoga 2 13&#8243; (non-pro) running Ubuntu 14.04.1, I couldn&#8217;t get Wireless LAN up and running, as the WLAN NIC appeared to be &#8220;hardware locked&#8221;. This is the summary of how I solved this issue. If you&#8217;re not interested in the gory details, you may jump right to bottom, where I offer a replacement module that fixes it. At least for me.</p>
<p>Environment details: Distribution kernel 3.13.0-32-generic on an Intel i5-4210U CPU @  1.70GHz. The Wifi device is an <a href="http://ark.intel.com/products/75439/Intel-Dual-Band-Wireless-AC-7260" target="_blank">Intel Dual Band Wireless-AC 7260</a> (8086:08b1) connected to the PCIe bus, taken care of by the <a href="http://wireless.kernel.org/en/users/Drivers/iwlwifi" target="_blank">iwlwifi driver.</a></p>
<h3>The problem</h3>
<p>Laptops have a mechanism for working in &#8220;flight mode&#8221; which means turning off any device that could emit RF power, so that the airplane can crash for whatever different reason. Apparently, some laptops have a physical on-off switch to request this, but on Lenovo Yoga 13, the arrangement is to press a button on the keyboard with an airplane drawn on it. The one shared with F7.</p>
<p>It seems to be, that on Lenovo Yoga 13, the ACPI interface, which is responsible for reporting the Wifi&#8217;s buttons state, always reports that it&#8217;s in flight mode. So Linux turns off Wifi, and on the desktop&#8217;s Gnome network applet it says &#8220;Wi-Fi is disabled by hardware switch&#8221;.</p>
<p>In the dmesg log one can tell the problem with a line like</p>
<pre>iwlwifi 0000:01:00.0: RF_KILL bit toggled to disable radio.</pre>
<p>which  is issued by the interrupt request handler defined in   drivers/net/wireless/iwlwifi/pcie/rx.c, which responds to an   interrupt from the device that informs the host that the hardware RF   kill bit is set. So the iwlwifi module is not to blame here &#8212; it just responds to a request from the ACPI subsystem.</p>
<h3>rfkill</h3>
<p>The management of RF-related devices is handled by the rfkill subsystem. On my laptop, before solving the problem, a typical output went</p>
<pre>$ rfkill list all
0: ideapad_wlan: Wireless LAN
        Soft blocked: yes
        Hard blocked: <strong><span style="color: #ff0000;">yes</span></strong>
1: ideapad_bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: yes
6: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
7: phy1: Wireless LAN
        Soft blocked: yes
        Hard blocked: <span style="color: #ff0000;"><strong>yes</strong></span></pre>
<p>So there are different entities that can be controlled with rfkill, enumerated and assigned soft and hard blocks. Each of these relate to a directory in /sys/class/rfkill/. For example, the last device, &#8220;phy7&#8243; enumerated as 7 corresponds to /sys/class/rfkill/rfkill7, where the &#8220;hard&#8221; and &#8220;soft&#8221; pseudo-files signify the status with &#8220;0&#8243; or &#8220;1&#8243; values.</p>
<p>The soft block can be changed by &#8220;rfkill unblock 0&#8243; or &#8220;rfkill unblock 7&#8243;, but this doesn&#8217;t really help with the hardware block. Both has to be &#8220;off&#8221; to use the device.</p>
<p>As can be seen easily from the rkfill list above, each of the physical devices are registered twice as rfkill devices: Once by their driver, and a second time by the ideapad_laptop driver. This will be used in the solution below.</p>
<h3>The ideapad_laptop module</h3>
<p>The ideapad-laptop module is responsible for talking with the ACPI layer on machines that match &#8220;VPC2004&#8243; as a platform (as in /sys/devices/platform/VPC2004:00, or  /sys/bus/acpi/devices/VPC2004:00, but doesn&#8217;t fit anything found in  /sys/class/dmi/id/).</p>
<p>Blacklisting this module has been suggested for Yoga laptops all over the web. In particular  <a href="http://ubuntuforums.org/showthread.php?t=2215044&amp;page=3" target="_blank">this post</a> suggests to insmod the module once with a hack that forces the Wifi on, and then blacklist it.</p>
<p>But by blacklisting ideapad-laptop, the computer loses some precious functionality, including disabling Wifi and the touchpad by pressing a button. So this is not an appealing solution.</p>
<p>Ideapad&#8217;s two debugfs output files go:</p>
<pre># cat /sys/kernel/debug/ideapad/cfg
cfg: 0x017DE014

Capability: Bluetooth Wireless Camera
Graphic:
# cat /sys/kernel/debug/ideapad/status
Backlight max:	16
Backlight now:	9
BL power value:	On
=====================
<strong>Radio status:	Off(0)
Wifi status:	Off(0)
</strong>BT status:	On(1)
3G status:	Off(0)
=====================
Touchpad status:Off(0)
Camera status:	On(1)</pre>
<p>So the Radio and Wifi statuses, which are read from the ACPI registers, are off. This makes the ideapad_laptop module conclude that everything should go off.</p>
<h3>The solution</h3>
<p>In essence, the solution for the problem is to take the ideapad_laptop&#8217;s hands off the Wifi hardware, except for turning the hardware block off when it&#8217;s loaded. It consists of making the following changes in drivers/platform/x86/ideapad-laptop.c:</p>
<ul>
<li>First, remove the driver&#8217;s rfkill registration. Somewhere at the beginning of the file, change
<pre>#define IDEAPAD_RFKILL_DEV_NUM	(3)</pre>
<p>to</p>
<pre>#define IDEAPAD_RFKILL_DEV_NUM	(2)</pre>
<p>and in the definition of ideapad_rfk_data[], <strong>remove</strong> the line saying</p>
<pre>{ "ideapad_wlan", CFG_WIFI_BIT, VPCCMD_W_WIFI, RFKILL_TYPE_WLAN }</pre>
<p>This prevents the driver from presenting an rfkill interface, so it keeps its hands off.</li>
<li>There is however a chance that the relevant bit in the ACPI layer already has the hardware block on. So let&#8217;s turn it off every time the driver loads. In ideapad_acpi_add(), after the call to ideapad_sync_rfk_state(), more or less, add the following two lines:
<pre>pr_warn("Hack: Forcing WLAN hardware block off\n");
write_ec_cmd(priv-&gt;adev-&gt;handle, VPCCMD_W_WIFI, 1);</pre>
</li>
<li>And finally, solve a rather bizarre phenomenon, that when reading for the RF state with a VPCCMD_R_RF command, the Wifi interface is hardware blocked for some reason. Note that radio is always in off mode, so it&#8217;s a meaningless register on Yoga 2. This is handled in two places. First, empty ideapad_sync_rfk_state() completely, by turning it into
<pre>static void ideapad_sync_rfk_state(struct ideapad_private *priv)
{
}</pre>
<p>This function reads VPCCMD_R_RF and calls rfkill_set_hw_state() accordingly, but on Yoga 2 it will always block everything, so what&#8217;s the point?<br />
Next, in  debugfs_status_show() which prints out /sys/kernel/debug/ideapad/status, remove the following three lines:</p>
<pre>if (!read_ec_data(priv-&gt;adev-&gt;handle, VPCCMD_R_RF, &amp;value))
  seq_printf(s, "Radio status:\t%s(%lu)\n",
    value ? "On" : "Off", value);</pre>
</li>
</ul>
<p>Having these changes made, the Wifi works properly, regardless of it was previously reported hardware blocked.</p>
<p>This can&#8217;t be submitted as a patch to the kernel, because presumably some laptops need the rfkill interface for Wifi through ideapad_laptop (or else, why was it put there in the first place?).</p>
<p>Also, maybe I should have done this for Bluetooth too? Don&#8217;t know. I don&#8217;t use Bluetooth right now, and the desktop applet seems to say all is fine with it anyhow.</p>
<h3>Download the driver fix</h3>
<p>For the lazy ones, I&#8217;ve prepared a little kit for compiling the relevant driver. I&#8217;ve taken the driver as it appears in kernel 3.16, more or less, and applied the changes above. And I then added a Makefile to make it compile easily. Since the kernel API changes rather rapidly, this will probably work well for kernels around 3.16 (that includes 3.13), and then you&#8217;ll have to apply the changes manually. If it isn&#8217;t fixed in the kernel itself by then.</p>
<p>Download it from <a href="https://billauer.se/download/yoga-wifi-fix.zip" target="_blank">here</a>, unzip it, change directory, and compile it with typing &#8220;make&#8221;. This works only if you have the kernel headers and gcc compiler installed, which is usually the case in recent distributions. So a session like this is expected:</p>
<pre>$ make
make -C /lib/modules/3.13.0-32-generic/build SUBDIRS=/home/eli/yoga-wifi-fix modules
make[1]: Entering directory `/usr/src/linux-headers-3.13.0-32-generic'
  CC [M]  /home/eli/yoga-wifi-fix/ideapad-laptop.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/eli/yoga-wifi-fix/ideapad-laptop.mod.o
  LD [M]  /home/eli/yoga-wifi-fix/ideapad-laptop.ko
make[1]: Leaving directory `/usr/src/linux-headers-3.13.0-32-generic'</pre>
<p>Then replace the fresh ideapad-laptop.ko with the one the kernel uses. First, let&#8217;s figure out where to. The modinfo command help here:</p>
<pre>$ modinfo ideapad_laptop
filename:       <span style="color: #ff0000;"><strong>/lib/modules/3.13.0-32-generic/kernel/drivers/platform/x86/</strong></span>ideapad-laptop.ko
license:        GPL
description:    IdeaPad ACPI Extras
author:         David Woodhouse &lt;dwmw2@infradead.org&gt;
srcversion:     BA339D663FA3B10105A1DC0
alias:          acpi*:VPC2004:*
depends:        sparse-keymap
vermagic:       3.13.0-32-generic SMP mod_unload modversions
parm:           no_bt_rfkill:No rfkill for bluetooth. (bool)</pre>
<p>So the directory is now known (marked in red). This leaves us with copying it into the right place:</p>
<pre>$ sudo cp ideapad-laptop.ko /lib/modules/3.13.0-32-generic/kernel/drivers/platform/x86/</pre>
<p>The new module is valid on the next reboot. Or the next insmod/modprobe, if you&#8217;re have the same allergy as myself regarding rebooting a Linux system.</p>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2014/08/linux-ubuntu-yoga-hardware-blocked-wireless-lan/feed/</wfw:commentRss>
		<slash:comments>83</slash:comments>
		</item>
		<item>
		<title>Wifi Access Point on my desktop with USB dongles</title>
		<link>https://billauer.se/blog/2014/06/linux-realtek-hostapd/</link>
		<comments>https://billauer.se/blog/2014/06/linux-realtek-hostapd/#comments</comments>
		<pubDate>Sat, 21 Jun 2014 15:28:10 +0000</pubDate>
		<dc:creator>eli</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">https://billauer.se/blog/?p=4325</guid>
		<description><![CDATA[Introduction These are my rather messy notes as I set up a wireless access point on my desktop (Fedora 12) running a home-compiled 3.12.20 Linux kernel. Somewhere below (see &#8220;Rubbish starts here&#8221;) I&#8217;ve added things that I tried out but lead nowhere. Beware. I began with two USB dongles, 8188EU and 8192CU. I got 8188EU [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>These are my rather messy notes as I set up a wireless access point on my desktop (Fedora 12) running a home-compiled 3.12.20 Linux kernel. Somewhere below (see &#8220;Rubbish starts here&#8221;) I&#8217;ve added things that I tried out but lead nowhere. Beware.</p>
<p>I began with two USB dongles, 8188EU and 8192CU. I got 8188EU up and running with Realtek&#8217;s hostapd and driver, but only for the 2.4 GHz band. So I bought a RaLink-based <a href="http://www.ebay.com/itm/300M-USB-WiFi-Wireless-802-11a-b-g-n-Adapter-Dual-Band-2-4G-5G-Network-LAN-Card-/281271431446?pt=US_USB_Wi_Fi_Adapters_Dongles&amp;hash=item417d157116">dual-band USB dongle</a>, and ran it with the kernel&#8217;s built-in driver and an updated version of hostapd (it&#8217;s hardware neutral however). If you want it, search E-Bay for &#8220;300m USB Wifi dual band&#8221;. It should look like this, and cost some $15 or so:</p>
<p><a href="https://billauer.se/blog/wp-content/uploads/2014/06/dongle.jpg"><img class="aligncenter size-medium wp-image-4439" title="Dual band Wifi USB dongle" src="https://billauer.se/blog/wp-content/uploads/2014/06/dongle-300x164.jpg" alt="Dual band Wifi USB dongle" width="300" height="164" /></a></p>
<p>This dongle is what I ended up using. <strong>You may skip to &#8220;Dual-band dongle&#8221; below</strong> if you don&#8217;t care about the other things I tried out before I chose this one.</p>
<p>The purpose is a manual setup for occasional use. There are plenty of similar writeouts, like <a href="https://nims11.wordpress.com/2012/04/27/hostapd-the-linux-way-to-create-virtual-wifi-access-point/comment-page-4/" target="_blank">this one</a>.</p>
<p>It&#8217;s very easy to get mixed up with all those do-this-do-that howtos, and forget one simple fact: A wireless NIC is just another Ethernet card that happens not to have a cable. The authentication of a wireless link takes place with plain Ethernet packets, and once the two sides agree on talking with each other, it&#8217;s back to two Ethernet cards with a cross cable.</p>
<p>To make a machine serve as an access point, the NIC must support Master mode, and there must be software running that plays the role of authenticating clients and setting up encryption. But in the end of the day, that all there is to it. Linux&#8217; daemon for doing this is <strong>hostapd</strong>.</p>
<p>The swiss army knives are &#8220;<a href="http://wireless.kernel.org/en/users/Documentation/iw" target="_blank">iw</a>&#8220;, &#8220;iwconfig&#8221; and &#8220;iwlist&#8221;. Try &#8220;iw help&#8221; in particular.</p>
<h3>In short</h3>
<ol>
<li>Plug in device &#8212; driver autoloads</li>
<li>Bring up the device with ifconfig (assign an IP address)</li>
<li>Switch regulation region, if the 5 GHz band is required (and the device reports old and over-restrictive regulation rules):
<pre># iw reg set GD</pre>
</li>
<li>Restart dhcpd, so that it listens for requests on wlan0</li>
<li>Start hostapd</li>
</ol>
<h3>Realtek vs. community</h3>
<p>There are two completely different takes on getting the Wifi working. One is to use the tools that are maintained by the community: The hostapd that arrives along with distributions, and the drivers compiled in the kernel. Well, as of June 2014, that&#8217;s not a go with Realtek&#8217;s USB Wifi dongles.</p>
<p>The thing is that the typical distribution hostapd expects to find the kernel&#8217;s native interface, which is implemented in the cfg80211 and mac80211 kernel modules. These modules are supposed to talk with the low-level hardware drivers. Very structured and nice. Only hi-tec companies don&#8217;t always play ball with the kernel community.</p>
<p>Realtek, in this case, chose to compile together everything, including the higher level frontend source code, and make a single kernel module of that. Kinda makes sense when all you need is a single driver for your specific hardware (a bit like static linking of a program), but not when that hardware is just one of many to be supported.</p>
<p>For example, the kernel&#8217;s 8192CU driver (appears as rtl8192cu on lsmod  with ~79kB) relies on the kernel&#8217;s low-level modules (which are mac80211. cfg80211, rtl8192c_common, rtl_usb, rtlwifi), but  the Realtek driver has everything in a single module, which appears as  8192cu and takes ~526kB.</p>
<p>Now to hostapd: The distribution&#8217;s version are minded on the kernel&#8217;s native interface (&#8220;driver=nl80211&#8243;) with some partial support for Realtek&#8217;s drivers (&#8220;driver=rtl871x&#8221;), so all in all, if you use Realtek&#8217;s kernel drivers, use their hostapd as well.</p>
<p>My chosen solution (well, no-other-choice solution) was to compile the Realtek&#8217;s kernel modules and hostapd. With slight variations.</p>
<p>So first is a summary of commands when things finally work, and then the battle field (compilations from sources etc.).</p>
<h3>ifconfig</h3>
<p>This is necessary for the already running DHCP daemon to answer requests from   wireless clients. This ifconfig command is also the moment at which the   firmware is loaded (and not when the driver loads, as one could  expect).</p>
<p><strong>Important:</strong> Remember that routing rules apply like any Ethernet card, so don&#8217;t pick an IP address space that is already accounted for in the access point&#8217;s routing table. Doing that mistake will not just make pings fail, but the access point will also ignore ARP requests (see below).</p>
<pre># ifconfig wlan0 10.10.0.1 netmask 255.255.255.0
# service dhcpd restart</pre>
<h3>Starting hostapd</h3>
<pre># service hostapd start</pre>
<p>or running in the foreground, with a lot of debug output</p>
<pre># hostapd -dd /etc/hostapd/hostapd.conf</pre>
<p>Note that when hostapd is running in the foreground and is stopped with CTRL-C, unplugging and replugging the device may be necessary before re-attempting to work with it.</p>
<h3>What happens if you pick a bad IP address</h3>
<p>For some reason, I had the silly idea that since my internal LAN&#8217;s subnet is 10.1.0.0/16, I should assign my wlan0 card the address 10.1.1.123, so it will natively belong to the LAN. What I didn&#8217;t realize was that another NIC is already assigned for handling 10.1.0.0/16, so wlan0 will never get packets routed to it.</p>
<p>Even worse, the wireless adapter will not answer to ARP requests, which kinda makes sense &#8212; the wireless adapter &#8220;knows&#8221; that it can&#8217;t work with the IP address it has, so it might as well not announce any IP connectivity. The interesting thing was that ping requests were ignored completely as well. It&#8217;s not like the replies went out on NIC to which the IP subnet belongs. There was no reply packet at all. Which again, makes sense, because pings are not supposed to go out on another NIC. That could potentially confuse someone into thinking that the link is OK (in case there was a way for the reply to reach the requester).</p>
<p>In grey, with a line-over, here is the description of the problem, as I saw it <strong>before I solved it</strong>. Just in case someone is stuck in the same situation.</p>
<div style="color: #888888; text-decoration: line-through;">
<p>At this point, I can connect to the Access Point from Windows XP  (even with a client having poor WPA support) as well as Linux with  seemingly no problem. But there&#8217;s no real internet access. The reason  seems to be, that the USB dongle doesn&#8217;t seem to be connected with its  IP protocol layer. Ethernet packets go through well, as can be seen in  sniff dumps on both sides, and the client manages to acquire an address  with DHCP, because it depends only on plain MAC packets.</p>
<p>Despite setting an address with ifconfig (or &#8220;ip address add&#8221; for  that matter), the dongle doesn&#8217;t respond to ARP requests asking for the  address it has, and doesn&#8217;t respond to pings.</p>
<p>ARP packets are sent properly from the dongle (acting as AP) and the  responses from the client arrive fine as well (when asking for the  address of the client&#8217;s Wifi NIC as well as another wired Ethernet NIC,  both are answered).</p>
<pre># arping -I wlan0 10.1.1.166
ARPING 10.1.1.166 from 10.1.1.123 wlan0
Unicast reply from 10.1.1.166 [00:0E:2E:40:5B:11]  48.329ms
Unicast reply from 10.1.1.166 [00:0E:2E:40:5B:11]  80.612ms
Unicast reply from 10.1.1.166 [00:0E:2E:40:5B:11]  104.531ms</pre>
<p>but not on the other way (from the client):</p>
<pre># arping -I wlan0 10.1.1.123</pre>
<p>(nothing happens)</p>
<p>Now, if the access point sends a gratuitous ARP to the client:</p>
<pre># arping -A -I wlan0 10.1.1.123</pre>
<p>the client can send ping packets to the access point. These ICMP  packets appear in the sniff dump of wlan0 on both sides, but the access  point doesn&#8217;t reply. So did pinging to the broadcast address. The  packets were seen at the access point&#8217;s sniff dumps with all 0xff&#8217;s MAC  address, but with no response:</p>
<pre># ping -b 10.1.255.255</pre>
<p>This is not a firewall issue. The problem remains with the firewall taken down. Both USB dongles have this same problem.</p>
</div>
<h3>Compiling Realtek&#8217;s driver for RTL8188EU</h3>
<p>Possible reason why this is necessary: The USB device  is V2.0 according to the package, and the newer version contains  firmware. Anyhow,</p>
<pre>$ git clone https://github.com/lwfinger/rtl8188eu.git</pre>
<p>A plain &#8220;make&#8221; compiled the code cleanly on kernel 3.12.20 (using   commit ID 63fe7cda86c2830d66335026efde7472c10bc5c2). Copy firmware (also   in Git bundle):</p>
<pre># cp rtl8188eufw.bin /lib/firmware/rtlwifi/</pre>
<p>(well, I ended up doing &#8220;make install&#8221;. After removing the existing driver from the staging subdirectory).</p>
<h3>Compiling Realtek&#8217;s driver for RTL8192CU</h3>
<p>Following <a href="http://www.daveconroy.com/turn-your-raspberry-pi-into-a-wifi-hotspot-with-edimax-nano-usb-ew-7811un-rtl8188cus-chipset/" target="_blank">this guide</a>, went to <a href="http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&amp;PNid=21&amp;PFid=48&amp;Level=5&amp;Conn=4&amp;DownTypeID=3&amp;GetDown=false" target="_blank">Realtek&#8217;s site</a>,    and download something like    RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip (ZIP??!), untarred    wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz.</p>
<p>Tried to compile from this zip file (under &#8220;driver&#8221;). Compilation failed against my kernel (3.12) on the  change of the &#8220;create_proc_entry&#8221; API. So instead, I went for</p>
<pre>$ git clone https://github.com/pvaret/rtl8192cu-fixes.git</pre>
<p>and compiled cleanly from commit ID f0dfbb46a891820b27942ba3e213af83f2452957.</p>
<h3>Compiling and running Realtek&#8217;s hostapd</h3>
<p>From the zip file that I downloaded from Realtek, went to the hostapd subdirectory in    wpa_supplicant_hostapd/, and typed &#8220;make&#8221;. Compiled cleanly, and generated a &#8220;hostapd&#8221;   and &#8220;hostapd_cli&#8221; executables. Yey.</p>
<p>And that actually worked! Note that the rtl871x driver is picked even  though the &#8220;driver=&#8221; isn&#8217;t assigned at all in hostapd.conf.</p>
<pre># hostapd -d /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
ctrl_interface_group=0
eapol_version=1
drv-&gt;ifindex=35
l2_sock_recv==l2_sock_xmit=0x0x1203be0
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
Completing interface initialization
Mode: IEEE 802.11g  Channel: 4  Frequency: 2427 MHz
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x1
RATE[3] rate=110 flags=0x1
RATE[4] rate=60 flags=0x0
RATE[5] rate=90 flags=0x0
RATE[6] rate=120 flags=0x0
RATE[7] rate=180 flags=0x0
RATE[8] rate=240 flags=0x0
RATE[9] rate=360 flags=0x0
RATE[10] rate=480 flags=0x0
RATE[11] rate=540 flags=0x0
Flushing old station entries
Deauthenticate all stations
+rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
Using interface wlan0 with hwaddr c0:4a:00:18:ef:21 and ssid 'ocho'
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=4):
 6f 63 68 6f                                       ocho           
PSK (ASCII passphrase) - hexdump_ascii(len=9): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVED]
rtl871x_set_wps_assoc_resp_ie
rtl871x_set_wps_beacon_ie
rtl871x_set_wps_probe_resp_ie
urandom: Got 20/20 bytes from /dev/urandom
GMK - hexdump(len=32): [REMOVED]
Key Counter - hexdump(len=32): [REMOVED]
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
GTK - hexdump(len=32): [REMOVED]
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
rtl871x_set_key_ops
rtl871x_set_beacon_ops
rtl871x_set_hidden_ssid ignore_broadcast_ssid:0, ocho,4
rtl871x_set_acl
wlan0: Setup of interface done.</pre>
<p>But with WPA authentication enabled, I got a lot of</p>
<pre>hostapd: wlan0: STA 00:0e:2e:40:5b:94 IEEE 802.11: associated
hostapd: wlan0: STA 00:0e:2e:40:5b:94 IEEE 802.11: deauthenticated due to local deauth request
hostapd: wlan0: STA 00:0e:2e:40:5b:94 IEEE 802.11: disassociated</pre>
<p>It was also evident sniffing wlan0   that EAPOL WPA key (254) frames were sent to the client, but they didn&#8217;t   get answered, which is probably the reason for the whole thing, as   mentioned on <a href="http://madwifi-project.org/wiki/UserDocs/HostAP" target="_blank">this page</a>.</p>
<p>The solution was to restrict the protocol to version 1 with</p>
<pre>eapol_version=1</pre>
<p>in hostapd.conf. This problem occurred only when I used the RT2500   utility on the Windows laptop. Using Windows XP&#8217;s native wireless   selection tool connected well either way.</p>
<h3>8192CU is single band. Really.</h3>
<p>I tried to work with the 8192CU dongle, because it supposedly supports the 5 GHz band as well. The 2.4 GHz is heavily crowded. I don&#8217;t know why I got the impression that it&#8217;s dual-band. Anyhow,</p>
<pre># cp 8192cu.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless/
# depmod -a</pre>
<p>and also blacklist the kernel&#8217;s native driver by adding the following lines to /etc/modprobe.d/blacklist.conf</p>
<pre># Native Wifi drivers not usable as accept points
blacklist rtl8192cu
blacklist rtl8192c_common</pre>
<p>To see the list of channels:</p>
<pre>$ iwlist wlan0 freq</pre>
<p>Darn, only 2.4 GHz! It even says so on Realtek&#8217;s <a href="http://www.realtek.com/products/productsView.aspx?Langid=2&amp;PFid=48&amp;Level=5&amp;Conn=4&amp;ProdID=277" target="_blank">site</a>: &#8220;Complete 802.11n MIMO solution for 2.4GHz band&#8221; and &#8220;Single-Band 11n (2x2) WLAN USB Dongle&#8221;.</p>
<p>Besides, the signal it transmits appears to be really lousy. I got a really bad link quality (but hey, this is a cheapo dongle from Ebay).</p>
<h3>Compiling hostapd from the sources</h3>
<p>First, install libnl-devel, which is required for compiling hostapd:</p>
<pre># yum install libnl-devel</pre>
<p>Download from the hostapd&#8217;s <a href="http://wireless.kernel.org/en/users/Documentation/hostapd" target="_blank">main page</a>, copy the config file and compile:</p>
<pre>$ git clone git://w1.fi/srv/git/hostap.git
$ cd hostap/hostapd
$ git checkout hostap_2_2
$ cp defconfig .config
$ make</pre>
<h3>Dual-band dongle</h3>
<p>Plugged in an MediaTek (formerly RaLink) <a href="https://wikidevi.com/wiki/Ralink_RT5572" target="_blank">RT5572</a>-based no-brand dongle (0x148f/0x5572) into my computer with kernel 3.12. Was detected right away. &#8220;iw list&#8221; gave a long answer, so revert to the original hostapd, and pick driver=nl80211. The driver handling it was rt2800usb, along with its dependencies, rt2800usb, rt2x00usb, rt2x00lib, mac80211 and cfg80211.</p>
<p>The Linux drivers <a href="http://www.mediatek.com/en/downloads/" target="_blank">MediaTek&#8217;s site</a> were last updated in 2010, supporting kernel 2.4.0, but the rt2800usb driver seems to be maintained properly with occasional patches. So it looks like the kernel&#8217;s built-in driver is the best choice. The RT5572 was <a href="http://rt2x00.serialmonkey.com/pipermail/users_rt2x00.serialmonkey.com/2013-March/005801.html" target="_blank">added in March 2013</a> to kernel 3.10.</p>
<p>Attempted to run hostapd, it said</p>
<pre># hostapd -dd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
ctrl_interface_group=0
eapol_version=1
<span style="color: #ff0000;"><strong>ioctl[SIOCSIFFLAGS]: No such file or directory</strong></span>
nl80211 driver initialization failed.
wlan1: Unable to setup interface.
rmdir[ctrl_interface]: No such file or directory</pre>
<p>That wasn&#8217;t very helpful, but looking at the system log was:</p>
<pre>ieee80211 phy0: rt2x00lib_request_firmware: Info - Loading firmware file 'rt2870.bin'
ieee80211 phy0: rt2x00lib_request_firmware: Error - Failed to request Firmware</pre>
<p>Ah, yes. A firmware file. Taken from the Linux Firmware Git repo,</p>
<pre># cp rt2870.bin /lib/firmware/</pre>
<p>(note that it&#8217;s NOT to rtlwifi. The is RaLink, not RealTek).</p>
<p>At which point I got a lot of output from hostapd -dd, but it ended with</p>
<pre>Could not set DTIM period for kernel driver</pre>
<p>This <a href="http://lists.shmoo.com/pipermail/hostap/2010-February/021118.html" target="_blank">seems to be</a> an hostapd issue (I ran 0.6.9), as the driver is stable. Compiling hostapd-2.2 solved this (see just above), and the dongle works nicely as an access point.</p>
<h3>Access point at 5 GHz</h3>
<p>The whole point with this dual-band dongle was to run the access point at 5 GHz, and avoid all the noise from my neighbors. But alas, requesting a 5 GHz channel with hostapd -dd, says, somewhere in the middle:</p>
<pre>channel [40] (157) is disabled for use in AP mode, flags: 0x1
wlan1: IEEE 802.11 Configured channel (157) not found from the channel list of current mode (2) IEEE 802.11a
wlan1: IEEE 802.11 Hardware does not support configured channel
Could not select hw_mode and channel. (-3)
wlan1: interface state UNINITIALIZED-&gt;DISABLED
wlan1: AP-DISABLED
wlan1: Unable to setup interface.</pre>
<p>Hmmm&#8230; I failed twice here. The frequency isn&#8217;t allowed here, and the 5 GHz band is blocked altogether.</p>
<p>Indeed,</p>
<pre>$ iw list
Wiphy phy2
 Band 1:
 Capabilities: 0x2f2
<span style="color: #888888;"> [...]</span>
 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)
 * 2472 MHz [13] (20.0 dBm)
 * 2484 MHz [14] (disabled)
 Bitrates (non-HT):
 * 1.0 Mbps
 * 2.0 Mbps (short preamble supported)
 * 5.5 Mbps (short preamble supported)
 * 11.0 Mbps (short preamble supported)
 * 6.0 Mbps
 * 9.0 Mbps
 * 12.0 Mbps
 * 18.0 Mbps
 * 24.0 Mbps
 * 36.0 Mbps
 * 48.0 Mbps
 * 54.0 Mbps
 Band 2:
 Capabilities: 0x2f2
 HT20/HT40
<span style="color: #888888;"> [...]</span>
 Frequencies:
 * 5180 MHz [36] (disabled)
 * 5190 MHz [38] (disabled)
 * 5200 MHz [40] (disabled)
 * 5210 MHz [42] (disabled)
 * 5220 MHz [44] (disabled)
 * 5230 MHz [46] (disabled)
 * 5240 MHz [48] (disabled)
 * 5250 MHz [50] (disabled)
 * 5260 MHz [52] (disabled)
 * 5270 MHz [54] (disabled)
 * 5280 MHz [56] (disabled)
 * 5290 MHz [58] (disabled)
 * 5300 MHz [60] (disabled)
 * 5310 MHz [62] (disabled)
 * 5320 MHz [64] (disabled)
 * 5500 MHz [100] (disabled)
 * 5510 MHz [102] (disabled)
 * 5520 MHz [104] (disabled)
 * 5530 MHz [106] (disabled)
 * 5540 MHz [108] (disabled)
 * 5550 MHz [110] (disabled)
 * 5560 MHz [112] (disabled)
 * 5570 MHz [114] (disabled)
 * 5580 MHz [116] (disabled)
 * 5590 MHz [118] (disabled)
 * 5600 MHz [120] (disabled)
 * 5610 MHz [122] (disabled)
 * 5620 MHz [124] (disabled)
 * 5630 MHz [126] (disabled)
 * 5640 MHz [128] (disabled)
 * 5650 MHz [130] (disabled)
 * 5660 MHz [132] (disabled)
 * 5670 MHz [134] (disabled)
 * 5680 MHz [136] (disabled)
 * 5690 MHz [138] (disabled)
 * 5700 MHz [140] (disabled)
 * 5745 MHz [149] (disabled)
 * 5755 MHz [151] (disabled)
 * 5765 MHz [153] (disabled)
 * 5775 MHz [155] (disabled)
 * 5785 MHz [157] (disabled)
 * 5795 MHz [159] (disabled)
 * 5805 MHz [161] (disabled)
 * 5825 MHz [165] (disabled)
 * 4920 MHz [-16] (disabled)
 * 4940 MHz [-12] (disabled)
 * 4960 MHz [-8] (disabled)
 * 4980 MHz [-4] (disabled)
 Bitrates (non-HT):
 * 6.0 Mbps
 * 9.0 Mbps
 * 12.0 Mbps
 * 18.0 Mbps
 * 24.0 Mbps
 * 36.0 Mbps
 * 48.0 Mbps
 * 54.0 Mbps
<span style="color: #888888;"> [...]</span></pre>
<p>Are you kidding me? Disabled? Well, no wonder. The kernel thinks 5 GHz is disallowed:</p>
<pre>$ iw reg get
country IL:
 (2402 - 2482 @ 40), (N/A, 20)</pre>
<p>Where did it get that from? A peek on dmesg reveals the answer:</p>
<pre>cfg80211: Calling CRDA to update world regulatory domain
cfg80211: World regulatory domain updated:
cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
cfg80211:   (2457000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm)
cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm)
usb 5-1.4: reset full-speed USB device number 9 using uhci_hcd
ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5592, rev 0222 detected
ieee80211 phy0: rt2x00_set_rf: Info - RF chipset 000f detected
ieee80211 phy0: Selected rate control algorithm 'minstrel_ht'
usbcore: registered new interface driver rt2800usb
cfg80211: Calling CRDA for country: IL
cfg80211: Regulatory domain changed to country: IL
cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
cfg80211:   <span style="color: #ff0000;"><strong>(2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm)</strong></span></pre>
<p>The thing is that according to local regulations, the lower 5 GHz band is allowed for indoor use. My initial choice of channel 157 is probably illegal here (see <a href="http://en.wikipedia.org/wiki/List_of_WLAN_channels" target="_blank">Wikipedia&#8217;s list</a>). But hey, some channels are still open on the 5 GHz band! It&#8217;s also interesting to note that some of 5 GHz channels that are banned for Wifi are allowed for <a href="http://www.moc.gov.il/sip_storage/FILES/0/390.pdf" target="_blank">amateur radio</a> (also see <a href="http://en.wikipedia.org/wiki/5-centimeter_band" target="_blank">this</a> and <a href="http://en.wikipedia.org/wiki/ISM_band" target="_blank">this</a>).</p>
<p>As the regulations for each country is taken from some ROM on the hardware device itself, it&#8217;s probably outdated.</p>
<p>The ugly solution is to switch regulation country. For example, Granada has a relatively relaxed setting:</p>
<pre># iw reg set GD</pre>
<p>A full list of these country codes can be found <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" target="_blank">here</a>. &#8220;BO&#8221; (for Bolivia) is also worth a try.</p>
<p>Now the responsibility is on me to pick a legal frequency. For example, anywhere between 36-48.</p>
<hr />
<h3>Rubbish starts here</h3>
<p>From this point on, it&#8217;s just random stuff that I tried out, and didn&#8217;t lead anywhere. But since I write as I work, why delete it? Maybe it helps someone as is.</p>
<div style="color: #888888; text-decoration: line-through;">
<h3>Plugging in a TL-WN725N before switching to Realtek&#8217;s drivers</h3>
<p><del></del></p>
<pre><span style="color: #888888;">usb 2-2.2: Product: 802.11n NIC
usb 2-2.2: Manufacturer: Realtek
usb 2-2.2: SerialNumber: 00E04C0001
r8188eu: module is from the staging directory, the quality is unknown, you have been warned.
Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0)
usbcore: registered new interface driver r8188eu</span></pre>
<p><span style="color: #888888;">Check if it&#8217;s ready to be an access point:</span></p>
<pre><span style="color: #888888;"># iwconfig wlan0 mode master
# iwconfig wlan0
wlan0     unassociated  Nickname:"&lt;WIFI@REALTEK&gt;"
 Mode:<strong>Master</strong>  Frequency=2.412 GHz  Access Point: Not-Associated  
 Sensitivity:0/0 
 Retry:off   RTS thr:off   Fragment thr:off
 Encryption key:off
 Power Management:off
 Link Quality:0  Signal level:0  Noise level:0
 Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
 Tx excessive retries:0  Invalid misc:0   Missed beacon:0</span></pre>
<p><span style="color: #888888;">OK, so it is. :)</span></p>
<p><span style="color: #888888;">But this doesn&#8217;t seem very good:</span></p>
<pre><span style="color: #888888;"># iw list
nl80211 not found.</span></pre>
<p><span style="color: #888888;">And here comes a bit of nonsense that was fixed by compiling software from sources, as shown below.</span></p>
<p><span style="color: #888888;">Fixed with</span></p>
<p><span style="color: #888888;"> </span></p>
<pre><span style="color: #888888;"># modprobe mac80211</span></pre>
<p><span style="color: #888888;">Installing the access point daemon:</span></p>
<pre><span style="color: #888888;"># yum install hostapd</span></pre>
<p><span style="color: #888888;">Running manually for a test:</span></p>
<p>&nbsp;</p>
<pre><span style="color: #888888;"># hostapd -dd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
ctrl_interface_group=10 (from group name 'wheel')
nl80211 not found.
nl80211 driver initialization failed.
wlan0: Unable to setup interface.</span></pre>
<h3><span style="color: #888888;">Tried second dongle (the I bought cheap from Ebay)</span></h3>
<pre><span style="color: #888888;">usb 2-2.2: New USB device found, idVendor=0bda, idProduct=8176
usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-2.2: Product: 802.11n WLAN Adapter
usb 2-2.2: Manufacturer: Realtek
usb 2-2.2: SerialNumber: 00e04c000001
rtl8192cu: Chip version 0x10
rtl8192cu: MAC address: 00:13:ef:40:08:98
rtl8192cu: Board Type 0
rtl_usb: rx_max_size 15360, rx_urb_num 8, in_ep 1
rtl8192cu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin
usbcore: registered new interface driver rtl8192cu
rtlwifi: Loading alternative firmware rtlwifi/rtl8192cufw.bin
rtlwifi: Firmware rtlwifi/rtl8192cufw_TMSC.bin not available</span></pre>
<p><span style="color: #888888;">OK, OK, take the firmware!</span></p>
<pre><span style="color: #888888;"># mkdir /lib/firmware/rtlwifi
# cp rtl8192cufw.bin /lib/firmware/rtlwifi/</span></pre>
<p><span style="color: #888888;">Unplug-replug. This one went much better:</span></p>
<pre><span style="color: #888888;">usb 2-2.2: New USB device found, idVendor=0bda, idProduct=8176
usb 2-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-2.2: Product: 802.11n WLAN Adapter
usb 2-2.2: Manufacturer: Realtek
usb 2-2.2: SerialNumber: 00e04c000001
rtl8192cu: Chip version 0x10
rtl8192cu: MAC address: 00:13:ef:40:08:98
rtl8192cu: Board Type 0
rtl_usb: rx_max_size 15360, rx_urb_num 8, in_ep 1
rtl8192cu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin
rtlwifi: Loading alternative firmware rtlwifi/rtl8192cufw.bin
ieee80211 phy1: Selected rate control algorithm 'rtl_rc'
rtlwifi: wireless switch is on
cfg80211: Calling CRDA for country: IL
cfg80211: Regulatory domain changed to country: IL
cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
cfg80211:   (2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm)</span></pre>
<p><span style="color: #888888;">but</span></p>
<pre><span style="color: #888888;"># hostapd /etc/hostapd/hostapd.conf
ioctl[SIOCSIFFLAGS]: Unknown error 132
nl80211 driver initialization failed.
rmdir[ctrl_interface]: No such file or directory</span></pre>
<h3><span style="color: #888888;">Newer hostapd</span></h3>
<p><span style="color: #888888;">Stole the binaries from Fedora 20, including a set of necessary libraries, and created a chroot for that as follows:</span></p>
<pre><span style="color: #888888;"># chroot . /hostapd -d /hostapd.conf</span></pre>
<p><span style="color: #888888;">With the Ebay dongle, the AP was visible from my laptop, but I failed to connect. Nothing appears on sniffing wlan1, and strace shows nothing happens during these connection attempts, so the conclusion must be that the problem is with the dongle.</span></p>
<p><span style="color: #888888;">So I found the first firmware the driver was checking for,</span></p>
<pre><span style="color: #888888;">usb 2-2.3: New USB device found, idVendor=0bda, idProduct=8176
usb 2-2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-2.3: Product: 802.11n WLAN Adapter
usb 2-2.3: Manufacturer: Realtek
usb 2-2.3: SerialNumber: 00e04c000001
rtl8192cu: Chip version 0x10
rtl8192cu: MAC address: 00:13:ef:40:08:98
rtl8192cu: Board Type 0
rtl_usb: rx_max_size 15360, rx_urb_num 8, in_ep 1
rtl8192cu: Loading firmware rtlwifi/rtl8192cufw_TMSC.bin
ieee80211 phy7: Selected rate control algorithm 'rtl_rc'
rtlwifi: wireless switch is on
rtl8192cu: MAC auto ON okay!
rtl8192cu: Tx queue select: 0x05</span></pre>
<p><span style="color: #888888;">Didn&#8217;t make any difference.</span></p>
<h3><span style="color: #888888;">Creating a bridge</span></h3>
<p><span style="color: #888888;">This is the really manual route, based upon </span><a href="http://askubuntu.com/questions/21679/script-to-setup-ubuntu-as-a-wireless-access-point-on-a-bridge-mode" target="_blank"><span style="color: #888888;">this page</span></a><span style="color: #888888;">.</span></p>
<p><span style="color: #888888;">Basically,</span></p>
<pre><span style="color: #888888;"># brctl addbr br0
# brctl setfd br0 0
# brctl addif br0 eth0
# brctl addif br0 wlan0
# ifconfig br0 10.1.1.123 netmask 255.255.255.0
# ifconfig br0 up</span></pre>
<p><span style="color: #888888;">The second command sets the forward delay to zero, to prevent problems on the first connection, as mentioned on </span><a href="http://madwifi-project.org/wiki/UserDocs/HostAP" target="_blank"><span style="color: #888888;">this page</span></a><span style="color: #888888;">.</span></p>
<p><span style="color: #888888;">One can take a look on the status with</span></p>
<pre><span style="color: #888888;"># brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.00241dd37e38    no        eth0
                                          wlan0</span></pre>
<p><span style="color: #888888;">To remove the bridge:</span></p>
<pre><span style="color: #888888;"># ifconfig br0 down
# brctl delbr br0</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>https://billauer.se/blog/2014/06/linux-realtek-hostapd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
