Инструменты пользователя

Инструменты сайта


bananapi:wifi_bpi-m1

BPI-M1+ включение WI-FI

1. Загрузка WI-FI драйвера.

Настройка Banana Pi M1+ с ОС Вananian

uname -a
Linux bananapi 3.4.108-bananian #2 SMP PREEMPT Thu Aug 13 06:08:25 UTC 2015 armv7l GNU/Linux

В Banana Pi M1+ используется WI-FI чип AP6181. Для этого чипа подходит драйвер от чипа AP6210. Драйвер загружается командой:

modprobe ap6210
root@bananapi /mnt # iwconfig 
lo        no wireless extensions.

tunl0     no wireless extensions.

eth0      no wireless extensions.

root@bananapi /mnt # modprobe ap6210
root@bananapi /mnt # iwconfig       
lo        no wireless extensions.

tunl0     no wireless extensions.

wlan0     IEEE 802.11  ESSID:""  
        Mode:Managed  Frequency:2.412 GHz  Access Point: Not-Associated   
        Bit Rate:65 Mb/s   Tx-Power:32 dBm   
        Retry min limit:7   RTS thr:off   Fragment thr:off
        Power Managementmode:All packets received
        Link Quality=5/5  Signal level=0 dBm  Noise level=0 dBm
        Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
        Tx excessive retries:0  Invalid misc:0   Missed beacon:0

eth0      no wireless extensions.

Посмотреть загруженные модули можно командой:

root@bananapi /etc/network # lsmod
Module                  Size  Used by
ap6210                584108  0 
cfg80211              173441  1 ap6210
cpufreq_conservative     5966  0 
cpufreq_powersave       1197  0 
cpufreq_userspace       3294  0 
cpufreq_stats           5901  0 
8021q                  18594  0 
garp                    6114  1 8021q
stp                     1993  1 garp
llc                     5491  2 stp,garp

Если нужно, чтобы драйвер загружался автоматически при запуске системы, то в файл /etc/modules нужно добавить строку «ap6210».

root@bananapi /etc/network # cat /etc/modules 
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

# VLAN support for BPI-R1
8021q
ap6210

В линуксе Armbian используется драйвер brcmfmac и он уже есть в системе

uname -a
Linux BPI 5.10.60-sunxi #21.08.2 SMP Tue Sep 14 16:28:44 UTC 2021 armv7l GNU/Linux
lsmod | grep brcmfmac
brcmfmac              176128  0
brcmutil               16384  1 brcmfmac
cfg80211              495616  1 brcmfmac

НО!!! Оказывается, по умолчанию M1+ думает, что это просто M1, у которого нет Wi-Fi, это можно проверить командой

cat /proc/device-tree/model
LeMaker Banana Pi

Если это действительно так, можно добавить следующую строку к своему /boot/armbianEnv.txt и перезагрузиться, и система должна показать правильно определить модель устройства и появится сетевой интерфейс wlan0 и т. Д.

fdtfile=sun7i-a20-bananapi-m1-plus.dtb
cat /boot/armbianEnv.txt
verbosity=1
bootlogo=false
console=both
disp_mode=1920x1080p60
overlay_prefix=sun7i-a20
rootdev=UUID=42fa45e0-b41c-4985-8257-b549c8bd7070
rootfstype=ext4
fdtfile=sun7i-a20-bananapi-m1-plus.dtb
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u
cat /proc/device-tree/model
Banana Pi BPI-M1-Plus

2. Подключение в роли клиента.

Сканирую доступные WI-FI сети.

root@bananapi /etc # iwlist wlan0 scan             
wlan0     Scan completed :
          Cell 01 - Address: 40:4A:03:78:B1:5D
                    ESSID:"My-WI-FI"
                    Mode:Managed
                    Frequency:2.422 GHz (Channel 3)
                    Quality:3/5  Signal level:-69 dBm  Noise level:-92 dBm
                    IE: IEEE 802.11i/WPA2 Version 1
                        Group Cipher : TKIP
                        Pairwise Ciphers (2) : TKIP CCMP
                        Authentication Suites (1) : PSK
                    IE: Unknown:    DDA80050F204104A0001101044000102103B000103104700102880288028801880A880404A0378B15D1021001A5A7958454C20436F6D6D756E69636174696F6E7320436F72702E10230014486F6D6520496E7465726E65742043656E7465721024000F4B45454E4554494320736572696573104200046E6F6E651054000800060050F2040001101100155A7958454C20496E7465726E65742043656E746572100800020084103C000101
                    Encryption key:on
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 9 Mb/s
                              18 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 12 Mb/s
                              24 Mb/s; 48 Mb/s

Для системы без графической оболочки рекомендуется использовать supplicant tool для подключения к закрытым WI-FI сетям.
Установка пакета:

apt-get install wpasupplicant

Необходимо отредактировать файл /etc/wpa_supplicant/wpa_supplicant.conf. Если файла нет, то необходимо создать.

root@bananapi /etc/network # cat /etc/wpa_supplicant/wpa_supplicant.conf 
ap_scan=1
network={
        ssid="My-WI-FI"
        psk="*************"
}
root@bananapi /etc/network #

Где ssid - имя WI-FI сети, psk - пароль сети.

В файл /etc/network/interfaces дописываю следующее:

auto wlan0

# dhcp configuration
iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Активирую WI-FI интерфейс.

root@bananapi /etc/network # ifup wlan0  
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/98:3b:16:c6:3e:ad
Sending on   LPF/wlan0/98:3b:16:c6:3e:ad
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 20
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 10.215.130.1
DHCPACK from 10.215.130.1
bound to 10.215.130.179 -- renewal in 37933 seconds.

Проверяю, что получилось.

root@bananapi /etc/network # iwconfig    
lo        no wireless extensions.

tunl0     no wireless extensions.

wlan0     IEEE 802.11  ESSID:"My-WI-FI"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 40:4A:03:78:B1:5D   
          Bit Rate=39 Mb/s   Tx-Power:32 dBm   
          Retry min limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=2/5  Signal level=-70 dBm  Noise level=-92 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

eth0      no wireless extensions.

root@bananapi /etc/network # ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 98:3b:16:c6:3e:ad  
          inet addr:10.215.130.179  Bcast:10.215.130.255  Mask:255.255.255.0
          inet6 addr: fe80::9a3b:16ff:fec6:3ead/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1646 (1.6 KiB)  TX bytes:3662 (3.5 KiB)

3. Подключение в роли точки доступа.

Проверяю какие паке установлены в сиситеме

bananapi# dpkg -l | grep ssl
ii  libgnutls-openssl27:armhf      3.3.8-6+deb8u4             armhf        GNU TLS library - OpenSSL wrapper
ii  libio-socket-ssl-perl          2.002-2+deb8u2             all          Perl module implementing object 
oriented interface to SSL sockets
ii  libnet-ssleay-perl             1.65-1+deb8u1              armhf        Perl module for Secure Sockets Layer 
(SSL)
ii  libssl1.0.0:armhf              1.0.1t-1+deb8u6            armhf        Secure Sockets Layer toolkit - shared 
libraries
ii  openssl                        1.0.1t-1+deb8u6            armhf        Secure Sockets Layer toolkit - 
cryptographic utility
bananapi# dpkg -l | grep libnl
ii  libnl-3-200:armhf              3.2.24-2                   armhf        library for dealing with netlink sockets
ii  libnl-genl-3-200:armhf         3.2.24-2                   armhf        library for dealing with netlink sockets - generic netlink

Устанавливаю hostap

bananapi# git clone git://w1.fi/srv/git/hostap.git
Cloning into 'hostap'...
remote: Counting objects: 78515, done.
remote: Compressing objects: 100% (14137/14137), done.
remote: Total 78515 (delta 64276), reused 78373 (delta 64180)
Receiving objects: 100% (78515/78515), 15.86 MiB | 927.00 KiB/s, done.
Resolving deltas: 100% (64276/64276), done.
Checking connectivity... done.
bananapi# cp defconfig .config

Дополнительно устанавливаю

bananapi# apt-get install libnl-3-dev
bananapi# apt-get install libnl-genl-3-dev
bananapi# apt-get install libnl-dev
bananapi# apt-get install libssl-dev

Создаю ссылку

bananapi# ln -s  /usr/include/libnl3/netlink netlink

Устанавливаю

bananapi# make

bananapi#

cp hostapd /usr/sbin
cp hostapd_cli /usr/sbin
mkdir -p /etc/hostapd
cd /etc/hostapd
cat >> hostapd.conf
interface=wlanx
driver=nl80211
ssid=ap6210_ap_test
channel=6
hw_mode=g
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Проверяю

cat /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=banana
channel=10
hw_mode=g
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
hostapd -B /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Could not re-add multicast membership for vendor events: -2 (No such file or directory)
Using interface wlan0 with hwaddr 98:3b:16:c6:3e:ad and ssid "banana"
wlan0: Could not connect to kernel driver
Interface initialization failed
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED
wlan0: Unable to setup interface.
wlan0: interface state DISABLED->DISABLED
wlan0: AP-DISABLED
wlan0: CTRL-EVENT-TERMINATING
hostapd_free_hapd_data: Interface wlan0 wasn't started
nl80211: deinit ifname=wlan0 disabled_11b_rates=0

Смотрю, что получилось

bananapi# ifconfig
eth0      Link encap:Ethernet  HWaddr 02:17:02:01:d0:e8
          inet addr:10.215.130.6  Bcast:10.215.130.255  Mask:255.255.255.0
          inet6 addr: fe80::17:2ff:fe01:d0e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:329 errors:0 dropped:0 overruns:0 frame:0
          TX packets:275 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:42062 (41.0 KiB)  TX bytes:52593 (51.3 KiB)
          Interrupt:117 Base address:0xc000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1200 (1.1 KiB)  TX bytes:1200 (1.1 KiB)

wlan0     Link encap:Ethernet  HWaddr 98:3b:16:c6:3e:ad
          inet addr:192.168.100.1  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::9a3b:16ff:fec6:3ead/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:492 (492.0 B)

bananapi# iwconfig
lo        no wireless extensions.

tunl0     no wireless extensions.

wlan0     IEEE 802.11  ESSID:"banana"
          Mode:Master  Frequency:2.457 GHz  Access Point: 98:3B:16:C6:3E:AD
          Bit Rate=65 Mb/s   Tx-Power:32 dBm
          Retry min limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Managementmode:All packets received

eth0      no wireless extensions.
bananapi#

/ etc / init.d / hostapd
#!/bin/sh

### BEGIN INIT INFO
# Provides:		hostapd
# Required-Start:	$remote_fs
# Required-Stop:	$remote_fs
# Should-Start:		$network
# Should-Stop:
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description:	Advanced IEEE 802.11 management daemon
# Description:		Userspace IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP
#			Authenticator
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON_SBIN=/usr/sbin/hostapd
DAEMON_DEFS=/etc/default/hostapd
DAEMON_CONF=
NAME=hostapd
DESC="advanced IEEE 802.11 management"
PIDFILE=/var/run/hostapd.pid

[ -x "$DAEMON_SBIN" ] || exit 0
[ -s "$DAEMON_DEFS" ] && . /etc/default/hostapd
[ -n "$DAEMON_CONF" ] || exit 0

DAEMON_OPTS="-B -P $PIDFILE $DAEMON_OPTS $DAEMON_CONF"

. /lib/lsb/init-functions

case "$1" in
  start)
  log_daemon_msg "Starting $DESC" "$NAME"
	start-stop-daemon --start --oknodo --quiet --exec "$DAEMON_SBIN" \
	--pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null
log_end_msg "$?"
;;
  stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --oknodo --quiet --exec "$DAEMON_SBIN" \
	--pidfile "$PIDFILE"
log_end_msg "$?"
;;
  reload)
	log_daemon_msg "Reloading $DESC" "$NAME"
start-stop-daemon --stop --signal HUP --exec "$DAEMON_SBIN" \
	--pidfile "$PIDFILE"
log_end_msg "$?"
;;
 restart|force-reload)
	$0 stop
sleep 8
$0 start
;;
 status)
status_of_proc "$DAEMON_SBIN" "$NAME"
exit $?
;;
  *)
	N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|reload|status}" >&2
exit 1
;;
esac

exit 0
/ etc / default / hostapd
# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
#DAEMON_CONF=""

# Additional daemon options to be appended to hostapd command:-
# 	-d   show more debug messages (-dd for even more)
# 	-K   include key data in debug messages
# 	-t   include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""

Установка автоматического запуска hostapd при загрузке:

$sudo update-rc.d hostapd defaults

———— SystemD ————

$ sudo systemctl enable hostapd.service

———— SysVinit ————

$ sudo service hostapd enable

Отключение автоматического запуска hostapd при загрузке:

$sudo update-rc.d hostapd disable

———— SystemD ————

$ sudo systemctl disable hostapd.service

———— SysVinit ————

$ sudo service hostapd disable

Команда для перезапуска hostapd

$ sudo /etc/init.d/hostapd restart

———— SystemD ————

$ sudo systemctl restart hostapd.service

———— SysVinit ————

$ sudo service hostapd restart
reboot

Проверка запуска hostapd

# ps -ef | grep hostapd
root       512     1  0 20:51 ?        00:00:00 /usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf
/etc/init.d/hostapd status

———— SystemD ————

systemctl status hostapd

———— SysVinit ————

service hostapd status

Armbian

В линуксе Armbian для управления сетью используется NetworkManager и утилиты nmcli, nmtui Для нормальной работы в качестве точки доступа нужно его отключить

systemctl disable NetworkManager

Если хочется то можно и удалить

apt-get purge network-manager

Далее просто нужно настроить hostapd который уже установлен в системе. Проверить можно командой.

dpkg -l | grep hostapd
ii  hostapd                        3:2.9-102~armbian21.05.1+1     armhf        IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP Authenticator

Ссылки:
http://forum.banana-pi.org/t/wifi-on-bpi-m1/246
http://wiki.lemaker.org/BananaPro/Pi:WiFi_configuration
http://geekelectronics.org/raspberry-pi/banana-pi-nastroyka-wi-fi.html
http://www.awasu.com/weblog/bpi-gateway/wifi-access-point
http://www.myhsd.net/bananapro-wifi-access-point
http://wiki.lemaker.org/BananaPro/Pi:WiFi_configuration
https://www.linux.org.ru/forum/general/9869417 https://www.apt-browse.org/browse/ubuntu/trusty/universe/i386/hostapd/1:2.1-0ubuntu1/file/etc/init.d/hostapd
https://www.apt-browse.org/browse/ubuntu/trusty/universe/i386/hostapd/1:2.1-0ubuntu1/file/etc/default/hostapd
http://www.fedora.md/2015/03/26/bpi-r1-часть-3-bananian-настройка-точки-доступа-wifi
http://hizz.livejournal.com/3817.html
http://blog.tian.it/banana-pi-pro-wlan-configuration
https://forum.banana-pi.org/t/no-wifi-on-banana-pi-m1-running-armbian-buster/9911
https://awasu.com/weblog/bpi-gateway/wifi-access-point
http://www.myhsd.net/bananapro-wifi-access-point
https://www.fedora.md/2015/03/26/bpi-r1-%d1%87%d0%b0%d1%81%d1%82%d1%8c-2-fedora-%d0%bd%d0%b0%d1%81%d1%82%d1%80%d0%be%d0%b9%d0%ba%d0%b0-%d1%82%d0%be%d1%87%d0%ba%d0%b8-%d0%b4%d0%be%d1%81%d1%82%d1%83%d0%bf%d0%b0-wifi
https://blog.tian.it/banana-pi-pro-wlan-configuration/
https://adminblog.net.ua/raspberry/sozdanie-wi-fi-tochki-dostupa-raspberry-pi.html

bananapi/wifi_bpi-m1.txt · Последние изменения: 2022/05/15 17:12 — alex