← Back to Blog

Embedded Systems – aml-s905x-cc-v2 GPIO & Peripheral Control

Complete GPIO and peripheral control guide for the Libre Computer aml-s905x-cc-v2 (Sweet Potato) – LED blinking, button input, I2C sensors, OLED displays, servo motors, and PWM control.

8 min read Roman Swetly

Embedded Systems – aml-s905x-cc-v2 GPIO & Peripheral Control

Complete GPIO and peripheral control guide for the Libre Computer aml-s905x-cc-v2 (Sweet Potato) – LED blinking, button input, I2C sensors, OLED displays, servo motors, and PWM control.


Overview

The aml-s905x-cc-v2 (also known as the Libre Computer “Sweet Potato”) is an ARM-based single-board computer that is highly compatible with Raspberry Pi software, but with a different GPIO pinout. This platform offers:

  • Amlogic S905X SoC – Quad-core ARM Cortex-A53.
  • Raspbian compatibility – Runs Raspberry Pi OS (Bookworm).
  • GPIO access – Via sysfs, libgpiod, and Python.
  • I2C, SPI, UART – Full peripheral support.

This page documents my practical exploration of the board’s GPIO capabilities, including working pins, control methods, and peripheral integration.


Architecture

aml-s905x-cc-v2 (Sweet Potato)

Getting Started

System Setup

1. Download the Image

# From Libre Computer distribution
wget https://distro.libre.computer/ci/raspbian/12/2023-10-10-raspbian-bookworm-arm64-full+aml-s905x-cc.img.xz

2. Decompress the Image

# Option 1: Direct unxz
unxz 2023-10-10-raspbian-bookworm-arm64-full+aml-s905x-cc.img.xz

# Option 2: Using 7zip
sudo apt install 7zip 7zip-rar
7z x 2023-10-10-raspbian-bookworm-arm64-full+aml-s905x-cc.img.xz

3. Flash to SD Card

Use balenaEtcher or Raspberry Pi Imager to flash the .img file to a microSD card.

4. Boot and Configure

Insert the SD card, power on, and follow the initial setup (similar to Raspberry Pi).


GPIO Pin Mapping

Important: The aml-s905x-cc-v2 has a different GPIO pinout from Raspberry Pi. Use the following verified working pins:

Physical PinChipLinesysfsNameStatus
4007474GPIOX_9✅ Clean GPIO
3807373GPIOX_8✅ Clean GPIO
3307070GPIOX_5✅ Clean GPIO
3507575GPIOX_10✅ Clean GPIO
1207676GPIOX_11✅ Clean GPIO
2708282GPIOX_17✅ Clean GPIO
2808383GPIOX_18✅ Clean GPIO
1902020GPIOH_4⚠️ SPI (may work)
2102121GPIOH_5⚠️ SPI (may work)
2302323GPIOH_7⚠️ SPI (may work)
2402222GPIOH_6⚠️ SPI (may work)

GPIO Toolchain

The libgpiod tools are the standard GPIO control interface on modern Linux systems:

# Install gpiod tools
sudo apt update
sudo apt install gpiod python3-gpiod

# List all GPIO lines with their current configuration
gpioinfo

# Find which chip/line a named GPIO is on
gpiofind "GPIOX_9"

# Set a pin HIGH
sudo gpioset gpiochip0 74=1

# Set a pin LOW
sudo gpioset gpiochip0 74=0

# Read a pin value
sudo gpioget gpiochip0 74

Example Projects

Hardware: Connect an LED with a 330Ω resistor between Pin 40 and GND (Pin 39).

Command Line:

# Blink the LED using gpioset
while true; do
    sudo gpioset gpiochip0 74=1
    sleep 0.5
    sudo gpioset gpiochip0 74=0
    sleep 0.5
done

Python Script:

#!/usr/bin/env python3
import gpiod
import time

# Use gpiochip0, line 74
chip = gpiod.Chip('gpiochip0')
line = chip.get_line(74)

# Configure as output
line.request(consumer='blink', type=gpiod.LINE_REQ_DIR_OUT)

# Blink 10 times
try:
    for i in range(10):
        line.set_value(1)
        print("LED ON")
        time.sleep(0.5)
        line.set_value(0)
        print("LED OFF")
        time.sleep(0.5)
finally:
    line.release()
    print("Cleaned up")

2. 🎮 Read a Button (Input Example)

Hardware: Connect a push button between Pin 40 and GND (with optional pull-up resistor).

#!/usr/bin/env python3
import gpiod
import time

chip = gpiod.Chip('gpiochip0')
line = chip.get_line(74)

# Configure as input
line.request(consumer='button', type=gpiod.LINE_REQ_DIR_IN)

print("Press the button (Ctrl+C to exit)")
try:
    while True:
        if line.get_value() == 0:  # Button pressed (connected to GND)
            print("Button PRESSED!")
            time.sleep(0.2)  # Debounce
        time.sleep(0.1)
except KeyboardInterrupt:
    line.release()
    print("\nExited")

3. 📡 I2C OLED Display

Hardware: Connect an SSD1306 OLED display to I2C pins.

# Install I2C tools and libraries
sudo apt install i2c-tools python3-smbus python3-pip
sudo pip3 install adafruit-circuitpython-ssd1306

# Scan for I2C devices (bus 0 or 1)
sudo i2cdetect -y 0
sudo i2cdetect -y 1

Python Script:

#!/usr/bin/env python3
import board
import busio
import adafruit_ssd1306
from PIL import Image, ImageDraw

# Initialize I2C
i2c = busio.I2C(board.SCL, board.SDA)
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

# Clear display
oled.fill(0)
oled.show()

# Create image
image = Image.new("1", (128, 64))
draw = ImageDraw.Draw(image)

# Draw text
draw.text((0, 0), "Hello Sweet Potato!", font=None, fill=255)
draw.text((0, 20), "GPIO Works!", font=None, fill=255)

# Display
oled.image(image)
oled.show()

4. 🐍 Servo Motor Control

Hardware: Connect a servo (Signal->GPIO, VCC->5V, GND->GND).

# Install servo library
sudo pip3 install adafruit-circuitpython-servokit
#!/usr/bin/env python3
from adafruit_servokit import ServoKit
import time

# PCA9685 on I2C (default address 0x40)
kit = ServoKit(channels=16)

# Sweep servo
while True:
    for angle in range(0, 181, 10):
        kit.servo[0].angle = angle
        time.sleep(0.05)
    for angle in range(180, -1, -10):
        kit.servo[0].angle = angle
        time.sleep(0.05)

5. 🌡️ DHT11 Temperature/Humidity Sensor

Hardware: Connect DHT11 (VCC->3.3V, DATA->GPIO, GND->GND).

# Install DHT library
sudo pip3 install Adafruit_DHT
#!/usr/bin/env python3
import Adafruit_DHT
import time

sensor = Adafruit_DHT.DHT11
pin = 74  # GPIO line number

while True:
    humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
    if humidity is not None and temperature is not None:
        print(f"Temp: {temperature:0.1f}°C  Humidity: {humidity:0.1f}%")
    else:
        print("Sensor error")
    time.sleep(2)

6. 🎯 PWM Control (LED Brightness)

Hardware: Connect an LED to GPIO pin (with resistor).

Software PWM (Python):

#!/usr/bin/env python3
import gpiod
import time

chip = gpiod.Chip('gpiochip0')
line = chip.get_line(74)
line.request(consumer='pwm', type=gpiod.LINE_REQ_DIR_OUT)

# Software PWM: fade LED in and out
while True:
    # Fade in
    for duty in range(0, 101, 5):
        line.set_value(1)
        time.sleep(duty / 1000)  # On time
        line.set_value(0)
        time.sleep((100 - duty) / 1000)  # Off time

    # Fade out
    for duty in range(100, -1, -5):
        line.set_value(1)
        time.sleep(duty / 1000)
        line.set_value(0)
        time.sleep((100 - duty) / 1000)

GPIO Commands Reference

CommandDescription
gpioinfoList all GPIO lines and their current configuration.
gpioset gpiochip0 74=1Set pin HIGH.
gpioset --mode=time --sec=5 gpiochip0 74=1Set pin HIGH for 5 seconds.
gpioget gpiochip0 74Read pin value.
gpiofind "GPIOX_9"Find which chip/line a named GPIO is on.

Pin Map (Working Pins)

PhysicalGPIO NameChip:LineBest For
40GPIOX_90:74✅ General purpose
38GPIOX_80:73✅ General purpose
33GPIOX_50:70✅ General purpose
35GPIOX_100:75✅ General purpose
12GPIOX_110:76✅ General purpose
27GPIOX_170:82✅ General purpose
28GPIOX_180:83✅ General purpose

What You’ve Confirmed

TestStatus
GPIO output (LED)✅ Working
GPIO input (Button)✅ Working
I2C communication✅ Working
OLED display✅ Working
Servo control✅ Working
DHT11 sensor✅ Working

Key Achievements

  • Verified GPIO working pins on aml-s905x-cc-v2.
  • Established gpiod toolchain for GPIO control.
  • Implemented multiple peripheral drivers (LED, button, OLED, servo, DHT11).
  • Created reusable Python scripts for future projects.
  • Documented pin mapping for easy reference.

Technology Stack

CategoryTechnology
BoardLibre Computer aml-s905x-cc-v2 (Sweet Potato)
OSRaspberry Pi OS (Bookworm)
GPIO Controllibgpiod, gpiod tools
LanguagePython 3
I2C Librarysmbus2, Adafruit Blinka
DisplaySSD1306 OLED
SensorsDHT11
ServoPCA9685 (ServoKit)


This GPIO exploration is part of my broader Embedded Systems Engineering practice. For a detailed technical walkthrough or custom peripheral integration, feel free to reach out.

← Previous Post
Embedded Systems – Banana Pi BPI-M2 Ultra GPIO Control
Next Post →
Embedded Systems – Orange Pi RV Kernel Compilation for RISC-V

Related Articles