Skip to content

Commit 8a26c21

Browse files
committed
add micropython support for Pimoroni Plus 2W
1 parent a02cd5f commit 8a26c21

File tree

7 files changed

+369
-1
lines changed

7 files changed

+369
-1
lines changed
2.4 MB
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# cmake file for Raspberry Pi Pico
2+
set(PICO_BOARD "pimoroni_pico_plus2w_rp2350")
3+
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
4+
set(PICO_PLATFORM "rp2350")
5+
set(PICO_NUM_GPIOS 48)
6+
7+
set(MICROPY_C_HEAP_SIZE 4096)
8+
9+
# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1
10+
# Picked up and expanded upon in mpconfigboard.h
11+
set(MICROPY_PY_LWIP ON)
12+
13+
# Links cyw43-driver and sets:
14+
# MICROPY_PY_NETWORK_CYW43 = 1,
15+
# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000
16+
set(MICROPY_PY_NETWORK_CYW43 ON)
17+
18+
# Adds mpbthciport.c
19+
# And sets:
20+
# MICROPY_PY_BLUETOOTH = 1,
21+
# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1,
22+
# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1
23+
set(MICROPY_PY_BLUETOOTH ON)
24+
25+
# Links pico_btstack_hci_transport_cyw43
26+
# And sets:
27+
# MICROPY_BLUETOOTH_BTSTACK = 1,
28+
# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE =
29+
set(MICROPY_BLUETOOTH_BTSTACK ON)
30+
31+
# Sets:
32+
# CYW43_ENABLE_BLUETOOTH = 1,
33+
# MICROPY_PY_BLUETOOTH_CYW43 = 1
34+
set(MICROPY_PY_BLUETOOTH_CYW43 ON)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Board and hardware specific configuration
2+
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024))
3+
4+
// Set up networking.
5+
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PPP2"
6+
7+
#define MICROPY_HW_BOARD_NAME "Pimoroni Pico Plus 2 (PSRAM + LTE + WiFi)"
8+
9+
// Enable WiFi & PPP
10+
#define MICROPY_PY_NETWORK (1)
11+
#define MICROPY_PY_NETWORK_PPP_LWIP (1)
12+
13+
// CYW43 driver configuration.
14+
#define CYW43_USE_SPI (1)
15+
#define CYW43_LWIP (1)
16+
#define CYW43_GPIO (1)
17+
#define CYW43_SPI_PIO (1)
18+
19+
#ifndef CYW43_WL_GPIO_COUNT
20+
#define CYW43_WL_GPIO_COUNT 3
21+
#endif
22+
23+
#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT
24+
25+
int mp_hal_is_pin_reserved(int n);
26+
#define MICROPY_HW_PIN_RESERVED(i) mp_hal_is_pin_reserved(i)
27+
28+
// PSRAM Settings
29+
#define MICROPY_HW_ENABLE_PSRAM (1)
30+
#define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN
31+
#define MICROPY_GC_SPLIT_HEAP (1)
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
/*
2+
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
// -----------------------------------------------------
8+
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
9+
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
10+
// -----------------------------------------------------
11+
12+
// This header may be included by other board headers as "boards/pimoroni_pico_plus2w_rp2350.h"
13+
14+
// pico_cmake_set PICO_PLATFORM=rp2350
15+
16+
#ifndef _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H
17+
#define _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H
18+
19+
// For board detection
20+
#define PIMORONI_PICO_PLUS2_RP2350
21+
#define PIMORONI_PICO_PLUS2W_RP2350
22+
23+
// --- BOARD SPECIFIC ---
24+
#define SPICE_SPI 0
25+
#define SPICE_TX_MISO_PIN 32
26+
#define SPICE_RX_CS_PIN 33
27+
#define SPICE_NETLIGHT_SCK_PIN 34
28+
#define SPICE_RESET_MOSI_PIN 35
29+
#define SPICE_PWRKEY_BL_PIN 36
30+
31+
#define PIMORONI_PICO_PLUS2_USER_SW_PIN 45
32+
#define PIMORONI_PICO_PLUS2_PSRAM_CS_PIN 47
33+
34+
// --- UART ---
35+
#ifndef PICO_DEFAULT_UART
36+
#define PICO_DEFAULT_UART 0
37+
#endif
38+
#ifndef PICO_DEFAULT_UART_TX_PIN
39+
#define PICO_DEFAULT_UART_TX_PIN 0
40+
#endif
41+
#ifndef PICO_DEFAULT_UART_RX_PIN
42+
#define PICO_DEFAULT_UART_RX_PIN 1
43+
#endif
44+
45+
// --- LED ---
46+
#ifndef PICO_DEFAULT_LED_PIN
47+
#define PICO_DEFAULT_LED_PIN 25
48+
#endif
49+
// no PICO_DEFAULT_WS2812_PIN
50+
51+
// --- I2C ---
52+
#ifndef PICO_DEFAULT_I2C
53+
#define PICO_DEFAULT_I2C 0
54+
#endif
55+
#ifndef PICO_DEFAULT_I2C_SDA_PIN
56+
#define PICO_DEFAULT_I2C_SDA_PIN 4
57+
#endif
58+
#ifndef PICO_DEFAULT_I2C_SCL_PIN
59+
#define PICO_DEFAULT_I2C_SCL_PIN 5
60+
#endif
61+
62+
// --- SPI ---
63+
#ifndef PICO_DEFAULT_SPI
64+
#define PICO_DEFAULT_SPI 0
65+
#endif
66+
#ifndef PICO_DEFAULT_SPI_SCK_PIN
67+
#define PICO_DEFAULT_SPI_SCK_PIN SPICE_NETLIGHT_SCK_PIN
68+
#endif
69+
#ifndef PICO_DEFAULT_SPI_TX_PIN
70+
#define PICO_DEFAULT_SPI_TX_PIN SPICE_RESET_MOSI_PIN
71+
#endif
72+
#ifndef PICO_DEFAULT_SPI_RX_PIN
73+
#define PICO_DEFAULT_SPI_RX_PIN SPICE_TX_MISO_PIN
74+
#endif
75+
#ifndef PICO_DEFAULT_SPI_CSN_PIN
76+
#define PICO_DEFAULT_SPI_CSN_PIN SPICE_RX_CS_PIN
77+
#endif
78+
79+
// --- FLASH ---
80+
81+
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
82+
83+
#ifndef PICO_FLASH_SPI_CLKDIV
84+
#define PICO_FLASH_SPI_CLKDIV 2
85+
#endif
86+
87+
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
88+
#ifndef PICO_FLASH_SIZE_BYTES
89+
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
90+
#endif
91+
92+
#ifndef CYW43_WL_GPIO_COUNT
93+
#define CYW43_WL_GPIO_COUNT 3
94+
#endif
95+
96+
#ifndef CYW43_WL_GPIO_LED_PIN
97+
#define CYW43_WL_GPIO_LED_PIN 0
98+
#endif
99+
100+
// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS.
101+
// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered.
102+
// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined.
103+
104+
// no CYW43_WL_GPIO_VBUS_PIN
105+
106+
// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes.
107+
// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it.
108+
// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit.
109+
110+
// no CYW43_USES_VSYS_PIN
111+
112+
// The GPIO Pin used to read VBUS to determine if the device is battery powered.
113+
#ifndef PICO_VBUS_PIN
114+
#define PICO_VBUS_PIN 24
115+
#endif
116+
117+
// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC.
118+
// There is an example in adc/read_vsys in pico-examples.
119+
#ifndef PICO_VSYS_PIN
120+
#define PICO_VSYS_PIN 43
121+
#endif
122+
123+
#ifndef PICO_RP2350_A2_SUPPORTED
124+
#define PICO_RP2350_A2_SUPPORTED 1
125+
#endif
126+
127+
// PICO_CONFIG: CYW43_PIN_WL_DYNAMIC, flag to indicate if cyw43 SPI pins can be changed at runtime, type=bool, default=false, advanced=true, group=pico_cyw43_driver
128+
#ifndef CYW43_PIN_WL_DYNAMIC
129+
#define CYW43_PIN_WL_DYNAMIC 1
130+
#endif
131+
132+
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_REG_ON, gpio pin to power up the cyw43 chip, type=int, default=23, advanced=true, group=pico_cyw43_driver
133+
#ifndef CYW43_DEFAULT_PIN_WL_REG_ON
134+
#define CYW43_DEFAULT_PIN_WL_REG_ON 23u
135+
#endif
136+
137+
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_OUT, gpio pin for spi data out to the cyw43 chip, type=int, default=24, advanced=true, group=pico_cyw43_driver
138+
#ifndef CYW43_DEFAULT_PIN_WL_DATA_OUT
139+
#define CYW43_DEFAULT_PIN_WL_DATA_OUT 24u
140+
#endif
141+
142+
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_IN, gpio pin for spi data in from the cyw43 chip, type=int, default=24, advanced=true, group=pico_cyw43_driver
143+
#ifndef CYW43_DEFAULT_PIN_WL_DATA_IN
144+
#define CYW43_DEFAULT_PIN_WL_DATA_IN 24u
145+
#endif
146+
147+
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_HOST_WAKE, gpio (irq) pin for the irq line from the cyw43 chip, type=int, default=24, advanced=true, group=pico_cyw43_driver
148+
#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE
149+
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24u
150+
#endif
151+
152+
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_CLOCK, gpio pin for the spi clock line to the cyw43 chip, type=int, default=29, advanced=true, group=pico_cyw43_driver
153+
#ifndef CYW43_DEFAULT_PIN_WL_CLOCK
154+
#define CYW43_DEFAULT_PIN_WL_CLOCK 29u
155+
#endif
156+
157+
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_CS, gpio pin for the spi chip select to the cyw43 chip, type=int, default=25, advanced=true, group=pico_cyw43_driver
158+
#ifndef CYW43_DEFAULT_PIN_WL_CS
159+
#define CYW43_DEFAULT_PIN_WL_CS 25u
160+
#endif
161+
162+
#endif
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
GP0,GPIO0
2+
GP1,GPIO1
3+
GP2,GPIO2
4+
GP3,GPIO3
5+
GP4,GPIO4
6+
GP5,GPIO5
7+
GP6,GPIO6
8+
GP7,GPIO7
9+
GP8,GPIO8
10+
GP9,GPIO9
11+
GP10,GPIO10
12+
GP11,GPIO11
13+
GP12,GPIO12
14+
GP13,GPIO13
15+
GP14,GPIO14
16+
GP15,GPIO15
17+
GP16,GPIO16
18+
GP17,GPIO17
19+
GP18,GPIO18
20+
GP19,GPIO19
21+
GP20,GPIO20
22+
GP21,GPIO21
23+
GP22,GPIO22
24+
GP25,GPIO25
25+
GP26,GPIO26
26+
GP27,GPIO27
27+
GP28,GPIO28
28+
GP29,GPIO29
29+
GP30,GPIO30
30+
GP31,GPIO31
31+
GP32,GPIO32
32+
GP33,GPIO33
33+
GP34,GPIO34
34+
GP35,GPIO35
35+
GP36,GPIO36
36+
GP37,GPIO37
37+
GP38,GPIO38
38+
GP39,GPIO39
39+
GP40,GPIO40
40+
GP41,GPIO41
41+
GP42,GPIO42
42+
GP43,GPIO43
43+
GP44,GPIO44
44+
GP45,GPIO45
45+
GP46,GPIO46
46+
GP47,GPIO47
47+
LED,GPIO25
48+
LEDW,EXT_GPIO0
49+
WL_GPIO0,EXT_GPIO0
50+
WL_GPIO1,EXT_GPIO1
51+
WL_GPIO2,EXT_GPIO2
52+
SPICE_TX,GPIO32
53+
SPICE_RX,GPIO33
54+
SPICE_NETLIGHT,GPIO34
55+
SPICE_RESET,GPIO35
56+
SPICE_PWRKEY,GPIO36

tools/micropython-all.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@ rm -rf "$micropython_dir"/modules/vector
3030
# Clean previous builds
3131
echo "Cleaning previous builds..."
3232
cd "$micropython_dir"
33-
rm -rf build-RPI_PICO build-RPI_PICO_W build-RPI_PICO2 build-RPI_PICO2_W
33+
rm -rf build-RPI_PICO build-RPI_PICO_W build-RPI_PICO2 build-RPI_PICO2_W build-PIMORONI_PICO_PLUS2W_RP2350
3434

3535
echo "Installing new MicroPython Picoware modules..."
3636

3737
# copy main.py and picoware folder if it exists
3838
cp "$picoware_dir"/src/MicroPython/main.py "$micropython_dir"/modules/main.py
3939
cp -r "$picoware_dir"/src/MicroPython/picoware "$micropython_dir"/modules/picoware
4040

41+
# copy pIMORONI_PICO_PLUS2W_RP2350 boards folder to micropython boards directory
42+
cp -r "$picoware_dir"/src/MicroPython/boards/PIMORONI_PICO_PLUS2W_RP2350 "$micropython_dir"/boards
43+
44+
# copy pIMORONI_PICO_PLUS2W_RP2350.h to PicoSDK boards include directory
45+
cp "$picoware_dir"/src/MicroPython/boards/PIMORONI_PICO_PLUS2W_RP2350/pIMORONI_PICO_PLUS2W_RP2350.h "$micropython_dir"/../../lib/pico-sdk/src/boards/include/boards/
46+
4147
# ensure PicoCalc modules directory exists
4248
mkdir -p "$micropython_dir"/modules/PicoCalc
4349

@@ -82,6 +88,11 @@ make BOARD=RPI_PICO2_W USER_C_MODULES="$micropython_dir"/modules/PicoCalc/picowa
8288
cp "$micropython_dir"/build-RPI_PICO2_W/firmware.uf2 "$picoware_dir"/builds/MicroPython/Picoware-PicoCalcPico2W.uf2
8389
echo "PicoCalc - Pico 2W build complete."
8490

91+
# PicoCalc - Pimoroni 2W
92+
make BOARD=PIMORONI_PICO_PLUS2W_RP2350 USER_C_MODULES="$micropython_dir"/modules/PicoCalc/picoware_modules.cmake
93+
cp "$micropython_dir"/build-PIMORONI_PICO_PLUS2W_RP2350/firmware.uf2 "$picoware_dir"/builds/MicroPython/Picoware-PicoCalcPimoroni2W.uf2
94+
echo "PicoCalc - Pimoroni 2W build complete."
95+
8596
echo "MicroPython Picoware PicoCalc builds completed successfully!"
8697
echo "---------------------------------------"
8798
echo "Cleaning PicoCalc modules to prepare for Waveshare 1.28..."
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/sh
2+
# Script to build and install the MicroPython version of Picoware
3+
echo "Building MicroPython Picoware firmware for PicoCalc Pimoroni 2W..."
4+
5+
# set your locations
6+
micropython_dir="/Users/user/pico/micropython/ports/rp2"
7+
picoware_dir="/Users/user/Desktop/Picoware"
8+
9+
echo "Using MicroPython directory: $micropython_dir"
10+
echo "Using Picoware directory: $picoware_dir"
11+
12+
echo "Cleaning existing MicroPython Picoware modules..."
13+
14+
# remove existing main.py and picoware folder if it exists
15+
rm -rf "$micropython_dir"/modules/main.py
16+
rm -rf "$micropython_dir"/modules/picoware
17+
18+
# remove existing PicoCalc modules directory if it exists
19+
rm -rf "$micropython_dir"/modules/PicoCalc # delete entire PicoCalc directory
20+
21+
# remove existing Waveshare modules directory if it exists
22+
rm -rf "$micropython_dir"/modules/Waveshare
23+
24+
# remove auto complete module if it exists
25+
rm -rf "$micropython_dir"/modules/auto_complete
26+
27+
# remove vector module if it exists
28+
rm -rf "$micropython_dir"/modules/vector
29+
30+
# Clean previous builds
31+
echo "Cleaning previous builds..."
32+
cd "$micropython_dir"
33+
rm -rf build-PIMORONI_PICO_PLUS2W_RP2350
34+
35+
echo "Installing new MicroPython Picoware modules..."
36+
37+
# copy main.py and picoware folder if it exists
38+
cp "$picoware_dir"/src/MicroPython/main.py "$micropython_dir"/modules/main.py
39+
cp -r "$picoware_dir"/src/MicroPython/picoware "$micropython_dir"/modules/picoware
40+
41+
# copy pIMORONI_PICO_PLUS2W_RP2350 boards folder to micropython boards directory
42+
cp -r "$picoware_dir"/src/MicroPython/boards/PIMORONI_PICO_PLUS2W_RP2350 "$micropython_dir"/boards
43+
44+
# copy pIMORONI_PICO_PLUS2W_RP2350.h to PicoSDK boards include directory
45+
cp "$picoware_dir"/src/MicroPython/boards/PIMORONI_PICO_PLUS2W_RP2350/pIMORONI_PICO_PLUS2W_RP2350.h "$micropython_dir"/../../lib/pico-sdk/src/boards/include/boards/
46+
47+
# ensure PicoCalc modules directory exists
48+
mkdir -p "$micropython_dir"/modules/PicoCalc
49+
50+
# copy picoware modules file to micropython modules directory
51+
cp "$picoware_dir"/src/MicroPython/PicoCalc/picoware_modules.cmake "$micropython_dir"/modules/PicoCalc/picoware_modules.cmake
52+
cp -r "$picoware_dir"/src/MicroPython/PicoCalc/picoware_boards "$micropython_dir"/modules/PicoCalc/picoware_boards
53+
cp -r "$picoware_dir"/src/MicroPython/PicoCalc/picoware_game "$micropython_dir"/modules/PicoCalc/picoware_game
54+
cp -r "$picoware_dir"/src/MicroPython/PicoCalc/picoware_keyboard "$micropython_dir"/modules/PicoCalc/picoware_keyboard
55+
cp -r "$picoware_dir"/src/MicroPython/PicoCalc/picoware_lcd "$micropython_dir"/modules/PicoCalc/picoware_lcd
56+
cp -r "$picoware_dir"/src/MicroPython/PicoCalc/picoware_psram "$micropython_dir"/modules/PicoCalc/picoware_psram
57+
cp -r "$picoware_dir"/src/MicroPython/PicoCalc/picoware_sd "$micropython_dir"/modules/PicoCalc/picoware_sd
58+
cp -r "$picoware_dir"/src/MicroPython/PicoCalc/picoware_lvgl "$micropython_dir"/modules/PicoCalc/picoware_lvgl
59+
60+
# copy auto complete module
61+
cp -r "$picoware_dir"/src/MicroPython/auto_complete "$micropython_dir"/modules/auto_complete
62+
63+
# copy vector module
64+
cp -r "$picoware_dir"/src/MicroPython/vector "$micropython_dir"/modules/vector
65+
66+
echo "Starting PicoCalc build process..."
67+
68+
# move to the micropython rp2 port directory
69+
cd "$micropython_dir"
70+
71+
# PicoCalc - Pimoroni 2W
72+
make BOARD=PIMORONI_PICO_PLUS2W_RP2350 USER_C_MODULES="$micropython_dir"/modules/PicoCalc/picoware_modules.cmake
73+
cp "$micropython_dir"/build-PIMORONI_PICO_PLUS2W_RP2350/firmware.uf2 "$picoware_dir"/builds/MicroPython/Picoware-PicoCalcPimoroni2W.uf2
74+
echo "PicoCalc - Pimoroni 2W build complete."

0 commit comments

Comments
 (0)