RDK X5 40-PIN Header: Pin Definitions and GPIO Applications

The RDK X5 development board exposes a 40-pin header that lets you interface with sensors, actuators, and peripheral buses. This guide walks through the pin definitions, multiplexing rules, and a hands-on GPIO example so you can start driving hardware from userspace right away.

40-PIN Header Overview

The RDK X5 40-pin header follows the familiar Raspberry-Pi-compatible layout. Keep these electrical limits in mind when you design your circuit:

Parameter Value
Logic voltage 3.3 V
Max voltage on any pin 3.46 V
3.3 V rail current budget 800 mA
5 V rail current budget 500 mA

⚠️ Caution: Never apply a voltage higher than 3.46 V to any GPIO pin. The header is 3.3 V logic only and is not 5 V tolerant.

Pin Definitions

The table below lists every pin on the 40-pin header along with its default function and any multiplexed alternate functions.

Pin Default Function Alternate Function Notes
1 3.3V Power 800 mA max
2 5V Power 500 mA max
3 I2C0 SDA PWM2 Multiplexed
5 I2C0 SCL PWM2 Multiplexed
6 GND
8 UART3 TX
10 UART3 RX
12 I2C1 SDA PWM3 Multiplexed
14 GND
16 GPIO
18 GPIO
19 SPI2 MOSI PWM0 Multiplexed
20 GND
21 SPI2 MISO PWM1 Multiplexed
22 GPIO
23 SPI2 SCLK PWM0/PWM1 Multiplexed
24 SPI2 CS0
25 GND
26 SPI2 CS1
27 I2C5 SDA UART3 Multiplexed
28 I2C5 SCL UART3 Multiplexed
29 GPIO
30 GND
31 GPIO Used in demo as output
32 GPIO
33 GPIO
34 GND
35 GPIO
36 GPIO
37 GPIO Used in demo as input
38 GPIO
39 GND
40 GPIO

Pin Multiplexing Rules

Several pins on the header can be switched between a dedicated peripheral function (I2C, UART, SPI, PWM) and plain GPIO. The multiplexing groups are:

  • UART3 / I2C5 — pins 8/10 (UART3) and pins 27/28 (I2C5) share the same controller configuration.
  • I2C0 / PWM2 — pins 3/5 can act as I2C0 or as a PWM channel.
  • SPI2 / PWM0 — pins 19/23 carry SPI2 signals or PWM0.
  • SPI2 / PWM1 — pins 21/23 carry SPI2 signals or PWM1.
  • I2C1 / PWM3 — pins 12 can act as I2C1 or PWM3.

The way multiplexing is reported after configuration is straightforward:

Configuration Status Meaning
okay The pin is dedicated to its peripheral function (e.g. I2C, UART).
disabled The pin is available as a generic GPIO.

📌 Note: Changing a pin's multiplexing mode requires a reboot to take effect. Plan your configuration step before you wire up hardware.

Configuring Pin Functions with srpi-config

The RDK X5 ships with srpi-config, a menu-driven utility (similar to raspi-config) for enabling and disabling on-board peripherals.

Step 1: Open the configuration tool

sudo srpi-config

Enter fullscreen mode Exit fullscreen mode

Step 2: Navigate to the peripheral menu

  1. Select 3 Interface Options.
  2. Select I3 Peripheral bus config.

Step 3: Enable or disable a peripheral

You will see a list of peripheral buses (UART, I2C, SPI, PWM). Toggle each one according to your needs:

  • Select a bus and press Enter to enable it.
  • Select an already-enabled bus and press Enter to disable it.

Step 4: Reboot

sudo reboot

Enter fullscreen mode Exit fullscreen mode

After reboot, the pins you enabled will be dedicated to their peripheral function (status okay), and the pins you disabled will revert to GPIO (status disabled).

GPIO Application: Button + LED Demo

This example reads a button connected to pin 37 (input) and drives an LED on pin 31 (output). When the button is pressed, the LED turns on.

Hardware Setup

Component Header Pin
LED anode (via ~220Ω resistor) Pin 31 (GPIO output)
LED cathode Pin 39 (GND)
Button — one terminal Pin 37 (GPIO input)
Button — other terminal Pin 39 (GND)

Software Prerequisites

Make sure the pin you are using is configured as GPIO (its peripheral function should be disabled in srpi-config). Install the GPIO library if it is not already present:

pip3 install gpio

Enter fullscreen mode Exit fullscreen mode

Running the Example

The demo script ships with the board image at /app/40pin_samples/. Navigate there and run it:

cd /app/40pin_samples
sudo python3 button_led.py

Enter fullscreen mode Exit fullscreen mode

Expected Output

When the script starts you should see:

Starting demo now!

Enter fullscreen mode Exit fullscreen mode

While the demo runs, each time the button is pressed or released the script prints the new output state being driven to pin 31:

Outputting 0 to Pin 31
Outputting 1 to Pin 31

Enter fullscreen mode Exit fullscreen mode

0 means the LED is off, 1 means it is on.

Source Code: button_led.py

#!/usr/bin/env python3
# button_led.py
# Pin 37: input  (button)
# Pin 31: output (LED)

import time
import gpio

# Configure pins
gpio.pin_mode(37, gpio.INPUT)   # Button as input
gpio.pin_mode(31, gpio.OUTPUT)  # LED as output

print("Starting demo now!")

last_state = None

try:
    while True:
        # Read the button state
        button_state = gpio.digital_read(37)

        if button_state == 0:
            # Button pressed (pulled low)
            gpio.digital_write(31, 1)
            new_state = 1
        else:
            # Button released
            gpio.digital_write(31, 0)
            new_state = 0

        if new_state != last_state:
            print("Outputting {} to Pin 31".format(new_state))
            last_state = new_state

        time.sleep(0.05)  # Simple debounce

except KeyboardInterrupt:
    print("\nExiting demo...")
finally:
    gpio.digital_write(31, 0)
    gpio.cleanup()

Enter fullscreen mode Exit fullscreen mode

💡 Tip: If the LED behavior looks inverted, your button module may include a pull-up resistor. Swap the 0 and 1 logic in the if button_state == 0: block to match your hardware.

Troubleshooting

  • Permission denied: GPIO access requires root. Always run the script with sudo.
  • Pin not responding: Confirm the pin is set to disabled (GPIO mode) in srpi-config and that you rebooted after changing it.
  • Demo file missing: The samples live under /app/40pin_samples/. If the directory is absent, update your board image or copy the samples from the official RDK X5 documentation.

Summary

You now know how to:

  • Read the RDK X5 40-pin header pinout and its electrical limits.
  • Understand pin multiplexing and the okay / disabled status meanings.
  • Use srpi-config to enable or disable peripheral buses.
  • Drive a button + LED circuit from userspace Python.

From here you can branch out into I2C sensors, UART communication, SPI displays, and PWM motor control — all from the same 40-pin header.


*This article is adapted from D-Robotics official documentation. Original source: https://d-robotics.github.io/rdk_x_doc/en/Basic_Application/01_40pin_user_sample/40pin_define?v=3.5.0&p=RDK+X5