wifi-nmcli.sh

Arduino Portenta X8 · File : wifi-nmcli.sh · Language : Bash · Use case : Connecter la X8 au Wi-Fi avec NetworkManager

The X8 Wi-Fi radio behaves like any modern Linux: nmcli scans, connects and stores the profile for boot. The board joins the network with nothing plugged in.

Hardware

An Arduino Portenta X8 (ST STM32MP1 module: quad Cortex-A7 Linux + dual Cortex-M4 real-time core, 8 GB eMMC, 2 GB LPDDR4, on-board Wi-Fi/BT, optional LTE). None: on-board 2.4/5 GHz Wi-Fi (plus Bluetooth, optional cellular).

Wiring

Nothing to wire. In a metal enclosure, fit the external antenna on the U.FL connector.

How it works

nmcli drives NetworkManager: rescan, WPA2 association with persistent profile, then display of the DHCP-obtained IP.

Running it

Linux side: SSH access (routed USB-C or network) on the Portenta Linux image, bash/Python scripts. Real-time side: Arduino IDE with the « Arduino Mbed OS Portenta X8 Boards » core, application M7 core, flashing via mboot from Linux.

Variants

Add a systemd keep-alive ping (Restart on network failure), or expose a Docker service once connected.

wifi-nmcli.sh

#!/bin/bash
# Connexion Wi-Fi de la X8 (radio embarquee) via nmcli.
# Usage : ./wifi-nmcli.sh "SSID" "cle"

set -e
SSID="${1:?Usage: $0 SSID CLE}"
CLE="${2:?Usage: $0 SSID CLE}"

DEV=$(nmcli -t -f DEVICE,TYPE device | awk -F: '$2=="wifi"{print $1; exit}')
[ -n "$DEV" ] || { echo "aucune interface wifi (radio eteinte ?)"; exit 1; }

sudo nmcli radio wifi on
sudo nmcli device wifi rescan || true
nmcli -f SSID,SIGNAL device wifi list | head -12

nmcli device wifi connect "$SSID" password "$CLE" ifname "$DEV"
nmcli -f NAME,DEVICE,STATE connection show --active
ip -4 -brief addr show "$DEV"

# La X8 garde le profil : la connexion se refait au boot.

← Back to the board