Jump to content

Recommended Posts

Posted

As other people have noted, there are issues trying to connect the CB1 to wifi after the first boot. I believe I've narrowed down the cause, but I'm not sure about the right way to fix it permanently.

The issue I was experiencing is as follows:
1. Flash latest armbian minimal to sd card

2. Plug into CB1 and turn it on

3. Go through first boot setup and connect to wifi normally

4. Reboot CB1

5. CB1 no longer connects to wifi, wpa_cli says 'CTRL_EVENT_SCAN_FAILED'

 

A temporary solution I found is to mask systemd-networkd, then manually unmask systemd-networkd and start it after booting. This suggests that the problem is that systemd-networkd tries to talk to the RTL8189 before it's ready, and that puts the chip into a bad state. The wireless connection works on the first boot, because the CB1 doesn't try to configure the chip until after it has booted up.

If I only mask netplan-wpa-wlan0 (instead of masking networkd) and try to manually bring it up, then I get an empty scan result, rather than CTRL_EVENT_SCAN_FAILED.

 

Is there a way to make systemd-networkd wait until after the driver has loaded before trying to configure the chip? The easiest temporary solution is probably to just add a delay before systemd-networkd starts.

 

Posted

For anyone interested in solving this temporarily, doing the following steps worked for me:

sudo systemctl edit systemd-networkd


### Editing /etc/systemd/system/systemd-networkd.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

 

[Service]
ExecStartPre=/bin/sleep 5

 

### Lines below this comment will be discarded

 

sudo systemctl daemon-reexec

sudo reboot

Posted

Hello,
I was experiencing the same problem, and both of these workarounds did not work for me.
However!
Even though I am quite inexperienced when it comes to these kinds of problems, I managed to get it working reliably again with the help of my favourite LLM-slop-machine.
Made the file: /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ctrl_interface=/run/wpa_supplicant
update_config=1

network={
  ssid="YourSSID"
  psk="YourPassword"
  key_mgmt=WPA-PSK
}

ran these commands:
sudo systemctl enable wpa_supplicant@wlan0.service
sudo systemctl restart wpa_supplicant@wlan0.service
sudo systemctl restart systemd-networkd

then this one:
sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant-wlan0.conf -D nl80211 -d
got this error from that: nl80211: Register frame command failed (type=208): ret=-114 (Operation already in progress)
then these commands:
sudo systemctl stop wpa_supplicant@wlan0.service
sudo systemctl stop wpa_supplicant.service
sudo pkill -9 wpa_supplicant || true
sudo rm -f /run/wpa_supplicant/* 

then started the service again and watching logs:
sudo systemctl start wpa_supplicant@wlan0.service
sudo journalctl -u wpa_supplicant@wlan0 -f
From there i saw "wlan0: Associated with" and "wlan0: WPA: Key negotiation completed"
however when running
ip addr show wlan0
It only showed me 2 lines and no IP. Checked that I was connected to the correct access point with:
iw dev wlan0 link
I installed dhcpcd5 to assign an IP.
sudo apt install dhcpcd5
assigning IP and checking if it was assigned:
sudo dhcpcd wlan0
ip addr show wlan0

Then also after restarting everything worked well for me.
From the wpa error, it looks like there were 2 instances? I am not sure.
I would love to hear someone elses opinion on this, since I am not 100% sure what exactly I did, but it worked. 
I hope this helps someone!

Posted (edited)

Couple of data points that may be helpful.

Platform: BTT PI v1.2 D/C 2023.11.8 with the U2C CAN board
Distro: Armbian 25.8.1 Bookworm
Kernel: 6.12.43-current-sunxi64
Overlays: spidev0_0

1. Adding a sleep 5 hack did not work for me, however what does *seem* to work is inserting the following line to /etc/netplan/30-wifis-dhcp.yaml

activation-mode: manual

WiFi was still activated (which may be another bug) for at least 3 cold boots in a row (didn't have time to test more thoroughly). Here's a pastebin link from right after one such boot - https://paste.armbian.com/umijapukiy


 

2. The error from wpa_supplicant is 

CTRL-EVENT-SCAN-FAILED ret=-1 retry=1

.Same error code (-1) is also reported when attempting a manual scan

pi@jubilee:~$ sudo iw wlan1 scan
command failed: Operation not permitted (-1)



3. Broken state of the WiFi driver seems to be correlated with mmc errors in dmesg

[   11.490708] sunxi-mmc 4021000.mmc: data error, sending stop command
[   11.490745] sunxi-mmc 4021000.mmc: send stop command failed
[   11.490856] sunxi-mmc 4021000.mmc: data error, sending stop command
[   11.490880] sunxi-mmc 4021000.mmc: send stop command failed
[   11.491071] sunxi-mmc 4021000.mmc: data error, sending stop command
[   11.491098] sunxi-mmc 4021000.mmc: send stop command failed
[   11.491224] sunxi-mmc 4021000.mmc: data error, sending stop command
[   11.491248] sunxi-mmc 4021000.mmc: send stop command failed


These are not present if wifi was activated successfully.

Here's a pastebin link from right after such boot - https://paste.armbian.com/xovixuniti

EDIT: Ran armbianmonitor -c overnight and the SD card seems fine
 

The results from testing /dev/mmcblk0p2 (ext4):
Data OK: 111.37 GB (233561400 sectors)                                                                      
Data LOST: 0.00 Byte (0 sectors)
Average writing speed: 18.41 MB/s
Average reading speed: 22.74 MB/s 
...
Health summary: OK



3. Reloading the kernel driver (8189fs) when it is already in a broken state is very slow and provokes a slew of mmc errors
 

$ sudo /sbin/rmmod 8189fs
pi@jubilee:~$ time sudo /sbin/modprobe 8189fs

real    2m15.835s
user    0m0.008s
sys     0m0.048s
$ dmesg

....
[  673.262192] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.262286] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.262379] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.262471] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.262563] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.262656] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.262716] ====>_BlockWrite 101 i:0
[  673.262742] ====>_WriteFW 230
[  673.263001] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.263088] sunxi-mmc 4021000.mmc: data error, sending stop command
[  673.263141] ====>_BlockWrite 101 i:0
[  673.263162] ====>_WriteFW 230


Again the same problem is not present if WiFi was activated successfully after boot: Shutting down the interface and reloading the driver works just fine.

Please let me know if there's anything else I can collect that can help to track this down. Given this is a fresh install and has no personal data in it yet, I can share my SD card image if that would be helpful.
 

Edited by anttix
Posted (edited)

Small update. The hack below seems to work as well.

 

$ sudo systemctl edit armbian-hardware-optimize.service


Add the following content between comments
 

[Unit]
Before=basic.target systemd-networkd.service netplan-wpa-wlan1.service


Please note that armbian-hardware-optimize was picked at random to force anything that touches wlan1 to wait until slightly later in the boot process. No tests were done to determine at what exact point in the boot process wlan is "safe" to interact with.

Edited by anttix
Posted (edited)

@JohnTheCoolingFan what image are you using? I can reproduce the issue consistently with Armbian_25.8.1_Bigtreetech-cb1_bookworm_current_6.12.35_minimal.img  . This is the Minimal / IOT image one can grab from https://www.armbian.com/bigtreetech-cb1/ . 

Interestingly enough, the Minimal / IOT image does not use NetworkManager, it's configured with systemd-networkd backend (or "renderer" as they call it) for netplan. Perhaps this is the key difference: I saw a comment on a topic below stating that MainsailOS has added CB1 Trixie image which is forced to NetworkManager and it's claimed to be stable.

 

Edited by anttix
Posted

Yep, looks like it's about the netplan renderer. I've tried the actual image instead of the one I built locally and even just a reboot is able to reproduce the issue. The main difference is that on the image I built networking was via NetworkManager by default, while the image on the website uses systemd-networkd.

Posted

I can confirm that switching to network-manager seems to make the Bookworm image more stable on my hardware.

@bobby3605 @bundle @Eatocee can you confirm if one of the two options below work for you as well.
 

  1. Use Debian Trixie image instead of Bookworm. These can be found by scrolling a bit further down on the official download page at https://www.armbian.com/bigtreetech-cb1/
     
  2. OR switch to NetworkManager
     
    sudo apt install network-manager -y


    Change renderer from networkd to NetworkManager in /etc/netplan/10-dhcp-all-interfaces.yaml 
     

    --- /etc/netplan/10-dhcp-all-interfaces.yaml.orig       2025-10-12 20:53:08.558759013 +0300
    +++ /etc/netplan/10-dhcp-all-interfaces.yaml    2025-10-12 20:53:28.826717724 +0300
    @@ -6,7 +6,7 @@
    
     network:
       version: 2
    -  renderer: networkd
    +  renderer: NetworkManager
       ethernets:
         all-eth-interfaces:
           match:

Thank you!

Posted

Same/similar issue. Armbian Bookworm v25.8.1 on BTT Pi. wlan0/wlan1 devices are visible, but after first reboot, do not connect anymore. Even after stopping any networking-related services/processes, "iw wlan0 scan" just returns "device or resource busy".

 

Changing the netplan renderer to network-manager as recommended did not work for me either. I also experienced the sunxi64-mmc kernel error messages when trying to reload the rt8189fs module.

 

After switching kernel from 6.12.47-current to 6.16.8-edge, WLAN worked right away. But in exchange the wired eth0 device is now gone completely... you can't have it all ;)  (Maybe related to this?)

 

Posted (edited)

This issues has had me sticking with the old BTT images for ages, then I found a different issue with those so was forced to come back to try again with Armbian. After going down many rabbit holes a friend said just install KlipperScreen earlier than you normally would when running up a Klipper install, that will pull in network manager. It was so simple for my use case I hadn't even considered it. Worked a treat, I could set up the wifi on the touchscreen and it survived reboots.

 

I then found a slow down in the boot process because networkd was still waiting for a connection, a solution to that wasn't as hard to find I ran these two commands in the terminal and now it doesn't slow anything down during boot up. I have no idea if this is the correct way but I'll post it in case it helps anyone else following the same breadcrumbs I've been chasing.

 

  sudo systemctl disable systemd-networkd-wait-online.service

 

  sudo systemctl mask systemd-networkd-wait-online.service 

 

 

Edited by DaveTheBuskerUK
Posted

After some experimentation, I realized that the full xfce images are working fine, likely because NetworkManager is built in. The minimal CLI images, even after switching to NetworkManager per the instructions here, never worked for me to retain Wifi after a reboot.

 

I'm going through the process of removing the XFCE desktop from my install as CPU utilization in Klipper is very high otherwise.

Posted

BTT since at least Buster provides in their vendor image a script to solve issues with the Wifi. And yes it in some conditions may have some issues with the network coming up, I even run in some issues with ethernet. They are solvable by restarting the networkdevice (either ethernet or wifi) with NetworkManager as well as with systemd-networkd.
From history. The CB1 Buster vendor image from BTT as well as the vendor image for Bookworm, which actually you still can download at BTTs website contain a scrit that solves the issue by checking the network state all 5 seconds and in case restart the device.
I personally used the vendor Buster image and the vendor Bookworm image on the CB1 to operate Openmediavault on it and believe me reliable Network is essential for a NAS. So yes those scripts work. I finally moved to the Armbian general Trixie image, just I was courious, but I took those scripts from bookworm with me. I even copied them to my "vault" of nice to have things for any device that needs reliable network. So I suggest to get yourself A vendor Bookworm image and loop mount it. No need to flash it. (if you are on Windoof, you need to flash it and have a look at the boot partition . At least I don't know a way to mount a partion inside a dd image of a blockdvice stored with sparse option.)
Then have a look at the boot partion. There is a folder scripts.
Interesing ther:
/scripts/btt_init.sh
/script/connect_wifi.sh

what they do is, they start btt_init.sh in /etc/rc.local, which means always when the system boots at the very end of the boot process
and btt init.sh starts a lot of those scripts in background mode, which meens if they have an endless loop, they never die.
Only thing u need is connect_wifi.sh from there, so you can hash out all other or directly start connect_wifi.sh like they do..
 

#!/bin/bash

# original BTT code, where the device name is set to a variable in the system.cfg:
# cfg_file=/boot/system.cfg

#enter the name of the wlandevice to check here:
WLAN=wlan0

log_file=/boot/scripts/wifi.log

IFS=\"

sta_mount=0

wifi_path="/etc/NetworkManager/system-connections/"

function connect_wifi() {
    # whether there is configured wifi in the history
    if [[ `sudo nmcli c s | grep wifi |  awk '{ for(i=NF-2; i<=NF; i++){ $i="" }; print $0 }'` =~ "${WIFI_SSID}" ]] ; then
        set_wifi_path="${wifi_path}${WIFI_SSID}.nmconnection"
        if [[ -e ${set_wifi_path} ]]; then
            psk=`sudo cat ${set_wifi_path} | grep ^psk | awk -F '=' '{print $2}'`
            if [[ ${psk} == $WIFI_PASSWD ]]; then
                # both ssid & passwd matched.
                sys_now_wifi=`sudo nmcli c s --active | grep wlan0 | awk '{ for(i=NF-2; i<=NF; i++){ $i="" }; print $0 }' | awk '{t=length($0)}END{print substr($0, 0, t-3)}'`
                if [[ ${sys_now_wifi} != $WIFI_SSID ]]; then
                    sudo nmcli c up ${WIFI_SSID}
                    echo " ===> SSID & PSK is same as history, switch to: $WIFI_SSID " >> $log_file
                fi
                echo " ===> Now is: $WIFI_SSID, need not to do anything" >> $log_file
                return 0
            else
                # psk don't match, remove and reconnect.
                sudo nmcli c delete ${WIFI_SSID}
                echo " ===> Remove all: $WIFI_SSID " >> $log_file
            fi
        else
            # remove all WIFI_SSID info (Theoretically, never execute to here).
            sudo nmcli c delete ${WIFI_SSID}
            echo " ===> Remove all: $WIFI_SSID " >> $log_file
        fi
    fi

    # connect to the new wifi
    if [[ `sudo nmcli device wifi list` =~ $WIFI_SSID ]]
    then
        if [[ ! `sudo nmcli dev wifi connect $WIFI_SSID password $WIFI_PASSWD ifname $wlan` =~ "successfully" ]]
        then
            echo " ===> Specify the WPA encryption method: $WIFI_SSID " >> $log_file
            sudo nmcli c modify $WIFI_SSID wifi-sec.key-mgmt wpa-psk
            sudo nmcli dev wifi connect $WIFI_SSID password $WIFI_PASSWD ifname $wlan
        fi
    else
        echo " ===> Hide wifi_ssid: $WIFI_SSID " >> $log_file
        sudo nmcli c add type wifi con-name $WIFI_SSID ifname $wlan ssid $WIFI_SSID
        sudo nmcli c modify $WIFI_SSID wifi-sec.key-mgmt wpa-psk wifi-sec.psk $WIFI_PASSWD
        sudo nmcli c up $WIFI_SSID
    fi
}

function Env_init() {
    exec 1> /dev/null
    # without check_interval set, we risk a 0 sleep = busy loop
    if [ ! "$check_interval" ]; then
        echo $(date)" ===> No check interval set!" >> $log_file
        exit 1
    fi

    # enable wlan
    [[ $(ifconfig | grep $wlan) == "" ]] && sudo nmcli radio wifi on

    connect_wifi

    sleep 6
}

function is_network() {
    if [ $# -eq 0 ]; then
        get_ip=`ip route | grep "$eth proto kernel" | awk '{print $9}'`
        if [ -n "${get_ip}" ]; then
            Result=yes
        else
            get_ip=`ip route | grep "$wlan proto kernel" | awk '{print $9}'`
        fi
    else
        get_ip=`ip route | grep "$1 proto kernel" | awk '{print $9}'`
    fi

    if [ -n "${get_ip}" ]; then
        Result=yes
    else
        Result=no
    fi

    echo $Result
}

function startWifi_sta() {
    sta_mount=`expr $sta_mount + 1`
    echo $(date)" .... sta connecting...$sta_mount..." >> $log_file

    sleep 2
}

function startWifi() {
    [[ $(ifconfig | grep $wlan) == "" ]] && nmcli radio wifi on  # 确保wlan连接启动了

    if [[ $sta_mount -le 2 ]]; then
        nmcli device connect $wlan      # 连接wifi
        echo $(date)" .... $wlan connecting..." >> $log_file
        sleep 2
        [[ $(is_network $wlan) == no ]] && startWifi_sta
        [[ $(is_network $wlan) == yes ]] && sta_mount=0 && echo $(date)" [O.K.] $wlan connected!" >> $log_file
    else
        echo $(date)" xxxx $wlan connection failure..." >> $log_file
    fi
}

source $cfg_file
grep -e "^WIFI_SSID" ${cfg_file} > /dev/null
STATUS=$?
if [ ${STATUS} -eq 0 ]; then
    Env_init
    sleep 20

    while [ 1 ]; do

        if [[ $(is_network) == no ]]; then      # 没有网络连接
            echo -e $(date)" ==== No network connection..." >> $log_file
            startWifi
            sleep 6    # 更改间隔时间,因为有些服务启动较慢,试验后,改的间隔长一点有用
        fi

        sleep $check_interval
    done
fi


This script assumes you are using NetworkManager to manga the wifi.. if you don't one can modify it for systemd-networkd also.. :-)
 



 
 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines