gpio-led-blink.sh

AIWorld P1 AI Module for BPI-M2 Ultra and Berry · File : gpio-led-blink.sh · Language : bash · Use case : Allumer et éteindre une LED connectée sur un GPIO pour tester l'accès bas niveau.

Simple Bash script to control an LED via sysfs GPIO, ideal for checking port configuration.

This script uses the standard Linux sysfs interface. Ensure the gpio-sunxi module is loaded. Modify the GPIO_PIN variable according to your motherboard's pinout (BPI-M2 Ultra or Berry). Run with sudo bash led_blink.sh. Stop with Ctrl+C.

gpio-led-blink.sh

#!/bin/bash
# Script de clignotement LED pour AIWorld P1 (Allwinner V40)
# Vérifiez le mapping GPIO spécifique à votre configuration BPI-M2 Ultra/Berry
# Exemple : GPIO1_PB2 correspond souvent à /sys/class/gpio/gpio42

GPIO_PIN=42

# Exporter le pin GPIO
if [ ! -d "/sys/class/gpio/gpio${GPIO_PIN}" ]; then
    echo ${GPIO_PIN} > /sys/class/gpio/export
fi

# Configurer en sortie
if [ -f "/sys/class/gpio/gpio${GPIO_PIN}/direction" ]; then
    echo "out" > /sys/class/gpio/gpio${GPIO_PIN}/direction
fi

# Boucle de clignotement
while true; do
    echo 1 > /sys/class/gpio/gpio${GPIO_PIN}/value
    sleep 0.5
    echo 0 > /sys/class/gpio/gpio${GPIO_PIN}/value
    sleep 0.5
done

← Back to the board