🛠 GPIO du CM4 : comprendre les banks 1,8 V / 3,3 V avant de câbler
Objectives
Turn on an LED using gpiozero while understanding the GPIO peculiarity of the CM4: its 28 GPIO signals support 1.8 V or 3.3 V signaling per bank, with the VGPIO_VREF pin of each bank connected to the chosen rail — unlike the Pi 4B, which is fixed at 3.3 V. You will verify the actual voltage of the bank before wiring a module, and you will learn that the default drive strength is 4 mA (configurable 1–8 mA) with internal pull-ups of approximately 47 kΩ.
Hardware
- 1 × CM4 (variant of your choice) on a CM4 IO Board, with Raspberry Pi OS 64-bit booted
- 1 LED + 330 Ω resistor, breadboard, wires
- The GPIO voltage jumper/selector on the IO Board (set to 3.3 V for this tutorial)
- Know the Bank 2 pins reserved by the module (eMMC, HDMI hot-plug, ACT/boot USB LED): they do not appear on the connector and must not be repurposed
Complete Code
# Installer les outils et repérer la config des broches
sudo apt update && sudo apt install -y pinctrl gpiod-tools
pinctrl -p | grep -E '^(17|22|27)' # fonction et pull de chaque broche
gpioget gpiochip0 17 # état logique lu sur GPIO17
#!/usr/bin/env python3
# blink_cm4.py — 10 clignotements sur GPIO17 (bank 0 de l'IO Board en 3,3 V)
# AVANT de câbler : vérifier la tension du bank (VGPIO_VREF) sur sa carte porteuse !
from gpiozero import LED
from time import sleep
led = LED(17)
for _ in range(10):
led.on; sleep(0.25)
led.off; sleep(0.25)
print("OK — GPIO17 piloté")
Expected Verification
The LED blinks 10 times at 2 Hz. pinctrl -p shows gpio17 as gpio output during execution, and the script terminates without raising an exception. On a custom carrier board, measuring with a multimeter between the bank's VGPIO_VREF pin and GND should yield 3.3 V (or 1.8 V if the 1.8 V rail is selected).
Common Errors
- Wiring a 3.3 V module to a bank configured for 1.8 V: the high level does not exceed 1.8 V and the module does not react (or worse, the reverse case where a 1.8 V-tolerant module poorly handles a 3.3 V signal).
- Forgetting the series resistor with the LED: you draw beyond the default drive strength (4 mA).
- Using Bank 2 pins: they are reserved by the module (eMMC, HDMI hot-plug, ACT/boot) and are not broken out… but are not available.
- Looking for the 40-pin connector pins of a standard Pi: on the CM4, everything goes through the two 100-pin connectors or the IO Board's HAT footprint.
Other tutorials for this board
- Premier démarrage d'un CM4 Lite depuis la microSD de l'IO Board
- Basculer le Wi-Fi du CM4 sur l'antenne externe U.FL (dtparam=ant2)
- Bootloader EEPROM du CM4 : maîtriser BOOT_ORDER via usbboot
- Ajouter une RTC au CM4 (PCF8523 sur I2C1 via dt-blob)
- Son sur CM4 : DAC I2S/PCM (PCM5102) sans prise jack
- Horodatage industriel : PTP IEEE 1588 sur le PHY Ethernet du CM4
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash