Configuring Realtek RTL8191SE mini PCIe WiFi card

The following page will show how to build your Wi-Fi drivers and configure Realtek mini PCIe card on Ubuntu for ESPRESSObin to get your Wi-Fi up and running. Depending on your order, your ESPRESSObin package should include this PCIe card, but you can order it on Amazon or from Globalscale.

Building Wi-Fi driver

To build Wi-Fi drivers we need to select necessary options and modules in kernel configuration. Similarly to how we did in Ubuntu - initial network configuration, the quicker method is to replace the .config file with a pre-configured .config file which already has these options selected, but we can of course select them manually through menuconfig.

.config file

.config file is located in the top of your kernel source tree and it contains kernel configuration. This file can be configured manually or via menuconfig, make xconfig, make XXX defconfig, make oldconfig and similar make XXXconfig targets in the Linux kernel.

The quickest method of achieving a .config file with afore-mentioned options enabled is to replace the file with an .config that has all these options already enabled.

Download the .config with necessary Wi-Fi modules and options enabled here. Make sure to backup your existing .config file with:

espressobin@buildserver:~/kernel/4.4.8$ cp .config .config_old

before replacing it with the .config you have downloaded on the link above:

espressobin@buildserver:~/kernel/4.4.8$ cp /path_to_downloaded_config/config.nat.realtekwifi .config

Now we can issue kernel and ko modules build with:

espressobin@buildserver:~/kernel/4.4.8$ make -j4

If the build was successful, skip to Transferring to microSD card section.

To build the Wi-Fi driver by manually selecting necessary options go to where you have downloaded your kernel v4.4.8 source tree and issue make menuconfig (make sure you have NETFILTER/IPTABLES/NAT features enabled as shown in Ubuntu - initial network configuration):

espressobin@buildserver:~/kernel/4.4.8$ make menuconfig

and in there we will need to enable the following build options (note that some of the options need to be selected as modules ):

  • 1) WLAN


Symbol: WLAN [=y]
Type  : boolean
Prompt: Wireless LAN
    -> Device Drivers
(1)   -> Network device support (NETDEVICES [=y])
  Defined at drivers/net/wireless/Kconfig:5
  Depends on: NETDEVICES [=y] && !S390 && NET [=y]
  Selects: WIRELESS [=y]


  • 2) CFG80211


Symbol: CFG80211 [=y]
Type  : tristate
Prompt: cfg80211 - wireless configuration API
    -> Networking support (NET [=y])
(1)   -> Wireless (WIRELESS [=y])
  Defined at net/wireless/Kconfig:19
  Depends on: NET [=y] && WIRELESS [=y] && (RFKILL [=n] || !RFKILL [=n])
  Selected by: R8723AU [=n] && STAGING [=y] && USB [=y] && WLAN [=y] && RFKILL [=n]


  • 3) CFG80211_WEXT


Symbol: CFG80211_WEXT [=y]
Type  : boolean
Prompt: cfg80211 wireless extensions compatibility
    -> Networking support (NET [=y])
      -> Wireless (WIRELESS [=y])
(1)     -> cfg80211 - wireless configuration API (CFG80211 [=y])
  Defined at net/wireless/Kconfig:187
  Depends on: NET [=y] && WIRELESS [=y] && CFG80211 [=y]
  Selects: WEXT_CORE [=n]


  • 4) MAC80211


Symbol: MAC80211 [=y]
Type  : tristate
Prompt: Generic IEEE 802.11 Networking Stack (mac80211)
    -> Networking support (NET [=y])
(1)   -> Wireless (WIRELESS [=y]) 
  Defined at net/mac80211/Kconfig:1
  Depends on: NET [=y] && WIRELESS [=y] && CFG80211 [=y]
  Selects: CRYPTO [=y] && CRYPTO_ARC4 [=n] && CRYPTO_AES [=y] && CRYPTO_CCM [=n] && CRYPTO_GCM [=n] && CRC32 [=y]


  • 5) MAC80211_LEDS


Symbol: MAC80211_LEDS [=y]
Type  : boolean
Prompt: Enable LED triggers
    -> Networking support (NET [=y])
(1)   -> Wireless (WIRELESS [=y])
  Defined at net/mac80211/Kconfig:83
  Depends on: NET [=y] && WIRELESS [=y] && MAC80211 [=y] && LEDS_CLASS [=y]
  Selects: LEDS_TRIGGERS [=y]
  Selected by: IWLEGACY [=n] && NETDEVICES [=y] && WLAN [=y] || ATH5K [=n] && NETDEVICES [=y] && WLAN [=y] && ATH_CARDS [=n] && (PCI [=y] || ATH25) && MAC80211 [=y] || ATH9K [=n] && NETDEVICES [=y] && WLAN [=y] && ATH_CARDS [=n] && MAC80211 [=y] && HAS_DMA [=y] || ATH9K_HTC [=n] && NETDEVICES [=y] && WLAN [=y] && ...


  • 6) RFKILL


Symbol: RFKILL [=y]
Type  : tristate 
Prompt: RF switch subsystem support
(1) -> Networking support (NET [=y])
  Defined at net/rfkill/Kconfig:4
  Depends on: NET [=y]


  • 7) RTL8XXXU


Symbol: RTL8XXXU [=m]
Type  : tristate
Prompt: RTL8723AU/RTL8188[CR]U/RTL819[12]CU (mac80211) support
    -> Device Drivers 
      -> Network device support (NETDEVICES [=y])
(1)     -> Wireless LAN (WLAN [=y])
  Defined at drivers/net/wireless/realtek/rtl8xxxu/Kconfig:4
  Depends on: NETDEVICES [=y] && WLAN [=y] && MAC80211 [=y] && USB [=y]




Type  : boolean
Prompt: Include support for untested Realtek 8xxx USB devices (EXPERIMENTAL)
    -> Device Drivers 
      -> Network device support (NETDEVICES [=y])
        -> Wireless LAN (WLAN [=y])
(1)       -> RTL8723AU/RTL8188[CR]U/RTL819[12]CU (mac80211) support (RTL8XXXU [=m])
  Defined at drivers/net/wireless/realtek/rtl8xxxu/Kconfig:26
  Depends on: NETDEVICES [=y] && WLAN [=y] && RTL8XXXU [=m]


  • 9) RTL8192SE


Symbol: RTL8192SE [=m]
Type  : tristate
Prompt: Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter
    -> Device Drivers
      -> Network device support (NETDEVICES [=y])
        -> Wireless LAN (WLAN [=y])
(1)       -> Realtek rtlwifi family of devices (RTL_CARDS [=y])
  Defined at drivers/net/wireless/realtek/rtlwifi/Kconfig:25
  Depends on: NETDEVICES [=y] && WLAN [=y] && RTL_CARDS [=y] && PCI [=y]
  Selects: RTLWIFI [=m] && RTLWIFI_PCI [=n]

Now that all needed modules have been selected, save your configuration, exit menuconfig and issue kernel and ko modules build with:

espressobin@buildserver:~/kernel/4.4.8$ make -j4


Transferring to microSD card

Now we need to transfer the new kernel and ko modules to a microSD card containing Ubuntu. The new modules are located in /path_to_kernelv4.4.8/drivers/net/wireless/realtek directory and from there we will copy them to the Ubuntu file system on microSD card (our SD card here is mounted on /mnt/sdcard/ and we will copy the modules to /home directory on the file system):

espressobin@buildserver:~$ sudo mount /dev/sdb1 /mnt/sdcard/
espressobin@buildserver:~$ cd kernel/4.4.8/drivers/net/wireless/realtek/
espressobin@buildserver:~/kernel/4.4.8/drivers/net/wireless/realtek$ sudo cp rtlwifi/rtl8192se/rtl8192se.ko /mnt/sdcard/home/
espressobin@buildserver:~/kernel/4.4.8/drivers/net/wireless/realtek$ sudo cp rtlwifi/rtl_pci.ko /mnt/sdcard/home/
espressobin@buildserver:~/kernel/4.4.8/drivers/net/wireless/realtek$ sudo cp rtl8xxxu/rtl8xxxu.ko /mnt/sdcard/home/
espressobin@buildserver:~/kernel/4.4.8/drivers/net/wireless/realtek$ sudo cp rtlwifi/rtlwifi.ko /mnt/sdcard/home
# Copy the new kernel images to boot directory:
espressobin@buildserver:~/kernel/4.4.8/drivers/net/wireless/realtek$ cd /mnt/sdcard
espressobin@buildserver:~/mnt/sdcard$ sudo cp /home/espressobin/kernel/4.4.8/arch/arm64/boot/Image boot/
espressobin@buildserver:~/mnt/sdcard$ sudo cp /home/espressobin/kernel/4.4.8/arch/arm64/boot/dts/marvell/armada-3720-community.dtb boot/

Now that the new kernel images and ko modules are transferred to the microSD card, unmount it and boot it on ESPRESSObin (see how to boot Ubuntu on Boot from removable storage - Ubuntu).

Configuring AP

Once in Ubuntu console, open /etc/apt/sources.list file and there append:

deb http://httpredir.debian.org/debian jessie main contrib non-free

after which update and install necessary packages:

root@localhost:~# apt-get update
root@localhost:~# apt-get install firmware-realtek
root@localhost:~# apt-get install iw
root@localhost:~# apt-get install hostapd

Now that we have the necessary packages from it installed, we can remove the above source line in /etc/apt/sources.list in order to avoid package issues later on when following other Ubuntu tutorials:

root@localhost:~# vi /etc/apt/sources.list
# remove line 'deb http://httpredir.debian.org/debian jessie main contrib non-free'
# save and exit editor
root@localhost:~# apt-get update

In the same directory (in our case this was /home) where we have copied ko modules, we will create a hostapd.conf file containing our access point configuration:

root@localhost:~# cd /home
root@localhost:/home# vi hostapd.conf

which will contain our access point configuration:


Finally, we make a script file, e.g. ubuntu_ap:

root@localhost:/home# vi ubuntu_ap

where we will add access point capability to our ESPRESSObin router:

set -x
insmod rtlwifi.ko
sleep 1
insmod rtl8xxxu.ko
sleep 1
insmod rtl_pci.ko
sleep 1
insmod rtl8192se.ko
sleep 1
iw reg set US
hostapd -B ./hostapd.conf
brctl addbr br0
ifconfig eth0 up
ifconfig wan up
ifconfig lan0 up
ifconfig lan1 up
brctl addif br0 lan0
brctl addif br0 lan1
brctl addif br0 wlan0
ifconfig br0
sleep 2
/etc/init.d/smbd stop
sleep 1
/etc/init.d/smbd start
sleep 1
dnsmasq --interface=br0 --dhcp-range=br0,,,12h
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o wan -j MASQUERADE
dhclient wan

of course, make the script executable and run it with:

root@localhost:~# chmod +x ubuntu_ap
root@localhost:~# ./ubuntu_ap