Skip to content

Commit b63c1cf

Browse files
committed
add(board): add Pimoroni Explorer RP2350 (PIM720)
1 parent 57aec3a commit b63c1cf

File tree

9 files changed

+327
-13
lines changed

9 files changed

+327
-13
lines changed

.devcontainer/cortex-m-toolchain.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ echo -e "[cortex-m-toolchain.sh] starting install"
1111
# --- tooling --------------------------------------------------------------
1212

1313
echo -e "[cortex-m-toolchain.sh] downloading and installing gcc-arm-non-eabi toolchain"
14-
cd /workspaces
14+
cd /workspaces/circuitpython
1515

1616
wget -qO gcc-arm-none-eabi.tar.xz \
1717
https://developer.arm.com/-/media/Files/downloads/gnu/14.2.rel1/binrel/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi.tar.xz
@@ -21,4 +21,4 @@ ln -s arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-eabi gcc-arm-none-eabi
2121
rm -f gcc-arm-none-eabi.tar.xz
2222

2323
echo -e "[cortex-m-toolchain.sh] update PATH in environment"
24-
echo -e "\nexport PATH=/workspaces/gcc-arm-none-eabi/bin:$PATH" >> $HOME/.bashrc
24+
echo -e "\nexport PATH=/workspaces/circuitpython/gcc-arm-none-eabi/bin:$PATH" >> $HOME/.bashrc

.devcontainer/fetch-port-submodules.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ cd "$REPO_ROOT"
1212
if [ -z "$CP_PORT" ]; then
1313
echo -e "[fetch-port-submodules.sh] CP_PORT not set. Cannot fetch submodules!"
1414
exit 3
15+
else
16+
echo -e "[fetch-port-submodules.sh] CP_PORT=$CP_PORT"
1517
fi
1618

1719
cd "ports/$CP_PORT"

.devcontainer/install_build_env.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ REPO_ROOT="/workspaces/circuitpython"
2323

2424
on_exit() {
2525
rc=$?
26-
if [ -f /workspaces/install_build_env.log.active ]; then
27-
mv /workspaces/install_build_env.log.active /workspaces/install_build_env.log
26+
if [ -f /workspaces/circuitpython/install_build_env.log.active ]; then
27+
mv /workspaces/circuitpython/install_build_env.log.active /workspaces/circuitpython/install_build_env.log
2828
fi
2929
rm -rf /tmp/install_build_env
3030
exit $rc
3131
}
3232

3333
# --- test prerequisites for installation ------------------------------------
3434

35-
while ! test -f /workspaces/post_create.finished; do
36-
echo -e "[install_build_env.sh] waiting for /workspaces/post_create.finished ..."
35+
while ! test -f /workspaces/circuitpython/post_create.finished; do
36+
echo -e "[install_build_env.sh] waiting for /workspaces/circuitpython/post_create.finished ..."
3737
sleep 1
3838
done
3939

40-
if [ -f /workspaces/install_build_env.log ]; then
40+
if [ -f /workspaces/circuitpython/install_build_env.log ]; then
4141
echo -e "[install_build_env.sh] installation already done"
4242
exit 0
4343
elif ! mkdir /tmp/install_build_env 2>/dev/null; then
@@ -58,7 +58,7 @@ echo -e "[install_build_env.sh] starting install"
5858
"$REPO_ROOT/.devcontainer/$CP_TOOLCHAIN-toolchain.sh" || exit 3
5959
"$REPO_ROOT/.devcontainer/make-mpy-cross.sh" || exit 3
6060
echo -e "Setup complete!\nStart a new terminal and build CircuitPython!\n"
61-
) |& tee /workspaces/install_build_env.log.active
61+
) |& tee /workspaces/circuitpython/install_build_env.log.active
6262

6363
echo -e "[install_build_env.sh] Setup complete!"
6464
exit 0

.devcontainer/post_create.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ echo -e "[post_create.sh] PWD=$PWD\n"
1111

1212
cat >> $HOME/.bashrc << "EOF"
1313
14-
if [ -f /workspaces/install_build_env.log ]; then
14+
if [ -f /workspaces/circuitpython/install_build_env.log ]; then
1515
# setup already done
1616
echo "CircuitPython build-environment ready for $CP_TOOLCHAIN/$CP_PORT"
1717
echo "To start a build run:"
1818
echo " cd ports/$CP_PORT"
1919
echo " time make -j $(nproc) BOARD=your_board_name TRANSLATION=de_DE"
20-
elif [ -f /workspaces/install_build_env.log.active ]; then
20+
elif [ -f /workspaces/circuitpython/install_build_env.log.active ]; then
2121
echo "Initial setup of build environment in progress, please wait."
22-
echo "Use 'tail -f /workspaces/install_build_env.log.active' to monitor progress."
22+
echo "Use 'tail -f /workspaces/circuitpython/install_build_env.log.active' to monitor progress."
2323
echo "After successful installation, start a new terminal to build CircuitPython."
2424
else
2525
echo "Starting initial setup of build environment, please wait"
2626
nohup /workspaces/circuitpython/.devcontainer/install_build_env.sh >> $HOME/nohup.out &
27-
echo "Use 'tail -f /workspaces/install_build_env.log.active' to monitor progress."
27+
echo "Use 'tail -f /workspaces/circuitpython/install_build_env.log.active' to monitor progress."
2828
echo "After successful installation, start a new terminal to build CircuitPython."
2929
fi
3030
3131
EOF
32-
touch /workspaces/post_create.finished
32+
touch /workspaces/circuitpython/post_create.finished
3333

3434
# --- that's it! ------------------------------------------------------------
3535

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/microcontroller/Pin.h"
10+
#include "shared-bindings/paralleldisplaybus/ParallelBus.h"
11+
#include "shared-module/displayio/__init__.h"
12+
#include "shared-module/displayio/mipi_constants.h"
13+
#include "hardware/gpio.h"
14+
15+
// Display pins from Pimoroni Explorer parallel bus: {cs=27, dc=28, wr=30, rd=31, d0=32, bl=26}
16+
#define LCD_BACKLIGHT_PIN 26
17+
#define LCD_CS_PIN 27
18+
#define LCD_DC_PIN 28
19+
#define LCD_WR_PIN 30
20+
#define LCD_RD_PIN 31
21+
#define LCD_D0_PIN 32 // Data pins are GPIO32-39 (8 consecutive pins)
22+
23+
#define DELAY 0x80
24+
25+
// ST7789V display init sequence for 320x240 parallel bus
26+
// Based on Pimoroni's pimoroni-pico ST7789 driver configuration
27+
uint8_t display_init_sequence[] = {
28+
// Software reset
29+
0x01, 0 | DELAY, 150,
30+
// Sleep out
31+
0x11, 0 | DELAY, 255,
32+
// Tearing effect line on (frame sync)
33+
0x35, 1, 0x00,
34+
// COLMOD: 16-bit color (5-6-5 RGB)
35+
0x3A, 1, 0x55,
36+
// Porch control (PORCTRL)
37+
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
38+
// Gate control (GCTRL) - VGH=13.26V, VGL=-10.43V
39+
0xB7, 1, 0x35,
40+
// VCOM setting (VCOMS)
41+
0xBB, 1, 0x1F,
42+
// LCM control (LCMCTRL)
43+
0xC0, 1, 0x2C,
44+
// VDV and VRH command enable (VDVVRHEN)
45+
0xC2, 1, 0x01,
46+
// VRH set (VRHS)
47+
0xC3, 1, 0x12,
48+
// VDV set (VDVS)
49+
0xC4, 1, 0x20,
50+
// Frame rate control (FRCTRL2)
51+
0xC6, 1, 0x0F,
52+
// Power control 1 (PWCTRL1)
53+
0xD0, 2, 0xA4, 0xA1,
54+
// RAM control (RAMCTRL) - for proper endianness
55+
0xB0, 2, 0x00, 0xC0,
56+
// Positive gamma correction
57+
0xE0, 14, 0xD0, 0x08, 0x11, 0x08, 0x0C, 0x15, 0x39, 0x33, 0x50, 0x36, 0x13, 0x14, 0x29, 0x2D,
58+
// Negative gamma correction
59+
0xE1, 14, 0xD0, 0x08, 0x10, 0x08, 0x06, 0x06, 0x39, 0x44, 0x51, 0x0B, 0x16, 0x14, 0x2F, 0x31,
60+
// Inversion on
61+
0x21, 0,
62+
// Normal display mode on
63+
0x13, 0 | DELAY, 10,
64+
// MADCTL: MX=0, MY=1, MV=1, ML=1 (COL_ORDER | SWAP_XY | SCAN_ORDER) = 0x70
65+
// This configures the 320x240 display in landscape orientation
66+
0x36, 1, 0x70,
67+
// Display on
68+
0x29, 0 | DELAY, 100,
69+
};
70+
71+
static void display_init(void) {
72+
paralleldisplaybus_parallelbus_obj_t *bus = &allocate_display_bus()->parallel_bus;
73+
bus->base.type = &paralleldisplaybus_parallelbus_type;
74+
75+
common_hal_paralleldisplaybus_parallelbus_construct(bus,
76+
&pin_GPIO32, // Data0 (D0) - data pins are sequential GPIO32-39
77+
&pin_GPIO28, // Command/Data (DC)
78+
&pin_GPIO27, // Chip select (CS)
79+
&pin_GPIO30, // Write (WR)
80+
&pin_GPIO31, // Read (RD)
81+
NULL, // Reset (directly connected to board reset)
82+
15000000); // Frequency - ST7789 min clock cycle ~66ns = ~15MHz
83+
84+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
85+
display->base.type = &busdisplay_busdisplay_type;
86+
87+
common_hal_busdisplay_busdisplay_construct(display,
88+
bus,
89+
320, // Width
90+
240, // Height
91+
0, // column start
92+
0, // row start
93+
0, // rotation
94+
16, // Color depth
95+
false, // grayscale
96+
false, // pixels_in_byte_share_row
97+
1, // bytes per cell
98+
false, // reverse_pixels_in_byte
99+
true, // reverse_pixels_in_word
100+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
101+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
102+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
103+
display_init_sequence,
104+
sizeof(display_init_sequence),
105+
&pin_GPIO26, // Backlight pin (BL)
106+
NO_BRIGHTNESS_COMMAND,
107+
1.0f, // brightness
108+
false, // single_byte_bounds
109+
false, // data_as_commands
110+
true, // auto_refresh
111+
60, // native_frames_per_second
112+
true, // backlight_on_high
113+
false, // SH1107_addressing
114+
50000 // backlight pwm frequency
115+
);
116+
}
117+
118+
void board_init(void) {
119+
// Ensure backlight is on before display init
120+
board_reset_pin_number(LCD_BACKLIGHT_PIN);
121+
display_init();
122+
}
123+
124+
// Prevent the backlight pin from being reset, keeping display visible across soft resets
125+
bool board_reset_pin_number(uint8_t pin_number) {
126+
if (pin_number == LCD_BACKLIGHT_PIN) {
127+
// Keep backlight on - set high output without glitching
128+
gpio_put(pin_number, 1);
129+
gpio_set_dir(pin_number, GPIO_OUT);
130+
gpio_set_function(pin_number, GPIO_FUNC_SIO);
131+
return true;
132+
}
133+
return false;
134+
}
135+
136+
void reset_board(void) {
137+
// Keep backlight on during reset
138+
board_reset_pin_number(LCD_BACKLIGHT_PIN);
139+
}
140+
141+
void board_deinit(void) {
142+
// Backlight will be handled by board_reset_pin_number
143+
}
144+
145+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
#define MICROPY_HW_BOARD_NAME "Pimoroni Explorer"
10+
#define MICROPY_HW_MCU_NAME "rp2350b"
11+
12+
#define MICROPY_HW_LED_STATUS (&pin_GPIO25)
13+
14+
#define CIRCUITPY_BOARD_I2C (1)
15+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO21, .sda = &pin_GPIO20}}
16+
17+
#define DEFAULT_UART_BUS_RX (&pin_GPIO1)
18+
#define DEFAULT_UART_BUS_TX (&pin_GPIO0)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
USB_VID = 0x2E8A
2+
USB_PID = 0x10C0
3+
USB_PRODUCT = "Explorer"
4+
USB_MANUFACTURER = "Pimoroni"
5+
6+
CHIP_VARIANT = RP2350
7+
CHIP_PACKAGE = B
8+
CHIP_FAMILY = rp2
9+
10+
EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ"
11+
12+
CIRCUITPY__EVE = 1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2021 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
// Put board-specific pico-sdk definitions here. This file must exist.

0 commit comments

Comments
 (0)