Skip to content

Conversation

jhordies
Copy link

@jhordies jhordies commented Sep 1, 2025

This PR adds board support for the Raspberry Pi 500's embedded RP2040 microcontroller, enabling custom firmware development while maintaining compatibility with the original keyboard functionality.

Changes:

Add raspberry_pi_pi500.h board definition
Configure W25X10CL flash support
Document complete GPIO pin mapping for 8×18 keyboard matrix
Define system function pins (power control, LEDs, debug UART)
Enable USB operation independent of main Pi power state

Hardware Specifications:

Chip: RP2040 (same as Pico)
Flash: W25X10CL 1MB (DSPI mode)
USB: Connected to Pi 500 USB hub
Matrix: 8 rows × 18 columns keyboard matrix
System GPIO: GP16 (UART), GP17 (LED), GP19 (power), GP20 (power key), GP25 (Caps LED)
Available GPIO: None (all pins reserved)

Testing:
✅ Successful firmware compilation with
✅ USB device enumeration and communication
✅ System function compatibility (power, LEDs)
✅ Compatible with original keyboard firmware restoration

Use Cases:
This enables Pi 500 users to develop custom USB applications like MIDI controllers, HID devices, and keyboard firmware modifications while preserving hardware compatibility. Note that unlike standard Pico boards, no GPIO pins are available for general use.

Files Changed:
src/boards/include/boards/raspberry_pi_pi500_rp2040.h (new)

Usage:
-DBOARD=raspberry_pi_pi500_rp2040

⚠️ CRITICAL WARNING: Custom firmware must implement power button handling (GP19 control) or the Pi 500 power button will stop working, potentially making the device unbootable. Always include power management code from the original QMK firmware.

- W25X10CL flash configuration for DSPI mode
- USB standalone operation support
- Complete GPIO pin documentation with keyboard matrix mapping
- Debug UART configuration on GP16
- Hardware-specific boot and power management settings

Tested with TinyUSB MIDI example - successful enumeration and operation.
@lurch
Copy link
Contributor

lurch commented Sep 2, 2025

As I attempted to hint at in the linked issue, the Raspberry Pi 500 keyboard uses RP2040, not RP2350.

Also, IMHO it would be better if this header file just declared everything explicitly, rather than doing

#include "boards/pico2.h"

And the filename should perhaps clarify that this is only the keyboard part of the Pi 500, not the entire thing 😆

- Rename to raspberry_pi_pi500_rp2040.h for clarity
- Correct chip type from RP2350 to RP2040
- Remove pico2.h inheritance, use self-contained definitions
- Add comprehensive GPIO pin mapping documentation
- Include critical power management warning
- Configure W25X10CL flash support for RP2040
Comment on lines +27 to +29
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 1 // Standard RX pin
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to your comments below, GP1 is used as a matrix row, so you shouldn't define it here.

@jhordies jhordies changed the title Add Raspberry Pi 500's RP2350 board support Fixes #2640 Add Raspberry Pi 500's RP2040 board support Fixes #2640 Sep 3, 2025
Comment on lines +36 to +62
// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 4
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 5
#endif

// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 0
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 18
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 19
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 16
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 17
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it makes no sense to define any PICO_DEFAULT_I2C or PICO_DEFAULT_SPI settings here.

#endif

// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
#define PICO_SMPS_MODE_PIN 23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your comments say that this is used as a matrix row?

Comment on lines +84 to +92
// The GPIO Pin used to read VBUS to determine if the device is battery powered.
#ifndef PICO_VBUS_PIN
#define PICO_VBUS_PIN 24
#endif

// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC.
#ifndef PICO_VSYS_PIN
#define PICO_VSYS_PIN 29
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As before, you shouldn't be defining things if those pins are actually used by the keyboard matrix.

// --- USB CONFIGURATION ---
// Crucial for Pi 500 keyboard function when Pi is off - ignores USB startup check
#define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 0
#define PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this doesn't do what you think it does - it's not disabling USB_RESET_BOOTSEL_ACTIVITY_LED, but setting it to GP0.


// --- BOOTLOADER CONFIGURATION ---
// Disable double tap reset timeout for Pi 500
#define PICO_BOOTSEL_VIA_DOUBLE_RESET_ACTIVITY_LED 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment 🙂
(and look also at Chapter 6 of https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf )

Comment on lines +105 to +106
// Rows (8): GP0, GP1, GP2, GP3, GP4, GP5, GP6, GP7
// Cols (18): GP27, GP8, GP9, GP10, GP11, GP12, GP13, GP14, GP23, GP24, GP22, GP20, GP29, GP18, GP15, GP21, GP28, GP26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it might be useful to do e.g.

#define PI500_RP2040_MATRIX_ROW_0_PIN 0
#define PI500_RP2040_MATRIX_ROW_1_PIN 1

#define PI500_RP2040_MATRIX_COL_0_PIN 27
#define PI500_RP2040_MATRIX_COL_1_PIN 8

etc. ?

@jhordies
Copy link
Author

jhordies commented Sep 3, 2025

As I attempted to hint at in the linked issue, the Raspberry Pi 500 keyboard uses RP2040, not RP2350.

Also, IMHO it would be better if this header file just declared everything explicitly, rather than doing

#include "boards/pico2.h"

And the filename should perhaps clarify that this is only the keyboard part of the Pi 500, not the entire thing 😆

Sorry I didn't get the hint.
You are correct, and updated the code accordingly.

@lurch lurch linked an issue Sep 3, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Raspberry Pi 500's RP2040 board support
3 participants