User Tools

Site Tools


Translations of this page:

en:bpi-r2:wlan

WLAN

:!: Config-files don't have any security-params enabled (e.g. WLAN-security/authentification in HostAPd), these are only a start for quick testing

internal

in Kernel 4.4.70 code is available, but must be activated

GitHub Forum

Patch Patch #2

:!: wpasupplicant must be removed and hostapd+dnsmasq installed:

apt-get remove wpasupplicant

apt-get install hostapd dnsmasq

copy cfg to /system/etc/firmware/

helper-applications for next steps (unpack to /usr/bin) and Firmware (unpack to /etc/firmware/) from here

  1. wmt_loader
  2. stp_uart_launcher -p /etc/firmware &
  3. load driver module (if compiled as module 5.4+): modprobe wlan_gen2
  4. echo A >/dev/wmtWifi (activate AP-Mode)

in last step ap-device (Accesspoint) will be created, which can be used by hostapd

[14:14] root@bpi-r2:~# ifconfig -a|grep Link                                                                                                                                   
ap0       Link encap:Ethernet  HWaddr 02:08:22:68:39:ff
bond0     Link encap:Ethernet  HWaddr e2:7c:e0:71:31:c1
eth0      Link encap:Ethernet  HWaddr 08:00:00:00:00:00
          inet6 addr: fe80::a00:ff:fe00:0/64 Scope:Link
eth1      Link encap:Ethernet  HWaddr 08:00:00:00:00:01
          inet6 addr: fe80::a00:ff:fe00:1/64 Scope:Link
lo        Link encap:Local Loopback
sit0      Link encap:IPv6-in-IPv4
tunl0     Link encap:IPIP Tunnel  HWaddr
wlan0     Link encap:Ethernet  HWaddr 00:08:22:68:39:ff

/etc/hostapd/hostapd.conf:

hw_mode=g
interface=ap0
driver=nl80211
channel=1
auth_algs=1
ssid=test

start hostapd

hostapd -dd /etc/hostapd/hostapd.conf

interface can now be further configured and DHCP-Server configured and started: ip-configuration

old Script to start-up wireless AP wifi.sh

client-mode

Afair only working in vendor kernel versions (4.4,4.14)

http://forum.banana-pi.org/t/topic/5548

works with 4.14-mt6625 branch (4.14.32 + vendor-code + fixes)

apt install wpasupplicant
/usr/bin/wmt_loader
/usr/bin/stp_uart_launcher -p /etc/firmware &
echo 1 >/dev/wmtWifi

/etc/wpa_supplicant/wpa_supplicant.conf:

network={
        ssid="ssid"
        psk="12345678"
        priority=1
}
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
dhclient wlan0

Kernel 4.14

code from 4.4.70 has been merged to my github-repo

wifi-configuration is the same as in Kernel 4.4 internal

discussion here: forum

systemd init script here: http://forum.banana-pi.org/t/bpi-r2-internal-wifi-bt-mt6625l-kernel/4307/281

known issues

random numbers

after a (Re-)boot the random-number generator not filled enough, so that connection-attempts will be rejected.

in the hostapd-log there are entries like this:

random: Cannot read from /dev/random: Resource temporarily unavailable
random: Got 0/14 bytes from /dev/random
random: Only 6/20 bytes of strong random data available from /dev/random
random: Not enough entropy pool available for secure operations
WPA: Not enough entropy in random pool to proceed - reject first 4-way handshake
...
WPA: Reject 4-way handshake to collect more entropy for random number generation
random: Mark internal entropy pool to be ready (count=1/2)
...
random: Cannot read from /dev/random: Resource temporarily unavailable
random: Got 0/14 bytes from /dev/random
random: Only 6/20 bytes of strong random data available from /dev/random
random: Allow operation to proceed based on internal entropy

http://forum.banana-pi.org/t/bpi-r2-new-image-release-ubuntu-16-04-v1-3-2018-3-30/5293/25

apt-get install rng-tools
echo 'HRNGDEVICE=/dev/urandom' >> /etc/default/rng-tools

init failed

root@bpi-iot-ros-ai:~# wmt_loader init combo device
Opened combo device
get device id : 30243 
set device id : 30243
do module init: 30243
failed to init module

This can be ignored because the combo-driver tries to init wifi,bt,gps and fm. Last 2 fail because driver does not support them.

stpnode

Can't open device node(/dev/stpwmt) error:-1
//in dmesg:
[WMT-DEV][W]WMT_open:wait_event_timeout (2000)ms,(200)jiffies,return -EIO

reboot fixed that…reason still unclear

Also this can be tried:

apt-get install network-manager
sudo nmcli radio wifi off
rfkill unblock 1
rfkill unblock 2

no traffic

Kernelmodules SCH_FQ / SCH_FQ_CODEL are known breaking ap0-functionality

maybe there are some kalHifAhbKalWakeLockTimeout messages in dmesg

maybe NETFILTER_XT_TARGET_NFQUEUE does have similar effects (see here)

rcu_stall

this is maybe caused by net.ifnames=0

[  437.885886] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 2614)                                                                
[  437.892961] [MTK-WIFI] WIFI_write: WIFI_write A                                                                                          
[  437.892961]                                                                                                                              
[  437.938648] kalFirmwareImageMapping firmware size 225840                                                                                 
[  439.132189] [MTK-WIFI] register_set_p2p_mode_handler: (pid 2620) register set p2p mode handler b6888aac                                  
[  439.141960] [MTK-WIFI] WIFI_write: WMT turn on WIFI success!                                                                             
[  460.170441] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:

hang occours in kalioctl (drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_kal.c) while calling kernel-function down_interruptible (kernel/locking/semaphore.c), semaphore is created correctly in drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_init.c (sema_init(&prGlueInfo→ioctl_sem, 1);)

solution: do not use net.ifnames in cmdline and use udev-renaming

driver hang

check if there is a wlan0 device before starting wifi.sh/manual init of ap0 device. driver will hang after message

[MTK-WIFI] WIFI_write: WMT turn on WIFI success

if there is a wlan0 interface not mapped to the mt6625l driver (maybe pcie/usb-wifi-device).

rootcause is adding a handler to wrong netdev searched with hardcoded wlan0 in drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/wmt_chrdev_wifi.c

#define WLAN_IFACE_NAME "wlan0"
static INT8 *ifname = WLAN_IFACE_NAME;
netdev = dev_get_by_name(&init_net, ifname);
pf_set_p2p_mode(netdev, p2pmode);

you can rename existing wlan0 to anything else before starting ap0 init

ip link set wlan0 name wlan_2g
ip link set wlan1 name wlan_5g

did this with my mt7615 (dbdc mode) and wifi init finished with success in linux 5.10

client-mode does not work

client mode does not work in 4.9+

http://forum.banana-pi.org/t/bpi-r2-internal-wifi-bt-mt6625l-kernel/4307/293

i tested wifi-client in 5.10, here it is working with config posted here:

http://forum.banana-pi.org/t/bpi-r2-internal-wifi-bt-mt6625l-kernel/4307/329

external

MT7612

4.4.70

forum

git clone https://github.com/BPI-SINOVOIP/BPI-R2-bsp.git bpi_r2_mt76
cd bpi_r2_mt76/
cd linux-mt/drivers/net/wireless/mediatek
git clone https://github.com/dfiloni/mt76.git
cd ../../../.. #bpi_r2_mt76/linux-mt/
patch -p1 < drivers/net/wireless/mediatek/mt76/kernel-patches/0001-add-basic-register-field-manipulation-macros.patch
nano drivers/net/wireless/mediatek/Makefile 
#add: obj-$(CONFIG_MT76)     += mt76/
nano drivers/net/wireless/mediatek/Kconfig
#add before endif: before endif # WL_MEDIATEK: source "drivers/net/wireless/mediatek/mt76/Kconfig"
cd ..
./build.sh => 4
#networking support => wireless =>  <M>   Generic IEEE 802.11 Networking Stack (mac80211)
#Device Drivers  => Network device support => Wireless LAN => [*]   Mediatek Wireless LAN support => <M>   MediaTek MT76x2 802.11ac chips support
./build.sh => 1
cp SD/BPI-BOOT/bananapi/bpi-r2/linux/uImage /media/$USER/BPI-BOOT/bananapi/bpi-r2/linux/uImage
sudo cp -r SD/BPI-ROOT/lib/modules /media/$USER/BPI-ROOT/lib/
cp linux-mt/drivers/net/wireless/mediatek/mt76/firmware/* /media/$USER/BPI-ROOT/lib/firmware/
#scp linux-mt/drivers/net/wireless/mediatek/mt76/firmware/* root@192.168.0.10:/lib/firmware/
sync

4.14

Kernel 4.14 (in progress…):

Click to display ⇲

Click to hide ⇱

import PCIe-patch, if not done yet

patch -p1 < pcie.patch
cd drivers/net/wireless/mediatek/
git clone https://github.com/openwrt/mt76.git
  • in mt76/mt7603.h missing “#include <linux/interrupt.h>”
  • in mt76/mac80211.c missing “#include <linux/of.h>”
  • in Makefile missing “CFLAGS_trace.o := -I$(src)” und “CFLAGS_mt76x2_trace.o := -I$(src)”
  • and include code in drivers/net/wireless/mediatek/Makefile
    obj-$(CONFIG_MT76)  += mt76/

    and drivers/net/wireless/mediatek/Kconfig

    source "drivers/net/wireless/mediatek/mt76/Kconfig"

unpack full driver-code for mt76x2 + mt76x3 to drivers/net/wireless/mediatek/

activate following modules in kernel:

CONFIG_MAC80211=m
CONFIG_CFG80211=m
CONFIG_MT76=m

#pcie
CONFIG_PCIEPORTBUS=y
CONFIG_PCIE_MEDIATEK=y
CONFIG_PHY_MTK_TPHY=y

copy the firmware

sudo cp drivers/net/wireless/mediatek/mt76/firmware/* /media/$USER/BPI-ROOT/lib/firmware/

configure

[10:50] root@bpi-r2:~# ifconfig -a |grep wlan
wlan1     Link encap:Ethernet  HWaddr f8:62:aa:50:12:1d  <<<

if your wlan-device-number is above 1, you can edit that with

nano /etc/udev/rules.d/70-persistent-net.rules

/etc/hostapd/hostapd.conf (change interface)

interface=wlan1
#interface=ap0
driver=nl80211
 
ssid=r2_AP1
 
hw_mode=g
channel=1
#macaddr_acl=0
auth_algs=1
#ignore_broadcast_ssid=0
#wpa=2
#wmm_enabled=1
#wpa_passphrase=12345678
#wpa_key_mgmt=WPA-PSK
#wpa_pairwise=TKIP
#rsn_pairwise=CCMP

/etc/hostapd/hostapd_wlan1.conf

start hostapd (Debugmode):

hostapd -dd /etc/hostapd/hostapd.conf

set IP-address and start dnsmasq: ip-configuration

MT7615

firmware-files to /lib/firmware/mediatek/

http://forum.banana-pi.org/t/802-11ac-4x4-standard-size-mini-pcie-card-is-launched/11545/15?u=frank-w

I have added mt7615 driver in 5.4 on nov 19 2020 (should be 5.4.78).

Mt7615 is separate kernel-module which needs to be loaded

modprobe mt7615e

dual-ap

Dbdc mode was added in 5.7

echo 1 > /sys/kernel/debug/ieee80211/phy0/mt76/dbdc

There is a report that dbdc cannot be enabled after reboot,but on my tests this works without problems

You can only enable 2.4ghz on phy0, and 5ghz on phy1 simultaneously.

antenna connectors

HostAPd

5GHz

apt-get install iw
iw list | grep "Supported interface modes" -A 8
apt-get install iw wireless-regdb crda

country code

setting Country-Code (regulary domain) can be a bit tricky

iw reg set ISO_3166-1_alpha-2
iw reg set DE
iw reg get

wrong output:

global
country 00: DFS-UNSET

correct:

global
country US: DFS-ETSI

maybe try this:

modprobe cfg80211 ieee80211_regdom=US
COUNTRY=US crda
$ sudo nano /etc/modprobe.d/cfg80211.conf
options cfg80211 ieee80211_regdom=US

possible frequencies

iw list | grep MHz

Hostapd-Configuration

$ sudo nano /etc/hostapd/hostapd.conf
[...]
country_code=US
ieee80211n=1
ieee80211d=1
hw_mode=a
channel=48
[...]

Config-Examples taken from here (DE)

CountryCode-List

IP-Configuration

set IP-address:

#set IP and start 
ip addr add 192.168.10.1/24 dev ap0
#ip link set dev ap0 up
 
ip addr add 192.168.11.1/24 dev wlan1

/etc/dnsmasq.conf (activate line by removing # on begin of line)

conf-dir=/etc/dnsmasq.d

/etc/dnsmasq.d/interfaces.conf

#interface=eth0
interface=wlan0
#interface=eth1
interface=ap0
 
# DHCP-Server not active for Interface
#no-dhcp-interface=ppp0
no-dhcp-interface=eth0
no-dhcp-interface=eth1
 
#dhcp-authoritative
dhcp-range=ap0,192.168.10.100,192.168.10.150,255.255.255.0,48h
dhcp-option=ap0,3,192.168.10.1
dhcp-range=wlan1,192.168.11.100,192.168.11.150,255.255.255.0,48h
dhcp-option=wlan1,3,192.168.11.1
 
#special handling of some hosts (here using another dns-server)
#dhcp-host=ap0,x:y:z:x:y:z,frank,set:specialhosts,192.168.10.27,12h
dhcp-option=tag:specialhosts,option:dns-server,192.168.0.11,8.8.4.4

/etc/dnsmasq.d/interfaces.conf

service dnsmasq start

Routing

nano /etc/sysctl.conf
#activate net.ipv4.ip_forward=1 and net.ipv6.conf.all.forwarding=1 by removing # at beginning of line
sysctl -p /etc/sysctl.conf

if the BPI-R2 is not the main-router (access to internet), it is neccessary, that this main-router knows the networks (wlan) behind the R2.

The following commands must be entered on a (Debian-)Router, to append the networks to its routing-table (will be lost on reboot if not executed on boot):

route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.0.10
route add -net 192.168.11.0 netmask 255.255.255.0 gw 192.168.0.10

here is 192.168.10.0 the 1st WLAN, 192.168.11.0 the 2nd WLAN and 192.168.0.10 is the LAN-IP of the BPI-R2 (same subnet as LAN-IP from main-router)

en/bpi-r2/wlan.txt · Last modified: 2023/06/08 17:06 by 127.0.0.1