How to configure built-in WIFI module

This wiki page describes wifi setting instructions and available with OGA HW Rev 1.1 only.

  1. Module Key Features
  2. Configuring WIFI station mode (1) - using [Configuration] Menu
  3. Configuring WIFI station mode (2) - using command line
  4. Configuring WIFI AP mode
  5. Checking basic connection of wlan0
  6. Workaround to support Suspend/Resume with esp8089 module
Items Specifications
Module ESP-WROOM-S2
MCU ESP8266EX
WIFI Protocol 802.11 b/g/n, up to 72.2 Mbps of data rate
Frequency Range 2.4 GHz ~ 2.5 GHz (2400 MHz ~ 2483.5 MHz)
Interface SDIO interface up to 50MHz, SDIO v2.0

You can activate WIFI connection with built-in WIFI module ('wlan0' node) using [CONFIGURATION] menu of Emulationstation.
Please refer to this wiki page.
-> Setting Network

Or you can establish WIFI network using the following instuctions.

First, check esp8089 module is loaded normally.

$ lsmod
Module                  Size  Used by
esp8089               266240  0
sch_fq_codel           20480  5
ip_tables              24576  0
x_tables               32768  1 ip_tables
ipv6                  372736  24

Turn on wifi radio.

# nmcli radio wifi on

You can get all available WIFI list as following.

$ nmcli dev wifi list
IN-USE  SSID            MODE   CHAN  RATE        SIGNAL  BARS  SECURITY  
        SSID_1          Infra  1     130 Mbit/s  92      ▂▄▆█  WPA1 WPA2 
        SSID_2          Infra  11    130 Mbit/s  92      ▂▄▆█  WPA2 802.1
        SSID_3          Infra  11    130 Mbit/s  92      ▂▄▆█  WPA2     

Enter SSID and password data.

$ nmcli dev wifi con 'SSID_1' password 'password_of_ssid1'

If there is no issue during network establishment, you will get IP information.

$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether ab:cd:ef:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.5/24 brd 192.168.0.255 scope global dynamic noprefixroute wlan0
       valid_lft 6830sec preferred_lft 6830sec
    inet6 fe80::1234:1234:1234:1234/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Then, check ping operation.

$ ping google.com

There is no GUI menu to configure WIFI AP mode for now.
Please use the following instruction via command line.

1. Update & Upgrade

$ sudo apt update -y
$ sudo apt upgrade -y

2. Install Packages

$ sudo apt install -y dhcpcd5
$ sudo apt install -y hostapd dnsmasq

Since the configurations are not ready yet, so display related services now.

$ sudo systemctl disable hostapd
$ sudo systemctl disable dnsmasq

3. Setup (1) - Configuring a static IP

To configure the static IP address, please edit a dhcpcd configuration file, /etc/dhcpcd.conf.
Go to the end fo this file and add the following lines.
For this example, we will use a static IP, 192.168.4.1.

$ vi /etc/dhcpcd.conf
interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

4. Setup (2) - Configuring the access point host software - 'hostapd'

(1) You need to edit the hostapd configuration file in /etc/hostapd.

$ vi /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=${NameOfNetwork}
hw_mode=${hw_mode}
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=${password}
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

ESP8266ex supports 2.4GHz band, so we will set 'hw_mode' ad 'g' for this example.

  • a = IEEE 802.11a (5 GHz)
  • b = IEEE 802.11b (2.4 GHz)
  • g = IEEE 802.11g (2.4 GHz)
  • ad = IEEE 802.11ad (60 GHz)

(2) Then need to tell the system where to find this configuration file.

$ vi /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"

5. Setup (3) - Configuring DHCP server - 'dnsmasq'

Add the following information in the dnsmasq configuration file, /etc/dnsmasq.conf.

$ vi /etc/dnsmasq.conf
# If you don't want dnsmasq to read /etc/resolv.conf or any other
# file, getting its servers from this file instead (see below), then
# uncomment this.
no-resolv
 
# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
interface=wlan0
 
# On systems which support it, dnsmasq binds the wildcard address,
# even when it is listening on only some interfaces. It then discards
# requests that it shouldn't reply to. This has the advantage of
# working even when interfaces come and go and change address. If you
# want dnsmasq to really bind only the interfaces it is listening on,
# uncomment this option. About the only time you may need this is when
# running another nameserver on the same machine.
bind-interfaces
 
# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
dhcp-range=192.168.4.3,192.168.4.20,12h

6. Setup (4) - Configuring Network

Create /etc/network/interfaces.
Make sure that 3rd line is blocked using “#”.

allow-hotplug wlan0
iface wlan0 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

7. Start services

$ sudo systemctl enable dnsmasq
$ sudo systemctl start dnsmasq
 
$ sudo systemctl enable hostapd
$ sudo systemctl start hostapd
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether ab:cd:ef:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 192.168.4.1/24 brd 192.168.4.255 scope global noprefixroute wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::1234:1234:1234:1234/64 scope link 
       valid_lft forever preferred_lft forever

If you get fails during network setup, please check the followings using ssh with a USB-to-Ethernet adapter or UART console.

mmc1 node

$ cat /sys/kernel/debug/mmc1/ios
clock:          50000000 Hz
vdd:            21 (3.3 ~ 3.4 V)
bus mode:       2 (push-pull)
chip select:    0 (don't care)
power mode:     2 (on)
bus width:      2 (4 bits)
timing spec:    2 (sd high-speed)
signal voltage: 0 (3.30 V)
driver type:    0 (driver type B)

sdio id

$ cat /sys/bus/sdio/devices/mmc1\:0001\:1/modalias 
sdio:c00v6666d1111

module

$ lsmod
Module                  Size  Used by
esp8089               266240  0
sch_fq_codel           20480  5
ip_tables              24576  0
x_tables               32768  1 ip_tables
ipv6                  372736  24

/lib/systemd/system-sleep/sleep

#!/bin/bash

case $1 in
  pre)
       rmmod esp8089
       ;;
  post)
       modprobe -i esp8089
       ;;
esac
$ sudo chmod a+x /lib/systemd/system-sleep/sleep