Home of the Squeezebox™ & Transporter® network music players.
Results 1 to 1 of 1
  1. #1
    Senior Member
    Join Date
    Apr 2008
    Paris, France

    Pi2 with Edimax EW-7811Un as wireless AP: my recipe

    I got an Edimax EW-7811Un USB nano wireless adapter in order to add a short-range AP to a Pi2. The thing says "Ideal for Raspberry Pi" on the tin...
    When I put it in, it was recognized ok but I could not get hostapd to work with it. Then I found a version of hostapd that would work, but the AP would die overnight (adapter reversed to STA mode, hostapd process gone.) Finally I have found a setup that seems solid. For anyone's interested, here is my recipe.

    Before that I'd like to point I don't think this is the greatest adapter to choose as an AP. First off it doesn't work with the stock hostapd software, then it does not support any form of best channel selection (the "iwlist wlan0 scan ; cat /proc/net/rtl819xD/wlan0/best_channel" method advertised in Realtek's docs no longer works) nor on-the fly channel change, it is limited to 8 clients, and of course it is 2.4GHz only and its range is limited.
    But I got it to run reliably at wifi-N speeds (my mac mini desktop client topped at 73Mbps), it is tiny and cheap. Not so bad overall.

    Now for the recipe:
    a) Machine id and software versions (a Pi2 Model B with current firmware and raspbian, managed by systemd). As a precaution, I've set max_usb_current=1 in the Pi boot parameters, but given the requirement of 500mA for the device and the fact the hub won't be further populated, I don't really think this is necessary in my case. Ran fine without it, feeding the Pi with either a 5W or a 12W PSU.
    root@vence:/# cat /proc/cpuinfo | sed -n '2p;41p;42p' 
    model name	: ARMv7 Processor rev 5 (v7l)
    Hardware	: BCM2709
    Revision	: a01041
    root@vence:/# /opt/vc/bin/vcgencmd version
    Jan 15 2016 17:24:08 
    Copyright (c) 2012 Broadcom
    version 50b1ff57f80db9c96b78757d2d2cfc226ed71f93 (clean) (release)
    root@vence:/# cat /proc/version 
    Linux version 4.1.15-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.8.3 20140303 (prerelease) (crosstool-NG linaro-1.13.1+bzr2650 - Linaro GCC 2014.03) ) #830 SMP Tue Dec 15 17:02:45 GMT 2015
    root@vence:/# lsb_release -a
    No LSB modules are available.
    Distributor ID:	Raspbian
    Description:	Raspbian GNU/Linux 8.0 (jessie)
    Release:	8.0
    Codename:	jessie
    root@vence:/# cat /boot/cmdline.txt 
    dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline fsck.repair=yes max_usb_current=1 rootwait
    root@vence:/# ls -la /sbin/init
    lrwxrwxrwx 1 root root 20 Sep  5 22:23 /sbin/init -> /lib/systemd/systemd
    b) The Edimax adapter plugged into the Pi, using the stock 8192cu module and all-important module options:
    root@vence:/# lsusb -t
    /:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
        |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/5p, 480M
            |__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
            |__ Port 2: Dev 4, If 0, Class=Vendor Specific Class, Driver=rtl8192cu, 480M
    root@vence:/# lsusb -v -s 1:4 | sed -n '2,3p;11,15p;28p'
    Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
    Device Descriptor:
      idVendor           0x7392 Edimax Technology Co., Ltd
      idProduct          0x7811 EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
      bcdDevice            2.00
      iManufacturer           1 Realtek
      iProduct                2 802.11n WLAN Adapter
        MaxPower              500mA
    root@vence:/# modinfo 8192cu | sed -n '1,6p'
    filename:       /lib/modules/4.1.15-v7+/kernel/drivers/net/wireless/rtl8192cu/8192cu.ko
    version:        v4.0.2_9000.20130911
    author:         Realtek Semiconductor Corp.
    description:    Realtek Wireless Lan Driver
    license:        GPL
    srcversion:     133EACDEB0C6BEBC3ECA8D0
    root@vence:/# cat /etc/modprobe.d/8192cu.conf 
    options 8192cu rtw_power_mgnt=0 rtw_enusbss=0 rtw_hwpwrp_detect=0 rtw_ips_mode=1
    # From Realtek's doc
    # rtw_power_mgnt=1 is Min powersaving, =2 is max powersave, =0 is disable
    # rtw_enusbss=0 is default, disable USB autosuspend =1 is enable.
    # rtw_hwpwrp_detect=0 is disable hw power pin "RF on/off" detection, =1 is enable
    # rtw_ips_mode=0 is default, max powersave when unassociated, =1 is the faster, power guzzler opt.
    # From: http://curiouser.cheshireeng.com/2015/05/27/raspberry-pi-wifi-stability/
    # options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1
    c) Version of hostapd used: a debianified, Realtek-specific version of hostapd 2.4 (jessie offers v. 2.3) available on github at https://github.com/jekader/hostapd-rtl.
    To build you'll need the raspbian kernel source code, or kernel headers.
    For some reason raspbian.org does not offer kernel-related packages, but with a bit of luck I found at https://www.niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/ a linux-headers-4.1.15-v7+_4.1.15-v7+-2_armhf.deb package already made by a kind soul (a bit of digging reveals this is thanks to Markus Hiienkari, a graduate of Aalto University in Finland)
    Following Jeka Der's instructions and making sure you compile with gcc version 4.9, you'll end up with an hostapd-rtl package in no time.
    root@vence:/usr/src# update-alternatives --display gcc
    gcc - auto mode
      link currently points to /usr/bin/gcc-4.9
    /usr/bin/gcc-4.7 - priority 10
    /usr/bin/gcc-4.9 - priority 20
    Current 'best' version is '/usr/bin/gcc-4.9'.
    root@vence:/# apt-cache show hostapd-rtl
    Package: hostapd-rtl
    Status: install ok installed
    Priority: optional
    Section: network
    Installed-Size: 541
    Maintainer: Jeka Der <jekader@gmail.com>
    Architecture: armhf
    Version: 2.4-4
    Depends: lsb-base, initscripts (>= 2.88), libc6 (>= 2.4)
    Conflicts: hostapd
     /etc/hostapd/hostapd.conf 1ae3c5af34419d92df0b45fa7d29f53d
     /etc/init.d/hostapd a7931d02817e1ae9beb1b2cd0398dcb8
     /etc/default/hostapd a2621018a0e19ddd3597517ca055e5aa
     /etc/default/hostapd a2621018a0e19ddd3597517ca055e5aa
     /etc/hostapd/hostapd.conf 1ae3c5af34419d92df0b45fa7d29f53d
     /etc/init.d/hostapd a7931d02817e1ae9beb1b2cd0398dcb8
    Description: IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
     hostapd is a user space daemon for access point and authentication servers.
     It implements IEEE 802.11 access point management, IEEE 802.1X/WPA/WPA2/EAP
     Authenticators, RADIUS client, EAP server, and RADIUS authentication server.
     The current version supports Linux (Host AP, madwifi, mac80211-based drivers)
     and FreeBSD (net80211).
    Description-md5: f19d8b9ca3a8939f8d047c5f85660580
    d) Finally, relevant items in my hostapd.conf (the hostapd-rtl package includes a demo file)
    # From Realtek docs
    # hostapd-rtl specific driver
    # 2.4 GHz
    # Wifi-N
    # Avoid crash at startup with Realtek RTL8188CUS
    # QoS support - Can't find out if it's called wme or wmm !!
    # from Realtek's docs Quick_Start_Guide_for_SoftAP.pdf and
    # SoftAP_Mode_features.pdf. The [DSSS_CCK-40][MAX-AMSDU-7935]
    # part comes from the interweb. Use [HT40-] or [HT40+]
    Where 'Realtek's docs' are referenced, this means the documentation in the driver source archive you can recover from Realtek downloads area. The file I downloaded was named "RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip ".

    HTH, EOF
    Last edited by epoch1970; 2016-01-23 at 10:12.
    3 SB 3 • Libratone Loop, Zipp Mini • iPeng (iPhone + iPad) • LMS 7.9 (linux) with plugins: CD Player, WaveInput, Triode's BBC iPlayer by bpa • IRBlaster by Gwendesign (Felix) • Server Power Control by Gordon Harris • Smart Mix, Music Walk With Me, What Was That Tune? by Michael Herger • PowerSave by Jason Holtzapple • Song Info, Song Lyrics by Erland Isaksson • AirPlay Bridge by philippe_44 • WeatherTime by Martin Rehfeld • Auto Dim Display, SaverSwitcher, ContextMenu by Peter Watkins.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts