Skip to main content
Logo
Overview

How to Configure Wi-Fi on a Raspberry Pi 5 Running Minimal Yocto

March 5, 2026
4 min read

Navigating networking on a minimal Linux distribution can sometimes feel like solving a puzzle. If you are running a custom Yocto image on a Raspberry Pi 5 and trying to get your Wi-Fi working without the luxury of NetworkManager, you might run into a few roadblocks.

When you check your network interfaces using networkctl and see that wlan0 is sitting stubbornly in an “off” and “unmanaged” state, it’s a clear sign that the default networking mechanisms aren’t kicking in as expected. Here is a comprehensive guide to understanding why this happens and how to fix it using wpa_supplicant and systemd-networkd.

The Problem: The “Yocto Factor”

In a standard Raspberry Pi OS setup, NetworkManager typically handles everything seamlessly out of the box. However, in a custom, minimal Yocto build, wpa_supplicant might be running via D-Bus (often denoted by the -u flag in its process string) but without a dedicated configuration file or a defined control interface.

Because of this missing link between the hardware and the daemon, running wpa_cli -i wlan0 to interactively connect to a network results in an error like:

Could not connect to wpa_supplicant: wlan0 - re-trying

This means wpa_cli is essentially shouting into a void. Let’s manually bridge that gap.

1. Create the Missing Configuration

We need to provide wpa_supplicant with a configuration file that explicitly defines the control interface socket required by wpa_cli.

Create the directory and the configuration file:

Terminal window
sudo mkdir -p /etc/wpa_supplicant
sudo tee /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null <<EOF
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
EOF
  • ctrl_interface: Creates the socket that wpa_cli uses to connect.
  • update_config=1: Allows wpa_cli to save new networks directly back to this file.

2. Bind wpa_supplicant to the Interface

The existing wpa_supplicant service, managed by systemd, is likely running generally without being bound to the wlan0 interface. We need to kill that process, bring the wireless interface up at the kernel level, and restart the daemon manually.

Terminal window
# Stop the D-Bus version from running
sudo systemctl stop wpa_supplicant
# Force wlan0 up at the kernel level
sudo ip link set wlan0 up
# Start wpa_supplicant manually, linking it to the config and interface
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
Tip

The -B flag runs the process in the background, -i specifies the interface, and -c points to the new configuration file we just made.

3. Connect via wpa_cli

Now that the daemon is explicitly watching wlan0 and has a control socket at /var/run/wpa_supplicant, wpa_cli will work as expected:

Terminal window
sudo wpa_cli -i wlan0

Once inside the interactive prompt (>), you can scan and connect to your network:

> scan
> scan_results
> add_network
0
> set_network 0 ssid "Your_Network_Name"
> set_network 0 psk "Your_Password"
> enable_network 0
> save_config
> quit

4. Make it Persistent with systemd-networkd

Even after successfully connecting to your Wi-Fi network, networkctl may still report the interface as unmanaged. This happens because systemd-networkd doesn’t automatically know it should manage IP assignment for this link.

To fix this and ensure the lifecycle is managed correctly on subsequent reboots, create a .network profile to handle DHCP:

Terminal window
sudo tee /etc/systemd/network/25-wlan0.network > /dev/null <<EOF
[Match]
Name=wlan0
[Network]
DHCP=yes
EOF

Restart the network manager to apply the changes:

Terminal window
sudo systemctl restart systemd-networkd

Your wlan0 interface should now be properly configured, connected, and assigned an IP address!

Troubleshooting: “Failed to initiate sched scan”

While working through these steps, checking your systemctl logs (sudo systemctl status wpa_supplicant) might reveal the following error:

wlan0: Failed to initiate sched scan

This commonly occurs if the interface is soft-blocked by a software switch or if there are issues with power saving modes affecting the Wi-Fi chip.

To resolve this:

  1. Try disabling power management for the interface to see if scanning resumes:
    Terminal window
    sudo iw dev wlan0 set power_save off
  2. Double-check that your radio is not blocked using rfkill:
    Terminal window
    sudo rfkill list
    sudo rfkill unblock wifi

By manually defining the control interface for wpa_supplicant and tying IP configuration to systemd-networkd, you can successfully tame the Wi-Fi on a custom Yocto build for the Raspberry Pi 5.

But there is another, often more integrated way to manage networking on embedded Linux: ConnMan (Connection Manager). Many AGL (Automotive Grade Linux) and Yocto-based images ship ConnMan as the primary network management daemon. Read on to see how to use it.


Alternative: Using ConnMan

ConnMan is a lightweight network manager designed for embedded devices. If your Yocto image includes connman (check with which connmanctl), you can use it to connect to Wi-Fi without touching wpa_supplicant or systemd-networkd directly.

Enable and Start ConnMan

Terminal window
sudo systemctl enable connman
sudo systemctl start connman

Connect with connmanctl

connmanctl provides an interactive shell for managing connections.

Terminal window
sudo connmanctl

Inside the interactive prompt:

connmanctl> enable wifi
connmanctl> scan wifi
connmanctl> services

The services command lists available networks in the format:

*AO MyNetwork wifi_aabbccddee_4d794e6574776f726b_managed_psk

The long identifier (e.g., wifi_aabbccddee_...) is the service path you’ll need next. Register an agent so ConnMan can ask for passwords, then connect:

connmanctl> agent on
connmanctl> connect wifi_aabbccddee_4d794e6574776f726b_managed_psk
Agent RequestInput wifi_aabbccddee_...
Passphrase = [ Type=psk, Requirement=mandatory ]
Passphrase? YourPassword
connmanctl> quit

ConnMan handles DHCP automatically. Verify your connection:

Terminal window
ip addr show wlan0
connmanctl services
Tip

ConnMan remembers previously connected networks and reconnects automatically on boot. No extra systemd units needed.


Configuring Wi-Fi via D-Bus

ConnMan exposes its full API over D-Bus, which is how programmatic clients (like embedded UIs) communicate with it. You can also exercise this API directly from the shell using busctl.

Key D-Bus Interfaces

InterfaceObject PathPurpose
net.connman.Manager/Global manager: enable technologies, list services
net.connman.Technology/net/connman/technology/wifiWi-Fi radio control
net.connman.Service/net/connman/service/<id>Per-network: connect, disconnect, properties

1. Check the Manager State

Terminal window
busctl call net.connman / net.connman.Manager GetProperties

2. Enable Wi-Fi Technology

Terminal window
busctl call net.connman /net/connman/technology/wifi net.connman.Technology SetProperty sv "Powered" b true

3. Trigger a Wi-Fi Scan

Terminal window
busctl call net.connman /net/connman/technology/wifi net.connman.Technology Scan

4. List Available Services

Terminal window
busctl call net.connman / net.connman.Manager GetServices

This returns a list of (object_path, dict) pairs. Note the object path for the network you want (e.g., /net/connman/service/wifi_aabbccddee_4d794e6574776f726b_managed_psk).

5. Connect to a Service

For open networks, connect directly:

Terminal window
busctl call net.connman /net/connman/service/wifi_aabbccddee_<id>_managed_none net.connman.Service Connect

For WPA2 networks ConnMan requires an agent to supply the passphrase. The agent must be registered before calling Connect. The easiest approach for scripting is to pre-provision the credentials using a config file.

6. Pre-provision Wi-Fi Credentials (for WPA2)

Create a provisioning file in /var/lib/connman/ (ConnMan reads these on startup):

Terminal window
sudo tee /var/lib/connman/my-network.config > /dev/null <<EOF
[service_wifi_aabbccddee_4d794e6574776f726b_managed_psk]
Type=wifi
Name=MyNetwork
Passphrase=YourPassword
EOF
sudo systemctl restart connman

After restart, ConnMan will auto-connect to the provisioned network. You can then confirm via D-Bus:

Terminal window
busctl call net.connman /net/connman/service/wifi_aabbccddee_4d794e6574776f726b_managed_psk net.connman.Service GetProperties

Look for "State""online" in the output.

7. Disconnect from a Service

Terminal window
busctl call net.connman /net/connman/service/wifi_aabbccddee_<id>_managed_psk net.connman.Service Disconnect
Tip

You can monitor real-time D-Bus signals from ConnMan (e.g., service state changes) with:

Terminal window
busctl monitor net.connman

This is very useful when debugging connectivity issues or building reactive UI clients.


Happy tinkering!

References