# How do I kick an Atheros AR9285 into master mode? [Solved]

## Bullet Dodger

This is my 1st attempt to build a linux access point.

I have tried to follow various guides.

I think I used the following but they seem to be down at the moment.

http://en.gentoo-wiki.com/wiki/Wireless/Access_point

http://en.gentoo-wiki.com/wiki/Madwifi_Wireless_Access_Point

http://en.gentoo-wiki.com/wiki/Atheros_Ath5k_Wireless_Access_Point

I am currently using the 2.6.38-sysrescue-std220 kernel.

I don't know if this kernel has all the modules required for master mode and might have to break out genkernel, but though I'd ask some advice before doing that.

So, at the moment I currently have a working wifi in managed mode.

```

# ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:01:2e:2f:28:c0  

          inet addr:192.168.2.4  Bcast:192.168.2.255  Mask:255.255.255.0

          inet6 addr: fe80::201:2eff:fe2f:28c0/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1178 errors:0 dropped:0 overruns:0 frame:0

          TX packets:601 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:148267 (144.7 KiB)  TX bytes:129680 (126.6 KiB)

          Interrupt:42 

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:45 errors:0 dropped:0 overruns:0 frame:0

          TX packets:45 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:3746 (3.6 KiB)  TX bytes:3746 (3.6 KiB)

wlan0     Link encap:Ethernet  HWaddr 1c:4b:d6:72:3b:e7  

          UP BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

# iwconfig

lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:off/any  

          Mode:Managed  Access Point: Not-Associated   Tx-Power=17 dBm   

          Retry  long limit:7   RTS thr:off   Fragment thr:off

          Encryption key:off

          Power Management:on

```

And an  iwlist wlan0 scan finds my current wifi router.

Although I only returns 1 result, where my laptop finds 5 wifi routers near by (?)

So, any pointers in how to setup master mode?

Do I need to compile a new kernel?

ThanksLast edited by Bullet Dodger on Fri Nov 04, 2011 1:26 am; edited 1 time in total

----------

## roarinelk

install & use hostapd

----------

## Bullet Dodger

```

# /etc/init.d/hostapd start

 * Starting hostapd ...

 * start-stop-daemon: failed to start `/usr/sbin/hostapd'                                                           [ !! ]

 * ERROR: hostapd failed to start

```

```

# cat /etc/modprobe.d/ath_pci.conf 

options ath_pci autocreate=ap

```

```

# cat /etc/conf.d/local.stop

ifconfig ath0 down

wlanconfig ath0 destroy

wlanconfig ath0 create wlandev wifi0 wlanmode ap

```

```

# cat /etc/conf.d/net

config_ath0="192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255"

mode_ath0="master"

essid_ath0="MyNetwork"

```

```

# cat /etc/conf.d/dhcpd   

DHCPD_IFACE="ath0"

```

```

# cat /etc/dhcp/dhcpd.conf|sed -e '/^#/d'

ddns-update-style none;

authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.75 192.168.0.100;

option domain-name-servers 192.168.0.1;              (Make sure BIND is listening on this IP)

option domain-name "hostname.domain.tld";

option routers 192.168.0.1;

option broadcast-address 192.168.0.255;

default-lease-time 10000;

max-lease-time 20000;

}

subnet 192.168.1.0 netmask 255.255.255.0 {

range 192.168.1.75 192.168.1.100;

option domain-name-servers 192.168.1.1;               (Make sure BIND is listening on this IP)

option domain-name "hostname.domainn.tld";

option routers 192.168.1.1;

option broadcast-address 192.168.1.255;

default-lease-time 10000;

max-lease-time 20000;

}

```

```

# cat /etc/conf.d/hostapd|sed -e '/^#/d'

INTERFACES="ath0"

CONFIGS="/etc/hostapd/hostapd.conf"

```

```

# rc-status |grep net.ath0 

 net.ath0                                                          [  started  ]

```

```

# ls net* -l

lrwxrwxrwx 1 root root    8 Oct 31 00:32 net.ath0 -> netif.lo

lrwxrwxrwx 1 root root    8 Oct 30 23:35 net.wlan0 -> netif.lo

-rwxr-xr-x 1 root root  521 Oct 26 23:09 netif.lo

-rwxr-xr-x 1 root root 5323 Oct 26 23:09 netif.tmpl

-rwxr-xr-x 1 root root 2162 Oct 26 23:08 netmount

```

It's probably worth mentioning that this is a funtoo install, not gentoo. And I have just found out they do networking differently.

http://www.funtoo.org/wiki/Funtoo_Linux_Networking

I don't know if this has any impact on setting up a wifi access point.

----------

## Bullet Dodger

And this 1

```

# sed -e'/^#/d' /etc/hostapd/hostapd.conf

interface=ath0 

driver=madwifi 

logger_syslog=-1 

logger_syslog_level=2 

logger_stdout=-1 

logger_stdout_level=1 

debug=0 

dump_file=/tmp/hostapd.dump 

ctrl_interface=/var/run/hostapd 

ctrl_interface_group=0 

ssid=MyNetwork 

macaddr_acl=0 

accept_mac_file=/etc/hostapd/hostapd.accept 

deny_mac_file=/etc/hostapd/hostapd.deny 

auth_algs=1 

wpa=1 

wpa_passphrase=Enter your Passphrase            

wpa_key_mgmt=WPA-PSK 

wpa_pairwise=TKIP CCMP

```

----------

## solamour

You might not even need it, but it doesn't hurt, so make sure to install the firmware.

```
emerge -v linux-firmware
```

It's also a good idea to build hostapd with debug info. It comes handy when troubleshooting.

```
net-wireless/hostapd debug
```

I suggest you start with something simple and add additional functionality later on.

```
interface=wlan0

driver=nl80211   <-- Try this first

ssid=mywifi

hw_mode=g

channel=1
```

Also, the following command gives more info on what's happening.

```
hostapd -dd /etc/hostapd/hostapd.conf
```

While you are at it, share the output of "lspci" as well.

__

sol

----------

## Bullet Dodger

Ok,

I have done the following

re-emerged hostapd with the debug flag

```

# hostapd -dd /etc/hostapd/hostapd.conf

Configuration file: /etc/hostapd/hostapd.conf

Line 3: invalid/unknown driver 'madwifi '

Line 8: DEPRECATED: 'debug' configuration variable is not used anymore

Line 11: Invalid group '0 '

MAC list file '/etc/hostapd/hostapd.accept ' not found.

Line 14: Failed to read accept_mac_file '/etc/hostapd/hostapd.accept '

MAC list file '/etc/hostapd/hostapd.deny ' not found.

Line 15: Failed to read deny_mac_file '/etc/hostapd/hostapd.deny '

4 errors found in configuration file '/etc/hostapd/hostapd.conf'

# head -n20  /etc/hostapd/hostapd.conf

interface=ath0 

#bridge=br0                          (optional, if you want bridging remove the #) 

driver=madwifi 

logger_syslog=-1 

logger_syslog_level=2 

logger_stdout=-1 

logger_stdout_level=1 

debug=0 

dump_file=/tmp/hostapd.dump 

ctrl_interface=/var/run/hostapd 

ctrl_interface_group=0 

ssid=MyNetwork 

macaddr_acl=0 

accept_mac_file=/etc/hostapd/hostapd.accept 

deny_mac_file=/etc/hostapd/hostapd.deny 

auth_algs=1 

wpa=1 

wpa_passphrase=password

wpa_key_mgmt=WPA-PSK 

wpa_pairwise=TKIP CCMP

```

 *Quote:*   

> 
> 
> I suggest you start with something simple and add additional functionality later on. 
> 
> ```
> ...

 

I didn't know madwifi was an additional extra. These config files were ripped straight out of the howtos.

Changed driver to nl80211.

Removed debug line

Removed white space after ctrl_interface_group=0 

Commented out accept/deny files

```

# hostapd -dd /etc/hostapd/hostapd.conf

Configuration file: /etc/hostapd/hostapd.conf

ctrl_interface_group=0

nl80211: Register Action command failed: ret=-19 (No such device)

nl80211: Register Action match - hexdump(len=1): 06

nl80211: Failed to register Action frame processing - ignore for now

nl80211: Add own interface ifindex 0

Could not read interface ath0  flags: No such device

nl80211 driver initialization failed.

rmdir[ctrl_interface]: No such file or directory

ELOOP: remaining socket: sock=4 eloop_data=0x25754a0 user_data=0x25782a0 handler=0x433730

ELOOP: remaining socket: sock=6 eloop_data=0x257a930 user_data=(nil) handler=0x43c2d0

```

emerge linux-firmware

```

# hostapd -dd /etc/hostapd/hostapd.conf

Configuration file: /etc/hostapd/hostapd.conf

ctrl_interface_group=0

nl80211: Register Action command failed: ret=-19 (No such device)

nl80211: Register Action match - hexdump(len=1): 06

nl80211: Failed to register Action frame processing - ignore for now

nl80211: Add own interface ifindex 0

Could not read interface ath0  flags: No such device

nl80211 driver initialization failed.

rmdir[ctrl_interface]: No such file or directory

ELOOP: remaining socket: sock=4 eloop_data=0x11534a0 user_data=0x11562a0 handler=0x433730

ELOOP: remaining socket: sock=6 eloop_data=0x1158930 user_data=(nil) handler=0x43c2d0

```

The 1st error appears to be:

```
nl80211: Register Action command failed: ret=-19 (No such device) 
```

and

```
Could not read interface ath0  flags: No such device
```

I don't know why this is failing. 

```

# lspci

00:00.0 Host bridge: Intel Corporation Pineview DMI Bridge (rev 02)

00:02.0 VGA compatible controller: Intel Corporation Pineview Integrated Graphics Controller (rev 02)

00:02.1 Display controller: Intel Corporation Pineview Integrated Graphics Controller (rev 02)

00:1b.0 Audio device: Intel Corporation 82801G (ICH7 Family) High Definition Audio Controller (rev 02)

00:1c.0 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 1 (rev 02)

00:1c.3 PCI bridge: Intel Corporation 82801G (ICH7 Family) PCI Express Port 4 (rev 02)

00:1d.0 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #1 (rev 02)

00:1d.1 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #2 (rev 02)

00:1d.2 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #3 (rev 02)

00:1d.3 USB Controller: Intel Corporation 82801G (ICH7 Family) USB UHCI Controller #4 (rev 02)

00:1d.7 USB Controller: Intel Corporation 82801G (ICH7 Family) USB2 EHCI Controller (rev 02)

00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)

00:1f.0 ISA bridge: Intel Corporation Tigerpoint LPC Controller (rev 02)

00:1f.2 IDE interface: Intel Corporation 82801GB/GR/GH (ICH7 Family) SATA IDE Controller (rev 02)

00:1f.3 SMBus: Intel Corporation 82801G (ICH7 Family) SMBus Controller (rev 02)

01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 03)

02:00.0 Network controller: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01)

```

----------

## Bullet Dodger

```

# ls -l /etc/init.d/|grep net

lrwxrwxrwx 1 root root    8 Oct 31 00:32 net.ath0 -> netif.lo

lrwxrwxrwx 1 root root    8 Oct 30 23:35 net.wlan0 -> netif.lo

-rwxr-xr-x 1 root root  521 Oct 26 23:09 netif.lo

-rwxr-xr-x 1 root root 5323 Oct 26 23:09 netif.tmpl

-rwxr-xr-x 1 root root 2162 Oct 26 23:08 netmount

```

```

# cat net.ath0

#!/sbin/runscript

# Copyright 2010 Funtoo Technologies

# All rights reserved. Released under the 2-clause BSD license.

depend() {

        provide net

}

start() {

        ebegin "Bringing up network interface lo"

        ip addr add 127.0.0.1/8 dev lo brd + scope host

        ip route add 127.0.0.0/8 dev lo scope host

        ip link set lo up

        eend $?

}

stop() {

        ebegin "Shutting down network interface lo"

        ip route del 127.0.0.0/8 dev lo scope host

        ip addr del 127.0.0.1/8 dev lo

        ip link set lo down

        eend $?

}

```

```

# /etc/init.d/net.ath0 restart

 * Shutting down network interface lo ...             [ ok ]

 * Bringing up network interface lo ...               [ ok ]

```

```

# rc-status |grep ath

 net.ath0                                                          [  started  ]

```

----------

## solamour

Your "ifconfig" shows "wlan0", so shouldn't "/etc/hostapd/hostapd.conf" also use "wlan0" instead of "ath0"? How does your "/etc/udev/rules.d/70-persistent-net.rules" look like?

__

sol

----------

## Bullet Dodger

 *Quote:*   

> 
> 
> Your "ifconfig" shows "wlan0", so shouldn't "/etc/hostapd/hostapd.conf" also use "wlan0" instead of "ath0"? How does your "/etc/udev/rules.d/70-persistent-net.rules" look like? 
> 
> 

 

I was starting to think the same thing, but it's the same result

```

# hostapd -dd /etc/hostapd/hostapd.conf

Configuration file: /etc/hostapd/hostapd.conf

ctrl_interface_group=0

nl80211: Register Action command failed: ret=-19 (No such device)

nl80211: Register Action match - hexdump(len=1): 06

nl80211: Failed to register Action frame processing - ignore for now

nl80211: Add own interface ifindex 0

Could not read interface wlan0  flags: No such device

nl80211 driver initialization failed.

rmdir[ctrl_interface]: No such file or directory

ELOOP: remaining socket: sock=4 eloop_data=0xf934a0 user_data=0xf962a0 handler=0x433730

ELOOP: remaining socket: sock=6 eloop_data=0xf98930 user_data=(nil) handler=0x43c2d0

```

```

# modprobe ath9k

# modprobe ath_pci

# dmesg

[40486.089323] ath9k 0000:02:00.0: PCI INT A -> GSI 19 (level, low) -> IRQ 19

[40486.089360] ath9k 0000:02:00.0: setting latency timer to 64

[40486.140478] ath: EEPROM regdomain: 0x60

[40486.140483] ath: EEPROM indicates we should expect a direct regpair map

[40486.140491] ath: Country alpha2 being used: 00

[40486.140495] ath: Regpair used: 0x60

[40486.146327] ieee80211 phy4: Selected rate control algorithm 'ath9k_rate_control'

[40486.157630] Registered led device: ath9k-phy4::radio

[40486.159654] Registered led device: ath9k-phy4::assoc

[40486.160440] Registered led device: ath9k-phy4::tx

[40486.162621] Registered led device: ath9k-phy4::rx

[40486.162650] ieee80211 phy4: Atheros AR9285 Rev:2 mem=0xffffc90022000000, irq=19

[40486.179193] ADDRCONF(NETDEV_UP): wlan0: link is not ready

[40491.732084] ath_pci: svn r4165 (branch madwifi-0.9.4)

```

dmesg shows madwifi even though nl80211 is used in /etc/hostapd/hostapd.conf

as well as  wlan0: link is not ready

```

# cat /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated by the /lib64/udev/write_net_rules

# program, run by the persistent-net-generator.rules rules file.

#

# You can modify it, as long as you keep each rule on a single

# line, and change only the value of the NAME= key.

# PCI device 0x10ec:0x8168 (r8169)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:01:2e:2f:28:c0", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x168c:0x002b (ath9k)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="1c:4b:d6:72:3b:e7", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

```

----------

## solamour

Does your "hostapd.conf" file contain "ssid", "hw_mode", and "channel"? Also check the vendor and device codes with "lspci -n" and see whether someone with the same device has any luck with hostapd.

I noticed that Atheros devices usually work well with hostapd, but sometimes I need to use a newer kernel to make it work. For example, AR9271 (ath9k_htc) works only if the kernel is 3.0 or later. The older one (e.g. ath5k) was never a problem.

__

sol

----------

## mr.sande

I have used hostapd (successfully) with the exact same wifi card, but I don't remember how I set it up  :Sad: 

What I do know is that you should use the ath9k driver, you should not use madwifi or need any firmware.

For reference, I used hostapd with 2.6.39.

----------

## Bullet Dodger

Arrrr - Solved it.

There were 2 problems.

I unemerge madwifi.

It appears madwifi will setup ath0 and ath9k will set up wlan0.

So I want to be using wlan0.

 *Quote:*   

> 
> 
> Does your "hostapd.conf" file contain "ssid", "hw_mode", and "channel"? Also check the vendor and device codes with "lspci -n" and see whether someone with the same device has any luck with hostapd. 
> 
> 

 

Problem 1.

hostapd.conf contains ssid, but not hw_mode and channel, so added these.

But same problem.

```

# hostapd -dd /etc/hostapd/hostapd.conf  

Configuration file: /etc/hostapd/hostapd.conf

ctrl_interface_group=0

nl80211: Register Action command failed: ret=-19 (No such device)

nl80211: Register Action match - hexdump(len=1): 06

nl80211: Failed to register Action frame processing - ignore for now

nl80211: Add own interface ifindex 0

Could not read interface wlan0  flags: No such device

nl80211 driver initialization failed.

rmdir[ctrl_interface]: No such file or directory

ELOOP: remaining socket: sock=4 eloop_data=0x20b94a0 user_data=0x20bc2a0 handler=0x433730

ELOOP: remaining socket: sock=6 eloop_data=0x20be930 user_data=(nil) handler=0x43c2d0

```

Problem 2.

It's very subtle, but just look at this line again

```

Could not read interface wlan0  flags: No such device

```

I've already posted a similar problem earlier in this thread.

 *Quote:*   

> Removed white space after ctrl_interface_group=0 

 

Yes, there is a space after wlan0.

Once I removed that it worked.

Thanks everyone

----------

## solamour

Good to hear it finally worked out. Perseverance pays off, I suppose. Great.

__

sol

----------

