I'm trying to make a very simple setup with my RPi. On the on-board standard wlan0 I want to connect to my home network normally, using a wpa_supplicant file this works very well.
Now I'm having issue because I plugged a wifi dongle in my RPi (Trendnet TEW-649UB) and I want to setup an AP on wlan1. It is properly detected by my RPi and I can ifconfig it.
wlan1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:14:d1:be:6a:a3 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Now before anyone says look at the hundred of posts on the internet, I did and very few of them actually are for Raspbian Stretch, even the ones on the official website do not take into account Stretch.
Just for the record:
pi@race_tracker_gateway:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
So first here are my wpa_supplicant files. First the wlan0 one, which works fine because it connects at start-up to my network without any issue.
pi@race_tracker_gateway:~ $ cat /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
# allow frontend (e.g., wpa_cli) to be used by all
ctrl_interface=/var/run/wpa_supplicant GROUP=netdev
country=CH
#
# home network; allow all valid ciphers
network={
ssid="hello*walter"
psk="XXXX"
priority=1
id_str="Home WiFi"
}
I'm not really sure on what to put in the wlan1 supplicant file so I just kept the basics
pi@race_tracker_gateway:~ $ cat /etc/wpa_supplicant/wpa_supplicant-wlan1.conf
ctrl_interface=/var/run/wpa_supplicant GROUP=netdev
country=CH
Searching around on the internet, after a while I found out I should not be modifying my /etc/network/interfaces file, so it is as default.
pi@race_tracker_gateway:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
Then I used part of this guide to configure dhcpcd : https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md My goal is to set a static ip address to the AP interface so I simply put the two last lines as shown here
pi@race_tracker_gateway:~ $ tail /etc/dhcpcd.conf
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1
# fallback to static profile on eth0
#interface eth0
#fallback static_eth0
interface wlan1
static ip_address=192.168.4.1/24
I setup the dhcp address pool
pi@race_tracker_gateway:~ $ cat /etc/dnsmasq.conf
interface=wlan1 # Use the require wireless interface - usually wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
Then I configured hostapd and that's where I need help. Here is the content.
pi@race_tracker_gateway:~ $ cat /etc/hostapd/hostapd.conf
interface=wlan1
driver=r8712u
ssid=RaceTrackerGateway
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=internetromero
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
My problem is related to the driver line, because when I start hostapd I get an error.
pi@race_tracker_gateway:~ $ sudo hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Line 2: invalid/unknown driver 'r8712u'
1 errors found in configuration file '/etc/hostapd/hostapd.conf'
Failed to set up interface with /etc/hostapd/hostapd.conf
Failed to initialize interface
I got the driver name doing the following
pi@race_tracker_gateway:~ $ sudo lshw -C network
...
*-network:1
description: Wireless interface
physical id: 3
bus info: usb@1:1.2
logical name: wlan1
serial: 00:14:d1:be:6a:a3
capabilities: ethernet physical wireless
configuration: broadcast=yes driver=r8712u multicast=yes wireless=unassociated
However for some reason hostapd refuses to use that driver. I can get more info on the driver doing this.
pi@race_tracker_gateway:~ $ modinfo r8712u
filename: /lib/modules/4.14.62-v7+/kernel/drivers/staging/rtl8712/r8712u.ko
firmware: rtlwifi/rtl8712u.bin
author: Larry Finger
description: rtl871x wireless lan driver
license: GPL
So I really don't understand why hostapd refuses this driver. When using the standard nl80211 I get the following error (if you are wondering why I changed driver).
pi@race_tracker_gateway:~ $ sudo hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Could not configure driver mode
nl80211: deinit ifname=wlan1 disabled_11b_rates=0
nl80211 driver initialization failed.
wlan1: interface state UNINITIALIZED->DISABLED
wlan1: AP-DISABLED
hostapd_free_hapd_data: Interface wlan1 wasn't started
So I guess here is my story, this is driving crazy, also it's driving me crazy because I've been trying to solve this problem for days and at some point I even managed to make it work, I could see my AP wifi, wlan1 was assigned the correct IP but after a reboot of the RPi and probably some more changing of settings it doesn't work anymore.
If someone could help me I'd be really grateful because I'm starting to think I'm crazy. I suspect something is wrong with the dongle because everytime I reboot my Pi I have the physically unplug and replug the dongle for it to show up as wlan1 so I guess something must be wrong.