ericwoud / buildR64arch

Build script for image for BananaPi R64 / R3 (R4) running Arch Linux
21 stars 5 forks source link

BPI-R3 AP Mode: wlan0 and wlan1 Interfaces Not Showing, Hostapd Service Failing #14

Closed GiovanniBalestrieri closed 3 months ago

GiovanniBalestrieri commented 3 months ago

I recently installed the minimal Arch Linux OS using the AP mode of the image. Based on my understanding, the Access Point should work out of the box, but I’ve encountered some issues.

Problems Encountered:

Details:

Hostapd Service Status:
○ hostapd.service - Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
   Loaded: loaded (/usr/lib/systemd/system/hostapd.service; disabled; preset: disabled)
   Drop-In: /etc/systemd/system/hostapd.service.d
           └─override.conf
   Active: inactive (dead)

Journalctl Output:

$ sudo journalctl -xeu hostapd.service
[...]
The job identifier is 48431.
Jul 25 03:47:29 bpir3 hostapd[239561]: /usr/bin/hostapd-launch: line 39: /etc/hostapd/hostapd.conf: No such file or directory
Jul 25 03:47:29 bpir3 hostapd[239561]: Running: /usr/sbin/hostapd -B -P /run/hostapd.pid /run/hostapdconf/hostapd.conf
Jul 25 03:47:29 bpir3 hostapd[239565]: Interface name not specified in /run/hostapdconf/hostapd.conf, nor by '-i' parameter
Jul 25 03:47:29 bpir3 hostapd[239565]: : interface state UNINITIALIZED->DISABLED
Jul 25 03:47:29 bpir3 hostapd[239565]: : AP-DISABLED
Jul 25 03:47:29 bpir3 hostapd[239565]: : CTRL-EVENT-TERMINATING
Jul 25 03:47:29 bpir3 hostapd[239565]: hostapd_free_hapd_data: Interface wasn't started
Jul 25 03:47:29 bpir3 hostapd[239565]: Failed to initialize interface
Jul 25 03:47:29 bpir3 systemd[1]: hostapd.service: Can't open PID file /run/hostapd.pid (yet?) after start: No such file or directory

Output of ip link show:


    $ sudo ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1
000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1504 qdisc mq state UP mode DEFAULT group default qlen
 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq master brlan state DOWN mode DEFAULT g
roup default qlen 1000
    link/ether aa:bb:cc:33:4d:a1 brd ff:ff:ff:ff:ff:ff
4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
5: wan@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master brlan state LOWERLAYER
DOWN mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff
6: lan0@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master brlan state LOWERLAYE
RDOWN mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff
7: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master brlan state LOWERLAYE
RDOWN mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff
8: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master brlan state LOWERLAYE
RDOWN mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff
9: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master brlan state LOWERLAYE
RDOWN mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff
10: lan4@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master brlan state LOWERLAY
ERDOWN mode DEFAULT group default qlen 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff
11: brlan: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group d
efault qlen 1000
    link/ether aa:bb:cc:33:4d:a0 brd ff:ff:ff:ff:ff:ff

Request:

Could you please guide me on how to resolve these issues? Specifically:

Any help or guidance would be greatly appreciated. Thank you for your continued work on this project.

ericwoud commented 3 months ago

hostapd.service is not used.

It is hostapd@wlan0.service and hostapd@wlan1.service.

They should already be enabled and started.

ericwoud commented 3 months ago

The fact there is no wlan0 and wlan1, this may be caused by using an incompatible uart cable.

ericwoud commented 3 months ago

See

https://forum.banana-pi.org/t/bpi-r3-failed-to-start-wa-firmware/17025

If this is not the problem, please post dmesg output.

GiovanniBalestrieri commented 3 months ago

I'll attempt to isolate the issue by SSHing into the device over the wired network to see if the problem still occurs.

GiovanniBalestrieri commented 3 months ago

Great news—I can now see the wlan0 interface, and the wireless network WIFI24 is available. However, I’m still encountering issues as I’m unable to connect to the network.

To debug the problem, I checked the status of the hostapd@wlan0.service:


[userk@bpir3 ~]$ sudo systemctl status hostapd@wlan0.service
● hostapd@wlan0.service - Access point and authentication server for Wi-Fi and Ethernet (wlan0)
     Loaded: loaded (/etc/systemd/system/hostapd@.service; enabled; preset: disabled)
     Active: active (running) since Sat 2024-08-17 00:40:27 CEST; 39s ago
    Process: 2863 ExecStart=/usr/bin/hostapd-launch --pidfile /run/hostapd.wlan0.pid --device wlan0 (code=exited, status=0/SUCCESS)
   Main PID: 2900 (hostapd)
      Tasks: 1 (limit: 2327)
     Memory: 3.2M (peak: 5.2M)
        CPU: 235ms
     CGroup: /system.slice/system-hostapd.slice/hostapd@wlan0.service
             └─2900 /usr/sbin/hostapd -B -P /run/hostapd.wlan0.pid /run/hostapdconf/wlan0.conf

Aug 17 00:40:26 bpir3 systemd[1]: Starting Access point and authentication server for Wi-Fi and Ethernet (wlan0)...
Aug 17 00:40:26 bpir3 hostapd-launch[2863]: Running: /usr/sbin/hostapd -B -P /run/hostapd.wlan0.pid /run/hostapdconf/wlan0.conf
Aug 17 00:40:26 bpir3 hostapd-launch[2872]: wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
Aug 17 00:40:26 bpir3 hostapd-launch[2863]: wlan0 brlan
Aug 17 00:40:27 bpir3 systemd[1]: Started Access point and authentication server for Wi-Fi and Ethernet (wlan0).

To troubleshoot further, I tried stopping the service:

sudo systemctl stop hostapd@wlan0.service

And then manually starting hostapd, but I encountered another error:

[userk@bpir3 ~]$ sudo hostapd -dd /etc/hostapd/wlan0.conf 
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/wlan0.conf
Line 26: Invalid mobility_domain '$(echo $ssid | md5sum | cut -c1-4)'
1 errors found in configuration file '/etc/hostapd/wlan0.conf'
Failed to set up interface with /etc/hostapd/wlan0.conf
hostapd_init: free iface 0xaaaad3a9b220
Failed to initialize interface

I then tried commenting out that line, and the hostapd service started, but I still cannot connect to the network.

Could you advise on how to resolve this or suggest any additional debugging steps?

Thanks in advance for your help!

ericwoud commented 3 months ago

The service I have setup with a helper script, so that the config can contain strings that are expanded through bash.

You can find the expanded config in /run/hostapdconf/. So feed this one when directly running hostapd.

/usr/sbin/hostapd -P /run/hostapd.pid /run/hostapdconf/wlan1.conf

or comment all lines containing $()

We experienced problems with 5ghz wlan1. It seems (almost) fixed when restarting the

systemctl restart hostapd@wlan1.service

But recently I did not reproduce the problem. Also sadly do not have enough time for it.

Also check the bpi forum at the armlinuxarm script for R3

Also can use the command:

iw dev

And it shows the state the interface is in. Useful here is the amount of db, which could be limited by country settings. Also it should state the ssid (wifi network name). I experienced a few times, it was not shown and a restart was needed.

ericwoud commented 3 months ago

The service I have setup with a helper script, so that the config can contain strings that are expanded through bash.

You can find the expanded config in /run/hostapdconf/. So feed this one when directly running hostapd

/usr/sbin/hostapd -P /run/hostapd.pid /run/hostapdconf/wlan1.conf

or comment all lines containing $()

We experienced problems with 5ghz wlan1. It seems (almost) fixed when restarting the

systemctl restart hostapd@wlan1.service

But recently I did not reproduce the problem. Also sadly do not have enough time for it.

Also check the bpi forum at the armlinuxarm script for R3

I also noticed you are using AP network setup. This setup requires that the R3 is connected to your router with a lan-lan connection. This means the subnet of R3 should also be the same as your router's lan network (first 3 numbers of ip). Since the AP and router are bridged, the wifi client should get an ip number from your router's dhcp server.

If something goes wrong here, your clients will not connect to the internet. If you do not like this setup, then choose RouTer setup for the R3.

I have just added more info about router and accesspoint setup to the readme.

GiovanniBalestrieri commented 3 months ago

Problem Solved! I’m happy to report that I can now successfully connect to the wireless network!

Regarding your suggestion:

You can find the expanded config in /run/hostapdconf/. So feed this one when directly running hostapd.

Just to ensure that I fully understand the configuration setup, I couldn't find any settings files related to the wireless interfaces in the /etc/systemd/network/ directory. Based on this, I’m assuming that the wireless interfaces are managed directly by hostapd, while systemd-networkd is responsible for handling only the wired and bridge configurations. Is that correct?

ericwoud commented 3 months ago

That is correct