Thursday, November 27, 2014

Use 802.11n on Asus RT-N16 with OpenWrt

(If you come from OpenWrt's official wiki, skip forward to the section "802.11n" for your answer.)

Overview

It took me a while to figure out how to setup 802.11n in OpenWrt on Asus RT-N16 so I figured I'd share the process, hopefully to save somebody's time.

Background

I've used dd-wrt for a long time (on 4 wireless routers over the years). However, my network setup is getting more and more complex. While dd-wrt allows some customization, the inconsistency between GUI and the command-line configuration made it very hard for me to maintain. For example, editing the DHCP static address table from the GUI is a tedious process because it doesn't sort so it's very hard to detect duplication. I could edit the configuration file directly but the GUI does not reflect my changes correctly. Saving from the GUI can easily overwrite my manually edited config files.

Choosing Alternatives

Therefore, I started to look for an alternative. Besides dd-wrt, Tomato and it's family, and OpenWrt are the other two high-profile router firmware development efforts. And both lineages provide very customizable environment.

However, there are two things I'm looking for.

1. I am looking for a project that's still actively maintained, especially after Heart Bleed, Shell Shock, and Poodle. (Note that these vulnerabilities don't necessarily compromise home routers, but in my environment, I'd rather not take the chance.) While a repository system allows individual package upgrade, I want the base developers to still be around.

2. I'm looking for a project that's owned by a team rather than individuals. In the WRT history, there have been many brilliant individuals that made crucial advances for everyone. However, it has happened a few times when these individuals moved on, their projects died, too.

Therefore, I ended up choosing OpenWrt.

Installation

It was quite straightforward to switch to OpenWrt from dd-wrt, as instructed in the official guide.

Securing the admin access was obvious. However, it took me a while to realize that I also needed to reboot my Cable Modem for it to reset its DHCP. If you are also doing this, I suggest you open all installation guides in the browser first before you flash your new firmware. I had to use my phone to check the guides before my internet was up.

802.11n

This took me a while because the guide is not very obvious. Anyway, after some trials and errors, broadcom-wl was the only one that worked for me (thanks to Stratos about the dependency nas. I already had that so I didn't realize that dependency).


  1. # opkg update
  2. # opkg install kmod-brcm-wl wl wlc
  3. # rm /etc/config/wireless
  4. # opkg install nas
  5. # reboot
Then login to shell again to edit /etc/config/wireless . This is mine.

config wifi-device  wl0
        option type     broadcom
        option channel  1
        option txantenna 3
        option rxantenna 3
        option txpower '20'
        option plcphdr 'auto'
        option frameburst 1
        option disabled 0
config wifi-iface
        option device   wl0
        option network  lan
        option mode     ap
        option ssid     YOUR_SSID
        option key      YOUR_KEY
        option wmm      1
        option encryption 'psk2'
        option disabled '0'
I added plcphdr and frameburst after reading this discussion thread.

Another strange thing to work around is that after reboot, while a client can connect to the router with 802.11n, the DHCP failed to issue IPs. I had to turn the wifi off and on for it to work properly.

# wifi down
# wifi up
I did not spend time debugging. Instead, as a temporary workaround, I added that to /etc/rc.local, which now looks like this:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
# workaround for Broadcom proprietary driver problem
/sbin/wifi down
/bin/sleep 1
/sbin/wifi up
exit 0

Update: badineu in the comment mentioned that he also needed to manually select the wifi frequency. You may also have to do so if, for some reason, it's not already properly set.

20 comments:

  1. Thank you! Your workaround for the Broadcom proprietary driver helped me finish my configuration.

    ReplyDelete
  2. I'm glad that this guide helped you. Thank you for letting me know.

    ReplyDelete
  3. You have to install utility called nas to get wifi authentication working:
    opkg update
    opkg install nas

    ReplyDelete
  4. Thanks a lot, StratoS. I've updated the post to include your info. I already had that installed so I didn't realize its dependency.

    ReplyDelete
  5. Thank you for the info! I was not able to get a stable connection using the kmod-brcmsmac driver but 'kmod-brcm-wl' driver is rock solid!

    ReplyDelete
  6. Thank you! I also had to switch the operating frequency in the wifi settings
    https://i.imgur.com/IIqwRfI.png

    ReplyDelete
  7. Thanks for letting me know, my anonymous friend.

    badineu, I added a note at the end of the post to mention that. Thank you for adding that info.

    ReplyDelete
  8. Directions worked perfectly on the latest release, Chaos Calmer 15.05. Thanks for the info!

    ReplyDelete
  9. I use N16 both as Client and Master.With what you gave
    /sbin/wifi down
    /bin/sleep 1
    /sbin/wifi up
    Client mode works perfectly after reboot but Master mode does not.As you said,while a client can connect to the router with 802.11n, the DHCP failed to issue IPs.

    ReplyDelete
    Replies
    1. Hero, my setting works for me on the Master (AP) mode, which is probably what most people use here, so I assume it works for most people on the Master mode. I'm therefore a bit surprised that you client mode works but master doesn't. I wish I could be of more help.

      Delete
  10. Be careful using kmod-brcmsmac with the RT-N16. It uses 100% of the CPU at under 20mbits. The kmod-b43 works perfectly at 5% at about 20mbits, but unfortunately it doesn't support N. For me the Broadcom-wl proprietary driver isn't a solution because it doesn't support 802.1X authentication.

    ReplyDelete
    Replies
    1. Thanks for the information. My router CPU level is very low though. I wonder what made the difference on your side.

      Delete
  11. Thanks. You saved my day. Unable to get 11n has been a huge trouble since i flashed my RT-N16 to OpenWrt

    ReplyDelete
    Replies
    1. You are welcome. I'm glad it was helpful for you.

      Delete
  12. works with current release of 15.05.1. Thank you!

    Note: the 2nd line of your instructions is missing 'install' after opkg...

    opkg install kmod-brcm-wl wl wlc

    ReplyDelete