🛠 GPIO du CM5 côté RP1 : force de conduite, budget 50 mA et broches pièges
Objectives
On the CM5, the GPIO is no longer wired to the SoC but to RP1, Raspberry Pi's I/O chip ("an entire extra chip on the board compared to the CM4"), exactly as on the Pi 5. Practical consequences: the gpiochip0 controller is named rp1, the drive strength is configurable at 2/4/8/12 mA, internal pull-ups are ~55 kΩ, and above all, the cumulative GPIO current must not exceed 50 mA across all 28 pins. This tutorial inventories the controller, blinks an LED, reads a button input, and calibrates your driving choices.
Hardware
- 1 × CM5 on CM5IO Board (GPIO jumper in 3.3 V position by default)
- 1 × LED + 470 Ω resistor; 1 × push button to GND
sudo apt install -y gpiod-tools pinctrl python3-gpiozero- Optional: multimeter to check the current budget of a setup driving multiple loads
Complete code
# 1) Prouver que le GPIO vient de RP1
sudo pinctrl -p | head -8 # gpiochip0 : « rp1 »
gpioinfo gpiochip0 | sed -n '1,14p'
# 2) Blink + bouton (gpiozero fonctionne inchangé, comme sur Pi 5)
cat > /tmp/rp1_demo.py <<'EOF'
from gpiozero import LED, Button
from signal import pause
led = LED(17) # LED + 470 ohm vers GND
btn = Button(4) # bouton vers GND, pull-up interne ~55 kohm
btn.when_pressed = led.on
btn.when_released = led.off
pause
EOF
python3 /tmp/rp1_demo.py
Expected verification
pinctrl -p identifies gpiochip0 = rp1 (on CM4 it was the BCM2711 SoC); the LED lights up during the press; gpioget gpiochip0 4 is 1 at rest (internal pull-up). Budget calculation: one LED at 5 mA × 8 pins = 40 mA, we are close to the 50 mA ceiling — the datasheet also imposes VOL ≤ 0.4 V at the current of the selected setting.
Common errors
- Exceeding the 50 mA cumulative limit on the 28 pins (LED groups, relays, displays): the GPIO collapses or the chip heats up; use an external transistor/driver.
- Using GPIO0/GPIO1 without configuring anything: these are the HAT identification bus (ID_SD/ID_SC); for normal GPIO, set
force_eeprom_read=0in config.txt. - Forgetting the default 1.8 kΩ pull-ups on GPIO2/GPIO3: they are too strong for a simple button or long I2C line, distorting levels — the datasheet explicitly flags them.
- Neglecting the bank voltage: GPIO_VREF is wired to 3.3 V, 1.8 V, or external 2.5 V; a 3.3 V peripheral on a 1.8 V bank will never see a valid high level.
Other tutorials for this board
- Alimenter un CM5 comme il faut : USB-C PD 5 V / 5 A et bouton d'alimentation
- La première RTC des Compute Modules : câbler et vérifier la VBAT du CM5
- Accès distant sans VPN : enregistrer un CM5 dans Raspberry Pi Connect
- Refroidir le CM5 : ventilateur PWM sur le connecteur JST-SH et tachymétrie
- Deux ports USB 3.0 simultanés : le CM5 fait du stockage rapide, pas sur une carte CM4
- Démarrer le CM5 sur un SSD NVMe dans le socket M.2 de la CM5IO
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash