🛠 Basculer le Wi-Fi du CM4 sur l'antenne externe U.FL (dtparam=ant2)

Raspberry Pi Compute Module 4 (CM4, 2020) — Board Sheet · debutant · Schéma : IMG-compute-module-4-debutant-3-antenne-wifi-externe-ant2-cm4.svg — CM4 wireless avec son antenne PCB embarquée d'un côté et un petit câble U.FL vers une antenne externe de l'autre ; un commutateur électronique d'antenne est dessiné entre les deux, sélectionné au boot par dtparam=ant2.

Objectives

The wireless module of the CM4 (Cypress/Infineon CYW43455, dual-band Wi-Fi 802.11ac + Bluetooth 5.0) features two antennas and an electronic switch: the onboard PCB antenna (ant1) and a U.FL connector for an external antenna (ant2). This tutorial shows how to force the use of the external antenna — essential when the module is enclosed in a metal case — and explains that the antenna selection is fixed at boot time, not at runtime.

Hardware

Complete code

# 1. Sélectionner l'antenne externe (choix figé au boot)
echo 'dtparam=ant2' | sudo tee -a /boot/firmware/config.txt
sudo reboot

# 2. Après redémarrage : vérifier l'interface et le scan
ip -br link show wlan0
iw dev wlan0 scan | grep -E 'SSID|signal' | head -n 10
iw reg get | head -n 5          # vérifie le pays configuré

# 3. Mesurer la qualité du lien avant/après (même AP)
iw dev wlan0 link | grep -E 'Signal|tx bitrate'

# 4. (Optionnel) désactiver le Bluetooth par rail si non utilisé
# WL_nDisable / BT_nDisable sont des broches du module ; côté OS :
sudo systemctl disable --now bluetooth

Expected verification

After rebooting with dtparam=ant2, iw dev wlan0 scan returns networks, iw dev wlan0 link displays a consistent signal (e.g., −60 dBm at 2 m), and switching from ant1 to ant2 measurably changes the signal when the module is near a metal case. dmesg | grep -i brcm confirms the initialization of the CYW43455.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials