From 83efc710af7ab8dff50496a3fbdaa8879cbdcba6 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 30 Aug 2024 07:44:31 +0100 Subject: [PATCH 01/38] Pico Plus 2: Add a PPP variant. --- .github/workflows/micropython.yml | 3 +++ .../board/PIMORONI_PICO_PLUS2/manifest-ppp.py | 3 +++ .../board/PIMORONI_PICO_PLUS2/mpconfigboard.h | 17 +++++++++++++++++ .../mpconfigvariant_PPP.cmake | 11 +++++++++++ 4 files changed, 34 insertions(+) create mode 100644 micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py create mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 6747508..7bea50e 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -30,6 +30,9 @@ jobs: - name: pico_plus2_rp2350_psram board: PIMORONI_PICO_PLUS2 variant: PSRAM + - name: pico_plus2_rp2350_psram_n_ppp + board: PIMORONI_PICO_PLUS2 + variant: PPP - name: pico_plus2_rp2350 board: PIMORONI_PICO_PLUS2 diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py b/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py new file mode 100644 index 0000000..0ab9bf0 --- /dev/null +++ b/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py @@ -0,0 +1,3 @@ +require("bundle-networking") + +include("manifest.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h index b641619..888f298 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h @@ -6,3 +6,20 @@ #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) #define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN + +#ifdef PPP_ENABLE_PPP + +// Enable networking. +#define MICROPY_PY_NETWORK 1 +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico" + +#define MICROPY_PY_NETWORK_PPP_LWIP 1 + +#define MICROPY_HW_NIC_PPP { MP_ROM_QSTR(MP_QSTR_PINT), MP_ROM_PTR(&mp_network_ppp_lwip_type) }, + +#define MICROPY_BOARD_NETWORK_INTERFACES \ + MICROPY_HW_NIC_PPP + +#define MICROPY_PY_SOCKET_EXTENDED_STATE 1 + +#endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake new file mode 100644 index 0000000..e7dc96b --- /dev/null +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake @@ -0,0 +1,11 @@ +# Override the MicroPython board name +list(APPEND MICROPY_DEF_BOARD + "MICROPY_HW_ENABLE_PSRAM=1" + "MICROPY_GC_SPLIT_HEAP=1" + "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (PSRAM)\"" + "PPP_ENABLE_PPP=1" +) + +set(MICROPY_PY_LWIP ON) + +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-ppp.py) From b22072632c9fe08efe7363a9eb9bcc6d9981ac07 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 2 Sep 2024 14:58:44 +0100 Subject: [PATCH 02/38] PPP: Add LTE module. --- .../board/PIMORONI_PICO_PLUS2/manifest-ppp.py | 4 +- .../pico_plus_2/breakouts/lte-breakout.py | 38 ++++ micropython/modules_py/lte.py | 209 ++++++++++++++++++ 3 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 micropython/examples/pico_plus_2/breakouts/lte-breakout.py create mode 100644 micropython/modules_py/lte.py diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py b/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py index 0ab9bf0..f42cb18 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py +++ b/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py @@ -1,3 +1,5 @@ require("bundle-networking") -include("manifest.py") \ No newline at end of file +include("manifest.py") + +freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/examples/pico_plus_2/breakouts/lte-breakout.py b/micropython/examples/pico_plus_2/breakouts/lte-breakout.py new file mode 100644 index 0000000..d20037d --- /dev/null +++ b/micropython/examples/pico_plus_2/breakouts/lte-breakout.py @@ -0,0 +1,38 @@ +import lte +import time +import requests +from machine import Pin, PWM + + +MOBILE_APN = "Your APN Here" + +# Setting this to True will attempt to resume an existing connection +RESUME = False + +# Fix the eye-searing brightness of the onboard LED with PWM +class Netlight: + def __init__(self): + self.pin = PWM(Pin("LED", Pin.OUT), freq=1000) + + def value(self, value): + self.pin.duty_u16(value * 2000) + + +con = lte.LTE(MOBILE_APN, netlight_led=Netlight(), skip_reset=RESUME) +con.start_ppp(connect=not RESUME) + +# Do some requests! Internet stuff should just work now. +try: + t_start = time.time() + for x in range(2): + req = requests.get("https://shop.pimoroni.com/robots.txt") + print(req) + +finally: + t_end = time.time() + + print(f"Took: {t_end - t_start} seconds") + + print("Disconnecting...") + con.stop_ppp() + print("Done!") diff --git a/micropython/modules_py/lte.py b/micropython/modules_py/lte.py new file mode 100644 index 0000000..1706f14 --- /dev/null +++ b/micropython/modules_py/lte.py @@ -0,0 +1,209 @@ +from machine import UART, Pin +from network import PPP +from micropython import const +import time + + +DEFAULT_PIN_RST = 35 +DEFAULT_PIN_NETLIGHT = 34 +DEFAULT_PIN_RX = 33 +DEFAULT_PIN_TX = 32 +DEFAULT_UART_ID = 0 + +DEFAULT_UART_TIMEOUT = const(1) +DEFAULT_UART_TIMEOUT_CHAR = const(1) +DEFAULT_UART_RXBUF = const(1024) +DEFAULT_UART_STARTUP_BAUD = const(115200) +DEFAULT_UART_BAUD = const(460800) + + +class CellularError(Exception): + def __init__(self, message=None): + self.message = "CellularError: " + message + + +class LTE(): + def __init__(self, apn, uart=None, reset_pin=None, netlight_pin=None, netlight_led=None, skip_reset=False): + self._apn = apn + self._reset = reset_pin or Pin(DEFAULT_PIN_RST, Pin.OUT) + self._uart = uart or UART( + DEFAULT_UART_ID, + tx=Pin(DEFAULT_PIN_TX, Pin.OUT), + rx=Pin(DEFAULT_PIN_RX, Pin.OUT)) + + # Set PPP timeouts and rxbuf + self._uart.init( + timeout=DEFAULT_UART_TIMEOUT, + timeout_char=DEFAULT_UART_TIMEOUT_CHAR, + rxbuf=DEFAULT_UART_RXBUF) + + if not skip_reset: + self._reset.value(0) + time.sleep(1.0) + self._reset.value(1) + + if netlight_led: + self._led = netlight_led + self._netlight = netlight_pin or Pin(DEFAULT_PIN_NETLIGHT, Pin.IN) + self._netlight.irq(self._netlight_irq) + + def _netlight_irq(self, pin): + self._led.value(pin.value()) + + def imei(self): + try: + return self._send_at_command("AT+CIMI", 1) + except CellularError: + return None + + def status(self): + lte_status = self._send_at_command("AT+CEREG?", 1) + gsm_status = self._send_at_command("AT+CGREG?", 1) + return lte_status, gsm_status + + def signal_quality(self): + try: + response = self._send_at_command("AT+CSQ", 1) + quality = int(response.split(":")[1].split(",")[0]) + db = -113 + (2 * quality) # conversion as per AT command set datasheet + return db + except CellularError: + pass + return None + + def stop_ppp(self): + self._ppp.disconnect() + self._send_at_command(f"AT+IPR={DEFAULT_UART_STARTUP_BAUD}") + self._flush_uart() + + def start_ppp(self, baudrate=DEFAULT_UART_BAUD, connect=True): + self._wait_ready(poll_time=1.0, timeout=30) + + # Switch to a faster baudrate + self._send_at_command(f"AT+IPR={baudrate}") + self._flush_uart() + self._uart.init( + baudrate=baudrate, + timeout=DEFAULT_UART_TIMEOUT, + timeout_char=DEFAULT_UART_TIMEOUT_CHAR, + rxbuf=DEFAULT_UART_RXBUF) + self._wait_ready(poll_time=1.0) + + # Connect! + if connect: + self.connect() + + # This will just always time out!? + # try: + # self._send_at_command("ATD*99#", timeout=300) + # except CellularError as e: + # print(e) + + # Force PPP to use modem's default settings... + #time.sleep(2.0) + self._flush_uart() + self._uart.write("ATD*99#\r") + self._uart.flush() + #time.sleep(2.0) + + self._ppp = PPP(self._uart) + self._ppp.connect() + while self._ppp.status() != 4: + time.sleep(1.0) + + return self._ppp.ifconfig() + + def connect(self, timeout=60): + print(" - setting up cellular uart") + # connect to and flush the uart + # consume any unsolicited messages first, we don't need those + self._flush_uart() + + print(" - waiting for cellular module to be ready") + + # wait for the cellular module to respond to AT commands + self._wait_ready() + + self._send_at_command("ATE0") # disable local echo + self._send_at_command(f"AT+CGDCONT=1,\"IP\",\"{self._apn}\"") # set apn and activate pdp context + + # wait for roaming lte connection to be established + giveup = time.time() + timeout + status = None + while status != "+CEREG: 0,5" and status != "+CEREG: 0,1": + status = self._send_at_command("AT+CEREG?", 1) + time.sleep(0.25) + if time.time() > giveup: + raise CellularError("timed out getting network registration") + + # disable server and client certification validation + self._send_at_command("AT+CSSLCFG=\"authmode\",0,0") + self._send_at_command("AT+CSSLCFG=\"enableSNI\",0,1") + + print(f" - cellular IMEI is {self.imei()}") + + def _wait_ready(self, poll_time=0.25, timeout=10): + giveup = time.time() + timeout + while time.time() <= giveup: + try: + self._send_at_command("AT") + return # if __send_at_command doesn't throw an exception then we're good! + except CellularError as e: + print(e) + time.sleep(poll_time) + + raise CellularError("timed out waiting for AT response") + + def _flush_uart(self): + self._uart.flush() + time.sleep(0.25) + while self._uart.any(): + self._uart.read(self._uart.any()) + time.sleep(0.25) + + def _send_at_command(self, command, result_lines=0, timeout=5.0): + # consume any unsolicited messages first, we don't need those + self._flush_uart() + + self._uart.write(command + "\r") + #print(f" - tx: {command}") + self._uart.flush() + status, data = self._read_result(result_lines, timeout=timeout) + + print(" -", command, status, data) + + if status == "TIMEOUT": + #print.error(" !", command, status, data) + raise CellularError(f"cellular module timed out for command {command}") + + if status not in ["OK", "DOWNLOAD"]: + #print(" !", command, status, data) + raise CellularError(f"non 'OK' or 'DOWNLOAD' result for command {command}") + + if result_lines == 1: + return data[0] + if result_lines > 1: + return data + return None + + def _read_result(self, result_lines, timeout=1.0): + status = None + result = [] + start = time.ticks_ms() + timeout *= 1000 + while len(result) < result_lines or status is None: + if (time.ticks_ms() - start) > timeout: + return "TIMEOUT", [] + + line = self._uart.readline() + + if line: + line = line.strip() + if line in [b"OK", b"ERROR", b"DOWNLOAD"]: + status = line.decode("ascii") + elif line != b"": + result.append(str(line, "ascii")) + start = time.ticks_ms() + + return status, result + From 803154a5411ccd48eb98820baef656c74ac2a195 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 11 Sep 2024 11:22:02 +0100 Subject: [PATCH 03/38] PPP: Fix board name. --- micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake index e7dc96b..5df8094 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake @@ -2,7 +2,7 @@ list(APPEND MICROPY_DEF_BOARD "MICROPY_HW_ENABLE_PSRAM=1" "MICROPY_GC_SPLIT_HEAP=1" - "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (PSRAM)\"" + "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (LTE + PSRAM)\"" "PPP_ENABLE_PPP=1" ) From de876b19ab8027686b19c9e909ade51ebef5de2b Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 17 Sep 2024 13:26:39 +0100 Subject: [PATCH 04/38] PPP: Add CYW43 wireless. If we're bringing in lwip and networking, this variant might as well support CYW43. --- .github/workflows/micropython.yml | 4 +-- .../{manifest-ppp.py => manifest-wireless.py} | 3 ++ .../board/PIMORONI_PICO_PLUS2/mpconfigboard.h | 34 ++++++++++++++---- .../mpconfigvariant_PPP.cmake | 11 ------ .../mpconfigvariant_PSRAM.cmake | 4 +-- .../mpconfigvariant_WIRELESS.cmake | 36 +++++++++++++++++++ .../board/PIMORONI_PICO_PLUS2/pins.csv | 7 +++- 7 files changed, 76 insertions(+), 23 deletions(-) rename micropython/board/PIMORONI_PICO_PLUS2/{manifest-ppp.py => manifest-wireless.py} (76%) delete mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake create mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 7bea50e..b81e601 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -30,9 +30,9 @@ jobs: - name: pico_plus2_rp2350_psram board: PIMORONI_PICO_PLUS2 variant: PSRAM - - name: pico_plus2_rp2350_psram_n_ppp + - name: pico_plus2_rp2350_wireless board: PIMORONI_PICO_PLUS2 - variant: PPP + variant: WIRELESS - name: pico_plus2_rp2350 board: PIMORONI_PICO_PLUS2 diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py b/micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py similarity index 76% rename from micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py rename to micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py index f42cb18..b34f473 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/manifest-ppp.py +++ b/micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py @@ -1,5 +1,8 @@ require("bundle-networking") +# Bluetooth +require("aioble") + include("manifest.py") freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h index 888f298..3f9dd70 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h @@ -7,19 +7,39 @@ #define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN -#ifdef PPP_ENABLE_PPP +// Might be defined in mpconfigvariant_PSRAM.cmake +// or mpconfigvariant_PPP.cmake +#if defined(MICROPY_HW_ENABLE_PSRAM) -// Enable networking. -#define MICROPY_PY_NETWORK 1 -#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico" +#define MICROPY_GC_SPLIT_HEAP (1) -#define MICROPY_PY_NETWORK_PPP_LWIP 1 +#endif -#define MICROPY_HW_NIC_PPP { MP_ROM_QSTR(MP_QSTR_PINT), MP_ROM_PTR(&mp_network_ppp_lwip_type) }, +// Set up networking. +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PPP2" + +#if defined(MICROPY_PY_NETWORK_CYW43) + +// CYW43 driver configuration. +#define CYW43_USE_SPI (1) +#define CYW43_LWIP (1) +#define CYW43_GPIO (1) +#define CYW43_SPI_PIO (1) + +#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT + +#endif + +// Might be defined in mpconfigvariant_PPP.cmake +// This is not checked by mpconfigport.h so we must set up networking below +#if defined(MICROPY_PY_NETWORK_PPP_LWIP) + +// TODO: This should be upstreamed to mpconfigport.h +#define MICROPY_HW_NIC_PPP { MP_ROM_QSTR(MP_QSTR_PPP), MP_ROM_PTR(&mp_network_ppp_lwip_type) }, #define MICROPY_BOARD_NETWORK_INTERFACES \ MICROPY_HW_NIC_PPP -#define MICROPY_PY_SOCKET_EXTENDED_STATE 1 +#define MICROPY_PY_SOCKET_EXTENDED_STATE (1) #endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake deleted file mode 100644 index 5df8094..0000000 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PPP.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# Override the MicroPython board name -list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_ENABLE_PSRAM=1" - "MICROPY_GC_SPLIT_HEAP=1" - "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (LTE + PSRAM)\"" - "PPP_ENABLE_PPP=1" -) - -set(MICROPY_PY_LWIP ON) - -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-ppp.py) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake index cb27d72..eedd565 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake @@ -1,6 +1,6 @@ # Override the MicroPython board name +# And set basic options which are expanded upon in mpconfigboard.h list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_ENABLE_PSRAM=1" - "MICROPY_GC_SPLIT_HEAP=1" "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (PSRAM)\"" + "MICROPY_HW_ENABLE_PSRAM=1" ) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake new file mode 100644 index 0000000..d75423f --- /dev/null +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake @@ -0,0 +1,36 @@ +# Override the MicroPython board name +# And set basic options which are expanded upon in mpconfigboard.h +list(APPEND MICROPY_DEF_BOARD + "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (Wireless + PSRAM)\"" + "MICROPY_HW_ENABLE_PSRAM=1" + "MICROPY_PY_NETWORK=1" +) + +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + +# Links cyw43-driver and sets: +# MICROPY_PY_NETWORK_CYW43 = 1, +# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 +set(MICROPY_PY_NETWORK_CYW43 ON) + +# Adds mpbthciport.c +# And sets: +# MICROPY_PY_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, +# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 +set(MICROPY_PY_BLUETOOTH ON) + +# Links pico_btstack_hci_transport_cyw43 +# And sets: +# MICROPY_BLUETOOTH_BTSTACK = 1, +# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = +set(MICROPY_BLUETOOTH_BTSTACK ON) + +# Sets: +# CYW43_ENABLE_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_CYW43 = 1 +set(MICROPY_PY_BLUETOOTH_CYW43 ON) + +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pins.csv b/micropython/board/PIMORONI_PICO_PLUS2/pins.csv index 9d58ee8..2f11f26 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/pins.csv +++ b/micropython/board/PIMORONI_PICO_PLUS2/pins.csv @@ -44,4 +44,9 @@ GP44,GPIO44 GP45,GPIO45 GP46,GPIO46 GP47,GPIO47 -LED,GPIO25 \ No newline at end of file +LED,GPIO25 +SPICE_TX,GPIO32 +SPICE_RX,GPIO33 +SPICE_NETLIGHT,GPIO34 +SPICE_RESET,GPIO35 +SPICE_PWRKEY,GPIO36 \ No newline at end of file From 45932be8e221029dc9aa4cdcf851421c86c2c331 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 17 Sep 2024 13:58:23 +0100 Subject: [PATCH 05/38] PPP: Add CYW43 wireless pins. --- .../mpconfigvariant_WIRELESS.cmake | 3 + .../pimoroni_pico_plus2w_rp2350.h | 136 ++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake index d75423f..f2f4dac 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake @@ -34,3 +34,6 @@ set(MICROPY_BLUETOOTH_BTSTACK ON) set(MICROPY_PY_BLUETOOTH_CYW43 ON) set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) + +set(PICO_BOARD "pimoroni_pico_plus2w_rp2350") +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h b/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h new file mode 100644 index 0000000..c0ff5d7 --- /dev/null +++ b/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// ----------------------------------------------------- +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES +// ----------------------------------------------------- + +// This header may be included by other board headers as "boards/pimoroni_pico_plus2w_rp2350.h" + +// pico_cmake_set PICO_PLATFORM=rp2350 + +#ifndef _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H +#define _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H + +// For board detection +#define PIMORONI_PICO_PLUS2_RP2350 +#define PIMORONI_PICO_PLUS2W_RP2350 + +// --- BOARD SPECIFIC --- +#define SPICE_SPI 0 +#define SPICE_TX_MISO_PIN 32 +#define SPICE_RX_CS_PIN 33 +#define SPICE_NETLIGHT_SCK_PIN 34 +#define SPICE_RESET_MOSI_PIN 35 +#define SPICE_PWRKEY_BL_PIN 36 + +#define PIMORONI_PICO_PLUS2_USER_SW_PIN 45 +#define PIMORONI_PICO_PLUS2_PSRAM_CS_PIN 47 + +// -- CYW43 Wireless -- +#ifndef CYW43_PIN_WL_HOST_WAKE +#define CYW43_PIN_WL_HOST_WAKE 24 +#endif + +#ifndef CYW43_PIN_WL_REG_ON +#define CYW43_PIN_WL_REG_ON 23 +#endif + +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 +#endif + +#ifndef CYW43_WL_GPIO_LED_PIN +#define CYW43_WL_GPIO_LED_PIN 0 +#endif + +// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS. +// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered. +// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined. + +// no CYW43_WL_GPIO_VBUS_PIN + +// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes. +// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it. +// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit. + +// no CYW43_USES_VSYS_PIN + +// --- UART --- +#ifndef PICO_DEFAULT_UART +#define PICO_DEFAULT_UART 0 +#endif +#ifndef PICO_DEFAULT_UART_TX_PIN +#define PICO_DEFAULT_UART_TX_PIN 0 +#endif +#ifndef PICO_DEFAULT_UART_RX_PIN +#define PICO_DEFAULT_UART_RX_PIN 1 +#endif + +// --- LED --- +#ifndef PICO_DEFAULT_LED_PIN +#define PICO_DEFAULT_LED_PIN 25 +#endif +// no PICO_DEFAULT_WS2812_PIN + +// --- 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 SPICE_NETLIGHT_SCK_PIN +#endif +#ifndef PICO_DEFAULT_SPI_TX_PIN +#define PICO_DEFAULT_SPI_TX_PIN SPICE_RESET_MOSI_PIN +#endif +#ifndef PICO_DEFAULT_SPI_RX_PIN +#define PICO_DEFAULT_SPI_RX_PIN SPICE_TX_MISO_PIN +#endif +#ifndef PICO_DEFAULT_SPI_CSN_PIN +#define PICO_DEFAULT_SPI_CSN_PIN SPICE_RX_CS_PIN +#endif + +// --- FLASH --- + +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 + +#ifndef PICO_FLASH_SPI_CLKDIV +#define PICO_FLASH_SPI_CLKDIV 2 +#endif + +// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024) +#ifndef PICO_FLASH_SIZE_BYTES +#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) +#endif + +// 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. +// There is an example in adc/read_vsys in pico-examples. +#ifndef PICO_VSYS_PIN +#define PICO_VSYS_PIN 43 +#endif + +#ifndef PICO_RP2350_A2_SUPPORTED +#define PICO_RP2350_A2_SUPPORTED 1 +#endif + +#endif \ No newline at end of file From 4b97c8512ade1f445a45e0e27d659392c50af350 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 17 Sep 2024 15:37:19 +0100 Subject: [PATCH 06/38] PPP: Enable PPP. --- .../board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake index f2f4dac..9d300ad 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake @@ -4,6 +4,7 @@ list(APPEND MICROPY_DEF_BOARD "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (Wireless + PSRAM)\"" "MICROPY_HW_ENABLE_PSRAM=1" "MICROPY_PY_NETWORK=1" + "MICROPY_PY_NETWORK_PPP_LWIP=1" ) # Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 From b5ab97559431d26be06346dfeee6b9120d98274e Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 19 Sep 2024 10:11:01 +0100 Subject: [PATCH 07/38] PPP: Simplify config. PPP does not use socket extended state, and should be added automatically in the networking module. --- micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h index 3f9dd70..34f260c 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h @@ -34,12 +34,6 @@ // This is not checked by mpconfigport.h so we must set up networking below #if defined(MICROPY_PY_NETWORK_PPP_LWIP) -// TODO: This should be upstreamed to mpconfigport.h -#define MICROPY_HW_NIC_PPP { MP_ROM_QSTR(MP_QSTR_PPP), MP_ROM_PTR(&mp_network_ppp_lwip_type) }, - -#define MICROPY_BOARD_NETWORK_INTERFACES \ - MICROPY_HW_NIC_PPP - -#define MICROPY_PY_SOCKET_EXTENDED_STATE (1) +// Nothing to do here? #endif \ No newline at end of file From dda8849634e343c49243846cb42f064470854a7e Mon Sep 17 00:00:00 2001 From: nkotilainen Date: Wed, 25 Sep 2024 08:55:09 +0100 Subject: [PATCH 08/38] PPP: LTE IMEI renamed to IMSI. --- micropython/modules_py/lte.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micropython/modules_py/lte.py b/micropython/modules_py/lte.py index 1706f14..d2faf07 100644 --- a/micropython/modules_py/lte.py +++ b/micropython/modules_py/lte.py @@ -50,7 +50,7 @@ class LTE(): def _netlight_irq(self, pin): self._led.value(pin.value()) - def imei(self): + def imsi(self): try: return self._send_at_command("AT+CIMI", 1) except CellularError: @@ -140,7 +140,7 @@ class LTE(): self._send_at_command("AT+CSSLCFG=\"authmode\",0,0") self._send_at_command("AT+CSSLCFG=\"enableSNI\",0,1") - print(f" - cellular IMEI is {self.imei()}") + print(f" - cellular IMSI is {self.imsi()}") def _wait_ready(self, poll_time=0.25, timeout=10): giveup = time.time() + timeout From 21fd5101b57ca865e80e3d645b3667f9f1f07915 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 25 Sep 2024 11:10:52 +0100 Subject: [PATCH 09/38] PPP2: Add wireless. --- .github/workflows/micropython.yml | 2 +- .../board/PIMORONI_PICO_PLUS2/mpconfigboard.h | 42 ++++++++++++++++--- .../mpconfigvariant_WIRELESS.cmake | 1 + .../pimoroni_pico_plus2w_rp2350.h | 8 ++-- micropython/board/manifest_pico2.py | 3 ++ 5 files changed, 46 insertions(+), 10 deletions(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index b81e601..cee634c 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -7,7 +7,7 @@ on: types: [created] env: - MICROPYTHON_VERSION: feature/psram + MICROPYTHON_VERSION: feature/spicy-wifi MICROPYTHON_FLAVOUR: pimoroni PIMORONI_PICO_VERSION: main diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h index 34f260c..7ee44ec 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h @@ -1,14 +1,10 @@ // Board and hardware specific configuration -#ifndef MICROPY_HW_BOARD_NAME -// Might be defined by mpconfigvariant.cmake -#define MICROPY_HW_BOARD_NAME "Pimoroni Pico Plus 2" -#endif #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) #define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN // Might be defined in mpconfigvariant_PSRAM.cmake -// or mpconfigvariant_PPP.cmake +// or mpconfigvariant_WIRELESS.cmake #if defined(MICROPY_HW_ENABLE_PSRAM) #define MICROPY_GC_SPLIT_HEAP (1) @@ -28,6 +24,35 @@ #define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT +#if defined(CYW43_PIN_WL_DYNAMIC) + +#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1) + +// Defined by pimoroni_pico_plus2w_rp2350.h +//#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN +//#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN +#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_CLOCK 29u +#define CYW43_DEFAULT_PIN_WL_CS 25u + +/* SPICE alternative +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN +#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN +#define CYW43_DEFAULT_PIN_WL_DATA_OUT SPICE_RESET_MOSI_PIN +#define CYW43_DEFAULT_PIN_WL_DATA_IN SPICE_RESET_MOSI_PIN +#define CYW43_DEFAULT_PIN_WL_CLOCK SPICE_NETLIGHT_SCK_PIN +#define CYW43_DEFAULT_PIN_WL_CS SPICE_RX_CS_PIN +*/ + +// Slow down the wireless clock, since we'll be running +// comms through wiring spaghetti! +#define CYW43_PIO_CLOCK_DIV_INT 50 +#define CYW43_PIO_CLOCK_DIV_FRAC 0 +#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1 + +#endif + #endif // Might be defined in mpconfigvariant_PPP.cmake @@ -36,4 +61,11 @@ // Nothing to do here? +#endif + +// If a variant is not used, define a fallback board name +#ifndef MICROPY_HW_BOARD_NAME + +#define MICROPY_HW_BOARD_NAME "Pimoroni Pico Plus 2" + #endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake index 9d300ad..6de4e4f 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake @@ -4,6 +4,7 @@ list(APPEND MICROPY_DEF_BOARD "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (Wireless + PSRAM)\"" "MICROPY_HW_ENABLE_PSRAM=1" "MICROPY_PY_NETWORK=1" + "CYW43_PIN_WL_DYNAMIC=1" "MICROPY_PY_NETWORK_PPP_LWIP=1" ) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h b/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h index c0ff5d7..f7a716f 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h @@ -32,12 +32,12 @@ #define PIMORONI_PICO_PLUS2_PSRAM_CS_PIN 47 // -- CYW43 Wireless -- -#ifndef CYW43_PIN_WL_HOST_WAKE -#define CYW43_PIN_WL_HOST_WAKE 24 +#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24 #endif -#ifndef CYW43_PIN_WL_REG_ON -#define CYW43_PIN_WL_REG_ON 23 +#ifndef CYW43_DEFAULT_PIN_WL_REG_ON +#define CYW43_DEFAULT_PIN_WL_REG_ON 23 #endif #ifndef CYW43_WL_GPIO_COUNT diff --git a/micropython/board/manifest_pico2.py b/micropython/board/manifest_pico2.py index df993ee..a400fdc 100644 --- a/micropython/board/manifest_pico2.py +++ b/micropython/board/manifest_pico2.py @@ -1,5 +1,8 @@ MODULES_PY = "../../../pimoroni-pico/micropython/modules_py" +# SD Card +require("sdcard") + freeze(MODULES_PY, "gfx_pack.py") freeze(MODULES_PY, "pimoroni.py") From 6df9a31ace5e4b3c2661ee17863eef54091db158 Mon Sep 17 00:00:00 2001 From: nkotilainen Date: Wed, 25 Sep 2024 13:43:43 +0100 Subject: [PATCH 10/38] PPP: LTE IMSI printout changed to ICCID. --- micropython/modules_py/lte.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/micropython/modules_py/lte.py b/micropython/modules_py/lte.py index d2faf07..18689a3 100644 --- a/micropython/modules_py/lte.py +++ b/micropython/modules_py/lte.py @@ -50,9 +50,9 @@ class LTE(): def _netlight_irq(self, pin): self._led.value(pin.value()) - def imsi(self): + def iccid(self): try: - return self._send_at_command("AT+CIMI", 1) + return self._send_at_command("AT+CICCID", 1) except CellularError: return None @@ -140,7 +140,7 @@ class LTE(): self._send_at_command("AT+CSSLCFG=\"authmode\",0,0") self._send_at_command("AT+CSSLCFG=\"enableSNI\",0,1") - print(f" - cellular IMSI is {self.imsi()}") + print(f" - SIM ICCID is {self.iccid()}") def _wait_ready(self, poll_time=0.25, timeout=10): giveup = time.time() + timeout From 0a0eea0e805977510f14ea2e42063147666815d2 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 25 Sep 2024 15:27:41 +0100 Subject: [PATCH 11/38] PPP: Add ipconfig pass-through. --- micropython/modules_py/lte.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/micropython/modules_py/lte.py b/micropython/modules_py/lte.py index 18689a3..5340650 100644 --- a/micropython/modules_py/lte.py +++ b/micropython/modules_py/lte.py @@ -50,6 +50,12 @@ class LTE(): def _netlight_irq(self, pin): self._led.value(pin.value()) + def ipconfig(self, *args, **kwargs): + if len(args): + return self._ppp.ipconfig(*args) + else: + return self._ppp.ipconfig(**kwargs) + def iccid(self): try: return self._send_at_command("AT+CICCID", 1) From 1c59ca6002d60b068acda8b9f5dadb2585cfccfe Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Thu, 26 Sep 2024 17:22:46 +0100 Subject: [PATCH 12/38] Pico2: Add WIRELESS variant for LTE + WiFi modules. --- .github/workflows/micropython.yml | 3 + .../board/RPI_PICO2/manifest-wireless.py | 8 ++ micropython/board/RPI_PICO2/mpconfigboard.h | 53 +++++++- .../RPI_PICO2/mpconfigvariant_WIRELESS.cmake | 40 ++++++ micropython/board/RPI_PICO2/pico2_w.h | 116 ++++++++++++++++++ 5 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 micropython/board/RPI_PICO2/manifest-wireless.py create mode 100644 micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake create mode 100644 micropython/board/RPI_PICO2/pico2_w.h diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index cee634c..5308eb5 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -21,6 +21,9 @@ jobs: include: - name: pico2_rp2350 board: RPI_PICO2 + - name: pico2_rp2350_wireless + board: RPI_PICO2 + variant: WIRELESS - name: pico2b_rp2350 board: RPI_PICO2B - name: plasma2350 diff --git a/micropython/board/RPI_PICO2/manifest-wireless.py b/micropython/board/RPI_PICO2/manifest-wireless.py new file mode 100644 index 0000000..b34f473 --- /dev/null +++ b/micropython/board/RPI_PICO2/manifest-wireless.py @@ -0,0 +1,8 @@ +require("bundle-networking") + +# Bluetooth +require("aioble") + +include("manifest.py") + +freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/RPI_PICO2/mpconfigboard.h b/micropython/board/RPI_PICO2/mpconfigboard.h index a50d66b..95385ba 100644 --- a/micropython/board/RPI_PICO2/mpconfigboard.h +++ b/micropython/board/RPI_PICO2/mpconfigboard.h @@ -1,3 +1,52 @@ // Board and hardware specific configuration -#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico" -#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024) \ No newline at end of file +#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) + +// Set up networking. +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2" + +#if defined(MICROPY_PY_NETWORK_CYW43) + +// CYW43 driver configuration. +#define CYW43_USE_SPI (1) +#define CYW43_LWIP (1) +#define CYW43_GPIO (1) +#define CYW43_SPI_PIO (1) + +#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT + +#if defined(CYW43_PIN_WL_DYNAMIC) + +#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1) + +// CYW43 default pin configuration +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24u +#define CYW43_DEFAULT_PIN_WL_REG_ON 23u +#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_CLOCK 29u +#define CYW43_DEFAULT_PIN_WL_CS 25u + +// Slow down the wireless clock, since we'll be running +// comms through wiring spaghetti! +#define CYW43_PIO_CLOCK_DIV_INT 50 +#define CYW43_PIO_CLOCK_DIV_FRAC 0 +#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1 + +#endif + +#endif + +// Might be defined in mpconfigvariant_PPP.cmake +// This is not checked by mpconfigport.h so we must set up networking below +#if defined(MICROPY_PY_NETWORK_PPP_LWIP) + +// Nothing to do here? + +#endif + +// If a variant is not used, define a fallback board name +#ifndef MICROPY_HW_BOARD_NAME + +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico 2" + +#endif \ No newline at end of file diff --git a/micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake b/micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake new file mode 100644 index 0000000..8493a5c --- /dev/null +++ b/micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake @@ -0,0 +1,40 @@ +# Override the MicroPython board name +# And set basic options which are expanded upon in mpconfigboard.h +list(APPEND MICROPY_DEF_BOARD + "MICROPY_HW_BOARD_NAME=\"Raspberry Pi Pico 2 (LTE + WiFi)\"" + "MICROPY_PY_NETWORK=1" + "CYW43_PIN_WL_DYNAMIC=1" + "MICROPY_PY_NETWORK_PPP_LWIP=1" +) + +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + +# Links cyw43-driver and sets: +# MICROPY_PY_NETWORK_CYW43 = 1, +# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 +set(MICROPY_PY_NETWORK_CYW43 ON) + +# Adds mpbthciport.c +# And sets: +# MICROPY_PY_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, +# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 +set(MICROPY_PY_BLUETOOTH ON) + +# Links pico_btstack_hci_transport_cyw43 +# And sets: +# MICROPY_BLUETOOTH_BTSTACK = 1, +# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = +set(MICROPY_BLUETOOTH_BTSTACK ON) + +# Sets: +# CYW43_ENABLE_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_CYW43 = 1 +set(MICROPY_PY_BLUETOOTH_CYW43 ON) + +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) + +set(PICO_BOARD "pico2_w") +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/micropython/board/RPI_PICO2/pico2_w.h b/micropython/board/RPI_PICO2/pico2_w.h new file mode 100644 index 0000000..68d5191 --- /dev/null +++ b/micropython/board/RPI_PICO2/pico2_w.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// ----------------------------------------------------- +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES +// ----------------------------------------------------- + +// This header may be included by other board headers as "boards/pico2_w.h" + +// pico_cmake_set PICO_PLATFORM=rp2350 +// pico_cmake_set PICO_CYW43_SUPPORTED = 1 + +#ifndef _BOARDS_PICO2_W_H +#define _BOARDS_PICO2_W_H + +// For board detection +#define RASPBERRYPI_PICO2_W + +// --- RP2350 VARIANT --- +#define PICO_RP2350A 1 + +// --- UART --- +#ifndef PICO_DEFAULT_UART +#define PICO_DEFAULT_UART 0 +#endif +#ifndef PICO_DEFAULT_UART_TX_PIN +#define PICO_DEFAULT_UART_TX_PIN 0 +#endif +#ifndef PICO_DEFAULT_UART_RX_PIN +#define PICO_DEFAULT_UART_RX_PIN 1 +#endif + +// --- LED --- +// no PICO_DEFAULT_LED_PIN - LED is on Wireless chip +// no PICO_DEFAULT_WS2812_PIN + +// --- 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 + +// --- FLASH --- + +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 + +#ifndef PICO_FLASH_SPI_CLKDIV +#define PICO_FLASH_SPI_CLKDIV 2 +#endif + +// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024) +#ifndef PICO_FLASH_SIZE_BYTES +#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024) +#endif +// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads) +// note the SMSP mode pin is on WL_GPIO1 + +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 +#endif + +#ifndef CYW43_WL_GPIO_LED_PIN +#define CYW43_WL_GPIO_LED_PIN 0 +#endif + +// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS. +// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered. +// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined. +#ifndef CYW43_WL_GPIO_VBUS_PIN +#define CYW43_WL_GPIO_VBUS_PIN 2 +#endif + +// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes. +// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it. +// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit. +#ifndef CYW43_USES_VSYS_PIN +#define CYW43_USES_VSYS_PIN 1 +#endif + +// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC. +// There is an example in adc/read_vsys in pico-examples. +#ifndef PICO_VSYS_PIN +#define PICO_VSYS_PIN 29 +#endif + +#ifndef PICO_RP2350_A2_SUPPORTED +#define PICO_RP2350_A2_SUPPORTED 1 +#endif + +#endif \ No newline at end of file From a6159c32ed13a7296e402aad9102abf5e8a5dcdb Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 27 Sep 2024 13:08:46 +0100 Subject: [PATCH 13/38] Plasma2350: Add WiFi + LTE variant. --- .github/workflows/micropython.yml | 3 + .../PIMORONI_PLASMA2350/manifest-wireless.py | 8 + .../board/PIMORONI_PLASMA2350/mpconfigboard.h | 62 +++++++- .../PIMORONI_PLASMA2350/mpconfigvariant.cmake | 0 .../mpconfigvariant_WIRELESS.cmake | 40 +++++ .../pimoroni_plasma2350w.h | 137 ++++++++++++++++++ 6 files changed, 248 insertions(+), 2 deletions(-) create mode 100644 micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py create mode 100644 micropython/board/PIMORONI_PLASMA2350/mpconfigvariant.cmake create mode 100644 micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake create mode 100644 micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 5308eb5..0991a2d 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -28,6 +28,9 @@ jobs: board: RPI_PICO2B - name: plasma2350 board: PIMORONI_PLASMA2350 + - name: plasma2350_wireless + board: PIMORONI_PLASMA2350 + variant: WIRELESS - name: tiny2350 board: PIMORONI_TINY2350 - name: pico_plus2_rp2350_psram diff --git a/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py b/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py new file mode 100644 index 0000000..b34f473 --- /dev/null +++ b/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py @@ -0,0 +1,8 @@ +require("bundle-networking") + +# Bluetooth +require("aioble") + +include("manifest.py") + +freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h index 9aed816..0ef5a1a 100644 --- a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h @@ -1,7 +1,65 @@ // Board and hardware specific configuration -#define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2350" #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) // I2C0 (non-default) #define MICROPY_HW_I2C0_SCL (PLASMA2350_SDA_PIN) -#define MICROPY_HW_I2C0_SDA (PLASMA2350_SCL_PIN) \ No newline at end of file +#define MICROPY_HW_I2C0_SDA (PLASMA2350_SCL_PIN) + +// Set up networking. +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PLASMA2350" + +#if defined(MICROPY_PY_NETWORK_CYW43) + +// CYW43 driver configuration. +#define CYW43_USE_SPI (1) +#define CYW43_LWIP (1) +#define CYW43_GPIO (1) +#define CYW43_SPI_PIO (1) + +#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT + +#if defined(CYW43_PIN_WL_DYNAMIC) + +#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1) + +// Defined by pimoroni_pico_plus2w_rp2350.h +//#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN +//#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN +#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_CLOCK 29u +#define CYW43_DEFAULT_PIN_WL_CS 25u + +/* SPICE alternative +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN +#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN +#define CYW43_DEFAULT_PIN_WL_DATA_OUT SPICE_RESET_MOSI_PIN +#define CYW43_DEFAULT_PIN_WL_DATA_IN SPICE_RESET_MOSI_PIN +#define CYW43_DEFAULT_PIN_WL_CLOCK SPICE_NETLIGHT_SCK_PIN +#define CYW43_DEFAULT_PIN_WL_CS SPICE_RX_CS_PIN +*/ + +// Slow down the wireless clock, since we'll be running +// comms through wiring spaghetti! +#define CYW43_PIO_CLOCK_DIV_INT 50 +#define CYW43_PIO_CLOCK_DIV_FRAC 0 +#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1 + +#endif + +#endif + +// Might be defined in mpconfigvariant_PPP.cmake +// This is not checked by mpconfigport.h so we must set up networking below +#if defined(MICROPY_PY_NETWORK_PPP_LWIP) + +// Nothing to do here? + +#endif + +// If a variant is not used, define a fallback board name +#ifndef MICROPY_HW_BOARD_NAME + +#define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2350" + +#endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant.cmake b/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant.cmake new file mode 100644 index 0000000..e69de29 diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake new file mode 100644 index 0000000..2aee992 --- /dev/null +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake @@ -0,0 +1,40 @@ +# Override the MicroPython board name +# And set basic options which are expanded upon in mpconfigboard.h +list(APPEND MICROPY_DEF_BOARD + "MICROPY_HW_BOARD_NAME=\"Pimoroni Plasma 2350 (LTE + WiFi)\"" + "MICROPY_PY_NETWORK=1" + "CYW43_PIN_WL_DYNAMIC=1" + "MICROPY_PY_NETWORK_PPP_LWIP=1" +) + +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + +# Links cyw43-driver and sets: +# MICROPY_PY_NETWORK_CYW43 = 1, +# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 +set(MICROPY_PY_NETWORK_CYW43 ON) + +# Adds mpbthciport.c +# And sets: +# MICROPY_PY_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, +# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 +set(MICROPY_PY_BLUETOOTH ON) + +# Links pico_btstack_hci_transport_cyw43 +# And sets: +# MICROPY_BLUETOOTH_BTSTACK = 1, +# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = +set(MICROPY_BLUETOOTH_BTSTACK ON) + +# Sets: +# CYW43_ENABLE_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_CYW43 = 1 +set(MICROPY_PY_BLUETOOTH_CYW43 ON) + +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) + +set(PICO_BOARD "pimoroni_plasma2350w") +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h new file mode 100644 index 0000000..f9c4177 --- /dev/null +++ b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// ----------------------------------------------------- +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES +// ----------------------------------------------------- + +// This header may be included by other board headers as "boards/pimoroni_plasma2350.h" + +// pico_cmake_set PICO_PLATFORM=rp2350 + +#ifndef _BOARDS_PIMORONI_PLASMA2350W_H +#define _BOARDS_PIMORONI_PLASMA2350W_H + +// For board detection +#define PIMORONI_PLASMA2350 +#define PIMORONI_PLASMA2350W + +// --- BOARD SPECIFIC --- +#define SPICE_SPI 0 +#define SPICE_TX_MISO_PIN 8 +#define SPICE_RX_CS_PIN 9 +#define SPICE_NETLIGHT_SCK_PIN 10 +#define SPICE_RESET_MOSI_PIN 11 +#define SPICE_PWRKEY_BL_PIN 7 + +#define PLASMA2350_SW_A_PIN 12 + +#define PLASMA2350_CLK_PIN 14 +#define PLASMA2350_DATA_PIN 15 + +#define PLASMA2350_LED_R_PIN 16 +#define PLASMA2350_LED_G_PIN 17 +#define PLASMA2350_LED_B_PIN 18 + +#define PLASMA2350_I2C 0 +#define PLASMA2350_INT_PIN 19 +#define PLASMA2350_SDA_PIN 20 +#define PLASMA2350_SCL_PIN 21 + +#define PLASMA2350_USER_SW_PIN 22 + +#define PLASMA2350_A0_PIN 26 +#define PLASMA2350_A1_PIN 27 +#define PLASMA2350_A2_PIN 28 +#define PLASMA2350_NUM_ADC_PINS 3 + +#define PLASMA2350_CURRENT_SENSE_PIN 29 + +// -- CYW43 Wireless -- +#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24 +#endif + +#ifndef CYW43_DEFAULT_PIN_WL_REG_ON +#define CYW43_DEFAULT_PIN_WL_REG_ON 23 +#endif + +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 +#endif + +#ifndef CYW43_WL_GPIO_LED_PIN +#define CYW43_WL_GPIO_LED_PIN 0 +#endif + +// --- RP2350 VARIANT --- +#define PICO_RP2350A 1 + +// --- UART --- +// no PICO_DEFAULT_UART +// no PICO_DEFAULT_UART_TX_PIN +// no PICO_DEFAULT_UART_RX_PIN + +// --- LED --- +#ifndef PICO_DEFAULT_LED_PIN +#define PICO_DEFAULT_LED_PIN TINY2350_LED_G_PIN +#endif +// no PICO_DEFAULT_WS2812_PIN + +#ifndef PICO_DEFAULT_LED_PIN_INVERTED +#define PICO_DEFAULT_LED_PIN_INVERTED 1 +#endif + +// --- I2C --- +// routed to Qw/St connector +#ifndef PICO_DEFAULT_I2C +#define PICO_DEFAULT_I2C PLASMA2350_I2C +#endif +#ifndef PICO_DEFAULT_I2C_SDA_PIN +#define PICO_DEFAULT_I2C_SDA_PIN PLASMA2350_SDA_PIN +#endif +#ifndef PICO_DEFAULT_I2C_SCL_PIN +#define PICO_DEFAULT_I2C_SCL_PIN PLASMA2350_SCL_PIN +#endif + +// --- SPI --- +#ifndef PICO_DEFAULT_SPI +#define PICO_DEFAULT_SPI 0 +#endif +#ifndef PICO_DEFAULT_SPI_SCK_PIN +#define PICO_DEFAULT_SPI_SCK_PIN SPICE_NETLIGHT_SCK_PIN +#endif +#ifndef PICO_DEFAULT_SPI_TX_PIN +#define PICO_DEFAULT_SPI_TX_PIN SPICE_RESET_MOSI_PIN +#endif +#ifndef PICO_DEFAULT_SPI_RX_PIN +#define PICO_DEFAULT_SPI_RX_PIN SPICE_TX_MISO_PIN +#endif +#ifndef PICO_DEFAULT_SPI_CSN_PIN +#define PICO_DEFAULT_SPI_CSN_PIN SPICE_RX_CS_PIN +#endif + +// --- FLASH --- +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 + +#ifndef PICO_FLASH_SPI_CLKDIV +#define PICO_FLASH_SPI_CLKDIV 2 +#endif + +// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024) +#ifndef PICO_FLASH_SIZE_BYTES +#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024) +#endif + +#ifndef PICO_RP2350_A2_SUPPORTED +#define PICO_RP2350_A2_SUPPORTED 1 +#endif + +// no PICO_VBUS_PIN +// no PICO_VSYS_PIN + +#endif \ No newline at end of file From 12620601b942b7c247c30d586b62b4c2e98788e8 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 30 Sep 2024 11:09:39 +0100 Subject: [PATCH 14/38] PPP2W: Add LEDW mapping and WL_GPIO pins. --- micropython/board/PIMORONI_PICO_PLUS2/pins.csv | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pins.csv b/micropython/board/PIMORONI_PICO_PLUS2/pins.csv index 2f11f26..792f5c4 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/pins.csv +++ b/micropython/board/PIMORONI_PICO_PLUS2/pins.csv @@ -45,6 +45,10 @@ GP45,GPIO45 GP46,GPIO46 GP47,GPIO47 LED,GPIO25 +LEDW,EXT_GPIO0 +WL_GPIO0,EXT_GPIO0 +WL_GPIO1,EXT_GPIO1 +WL_GPIO2,EXT_GPIO2 SPICE_TX,GPIO32 SPICE_RX,GPIO33 SPICE_NETLIGHT,GPIO34 From f9a22ce9946b43219bf4400619fc59fe54dfe795 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 30 Sep 2024 11:45:28 +0100 Subject: [PATCH 15/38] PPP: Shim EXT GPIO on non W builds. --- micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h index 7ee44ec..4fd3d44 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h @@ -3,6 +3,14 @@ #define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN +#ifndef CYW43_WL_GPIO_COUNT +// Effecively remaps LEDW,EXT_GPIO0 to GPIO25 on non-W builds +#define pin_EXT_GPIO0 pin_GPIO25 +// Shim the EXT GPIOs because we can't specify a variant pins.csv +#define pin_EXT_GPIO1 pin_GPIO1 +#define pin_EXT_GPIO2 pin_GPIO2 +#endif + // Might be defined in mpconfigvariant_PSRAM.cmake // or mpconfigvariant_WIRELESS.cmake #if defined(MICROPY_HW_ENABLE_PSRAM) From d099845fa63d54f5f1105ed5119887f68589a165 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 30 Sep 2024 14:08:14 +0100 Subject: [PATCH 16/38] Plasma3350: Add WL ext GPIOs and fallback. --- micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h | 8 ++++++++ micropython/board/PIMORONI_PLASMA2350/pins.csv | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h index 0ef5a1a..d99e39a 100644 --- a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h @@ -1,6 +1,14 @@ // Board and hardware specific configuration #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) +#ifndef CYW43_WL_GPIO_COUNT +// Shim the EXT GPIOs because we can't specify a variant pins.csv +// Remap them to LED R, G and B respectively on non-W builds +#define pin_EXT_GPIO0 pin_GPIO16 +#define pin_EXT_GPIO1 pin_GPIO17 +#define pin_EXT_GPIO2 pin_GPIO18 +#endif + // I2C0 (non-default) #define MICROPY_HW_I2C0_SCL (PLASMA2350_SDA_PIN) #define MICROPY_HW_I2C0_SDA (PLASMA2350_SCL_PIN) diff --git a/micropython/board/PIMORONI_PLASMA2350/pins.csv b/micropython/board/PIMORONI_PLASMA2350/pins.csv index ca53790..a300583 100644 --- a/micropython/board/PIMORONI_PLASMA2350/pins.csv +++ b/micropython/board/PIMORONI_PLASMA2350/pins.csv @@ -30,4 +30,7 @@ LED,GPIO17 LED_R,GPIO16 LED_G,GPIO17 LED_B,GPIO18 -USER_SW,GPIO22 \ No newline at end of file +USER_SW,GPIO22 +WL_GPIO0,EXT_GPIO0 +WL_GPIO1,EXT_GPIO1 +WL_GPIO2,EXT_GPIO2 \ No newline at end of file From 61b10ed10ad14c777b2beefb5441f4f660dcd99b Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 4 Oct 2024 15:41:00 +0100 Subject: [PATCH 17/38] PPP: Add send_text_message for #14. Also a quick cleanup of the lte module code. --- micropython/modules_py/lte.py | 61 +++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/micropython/modules_py/lte.py b/micropython/modules_py/lte.py index 5340650..435b2e2 100644 --- a/micropython/modules_py/lte.py +++ b/micropython/modules_py/lte.py @@ -18,8 +18,8 @@ DEFAULT_UART_BAUD = const(460800) class CellularError(Exception): - def __init__(self, message=None): - self.message = "CellularError: " + message + def __init__(self, message=None): + self.message = f"CellularError: {message}" class LTE(): @@ -30,13 +30,13 @@ class LTE(): DEFAULT_UART_ID, tx=Pin(DEFAULT_PIN_TX, Pin.OUT), rx=Pin(DEFAULT_PIN_RX, Pin.OUT)) - + # Set PPP timeouts and rxbuf self._uart.init( timeout=DEFAULT_UART_TIMEOUT, timeout_char=DEFAULT_UART_TIMEOUT_CHAR, rxbuf=DEFAULT_UART_RXBUF) - + if not skip_reset: self._reset.value(0) time.sleep(1.0) @@ -46,7 +46,7 @@ class LTE(): self._led = netlight_led self._netlight = netlight_pin or Pin(DEFAULT_PIN_NETLIGHT, Pin.IN) self._netlight.irq(self._netlight_irq) - + def _netlight_irq(self, pin): self._led.value(pin.value()) @@ -60,23 +60,23 @@ class LTE(): try: return self._send_at_command("AT+CICCID", 1) except CellularError: - return None + return None def status(self): lte_status = self._send_at_command("AT+CEREG?", 1) gsm_status = self._send_at_command("AT+CGREG?", 1) return lte_status, gsm_status - + def signal_quality(self): try: response = self._send_at_command("AT+CSQ", 1) quality = int(response.split(":")[1].split(",")[0]) - db = -113 + (2 * quality) # conversion as per AT command set datasheet + db = -113 + (2 * quality) # conversion as per AT command set datasheet return db except CellularError: pass return None - + def stop_ppp(self): self._ppp.disconnect() self._send_at_command(f"AT+IPR={DEFAULT_UART_STARTUP_BAUD}") @@ -106,11 +106,9 @@ class LTE(): # print(e) # Force PPP to use modem's default settings... - #time.sleep(2.0) self._flush_uart() self._uart.write("ATD*99#\r") self._uart.flush() - #time.sleep(2.0) self._ppp = PPP(self._uart) self._ppp.connect() @@ -122,16 +120,16 @@ class LTE(): def connect(self, timeout=60): print(" - setting up cellular uart") # connect to and flush the uart - # consume any unsolicited messages first, we don't need those + # consume any unsolicited messages first, we don't need those self._flush_uart() print(" - waiting for cellular module to be ready") # wait for the cellular module to respond to AT commands - self._wait_ready() + self._wait_ready() - self._send_at_command("ATE0") # disable local echo - self._send_at_command(f"AT+CGDCONT=1,\"IP\",\"{self._apn}\"") # set apn and activate pdp context + self._send_at_command("ATE0") # disable local echo + self._send_at_command(f"AT+CGDCONT=1,\"IP\",\"{self._apn}\"") # set apn and activate pdp context # wait for roaming lte connection to be established giveup = time.time() + timeout @@ -140,10 +138,10 @@ class LTE(): status = self._send_at_command("AT+CEREG?", 1) time.sleep(0.25) if time.time() > giveup: - raise CellularError("timed out getting network registration") + raise CellularError("timed out getting network registration") # disable server and client certification validation - self._send_at_command("AT+CSSLCFG=\"authmode\",0,0") + self._send_at_command("AT+CSSLCFG=\"authmode\",0,0") self._send_at_command("AT+CSSLCFG=\"enableSNI\",0,1") print(f" - SIM ICCID is {self.iccid()}") @@ -152,13 +150,14 @@ class LTE(): giveup = time.time() + timeout while time.time() <= giveup: try: + # if __send_at_command doesn't throw an exception then we're good! self._send_at_command("AT") - return # if __send_at_command doesn't throw an exception then we're good! + return except CellularError as e: print(e) time.sleep(poll_time) - raise CellularError("timed out waiting for AT response") + raise CellularError("timed out waiting for AT response") def _flush_uart(self): self._uart.flush() @@ -168,28 +167,22 @@ class LTE(): time.sleep(0.25) def _send_at_command(self, command, result_lines=0, timeout=5.0): - # consume any unsolicited messages first, we don't need those + # consume any unsolicited messages first, we don't need those self._flush_uart() self._uart.write(command + "\r") - #print(f" - tx: {command}") self._uart.flush() status, data = self._read_result(result_lines, timeout=timeout) print(" -", command, status, data) - if status == "TIMEOUT": - #print.error(" !", command, status, data) - raise CellularError(f"cellular module timed out for command {command}") - if status not in ["OK", "DOWNLOAD"]: - #print(" !", command, status, data) raise CellularError(f"non 'OK' or 'DOWNLOAD' result for command {command}") if result_lines == 1: return data[0] if result_lines > 1: - return data + return data return None def _read_result(self, result_lines, timeout=1.0): @@ -199,7 +192,7 @@ class LTE(): timeout *= 1000 while len(result) < result_lines or status is None: if (time.ticks_ms() - start) > timeout: - return "TIMEOUT", [] + raise CellularError("cellular module timed out") line = self._uart.readline() @@ -213,3 +206,15 @@ class LTE(): return status, result + def send_text_message(self, recipient, body, timeout=5.0): + self._uart.write("AT+CMGS=\"") + self._uart.write(recipient.encode("ascii")) + self._uart.write(b"\"\r") + time.sleep(0.5) + self._uart.write(body.encode("ascii")) + self._uart.write(b"\x1a\r") + self._uart.flush() + + status, _ = self._read_result(1, timeout=timeout) + + return status == "OK" From 40f33c8b8725e629cd30fa66bfa30c6744e48588 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 4 Nov 2024 16:29:11 +0000 Subject: [PATCH 18/38] CI: Retarget MicroPython to feature/psram-and-wifi. --- .github/workflows/micropython.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 0991a2d..1fe4b95 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -7,7 +7,7 @@ on: types: [created] env: - MICROPYTHON_VERSION: feature/spicy-wifi + MICROPYTHON_VERSION: feature/psram-and-wifi MICROPYTHON_FLAVOUR: pimoroni PIMORONI_PICO_VERSION: main From 436446c58adf4e99176de8aa24b9d703e18969ad Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 4 Nov 2024 17:16:53 +0000 Subject: [PATCH 19/38] plasma2350(w): Fix flash size to be 4MB instead of 8MB. Should prevent builds from self destructing when a user saves a file. --- .../PIMORONI_PLASMA2350/mpconfigboard.cmake | 3 + .../PIMORONI_PLASMA2350/pimoroni_plasma2350.h | 119 ++++++++++++++++++ .../pimoroni_plasma2350w.h | 4 +- 3 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake index 7ba0af6..d8fc435 100644 --- a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake @@ -6,3 +6,6 @@ set(PICO_PLATFORM "rp2350") set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) set(MICROPY_C_HEAP_SIZE 4096) + +set(PICO_BOARD "pimoroni_plasma2350") +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h new file mode 100644 index 0000000..9aeb28b --- /dev/null +++ b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +// ----------------------------------------------------- +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES +// ----------------------------------------------------- + +// This header may be included by other board headers as "boards/pimoroni_plasma2350.h" + +// pico_cmake_set PICO_PLATFORM=rp2350 + +#ifndef _BOARDS_PIMORONI_PLASMA2350_H +#define _BOARDS_PIMORONI_PLASMA2350_H + +// For board detection +#define PIMORONI_PLASMA2350 + +// --- BOARD SPECIFIC --- +#define SPICE_SPI 0 +#define SPICE_TX_MISO_PIN 8 +#define SPICE_RX_CS_PIN 9 +#define SPICE_NETLIGHT_SCK_PIN 10 +#define SPICE_RESET_MOSI_PIN 11 +#define SPICE_PWRKEY_BL_PIN 7 + +#define PLASMA2350_SW_A_PIN 12 + +#define PLASMA2350_CLK_PIN 14 +#define PLASMA2350_DATA_PIN 15 + +#define PLASMA2350_LED_R_PIN 16 +#define PLASMA2350_LED_G_PIN 17 +#define PLASMA2350_LED_B_PIN 18 + +#define PLASMA2350_I2C 0 +#define PLASMA2350_INT_PIN 19 +#define PLASMA2350_SDA_PIN 20 +#define PLASMA2350_SCL_PIN 21 + +#define PLASMA2350_USER_SW_PIN 22 + +#define PLASMA2350_A0_PIN 26 +#define PLASMA2350_A1_PIN 27 +#define PLASMA2350_A2_PIN 28 +#define PLASMA2350_NUM_ADC_PINS 3 + +#define PLASMA2350_CURRENT_SENSE_PIN 29 + +// --- RP2350 VARIANT --- +#define PICO_RP2350A 1 + +// --- UART --- +// no PICO_DEFAULT_UART +// no PICO_DEFAULT_UART_TX_PIN +// no PICO_DEFAULT_UART_RX_PIN + +// --- LED --- +#ifndef PICO_DEFAULT_LED_PIN +#define PICO_DEFAULT_LED_PIN TINY2350_LED_G_PIN +#endif +// no PICO_DEFAULT_WS2812_PIN + +#ifndef PICO_DEFAULT_LED_PIN_INVERTED +#define PICO_DEFAULT_LED_PIN_INVERTED 1 +#endif + +// --- I2C --- +// routed to Qw/St connector +#ifndef PICO_DEFAULT_I2C +#define PICO_DEFAULT_I2C PLASMA2350_I2C +#endif +#ifndef PICO_DEFAULT_I2C_SDA_PIN +#define PICO_DEFAULT_I2C_SDA_PIN PLASMA2350_SDA_PIN +#endif +#ifndef PICO_DEFAULT_I2C_SCL_PIN +#define PICO_DEFAULT_I2C_SCL_PIN PLASMA2350_SCL_PIN +#endif + +// --- SPI --- +#ifndef PICO_DEFAULT_SPI +#define PICO_DEFAULT_SPI 0 +#endif +#ifndef PICO_DEFAULT_SPI_SCK_PIN +#define PICO_DEFAULT_SPI_SCK_PIN SPICE_NETLIGHT_SCK_PIN +#endif +#ifndef PICO_DEFAULT_SPI_TX_PIN +#define PICO_DEFAULT_SPI_TX_PIN SPICE_RESET_MOSI_PIN +#endif +#ifndef PICO_DEFAULT_SPI_RX_PIN +#define PICO_DEFAULT_SPI_RX_PIN SPICE_TX_MISO_PIN +#endif +#ifndef PICO_DEFAULT_SPI_CSN_PIN +#define PICO_DEFAULT_SPI_CSN_PIN SPICE_RX_CS_PIN +#endif + +// --- FLASH --- +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 + +#ifndef PICO_FLASH_SPI_CLKDIV +#define PICO_FLASH_SPI_CLKDIV 2 +#endif + +// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024) +#ifndef PICO_FLASH_SIZE_BYTES +#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024) +#endif + +#ifndef PICO_RP2350_A2_SUPPORTED +#define PICO_RP2350_A2_SUPPORTED 1 +#endif + +// no PICO_VBUS_PIN +// no PICO_VSYS_PIN + +#endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h index f9c4177..4a721f9 100644 --- a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h +++ b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h @@ -122,9 +122,9 @@ #define PICO_FLASH_SPI_CLKDIV 2 #endif -// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (8 * 1024 * 1024) +// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024) #ifndef PICO_FLASH_SIZE_BYTES -#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024) +#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024) #endif #ifndef PICO_RP2350_A2_SUPPORTED From 98ff22ccfab9dbce123a8e0b2c196d73035ef1d6 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 6 Nov 2024 16:31:27 +0000 Subject: [PATCH 20/38] PPP/Plasma: Simplify config. Since both PPP2 or Plasma2350 have a SP/CE connector, enable WiFi in all cases. Additionally enable PPP in all cases. Finally, drop the non-PSRAM build. (TBC if it returns, since it's less RAM but faster.) --- .github/workflows/micropython.yml | 9 -- .../PIMORONI_PICO_PLUS2/manifest-wireless.py | 8 -- .../board/PIMORONI_PICO_PLUS2/manifest.py | 9 +- .../PIMORONI_PICO_PLUS2/mpconfigboard.cmake | 32 ++++- .../board/PIMORONI_PICO_PLUS2/mpconfigboard.h | 76 +++-------- .../PIMORONI_PICO_PLUS2/mpconfigvariant.cmake | 0 .../mpconfigvariant_PSRAM.cmake | 6 - .../mpconfigvariant_WIRELESS.cmake | 41 ------ .../pimoroni_pico_plus2w_rp2350.h | 84 ++++++++----- .../PIMORONI_PLASMA2350/manifest-wireless.py | 8 -- .../board/PIMORONI_PLASMA2350/manifest.py | 9 +- .../PIMORONI_PLASMA2350/mpconfigboard.cmake | 34 ++++- .../board/PIMORONI_PLASMA2350/mpconfigboard.h | 62 ++------- .../PIMORONI_PLASMA2350/mpconfigvariant.cmake | 0 .../mpconfigvariant_WIRELESS.cmake | 40 ------ .../PIMORONI_PLASMA2350/pimoroni_plasma2350.h | 119 ------------------ .../pimoroni_plasma2350w.h | 95 ++++++++++---- .../board/PIMORONI_PLASMA2350/pins.csv | 5 +- 18 files changed, 228 insertions(+), 409 deletions(-) delete mode 100644 micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py delete mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant.cmake delete mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake delete mode 100644 micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake delete mode 100644 micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py delete mode 100644 micropython/board/PIMORONI_PLASMA2350/mpconfigvariant.cmake delete mode 100644 micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake delete mode 100644 micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 1fe4b95..62b35f8 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -28,17 +28,8 @@ jobs: board: RPI_PICO2B - name: plasma2350 board: PIMORONI_PLASMA2350 - - name: plasma2350_wireless - board: PIMORONI_PLASMA2350 - variant: WIRELESS - name: tiny2350 board: PIMORONI_TINY2350 - - name: pico_plus2_rp2350_psram - board: PIMORONI_PICO_PLUS2 - variant: PSRAM - - name: pico_plus2_rp2350_wireless - board: PIMORONI_PICO_PLUS2 - variant: WIRELESS - name: pico_plus2_rp2350 board: PIMORONI_PICO_PLUS2 diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py b/micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py deleted file mode 100644 index b34f473..0000000 --- a/micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py +++ /dev/null @@ -1,8 +0,0 @@ -require("bundle-networking") - -# Bluetooth -require("aioble") - -include("manifest.py") - -freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest.py b/micropython/board/PIMORONI_PICO_PLUS2/manifest.py index fb2a59b..ab6e69e 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/manifest.py +++ b/micropython/board/PIMORONI_PICO_PLUS2/manifest.py @@ -1,3 +1,10 @@ +require("bundle-networking") + +# Bluetooth +require("aioble") + include("$(PORT_DIR)/boards/manifest.py") -include("../manifest_pico2.py") \ No newline at end of file +include("../manifest_pico2.py") + +freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.cmake index 9a18365..63092b6 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.cmake +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.cmake @@ -1,5 +1,6 @@ # cmake file for Raspberry Pi Pico -set(PICO_BOARD "pimoroni_pico_plus2_rp2350") +set(PICO_BOARD "pimoroni_pico_plus2w_rp2350") +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) set(PICO_PLATFORM "rp2350") set(PICO_NUM_GPIOS 48) @@ -7,3 +8,32 @@ set(PICO_NUM_GPIOS 48) set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) set(MICROPY_C_HEAP_SIZE 4096) + +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + +# Links cyw43-driver and sets: +# MICROPY_PY_NETWORK_CYW43 = 1, +# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 +set(MICROPY_PY_NETWORK_CYW43 ON) + +# Adds mpbthciport.c +# And sets: +# MICROPY_PY_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, +# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 +set(MICROPY_PY_BLUETOOTH ON) + +# Links pico_btstack_hci_transport_cyw43 +# And sets: +# MICROPY_BLUETOOTH_BTSTACK = 1, +# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = +set(MICROPY_BLUETOOTH_BTSTACK ON) + +# Sets: +# CYW43_ENABLE_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_CYW43 = 1 +set(MICROPY_PY_BLUETOOTH_CYW43 ON) + + diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h index 4fd3d44..4d3e7bf 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h @@ -1,28 +1,14 @@ // Board and hardware specific configuration #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) -#define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN - -#ifndef CYW43_WL_GPIO_COUNT -// Effecively remaps LEDW,EXT_GPIO0 to GPIO25 on non-W builds -#define pin_EXT_GPIO0 pin_GPIO25 -// Shim the EXT GPIOs because we can't specify a variant pins.csv -#define pin_EXT_GPIO1 pin_GPIO1 -#define pin_EXT_GPIO2 pin_GPIO2 -#endif - -// Might be defined in mpconfigvariant_PSRAM.cmake -// or mpconfigvariant_WIRELESS.cmake -#if defined(MICROPY_HW_ENABLE_PSRAM) - -#define MICROPY_GC_SPLIT_HEAP (1) - -#endif - // Set up networking. #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PPP2" -#if defined(MICROPY_PY_NETWORK_CYW43) +#define MICROPY_HW_BOARD_NAME "Pimoroni Pico Plus 2 (PSRAM + LTE + WiFi)" + +// Enable WiFi & PPP +#define MICROPY_PY_NETWORK (1) +#define MICROPY_PY_NETWORK_PPP_LWIP (1) // CYW43 driver configuration. #define CYW43_USE_SPI (1) @@ -30,50 +16,16 @@ #define CYW43_GPIO (1) #define CYW43_SPI_PIO (1) -#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT - -#if defined(CYW43_PIN_WL_DYNAMIC) - -#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1) - -// Defined by pimoroni_pico_plus2w_rp2350.h -//#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN -//#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN -#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_CLOCK 29u -#define CYW43_DEFAULT_PIN_WL_CS 25u - -/* SPICE alternative -#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN -#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN -#define CYW43_DEFAULT_PIN_WL_DATA_OUT SPICE_RESET_MOSI_PIN -#define CYW43_DEFAULT_PIN_WL_DATA_IN SPICE_RESET_MOSI_PIN -#define CYW43_DEFAULT_PIN_WL_CLOCK SPICE_NETLIGHT_SCK_PIN -#define CYW43_DEFAULT_PIN_WL_CS SPICE_RX_CS_PIN -*/ - -// Slow down the wireless clock, since we'll be running -// comms through wiring spaghetti! -#define CYW43_PIO_CLOCK_DIV_INT 50 -#define CYW43_PIO_CLOCK_DIV_FRAC 0 -#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1 - +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 #endif -#endif +#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT -// Might be defined in mpconfigvariant_PPP.cmake -// This is not checked by mpconfigport.h so we must set up networking below -#if defined(MICROPY_PY_NETWORK_PPP_LWIP) +int mp_hal_is_pin_reserved(int n); +#define MICROPY_HW_PIN_RESERVED(i) mp_hal_is_pin_reserved(i) -// Nothing to do here? - -#endif - -// If a variant is not used, define a fallback board name -#ifndef MICROPY_HW_BOARD_NAME - -#define MICROPY_HW_BOARD_NAME "Pimoroni Pico Plus 2" - -#endif \ No newline at end of file +// PSRAM Settings +#define MICROPY_HW_ENABLE_PSRAM (1) +#define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PICO_PLUS2_PSRAM_CS_PIN +#define MICROPY_GC_SPLIT_HEAP (1) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant.cmake deleted file mode 100644 index e69de29..0000000 diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake deleted file mode 100644 index eedd565..0000000 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_PSRAM.cmake +++ /dev/null @@ -1,6 +0,0 @@ -# Override the MicroPython board name -# And set basic options which are expanded upon in mpconfigboard.h -list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (PSRAM)\"" - "MICROPY_HW_ENABLE_PSRAM=1" -) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake deleted file mode 100644 index 6de4e4f..0000000 --- a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigvariant_WIRELESS.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# Override the MicroPython board name -# And set basic options which are expanded upon in mpconfigboard.h -list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_BOARD_NAME=\"Pimoroni Pico Plus 2 (Wireless + PSRAM)\"" - "MICROPY_HW_ENABLE_PSRAM=1" - "MICROPY_PY_NETWORK=1" - "CYW43_PIN_WL_DYNAMIC=1" - "MICROPY_PY_NETWORK_PPP_LWIP=1" -) - -# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 -# Picked up and expanded upon in mpconfigboard.h -set(MICROPY_PY_LWIP ON) - -# Links cyw43-driver and sets: -# MICROPY_PY_NETWORK_CYW43 = 1, -# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 -set(MICROPY_PY_NETWORK_CYW43 ON) - -# Adds mpbthciport.c -# And sets: -# MICROPY_PY_BLUETOOTH = 1, -# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, -# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 -set(MICROPY_PY_BLUETOOTH ON) - -# Links pico_btstack_hci_transport_cyw43 -# And sets: -# MICROPY_BLUETOOTH_BTSTACK = 1, -# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = -set(MICROPY_BLUETOOTH_BTSTACK ON) - -# Sets: -# CYW43_ENABLE_BLUETOOTH = 1, -# MICROPY_PY_BLUETOOTH_CYW43 = 1 -set(MICROPY_PY_BLUETOOTH_CYW43 ON) - -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) - -set(PICO_BOARD "pimoroni_pico_plus2w_rp2350") -set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h b/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h index f7a716f..aa2c987 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h +++ b/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h @@ -31,35 +31,6 @@ #define PIMORONI_PICO_PLUS2_USER_SW_PIN 45 #define PIMORONI_PICO_PLUS2_PSRAM_CS_PIN 47 -// -- CYW43 Wireless -- -#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24 -#endif - -#ifndef CYW43_DEFAULT_PIN_WL_REG_ON -#define CYW43_DEFAULT_PIN_WL_REG_ON 23 -#endif - -#ifndef CYW43_WL_GPIO_COUNT -#define CYW43_WL_GPIO_COUNT 3 -#endif - -#ifndef CYW43_WL_GPIO_LED_PIN -#define CYW43_WL_GPIO_LED_PIN 0 -#endif - -// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS. -// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered. -// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined. - -// no CYW43_WL_GPIO_VBUS_PIN - -// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes. -// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it. -// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit. - -// no CYW43_USES_VSYS_PIN - // --- UART --- #ifndef PICO_DEFAULT_UART #define PICO_DEFAULT_UART 0 @@ -118,6 +89,26 @@ #define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024) #endif +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 +#endif + +#ifndef CYW43_WL_GPIO_LED_PIN +#define CYW43_WL_GPIO_LED_PIN 0 +#endif + +// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS. +// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered. +// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined. + +// no CYW43_WL_GPIO_VBUS_PIN + +// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes. +// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it. +// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit. + +// no CYW43_USES_VSYS_PIN + // The GPIO Pin used to read VBUS to determine if the device is battery powered. #ifndef PICO_VBUS_PIN #define PICO_VBUS_PIN 24 @@ -133,4 +124,39 @@ #define PICO_RP2350_A2_SUPPORTED 1 #endif +// 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 +#ifndef CYW43_PIN_WL_DYNAMIC +#define CYW43_PIN_WL_DYNAMIC 1 +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_REG_ON +#define CYW43_DEFAULT_PIN_WL_REG_ON 23u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_DATA_OUT +#define CYW43_DEFAULT_PIN_WL_DATA_OUT 24u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_DATA_IN +#define CYW43_DEFAULT_PIN_WL_DATA_IN 24u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_CLOCK +#define CYW43_DEFAULT_PIN_WL_CLOCK 29u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_CS +#define CYW43_DEFAULT_PIN_WL_CS 25u +#endif + #endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py b/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py deleted file mode 100644 index b34f473..0000000 --- a/micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py +++ /dev/null @@ -1,8 +0,0 @@ -require("bundle-networking") - -# Bluetooth -require("aioble") - -include("manifest.py") - -freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/manifest.py b/micropython/board/PIMORONI_PLASMA2350/manifest.py index fb2a59b..ab6e69e 100644 --- a/micropython/board/PIMORONI_PLASMA2350/manifest.py +++ b/micropython/board/PIMORONI_PLASMA2350/manifest.py @@ -1,3 +1,10 @@ +require("bundle-networking") + +# Bluetooth +require("aioble") + include("$(PORT_DIR)/boards/manifest.py") -include("../manifest_pico2.py") \ No newline at end of file +include("../manifest_pico2.py") + +freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake index d8fc435..1516676 100644 --- a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake @@ -1,5 +1,6 @@ -# cmake file for Raspberry Pi Pico -set(PICO_BOARD "pimoroni_plasma2350") +# cmake file for Pimoroni Plasma 2350 +set(PICO_BOARD "pimoroni_plasma2350w") +set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) set(PICO_PLATFORM "rp2350") # Board specific version of the frozen manifest @@ -7,5 +8,30 @@ set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) set(MICROPY_C_HEAP_SIZE 4096) -set(PICO_BOARD "pimoroni_plasma2350") -set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + +# Links cyw43-driver and sets: +# MICROPY_PY_NETWORK_CYW43 = 1, +# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 +set(MICROPY_PY_NETWORK_CYW43 ON) + +# Adds mpbthciport.c +# And sets: +# MICROPY_PY_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, +# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 +set(MICROPY_PY_BLUETOOTH ON) + +# Links pico_btstack_hci_transport_cyw43 +# And sets: +# MICROPY_BLUETOOTH_BTSTACK = 1, +# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = +set(MICROPY_BLUETOOTH_BTSTACK ON) + +# Sets: +# CYW43_ENABLE_BLUETOOTH = 1, +# MICROPY_PY_BLUETOOTH_CYW43 = 1 +set(MICROPY_PY_BLUETOOTH_CYW43 ON) + diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h index d99e39a..08b6314 100644 --- a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h +++ b/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h @@ -1,14 +1,6 @@ // Board and hardware specific configuration #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) -#ifndef CYW43_WL_GPIO_COUNT -// Shim the EXT GPIOs because we can't specify a variant pins.csv -// Remap them to LED R, G and B respectively on non-W builds -#define pin_EXT_GPIO0 pin_GPIO16 -#define pin_EXT_GPIO1 pin_GPIO17 -#define pin_EXT_GPIO2 pin_GPIO18 -#endif - // I2C0 (non-default) #define MICROPY_HW_I2C0_SCL (PLASMA2350_SDA_PIN) #define MICROPY_HW_I2C0_SDA (PLASMA2350_SCL_PIN) @@ -16,7 +8,11 @@ // Set up networking. #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PLASMA2350" -#if defined(MICROPY_PY_NETWORK_CYW43) +#define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2350 (LTE + WiFi)" + +// Enable WiFi & PPP +#define MICROPY_PY_NETWORK (1) +#define MICROPY_PY_NETWORK_PPP_LWIP (1) // CYW43 driver configuration. #define CYW43_USE_SPI (1) @@ -24,50 +20,12 @@ #define CYW43_GPIO (1) #define CYW43_SPI_PIO (1) -#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT - -#if defined(CYW43_PIN_WL_DYNAMIC) - -#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1) - -// Defined by pimoroni_pico_plus2w_rp2350.h -//#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN -//#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN -#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_CLOCK 29u -#define CYW43_DEFAULT_PIN_WL_CS 25u - -/* SPICE alternative -#define CYW43_DEFAULT_PIN_WL_HOST_WAKE SPICE_RESET_MOSI_PIN -#define CYW43_DEFAULT_PIN_WL_REG_ON SPICE_TX_MISO_PIN -#define CYW43_DEFAULT_PIN_WL_DATA_OUT SPICE_RESET_MOSI_PIN -#define CYW43_DEFAULT_PIN_WL_DATA_IN SPICE_RESET_MOSI_PIN -#define CYW43_DEFAULT_PIN_WL_CLOCK SPICE_NETLIGHT_SCK_PIN -#define CYW43_DEFAULT_PIN_WL_CS SPICE_RX_CS_PIN -*/ - -// Slow down the wireless clock, since we'll be running -// comms through wiring spaghetti! -#define CYW43_PIO_CLOCK_DIV_INT 50 -#define CYW43_PIO_CLOCK_DIV_FRAC 0 -#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1 - +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 #endif -#endif +#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT -// Might be defined in mpconfigvariant_PPP.cmake -// This is not checked by mpconfigport.h so we must set up networking below -#if defined(MICROPY_PY_NETWORK_PPP_LWIP) +int mp_hal_is_pin_reserved(int n); +#define MICROPY_HW_PIN_RESERVED(i) mp_hal_is_pin_reserved(i) -// Nothing to do here? - -#endif - -// If a variant is not used, define a fallback board name -#ifndef MICROPY_HW_BOARD_NAME - -#define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2350" - -#endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant.cmake b/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant.cmake deleted file mode 100644 index e69de29..0000000 diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake b/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake deleted file mode 100644 index 2aee992..0000000 --- a/micropython/board/PIMORONI_PLASMA2350/mpconfigvariant_WIRELESS.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# Override the MicroPython board name -# And set basic options which are expanded upon in mpconfigboard.h -list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_BOARD_NAME=\"Pimoroni Plasma 2350 (LTE + WiFi)\"" - "MICROPY_PY_NETWORK=1" - "CYW43_PIN_WL_DYNAMIC=1" - "MICROPY_PY_NETWORK_PPP_LWIP=1" -) - -# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 -# Picked up and expanded upon in mpconfigboard.h -set(MICROPY_PY_LWIP ON) - -# Links cyw43-driver and sets: -# MICROPY_PY_NETWORK_CYW43 = 1, -# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 -set(MICROPY_PY_NETWORK_CYW43 ON) - -# Adds mpbthciport.c -# And sets: -# MICROPY_PY_BLUETOOTH = 1, -# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, -# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 -set(MICROPY_PY_BLUETOOTH ON) - -# Links pico_btstack_hci_transport_cyw43 -# And sets: -# MICROPY_BLUETOOTH_BTSTACK = 1, -# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = -set(MICROPY_BLUETOOTH_BTSTACK ON) - -# Sets: -# CYW43_ENABLE_BLUETOOTH = 1, -# MICROPY_PY_BLUETOOTH_CYW43 = 1 -set(MICROPY_PY_BLUETOOTH_CYW43 ON) - -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) - -set(PICO_BOARD "pimoroni_plasma2350w") -set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h deleted file mode 100644 index 9aeb28b..0000000 --- a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -// ----------------------------------------------------- -// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO -// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES -// ----------------------------------------------------- - -// This header may be included by other board headers as "boards/pimoroni_plasma2350.h" - -// pico_cmake_set PICO_PLATFORM=rp2350 - -#ifndef _BOARDS_PIMORONI_PLASMA2350_H -#define _BOARDS_PIMORONI_PLASMA2350_H - -// For board detection -#define PIMORONI_PLASMA2350 - -// --- BOARD SPECIFIC --- -#define SPICE_SPI 0 -#define SPICE_TX_MISO_PIN 8 -#define SPICE_RX_CS_PIN 9 -#define SPICE_NETLIGHT_SCK_PIN 10 -#define SPICE_RESET_MOSI_PIN 11 -#define SPICE_PWRKEY_BL_PIN 7 - -#define PLASMA2350_SW_A_PIN 12 - -#define PLASMA2350_CLK_PIN 14 -#define PLASMA2350_DATA_PIN 15 - -#define PLASMA2350_LED_R_PIN 16 -#define PLASMA2350_LED_G_PIN 17 -#define PLASMA2350_LED_B_PIN 18 - -#define PLASMA2350_I2C 0 -#define PLASMA2350_INT_PIN 19 -#define PLASMA2350_SDA_PIN 20 -#define PLASMA2350_SCL_PIN 21 - -#define PLASMA2350_USER_SW_PIN 22 - -#define PLASMA2350_A0_PIN 26 -#define PLASMA2350_A1_PIN 27 -#define PLASMA2350_A2_PIN 28 -#define PLASMA2350_NUM_ADC_PINS 3 - -#define PLASMA2350_CURRENT_SENSE_PIN 29 - -// --- RP2350 VARIANT --- -#define PICO_RP2350A 1 - -// --- UART --- -// no PICO_DEFAULT_UART -// no PICO_DEFAULT_UART_TX_PIN -// no PICO_DEFAULT_UART_RX_PIN - -// --- LED --- -#ifndef PICO_DEFAULT_LED_PIN -#define PICO_DEFAULT_LED_PIN TINY2350_LED_G_PIN -#endif -// no PICO_DEFAULT_WS2812_PIN - -#ifndef PICO_DEFAULT_LED_PIN_INVERTED -#define PICO_DEFAULT_LED_PIN_INVERTED 1 -#endif - -// --- I2C --- -// routed to Qw/St connector -#ifndef PICO_DEFAULT_I2C -#define PICO_DEFAULT_I2C PLASMA2350_I2C -#endif -#ifndef PICO_DEFAULT_I2C_SDA_PIN -#define PICO_DEFAULT_I2C_SDA_PIN PLASMA2350_SDA_PIN -#endif -#ifndef PICO_DEFAULT_I2C_SCL_PIN -#define PICO_DEFAULT_I2C_SCL_PIN PLASMA2350_SCL_PIN -#endif - -// --- SPI --- -#ifndef PICO_DEFAULT_SPI -#define PICO_DEFAULT_SPI 0 -#endif -#ifndef PICO_DEFAULT_SPI_SCK_PIN -#define PICO_DEFAULT_SPI_SCK_PIN SPICE_NETLIGHT_SCK_PIN -#endif -#ifndef PICO_DEFAULT_SPI_TX_PIN -#define PICO_DEFAULT_SPI_TX_PIN SPICE_RESET_MOSI_PIN -#endif -#ifndef PICO_DEFAULT_SPI_RX_PIN -#define PICO_DEFAULT_SPI_RX_PIN SPICE_TX_MISO_PIN -#endif -#ifndef PICO_DEFAULT_SPI_CSN_PIN -#define PICO_DEFAULT_SPI_CSN_PIN SPICE_RX_CS_PIN -#endif - -// --- FLASH --- -#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 - -#ifndef PICO_FLASH_SPI_CLKDIV -#define PICO_FLASH_SPI_CLKDIV 2 -#endif - -// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024) -#ifndef PICO_FLASH_SIZE_BYTES -#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024) -#endif - -#ifndef PICO_RP2350_A2_SUPPORTED -#define PICO_RP2350_A2_SUPPORTED 1 -#endif - -// no PICO_VBUS_PIN -// no PICO_VSYS_PIN - -#endif \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h index 4a721f9..499d630 100644 --- a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h +++ b/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. + * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -9,12 +9,13 @@ // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES // ----------------------------------------------------- -// This header may be included by other board headers as "boards/pimoroni_plasma2350.h" +// This header may be included by other board headers as "boards/pico2_w.h" // pico_cmake_set PICO_PLATFORM=rp2350 +// pico_cmake_set PICO_CYW43_SUPPORTED = 1 -#ifndef _BOARDS_PIMORONI_PLASMA2350W_H -#define _BOARDS_PIMORONI_PLASMA2350W_H +#ifndef _BOARDS_PICO2_W_H +#define _BOARDS_PICO2_W_H // For board detection #define PIMORONI_PLASMA2350 @@ -51,23 +52,6 @@ #define PLASMA2350_CURRENT_SENSE_PIN 29 -// -- CYW43 Wireless -- -#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24 -#endif - -#ifndef CYW43_DEFAULT_PIN_WL_REG_ON -#define CYW43_DEFAULT_PIN_WL_REG_ON 23 -#endif - -#ifndef CYW43_WL_GPIO_COUNT -#define CYW43_WL_GPIO_COUNT 3 -#endif - -#ifndef CYW43_WL_GPIO_LED_PIN -#define CYW43_WL_GPIO_LED_PIN 0 -#endif - // --- RP2350 VARIANT --- #define PICO_RP2350A 1 @@ -116,6 +100,7 @@ #endif // --- FLASH --- + #define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 #ifndef PICO_FLASH_SPI_CLKDIV @@ -126,12 +111,74 @@ #ifndef PICO_FLASH_SIZE_BYTES #define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024) #endif +// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads) +// note the SMSP mode pin is on WL_GPIO1 + +#ifndef CYW43_WL_GPIO_COUNT +#define CYW43_WL_GPIO_COUNT 3 +#endif + +#ifndef CYW43_WL_GPIO_LED_PIN +#define CYW43_WL_GPIO_LED_PIN 0 +#endif + +// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS. +// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered. +// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined. +#ifndef CYW43_WL_GPIO_VBUS_PIN +#define CYW43_WL_GPIO_VBUS_PIN 2 +#endif + +// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes. +// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it. +// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit. +#ifndef CYW43_USES_VSYS_PIN +#define CYW43_USES_VSYS_PIN 1 +#endif + +// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC. +// There is an example in adc/read_vsys in pico-examples. +#ifndef PICO_VSYS_PIN +#define PICO_VSYS_PIN 29 +#endif #ifndef PICO_RP2350_A2_SUPPORTED #define PICO_RP2350_A2_SUPPORTED 1 #endif -// no PICO_VBUS_PIN -// no PICO_VSYS_PIN +// 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 +#ifndef CYW43_PIN_WL_DYNAMIC +#define CYW43_PIN_WL_DYNAMIC 1 +#endif -#endif \ No newline at end of file +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_REG_ON +#define CYW43_DEFAULT_PIN_WL_REG_ON 23u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_DATA_OUT +#define CYW43_DEFAULT_PIN_WL_DATA_OUT 24u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_DATA_IN +#define CYW43_DEFAULT_PIN_WL_DATA_IN 24u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_CLOCK +#define CYW43_DEFAULT_PIN_WL_CLOCK 29u +#endif + +// 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 +#ifndef CYW43_DEFAULT_PIN_WL_CS +#define CYW43_DEFAULT_PIN_WL_CS 25u +#endif + +#endif diff --git a/micropython/board/PIMORONI_PLASMA2350/pins.csv b/micropython/board/PIMORONI_PLASMA2350/pins.csv index a300583..ca53790 100644 --- a/micropython/board/PIMORONI_PLASMA2350/pins.csv +++ b/micropython/board/PIMORONI_PLASMA2350/pins.csv @@ -30,7 +30,4 @@ LED,GPIO17 LED_R,GPIO16 LED_G,GPIO17 LED_B,GPIO18 -USER_SW,GPIO22 -WL_GPIO0,EXT_GPIO0 -WL_GPIO1,EXT_GPIO1 -WL_GPIO2,EXT_GPIO2 \ No newline at end of file +USER_SW,GPIO22 \ No newline at end of file From 81c3422e7950b924c17cda2919f636c9592a3e8a Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 26 Nov 2024 22:25:59 +0000 Subject: [PATCH 21/38] CI: Sync RPi stock boards with upstream. Replace our experimental configs with the board config(s) from the (as yet unmerged) Pico 2 W changes branch. --- .github/workflows/micropython.yml | 7 +-- micropython/board/RPI_PICO2/board.json | 19 ------ .../board/RPI_PICO2/manifest-wireless.py | 8 --- .../board/RPI_PICO2/mpconfigboard.cmake | 13 ++-- micropython/board/RPI_PICO2/mpconfigboard.h | 62 +++++-------------- .../RPI_PICO2/mpconfigvariant_WIRELESS.cmake | 40 ------------ micropython/board/RPI_PICO2_W/manifest.py | 8 +++ .../board/RPI_PICO2_W/mpconfigboard.cmake | 11 ++++ micropython/board/RPI_PICO2_W/mpconfigboard.h | 7 +++ micropython/board/RPI_PICO2_W/pins.csv | 30 +++++++++ 10 files changed, 83 insertions(+), 122 deletions(-) delete mode 100644 micropython/board/RPI_PICO2/board.json delete mode 100644 micropython/board/RPI_PICO2/manifest-wireless.py delete mode 100644 micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake create mode 100644 micropython/board/RPI_PICO2_W/manifest.py create mode 100644 micropython/board/RPI_PICO2_W/mpconfigboard.cmake create mode 100644 micropython/board/RPI_PICO2_W/mpconfigboard.h create mode 100644 micropython/board/RPI_PICO2_W/pins.csv diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 62b35f8..8a95ee0 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -19,11 +19,10 @@ jobs: strategy: matrix: include: - - name: pico2_rp2350 + - name: pico2 board: RPI_PICO2 - - name: pico2_rp2350_wireless - board: RPI_PICO2 - variant: WIRELESS + - name: pico2_w + board: RPI_PICO2_W - name: pico2b_rp2350 board: RPI_PICO2B - name: plasma2350 diff --git a/micropython/board/RPI_PICO2/board.json b/micropython/board/RPI_PICO2/board.json deleted file mode 100644 index d27a82f..0000000 --- a/micropython/board/RPI_PICO2/board.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "deploy": [ - "../deploy.md" - ], - "docs": "", - "features": [ - "Dual-core", - "External Flash", - "USB" - ], - "images": [ - "rp2-picos.jpg" - ], - "mcu": "rp2350", - "product": "Pico2", - "thumbnail": "", - "url": "https://www.raspberrypi.com/products/raspberry-pi-pico2/", - "vendor": "Raspberry Pi" -} diff --git a/micropython/board/RPI_PICO2/manifest-wireless.py b/micropython/board/RPI_PICO2/manifest-wireless.py deleted file mode 100644 index b34f473..0000000 --- a/micropython/board/RPI_PICO2/manifest-wireless.py +++ /dev/null @@ -1,8 +0,0 @@ -require("bundle-networking") - -# Bluetooth -require("aioble") - -include("manifest.py") - -freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file diff --git a/micropython/board/RPI_PICO2/mpconfigboard.cmake b/micropython/board/RPI_PICO2/mpconfigboard.cmake index 6b4a7cc..a869fd0 100644 --- a/micropython/board/RPI_PICO2/mpconfigboard.cmake +++ b/micropython/board/RPI_PICO2/mpconfigboard.cmake @@ -1,8 +1,11 @@ -# cmake file for Raspberry Pi Pico +# cmake file for Raspberry Pi Pico2 set(PICO_BOARD "pico2") -set(PICO_PLATFORM "rp2350") -# Board specific version of the frozen manifest -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) +# To change the gpio count for QFN-80 +# set(PICO_NUM_GPIOS 48) -set(MICROPY_C_HEAP_SIZE 4096) +if (PICO_CYW43_SUPPORTED) + include(enable_cyw43.cmake) + set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) + set(PICO_PINS_CSV_NAME pins_cyw43.csv) +endif() \ No newline at end of file diff --git a/micropython/board/RPI_PICO2/mpconfigboard.h b/micropython/board/RPI_PICO2/mpconfigboard.h index 95385ba..15b6dd3 100644 --- a/micropython/board/RPI_PICO2/mpconfigboard.h +++ b/micropython/board/RPI_PICO2/mpconfigboard.h @@ -1,52 +1,22 @@ // Board and hardware specific configuration -#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - (2 * 1024 * 1024)) +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico2" +#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024) -// Set up networking. -#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2" +#if MICROPY_PY_NETWORK_CYW43 +#include "enable_cyw43.h" -#if defined(MICROPY_PY_NETWORK_CYW43) +// Enable the ability to pass cyw43 pins into WiFi, Bluetooth and Pin constructors +#define CYW43_PIN_WL_DYNAMIC 1 +#define CYW43_PIO_CLOCK_DIV_DYNAMIC 1 -// CYW43 driver configuration. -#define CYW43_USE_SPI (1) -#define CYW43_LWIP (1) -#define CYW43_GPIO (1) -#define CYW43_SPI_PIO (1) - -#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT - -#if defined(CYW43_PIN_WL_DYNAMIC) - -#define CYW43_PIO_CLOCK_DIV_DYNAMIC (1) - -// CYW43 default pin configuration -#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24u -#define CYW43_DEFAULT_PIN_WL_REG_ON 23u -#define CYW43_DEFAULT_PIN_WL_DATA_OUT CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_DATA_IN CYW43_DEFAULT_PIN_WL_HOST_WAKE -#define CYW43_DEFAULT_PIN_WL_CLOCK 29u -#define CYW43_DEFAULT_PIN_WL_CS 25u - -// Slow down the wireless clock, since we'll be running -// comms through wiring spaghetti! -#define CYW43_PIO_CLOCK_DIV_INT 50 -#define CYW43_PIO_CLOCK_DIV_FRAC 0 -#define CYW43_SPI_PROGRAM_NAME spi_gap0_sample1 - -#endif - -#endif - -// Might be defined in mpconfigvariant_PPP.cmake -// This is not checked by mpconfigport.h so we must set up networking below -#if defined(MICROPY_PY_NETWORK_PPP_LWIP) - -// Nothing to do here? - -#endif - -// If a variant is not used, define a fallback board name -#ifndef MICROPY_HW_BOARD_NAME - -#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico 2" +// Set the default pins to gpios 2-5 +#define CYW43_DEFAULT_PIN_WL_REG_ON 2 +#define CYW43_DEFAULT_PIN_WL_CS 3 +#define CYW43_DEFAULT_PIN_WL_DATA_OUT 4 +#define CYW43_DEFAULT_PIN_WL_DATA_IN 4 +#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 4 +#define CYW43_DEFAULT_PIN_WL_CLOCK 5 +// Default pio clock +#define CYW43_PIO_CLOCK_DIV_INT 3 #endif \ No newline at end of file diff --git a/micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake b/micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake deleted file mode 100644 index 8493a5c..0000000 --- a/micropython/board/RPI_PICO2/mpconfigvariant_WIRELESS.cmake +++ /dev/null @@ -1,40 +0,0 @@ -# Override the MicroPython board name -# And set basic options which are expanded upon in mpconfigboard.h -list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_BOARD_NAME=\"Raspberry Pi Pico 2 (LTE + WiFi)\"" - "MICROPY_PY_NETWORK=1" - "CYW43_PIN_WL_DYNAMIC=1" - "MICROPY_PY_NETWORK_PPP_LWIP=1" -) - -# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 -# Picked up and expanded upon in mpconfigboard.h -set(MICROPY_PY_LWIP ON) - -# Links cyw43-driver and sets: -# MICROPY_PY_NETWORK_CYW43 = 1, -# MICROPY_PY_SOCKET_DEFAULT_TIMEOUT_MS = 30000 -set(MICROPY_PY_NETWORK_CYW43 ON) - -# Adds mpbthciport.c -# And sets: -# MICROPY_PY_BLUETOOTH = 1, -# MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS = 1, -# MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE = 1 -set(MICROPY_PY_BLUETOOTH ON) - -# Links pico_btstack_hci_transport_cyw43 -# And sets: -# MICROPY_BLUETOOTH_BTSTACK = 1, -# MICROPY_BLUETOOTH_BTSTACK_CONFIG_FILE = -set(MICROPY_BLUETOOTH_BTSTACK ON) - -# Sets: -# CYW43_ENABLE_BLUETOOTH = 1, -# MICROPY_PY_BLUETOOTH_CYW43 = 1 -set(MICROPY_PY_BLUETOOTH_CYW43 ON) - -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest-wireless.py) - -set(PICO_BOARD "pico2_w") -set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/micropython/board/RPI_PICO2_W/manifest.py b/micropython/board/RPI_PICO2_W/manifest.py new file mode 100644 index 0000000..77dc9fd --- /dev/null +++ b/micropython/board/RPI_PICO2_W/manifest.py @@ -0,0 +1,8 @@ +include("$(PORT_DIR)/boards/manifest.py") + +require("bundle-networking") + +# Bluetooth +require("aioble") + +include("../manifest_pico2.py") \ No newline at end of file diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.cmake b/micropython/board/RPI_PICO2_W/mpconfigboard.cmake new file mode 100644 index 0000000..49d92f5 --- /dev/null +++ b/micropython/board/RPI_PICO2_W/mpconfigboard.cmake @@ -0,0 +1,11 @@ +# cmake file for Raspberry Pi Pico 2 W + +set(PICO_BOARD "pico2_w") + +# To change the gpio count for QFN-80 +# set(PICO_NUM_GPIOS 48) + +include(enable_cyw43.cmake) + +# Board specific version of the frozen manifest +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) \ No newline at end of file diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.h b/micropython/board/RPI_PICO2_W/mpconfigboard.h new file mode 100644 index 0000000..3183d14 --- /dev/null +++ b/micropython/board/RPI_PICO2_W/mpconfigboard.h @@ -0,0 +1,7 @@ +// Board and hardware specific configuration +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico 2 W" +#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024) + +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2W" + +#include "enable_cyw43.h" \ No newline at end of file diff --git a/micropython/board/RPI_PICO2_W/pins.csv b/micropython/board/RPI_PICO2_W/pins.csv new file mode 100644 index 0000000..012bc7c --- /dev/null +++ b/micropython/board/RPI_PICO2_W/pins.csv @@ -0,0 +1,30 @@ +GP0,GPIO0 +GP1,GPIO1 +GP2,GPIO2 +GP3,GPIO3 +GP4,GPIO4 +GP5,GPIO5 +GP6,GPIO6 +GP7,GPIO7 +GP8,GPIO8 +GP9,GPIO9 +GP10,GPIO10 +GP11,GPIO11 +GP12,GPIO12 +GP13,GPIO13 +GP14,GPIO14 +GP15,GPIO15 +GP16,GPIO16 +GP17,GPIO17 +GP18,GPIO18 +GP19,GPIO19 +GP20,GPIO20 +GP21,GPIO21 +GP22,GPIO22 +GP26,GPIO26 +GP27,GPIO27 +GP28,GPIO28 +WL_GPIO0,EXT_GPIO0 +WL_GPIO1,EXT_GPIO1 +WL_GPIO2,EXT_GPIO2 +LED,EXT_GPIO0 \ No newline at end of file From 4de68aadc78d15a85e399b9953243f2ba13d857b Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 26 Nov 2024 22:48:31 +0000 Subject: [PATCH 22/38] CI: 2MB/2MB split for Pico 2 and Pico 2 W builds. --- micropython/board/RPI_PICO2/mpconfigboard.h | 2 +- micropython/board/RPI_PICO2_W/mpconfigboard.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/micropython/board/RPI_PICO2/mpconfigboard.h b/micropython/board/RPI_PICO2/mpconfigboard.h index 15b6dd3..5c03625 100644 --- a/micropython/board/RPI_PICO2/mpconfigboard.h +++ b/micropython/board/RPI_PICO2/mpconfigboard.h @@ -1,6 +1,6 @@ // Board and hardware specific configuration #define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico2" -#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024) +#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024 * 2) #if MICROPY_PY_NETWORK_CYW43 #include "enable_cyw43.h" diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.h b/micropython/board/RPI_PICO2_W/mpconfigboard.h index 3183d14..e31048a 100644 --- a/micropython/board/RPI_PICO2_W/mpconfigboard.h +++ b/micropython/board/RPI_PICO2_W/mpconfigboard.h @@ -1,6 +1,6 @@ // Board and hardware specific configuration #define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico 2 W" -#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024) +#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024 * 2) #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2W" From a4f4078e03aa894c741f7831d7297b4fba96d86a Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 28 Feb 2025 11:12:46 +0000 Subject: [PATCH 23/38] Pico2: Fix conditional include of manifest.py. --- micropython/board/RPI_PICO2/mpconfigboard.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/micropython/board/RPI_PICO2/mpconfigboard.cmake b/micropython/board/RPI_PICO2/mpconfigboard.cmake index a869fd0..28a8f67 100644 --- a/micropython/board/RPI_PICO2/mpconfigboard.cmake +++ b/micropython/board/RPI_PICO2/mpconfigboard.cmake @@ -6,6 +6,7 @@ set(PICO_BOARD "pico2") if (PICO_CYW43_SUPPORTED) include(enable_cyw43.cmake) - set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) set(PICO_PINS_CSV_NAME pins_cyw43.csv) -endif() \ No newline at end of file +endif() + +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) \ No newline at end of file From 0527852dbd823ffaed58b454a38a9ec5c451f8c2 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 28 Feb 2025 13:46:51 +0000 Subject: [PATCH 24/38] CI: Switch to pico2_w_2025 MicroPython branch. --- .github/workflows/micropython.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 8a95ee0..8fcfe7d 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -7,7 +7,7 @@ on: types: [created] env: - MICROPYTHON_VERSION: feature/psram-and-wifi + MICROPYTHON_VERSION: feature/pico2_w_2025 MICROPYTHON_FLAVOUR: pimoroni PIMORONI_PICO_VERSION: main From 776f21ea277a03f0f7e00b2584a24009fb107a14 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 10:43:07 +0000 Subject: [PATCH 25/38] Pico2: Remove spurious pico2_w.h. --- micropython/board/RPI_PICO2/pico2_w.h | 116 -------------------------- 1 file changed, 116 deletions(-) delete mode 100644 micropython/board/RPI_PICO2/pico2_w.h diff --git a/micropython/board/RPI_PICO2/pico2_w.h b/micropython/board/RPI_PICO2/pico2_w.h deleted file mode 100644 index 68d5191..0000000 --- a/micropython/board/RPI_PICO2/pico2_w.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2024 Raspberry Pi (Trading) Ltd. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -// ----------------------------------------------------- -// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO -// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES -// ----------------------------------------------------- - -// This header may be included by other board headers as "boards/pico2_w.h" - -// pico_cmake_set PICO_PLATFORM=rp2350 -// pico_cmake_set PICO_CYW43_SUPPORTED = 1 - -#ifndef _BOARDS_PICO2_W_H -#define _BOARDS_PICO2_W_H - -// For board detection -#define RASPBERRYPI_PICO2_W - -// --- RP2350 VARIANT --- -#define PICO_RP2350A 1 - -// --- UART --- -#ifndef PICO_DEFAULT_UART -#define PICO_DEFAULT_UART 0 -#endif -#ifndef PICO_DEFAULT_UART_TX_PIN -#define PICO_DEFAULT_UART_TX_PIN 0 -#endif -#ifndef PICO_DEFAULT_UART_RX_PIN -#define PICO_DEFAULT_UART_RX_PIN 1 -#endif - -// --- LED --- -// no PICO_DEFAULT_LED_PIN - LED is on Wireless chip -// no PICO_DEFAULT_WS2812_PIN - -// --- 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 - -// --- FLASH --- - -#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 - -#ifndef PICO_FLASH_SPI_CLKDIV -#define PICO_FLASH_SPI_CLKDIV 2 -#endif - -// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024) -#ifndef PICO_FLASH_SIZE_BYTES -#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024) -#endif -// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads) -// note the SMSP mode pin is on WL_GPIO1 - -#ifndef CYW43_WL_GPIO_COUNT -#define CYW43_WL_GPIO_COUNT 3 -#endif - -#ifndef CYW43_WL_GPIO_LED_PIN -#define CYW43_WL_GPIO_LED_PIN 0 -#endif - -// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS. -// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered. -// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined. -#ifndef CYW43_WL_GPIO_VBUS_PIN -#define CYW43_WL_GPIO_VBUS_PIN 2 -#endif - -// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes. -// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it. -// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit. -#ifndef CYW43_USES_VSYS_PIN -#define CYW43_USES_VSYS_PIN 1 -#endif - -// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC. -// There is an example in adc/read_vsys in pico-examples. -#ifndef PICO_VSYS_PIN -#define PICO_VSYS_PIN 29 -#endif - -#ifndef PICO_RP2350_A2_SUPPORTED -#define PICO_RP2350_A2_SUPPORTED 1 -#endif - -#endif \ No newline at end of file From 02d9e0fdf4b91c10bb3813873955d46b8646553c Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 10:45:30 +0000 Subject: [PATCH 26/38] Enable LTE & PPP for Pico2/Pico2W. --- micropython/board/RPI_PICO2/mpconfigboard.cmake | 4 ++++ micropython/board/RPI_PICO2/mpconfigboard.h | 6 ++++++ micropython/board/RPI_PICO2_W/mpconfigboard.cmake | 5 ++++- micropython/board/RPI_PICO2_W/mpconfigboard.h | 6 +++++- micropython/board/manifest_pico2.py | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/micropython/board/RPI_PICO2/mpconfigboard.cmake b/micropython/board/RPI_PICO2/mpconfigboard.cmake index 28a8f67..1e97f02 100644 --- a/micropython/board/RPI_PICO2/mpconfigboard.cmake +++ b/micropython/board/RPI_PICO2/mpconfigboard.cmake @@ -4,6 +4,10 @@ set(PICO_BOARD "pico2") # To change the gpio count for QFN-80 # set(PICO_NUM_GPIOS 48) +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + if (PICO_CYW43_SUPPORTED) include(enable_cyw43.cmake) set(PICO_PINS_CSV_NAME pins_cyw43.csv) diff --git a/micropython/board/RPI_PICO2/mpconfigboard.h b/micropython/board/RPI_PICO2/mpconfigboard.h index 5c03625..d52c6af 100644 --- a/micropython/board/RPI_PICO2/mpconfigboard.h +++ b/micropython/board/RPI_PICO2/mpconfigboard.h @@ -2,6 +2,12 @@ #define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico2" #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024 * 2) +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2" + +// Enable WiFi & PPP +#define MICROPY_PY_NETWORK (1) +#define MICROPY_PY_NETWORK_PPP_LWIP (1) + #if MICROPY_PY_NETWORK_CYW43 #include "enable_cyw43.h" diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.cmake b/micropython/board/RPI_PICO2_W/mpconfigboard.cmake index 49d92f5..3dd942c 100644 --- a/micropython/board/RPI_PICO2_W/mpconfigboard.cmake +++ b/micropython/board/RPI_PICO2_W/mpconfigboard.cmake @@ -1,10 +1,13 @@ # cmake file for Raspberry Pi Pico 2 W - set(PICO_BOARD "pico2_w") # To change the gpio count for QFN-80 # set(PICO_NUM_GPIOS 48) +# Links micropy_lib_lwip and sets MICROPY_PY_LWIP = 1 +# Picked up and expanded upon in mpconfigboard.h +set(MICROPY_PY_LWIP ON) + include(enable_cyw43.cmake) # Board specific version of the frozen manifest diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.h b/micropython/board/RPI_PICO2_W/mpconfigboard.h index e31048a..cf12e90 100644 --- a/micropython/board/RPI_PICO2_W/mpconfigboard.h +++ b/micropython/board/RPI_PICO2_W/mpconfigboard.h @@ -2,6 +2,10 @@ #define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico 2 W" #define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024 * 2) -#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2W" +#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2W" + +// Enable WiFi & PPP +#define MICROPY_PY_NETWORK (1) +#define MICROPY_PY_NETWORK_PPP_LWIP (1) #include "enable_cyw43.h" \ No newline at end of file diff --git a/micropython/board/manifest_pico2.py b/micropython/board/manifest_pico2.py index a400fdc..552182d 100644 --- a/micropython/board/manifest_pico2.py +++ b/micropython/board/manifest_pico2.py @@ -6,4 +6,4 @@ require("sdcard") freeze(MODULES_PY, "gfx_pack.py") freeze(MODULES_PY, "pimoroni.py") -freeze(MODULES_PY, "boot.py") +freeze(MODULES_PY, "boot.py") \ No newline at end of file From 4a24f872539c1e7e984fb11de971d107fd2df6f5 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 10:45:59 +0000 Subject: [PATCH 27/38] Add lte.py to common manifest. --- micropython/board/manifest_pico2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/micropython/board/manifest_pico2.py b/micropython/board/manifest_pico2.py index 552182d..8a52513 100644 --- a/micropython/board/manifest_pico2.py +++ b/micropython/board/manifest_pico2.py @@ -6,4 +6,6 @@ require("sdcard") freeze(MODULES_PY, "gfx_pack.py") freeze(MODULES_PY, "pimoroni.py") -freeze(MODULES_PY, "boot.py") \ No newline at end of file +freeze(MODULES_PY, "boot.py") + +freeze(MODULES_PY, "lte.py") From 4d4853e9e29b6a3bcdbb7f964ec2c20f7fb624ae Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 11:08:53 +0000 Subject: [PATCH 28/38] Remove duplicate lte.py. --- .../board/PIMORONI_PICO_PLUS2/manifest.py | 4 +- .../board/PIMORONI_PLASMA2350/manifest.py | 4 +- micropython/modules_py/lte.py | 220 ------------------ 3 files changed, 2 insertions(+), 226 deletions(-) delete mode 100644 micropython/modules_py/lte.py diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest.py b/micropython/board/PIMORONI_PICO_PLUS2/manifest.py index ab6e69e..563664c 100644 --- a/micropython/board/PIMORONI_PICO_PLUS2/manifest.py +++ b/micropython/board/PIMORONI_PICO_PLUS2/manifest.py @@ -5,6 +5,4 @@ require("aioble") include("$(PORT_DIR)/boards/manifest.py") -include("../manifest_pico2.py") - -freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file +include("../manifest_pico2.py") \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/manifest.py b/micropython/board/PIMORONI_PLASMA2350/manifest.py index ab6e69e..563664c 100644 --- a/micropython/board/PIMORONI_PLASMA2350/manifest.py +++ b/micropython/board/PIMORONI_PLASMA2350/manifest.py @@ -5,6 +5,4 @@ require("aioble") include("$(PORT_DIR)/boards/manifest.py") -include("../manifest_pico2.py") - -freeze("$(BOARD_DIR)/../../modules_py", "lte.py") \ No newline at end of file +include("../manifest_pico2.py") \ No newline at end of file diff --git a/micropython/modules_py/lte.py b/micropython/modules_py/lte.py deleted file mode 100644 index 435b2e2..0000000 --- a/micropython/modules_py/lte.py +++ /dev/null @@ -1,220 +0,0 @@ -from machine import UART, Pin -from network import PPP -from micropython import const -import time - - -DEFAULT_PIN_RST = 35 -DEFAULT_PIN_NETLIGHT = 34 -DEFAULT_PIN_RX = 33 -DEFAULT_PIN_TX = 32 -DEFAULT_UART_ID = 0 - -DEFAULT_UART_TIMEOUT = const(1) -DEFAULT_UART_TIMEOUT_CHAR = const(1) -DEFAULT_UART_RXBUF = const(1024) -DEFAULT_UART_STARTUP_BAUD = const(115200) -DEFAULT_UART_BAUD = const(460800) - - -class CellularError(Exception): - def __init__(self, message=None): - self.message = f"CellularError: {message}" - - -class LTE(): - def __init__(self, apn, uart=None, reset_pin=None, netlight_pin=None, netlight_led=None, skip_reset=False): - self._apn = apn - self._reset = reset_pin or Pin(DEFAULT_PIN_RST, Pin.OUT) - self._uart = uart or UART( - DEFAULT_UART_ID, - tx=Pin(DEFAULT_PIN_TX, Pin.OUT), - rx=Pin(DEFAULT_PIN_RX, Pin.OUT)) - - # Set PPP timeouts and rxbuf - self._uart.init( - timeout=DEFAULT_UART_TIMEOUT, - timeout_char=DEFAULT_UART_TIMEOUT_CHAR, - rxbuf=DEFAULT_UART_RXBUF) - - if not skip_reset: - self._reset.value(0) - time.sleep(1.0) - self._reset.value(1) - - if netlight_led: - self._led = netlight_led - self._netlight = netlight_pin or Pin(DEFAULT_PIN_NETLIGHT, Pin.IN) - self._netlight.irq(self._netlight_irq) - - def _netlight_irq(self, pin): - self._led.value(pin.value()) - - def ipconfig(self, *args, **kwargs): - if len(args): - return self._ppp.ipconfig(*args) - else: - return self._ppp.ipconfig(**kwargs) - - def iccid(self): - try: - return self._send_at_command("AT+CICCID", 1) - except CellularError: - return None - - def status(self): - lte_status = self._send_at_command("AT+CEREG?", 1) - gsm_status = self._send_at_command("AT+CGREG?", 1) - return lte_status, gsm_status - - def signal_quality(self): - try: - response = self._send_at_command("AT+CSQ", 1) - quality = int(response.split(":")[1].split(",")[0]) - db = -113 + (2 * quality) # conversion as per AT command set datasheet - return db - except CellularError: - pass - return None - - def stop_ppp(self): - self._ppp.disconnect() - self._send_at_command(f"AT+IPR={DEFAULT_UART_STARTUP_BAUD}") - self._flush_uart() - - def start_ppp(self, baudrate=DEFAULT_UART_BAUD, connect=True): - self._wait_ready(poll_time=1.0, timeout=30) - - # Switch to a faster baudrate - self._send_at_command(f"AT+IPR={baudrate}") - self._flush_uart() - self._uart.init( - baudrate=baudrate, - timeout=DEFAULT_UART_TIMEOUT, - timeout_char=DEFAULT_UART_TIMEOUT_CHAR, - rxbuf=DEFAULT_UART_RXBUF) - self._wait_ready(poll_time=1.0) - - # Connect! - if connect: - self.connect() - - # This will just always time out!? - # try: - # self._send_at_command("ATD*99#", timeout=300) - # except CellularError as e: - # print(e) - - # Force PPP to use modem's default settings... - self._flush_uart() - self._uart.write("ATD*99#\r") - self._uart.flush() - - self._ppp = PPP(self._uart) - self._ppp.connect() - while self._ppp.status() != 4: - time.sleep(1.0) - - return self._ppp.ifconfig() - - def connect(self, timeout=60): - print(" - setting up cellular uart") - # connect to and flush the uart - # consume any unsolicited messages first, we don't need those - self._flush_uart() - - print(" - waiting for cellular module to be ready") - - # wait for the cellular module to respond to AT commands - self._wait_ready() - - self._send_at_command("ATE0") # disable local echo - self._send_at_command(f"AT+CGDCONT=1,\"IP\",\"{self._apn}\"") # set apn and activate pdp context - - # wait for roaming lte connection to be established - giveup = time.time() + timeout - status = None - while status != "+CEREG: 0,5" and status != "+CEREG: 0,1": - status = self._send_at_command("AT+CEREG?", 1) - time.sleep(0.25) - if time.time() > giveup: - raise CellularError("timed out getting network registration") - - # disable server and client certification validation - self._send_at_command("AT+CSSLCFG=\"authmode\",0,0") - self._send_at_command("AT+CSSLCFG=\"enableSNI\",0,1") - - print(f" - SIM ICCID is {self.iccid()}") - - def _wait_ready(self, poll_time=0.25, timeout=10): - giveup = time.time() + timeout - while time.time() <= giveup: - try: - # if __send_at_command doesn't throw an exception then we're good! - self._send_at_command("AT") - return - except CellularError as e: - print(e) - time.sleep(poll_time) - - raise CellularError("timed out waiting for AT response") - - def _flush_uart(self): - self._uart.flush() - time.sleep(0.25) - while self._uart.any(): - self._uart.read(self._uart.any()) - time.sleep(0.25) - - def _send_at_command(self, command, result_lines=0, timeout=5.0): - # consume any unsolicited messages first, we don't need those - self._flush_uart() - - self._uart.write(command + "\r") - self._uart.flush() - status, data = self._read_result(result_lines, timeout=timeout) - - print(" -", command, status, data) - - if status not in ["OK", "DOWNLOAD"]: - raise CellularError(f"non 'OK' or 'DOWNLOAD' result for command {command}") - - if result_lines == 1: - return data[0] - if result_lines > 1: - return data - return None - - def _read_result(self, result_lines, timeout=1.0): - status = None - result = [] - start = time.ticks_ms() - timeout *= 1000 - while len(result) < result_lines or status is None: - if (time.ticks_ms() - start) > timeout: - raise CellularError("cellular module timed out") - - line = self._uart.readline() - - if line: - line = line.strip() - if line in [b"OK", b"ERROR", b"DOWNLOAD"]: - status = line.decode("ascii") - elif line != b"": - result.append(str(line, "ascii")) - start = time.ticks_ms() - - return status, result - - def send_text_message(self, recipient, body, timeout=5.0): - self._uart.write("AT+CMGS=\"") - self._uart.write(recipient.encode("ascii")) - self._uart.write(b"\"\r") - time.sleep(0.5) - self._uart.write(body.encode("ascii")) - self._uart.write(b"\x1a\r") - self._uart.flush() - - status, _ = self._read_result(1, timeout=timeout) - - return status == "OK" From d4205caedce8dc9a090d5f9731de357c00f5dd56 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 11:09:27 +0000 Subject: [PATCH 29/38] Remove duplicate MICROPY_PY_NETWORK. --- micropython/board/RPI_PICO2_W/mpconfigboard.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.h b/micropython/board/RPI_PICO2_W/mpconfigboard.h index cf12e90..49a7268 100644 --- a/micropython/board/RPI_PICO2_W/mpconfigboard.h +++ b/micropython/board/RPI_PICO2_W/mpconfigboard.h @@ -4,8 +4,7 @@ #define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2W" -// Enable WiFi & PPP -#define MICROPY_PY_NETWORK (1) +// Enable PPP #define MICROPY_PY_NETWORK_PPP_LWIP (1) #include "enable_cyw43.h" \ No newline at end of file From af670449c06aa625112b261d5b29db681893619a Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 11:52:34 +0000 Subject: [PATCH 30/38] CI: Refactor to match our other tooling. Retarget pimoroni-pico to feature/picovector2-and-layers. --- .github/workflows/micropython.yml | 142 +++++++----------- .gitignore | 39 +++++ boards/common.cmake | 37 +++++ .../board => boards}/manifest_pico2.py | 3 +- .../pimoroni_pico_plus2}/board.json | 0 .../pimoroni_pico_plus2}/manifest.py | 0 .../pimoroni_pico_plus2}/mpconfigboard.cmake | 0 .../pimoroni_pico_plus2}/mpconfigboard.h | 0 .../pimoroni_pico_plus2w_rp2350.h | 0 .../pimoroni_pico_plus2}/pins.csv | 0 boards/pimoroni_pico_plus2/usermodules.cmake | 3 + .../pimoroni_plasma2350}/board.json | 0 .../pimoroni_plasma2350}/manifest.py | 0 .../pimoroni_plasma2350}/mpconfigboard.cmake | 0 .../pimoroni_plasma2350}/mpconfigboard.h | 0 .../pimoroni_plasma2350w.h | 0 .../pimoroni_plasma2350}/pins.csv | 0 boards/pimoroni_plasma2350/usermodules.cmake | 3 + .../pimoroni_tiny2350}/board.json | 0 .../pimoroni_tiny2350}/manifest.py | 0 .../pimoroni_tiny2350}/mpconfigboard.cmake | 0 .../pimoroni_tiny2350}/mpconfigboard.h | 0 boards/pimoroni_tiny2350/usermodules.cmake | 3 + .../rpi_pico2}/manifest.py | 0 .../rpi_pico2}/mpconfigboard.cmake | 0 .../rpi_pico2}/mpconfigboard.h | 0 .../RPI_PICO2 => boards/rpi_pico2}/pins.csv | 0 boards/rpi_pico2/usermodules.cmake | 3 + .../rpi_pico2_w}/manifest.py | 0 .../rpi_pico2_w}/mpconfigboard.cmake | 0 .../rpi_pico2_w}/mpconfigboard.h | 0 .../rpi_pico2_w}/pins.csv | 0 boards/rpi_pico2_w/usermodules.cmake | 3 + .../rpi_pico2b}/board.json | 0 .../rpi_pico2b}/manifest.py | 0 .../rpi_pico2b}/mpconfigboard.cmake | 0 .../rpi_pico2b}/mpconfigboard.h | 0 .../RPI_PICO2B => boards/rpi_pico2b}/pico2b.h | 0 .../RPI_PICO2B => boards/rpi_pico2b}/pins.csv | 0 boards/rpi_pico2b/usermodules.cmake | 3 + .../usermod-common.cmake | 0 ci/micropython.sh | 113 +++++++++++--- .../pico_jumbo/big_blink.py | 0 .../pico_jumbo/big_button.py | 0 .../pico_jumbo/big_toggle.py | 0 .../pico_plus_2/breakouts/bme68x-breakout.py | 0 .../pico_plus_2/breakouts/lte-astronauts.py | 0 .../pico_plus_2/breakouts/lte-breakout.py | 0 .../pico_plus_2/breakouts/lte-catfacts.py | 0 .../breakouts/rm2-breakout-catfacts.py | 0 .../pico_plus_2/breakouts/scd41-breakout.py | 0 .../pico_plus_2/breakouts/secrets.py | 0 .../pico_plus_2/button.py | 0 .../pico_plus_2/onboard_led.py | 0 .../pico_plus_2_w/astronauts.py | 0 .../pico_plus_2_w/button.py | 0 .../pico_plus_2_w/catfacts.py | 0 .../pico_plus_2_w/onboard_led.py | 0 .../pico_plus_2_w/secrets.py | 0 .../breakouts/rm2-breakout-catfacts.py | 0 .../plasma_2350/breakouts/secrets.py | 0 .../breakouts/trackball-breakout.py | 0 .../plasma_2350/button_control.py | 0 .../plasma_2350/buttons.py | 0 .../plasma_2350/rainbow.py | 0 .../plasma_2350/rgb_led.py | 0 .../plasma_2350/single_colour.py | 0 .../plasma_2350_w/cheerlights.py | 0 .../plasma_2350_w/html/index.html | 0 .../plasma_2350_w/secrets.py | 0 .../plasma_2350_w/webpage.py | 0 .../tiny_2350/breakouts/bme688-breakout.py | 0 .../tiny_2350/breakouts/scd41-breakout.py | 0 .../tiny_2350/buttons.py | 0 .../tiny_2350/rgb_led.py | 0 75 files changed, 246 insertions(+), 106 deletions(-) create mode 100644 .gitignore create mode 100644 boards/common.cmake rename {micropython/board => boards}/manifest_pico2.py (60%) rename {micropython/board/PIMORONI_PICO_PLUS2 => boards/pimoroni_pico_plus2}/board.json (100%) rename {micropython/board/PIMORONI_PICO_PLUS2 => boards/pimoroni_pico_plus2}/manifest.py (100%) rename {micropython/board/PIMORONI_PICO_PLUS2 => boards/pimoroni_pico_plus2}/mpconfigboard.cmake (100%) rename {micropython/board/PIMORONI_PICO_PLUS2 => boards/pimoroni_pico_plus2}/mpconfigboard.h (100%) rename {micropython/board/PIMORONI_PICO_PLUS2 => boards/pimoroni_pico_plus2}/pimoroni_pico_plus2w_rp2350.h (100%) rename {micropython/board/PIMORONI_PICO_PLUS2 => boards/pimoroni_pico_plus2}/pins.csv (100%) create mode 100644 boards/pimoroni_pico_plus2/usermodules.cmake rename {micropython/board/PIMORONI_PLASMA2350 => boards/pimoroni_plasma2350}/board.json (100%) rename {micropython/board/PIMORONI_PLASMA2350 => boards/pimoroni_plasma2350}/manifest.py (100%) rename {micropython/board/PIMORONI_PLASMA2350 => boards/pimoroni_plasma2350}/mpconfigboard.cmake (100%) rename {micropython/board/PIMORONI_PLASMA2350 => boards/pimoroni_plasma2350}/mpconfigboard.h (100%) rename {micropython/board/PIMORONI_PLASMA2350 => boards/pimoroni_plasma2350}/pimoroni_plasma2350w.h (100%) rename {micropython/board/PIMORONI_PLASMA2350 => boards/pimoroni_plasma2350}/pins.csv (100%) create mode 100644 boards/pimoroni_plasma2350/usermodules.cmake rename {micropython/board/PIMORONI_TINY2350 => boards/pimoroni_tiny2350}/board.json (100%) rename {micropython/board/PIMORONI_TINY2350 => boards/pimoroni_tiny2350}/manifest.py (100%) rename {micropython/board/PIMORONI_TINY2350 => boards/pimoroni_tiny2350}/mpconfigboard.cmake (100%) rename {micropython/board/PIMORONI_TINY2350 => boards/pimoroni_tiny2350}/mpconfigboard.h (100%) create mode 100644 boards/pimoroni_tiny2350/usermodules.cmake rename {micropython/board/RPI_PICO2 => boards/rpi_pico2}/manifest.py (100%) rename {micropython/board/RPI_PICO2 => boards/rpi_pico2}/mpconfigboard.cmake (100%) rename {micropython/board/RPI_PICO2 => boards/rpi_pico2}/mpconfigboard.h (100%) rename {micropython/board/RPI_PICO2 => boards/rpi_pico2}/pins.csv (100%) create mode 100644 boards/rpi_pico2/usermodules.cmake rename {micropython/board/RPI_PICO2_W => boards/rpi_pico2_w}/manifest.py (100%) rename {micropython/board/RPI_PICO2_W => boards/rpi_pico2_w}/mpconfigboard.cmake (100%) rename {micropython/board/RPI_PICO2_W => boards/rpi_pico2_w}/mpconfigboard.h (100%) rename {micropython/board/RPI_PICO2_W => boards/rpi_pico2_w}/pins.csv (100%) create mode 100644 boards/rpi_pico2_w/usermodules.cmake rename {micropython/board/RPI_PICO2B => boards/rpi_pico2b}/board.json (100%) rename {micropython/board/RPI_PICO2B => boards/rpi_pico2b}/manifest.py (100%) rename {micropython/board/RPI_PICO2B => boards/rpi_pico2b}/mpconfigboard.cmake (100%) rename {micropython/board/RPI_PICO2B => boards/rpi_pico2b}/mpconfigboard.h (100%) rename {micropython/board/RPI_PICO2B => boards/rpi_pico2b}/pico2b.h (100%) rename {micropython/board/RPI_PICO2B => boards/rpi_pico2b}/pins.csv (100%) create mode 100644 boards/rpi_pico2b/usermodules.cmake rename micropython/micropython-pico2.cmake => boards/usermod-common.cmake (100%) rename {micropython/examples => examples}/pico_jumbo/big_blink.py (100%) rename {micropython/examples => examples}/pico_jumbo/big_button.py (100%) rename {micropython/examples => examples}/pico_jumbo/big_toggle.py (100%) rename {micropython/examples => examples}/pico_plus_2/breakouts/bme68x-breakout.py (100%) rename {micropython/examples => examples}/pico_plus_2/breakouts/lte-astronauts.py (100%) rename {micropython/examples => examples}/pico_plus_2/breakouts/lte-breakout.py (100%) rename {micropython/examples => examples}/pico_plus_2/breakouts/lte-catfacts.py (100%) rename {micropython/examples => examples}/pico_plus_2/breakouts/rm2-breakout-catfacts.py (100%) rename {micropython/examples => examples}/pico_plus_2/breakouts/scd41-breakout.py (100%) rename {micropython/examples => examples}/pico_plus_2/breakouts/secrets.py (100%) rename {micropython/examples => examples}/pico_plus_2/button.py (100%) rename {micropython/examples => examples}/pico_plus_2/onboard_led.py (100%) rename {micropython/examples => examples}/pico_plus_2_w/astronauts.py (100%) rename {micropython/examples => examples}/pico_plus_2_w/button.py (100%) rename {micropython/examples => examples}/pico_plus_2_w/catfacts.py (100%) rename {micropython/examples => examples}/pico_plus_2_w/onboard_led.py (100%) rename {micropython/examples => examples}/pico_plus_2_w/secrets.py (100%) rename {micropython/examples => examples}/plasma_2350/breakouts/rm2-breakout-catfacts.py (100%) rename {micropython/examples => examples}/plasma_2350/breakouts/secrets.py (100%) rename {micropython/examples => examples}/plasma_2350/breakouts/trackball-breakout.py (100%) rename {micropython/examples => examples}/plasma_2350/button_control.py (100%) rename {micropython/examples => examples}/plasma_2350/buttons.py (100%) rename {micropython/examples => examples}/plasma_2350/rainbow.py (100%) rename {micropython/examples => examples}/plasma_2350/rgb_led.py (100%) rename {micropython/examples => examples}/plasma_2350/single_colour.py (100%) rename {micropython/examples => examples}/plasma_2350_w/cheerlights.py (100%) rename {micropython/examples => examples}/plasma_2350_w/html/index.html (100%) rename {micropython/examples => examples}/plasma_2350_w/secrets.py (100%) rename {micropython/examples => examples}/plasma_2350_w/webpage.py (100%) rename {micropython/examples => examples}/tiny_2350/breakouts/bme688-breakout.py (100%) rename {micropython/examples => examples}/tiny_2350/breakouts/scd41-breakout.py (100%) rename {micropython/examples => examples}/tiny_2350/buttons.py (100%) rename {micropython/examples => examples}/tiny_2350/rgb_led.py (100%) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 8fcfe7d..eefbda6 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -6,46 +6,34 @@ on: release: types: [created] -env: - MICROPYTHON_VERSION: feature/pico2_w_2025 - MICROPYTHON_FLAVOUR: pimoroni - PIMORONI_PICO_VERSION: main - jobs: build: - name: ${{ matrix.name }} (${{ matrix.board }}) - runs-on: ubuntu-20.04 + name: MicroPython ${{ matrix.name }} + runs-on: ubuntu-24.04 continue-on-error: true strategy: matrix: include: - - name: pico2 - board: RPI_PICO2 - - name: pico2_w - board: RPI_PICO2_W - - name: pico2b_rp2350 - board: RPI_PICO2B - - name: plasma2350 - board: PIMORONI_PLASMA2350 - - name: tiny2350 - board: PIMORONI_TINY2350 - - name: pico_plus2_rp2350 - board: PIMORONI_PICO_PLUS2 + - name: rpi_pico2 + - name: rpi_pico2_w + - name: rpi_pico2b + - name: pimoroni_plasma2350 + - name: pimoroni_tiny2350 + - name: pimoroni_pico_plus2 env: # MicroPython version will be contained in github.event.release.tag_name for releases - RELEASE_FILE: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-pimoroni-micropython - PIMORONI_PICO_DIR: "${{ github.workspace }}/pimoroni-pico" - MICROPY_BOARD_DIR: "${{ github.workspace }}/pimoroni-pico-rp2350-${{ github.sha }}/micropython/board/${{ matrix.BOARD }}" - USER_C_MODULES: "${{ github.workspace }}/pimoroni-pico-rp2350-${{ github.sha }}/micropython/micropython-pico2.cmake" - TAG_OR_SHA: ${{ github.event.release.tag_name || github.sha }} - MICROPY_BOARD: ${{ matrix.board }} - MICROPY_BOARD_VARIANT: ${{ matrix.variant }} - BOARD_NAME: ${{ matrix.name }} - BUILD_TOOLS: pimoroni-pico-rp2350-${{ github.sha }}/ci/micropython.sh + RELEASE_FILE: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython + CI_PROJECT_ROOT: ${{ github.workspace }}/src-${{ github.sha }} + CI_BUILD_ROOT: ${{ github.workspace }} + CI_USE_ENV: 1 steps: - - name: Compiler Cache + - name: Compiler Cache Fixup + run: | + mkdir -p /home/runner/.ccache + + - name: "CCache: Restore saved cache" uses: actions/cache@v4 with: path: /home/runner/.ccache @@ -54,76 +42,62 @@ jobs: ccache-micropython-${{ matrix.name }}-${{ github.ref }} ccache-micropython-${{ matrix.name }}- - - uses: actions/checkout@v4 + - name: "Checkout Project" + uses: actions/checkout@v4 with: submodules: true - path: pimoroni-pico-rp2350-${{ github.sha }} + path: ${{ env.CI_PROJECT_ROOT }} - - uses: actions/checkout@v4 - with: - repository: pimoroni/pimoroni-pico - ref: ${{env.PIMORONI_PICO_VERSION}} - submodules: true - path: pimoroni-pico - - - name: Install Arm GNU Toolchain (arm-none-eabi-gcc) + - name: "Install Arm GNU Toolchain (arm-none-eabi-gcc)" uses: carlosperate/arm-none-eabi-gcc-action@v1 with: release: '13.3.Rel1' - - name: Install CCache - run: | - source $BUILD_TOOLS - apt_install_build_deps - - - name: Checkout MicroPython & Submodules - run: | - source $BUILD_TOOLS - micropython_clone - - - name: "Py_Decl: Checkout py_decl" - uses: actions/checkout@v4 - with: - repository: gadgetoid/py_decl - ref: v0.0.2 - path: py_decl - - - name: Build MPY Cross - run: | - source $BUILD_TOOLS - micropython_build_mpy_cross - - - name: Configure MicroPython + - name: "Prepare tools & dependencies" shell: bash run: | - source $BUILD_TOOLS + source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug + mkdir -p $CI_BUILD_ROOT + ci_apt_install_build_deps + ci_prepare_all + + - name: "MicroPython: Configure" + shell: bash + run: | + source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug micropython_version - cmake_configure + ci_cmake_configure ${{ matrix.name }} - - name: Build MicroPython + - name: "MicroPython: Build" shell: bash run: | - source $BUILD_TOOLS - cmake_build + source $CI_PROJECT_ROOT/ci/micropython.sh && ci_debug + python3 -m venv "$CI_BUILD_ROOT/.dir2uf2" + source "$CI_BUILD_ROOT/.dir2uf2/bin/activate" + ci_cmake_build ${{ matrix.name }} + mv "$CI_BUILD_ROOT/${{ matrix.name }}.uf2" "$CI_BUILD_ROOT/$RELEASE_FILE.uf2" + mv "$CI_BUILD_ROOT/${{ matrix.name }}-with-filesystem.uf2" "$CI_BUILD_ROOT/$RELEASE_FILE-with-filesystem.uf2" - - name: "Py_Decl: Verify UF2" - shell: bash - run: | - python3 py_decl/py_decl.py --to-json --verify build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 - - - name: Store .uf2 as artifact + - name: "Artifacts: Upload .uf2" uses: actions/upload-artifact@v4 with: name: ${{ env.RELEASE_FILE }}.uf2 - path: build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 - - - name: Upload .uf2 - if: github.event_name == 'release' - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + path: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2 + + - name: "Artifacts: Upload .uf2 (With Filesystem)" + uses: actions/upload-artifact@v4 with: - asset_path: build-${{ matrix.name }}/firmware.uf2 - upload_url: ${{ github.event.release.upload_url }} - asset_name: ${{ env.RELEASE_FILE }}.uf2 - asset_content_type: application/octet-stream \ No newline at end of file + name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 + path: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}-with-filesystem.uf2 + + - name: "Release: Upload .uf2" + if: github.event_name == 'release' + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2 + + - name: "Release: Upload .uf2 (With Filesystem)" + if: github.event_name == 'release' + uses: softprops/action-gh-release@v1 + with: + files: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}-with-filesystem.uf2 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..920b6f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +**/build +.vscode + +# Apple filesystem cruft +.DS_Store +venv \ No newline at end of file diff --git a/boards/common.cmake b/boards/common.cmake new file mode 100644 index 0000000..50bac0f --- /dev/null +++ b/boards/common.cmake @@ -0,0 +1,37 @@ +# Make sure we get our VirtualEnv Python +set(Python_FIND_VIRTUALENV "FIRST") +set(Python_FIND_UNVERSIONED_NAMES "FIRST") +set(Python_FIND_STRATEGY "LOCATION") +find_package (Python COMPONENTS Interpreter Development) + +message("dir2uf2/py_decl: Using Python ${Python_EXECUTABLE}") +MESSAGE("dir2uf2/py_decl: Using pimoroni tools dir ${PIMORONI_TOOLS_DIR}") + +# Convert supplies paths to absolute, for a quieter life +get_filename_component(PIMORONI_UF2_MANIFEST ${PIMORONI_UF2_MANIFEST} REALPATH) +get_filename_component(PIMORONI_UF2_DIR ${PIMORONI_UF2_DIR} REALPATH) + +if (EXISTS "${PIMORONI_TOOLS_DIR}/py_decl/py_decl.py") + MESSAGE("py_decl: py_decl.py found, will verify uf2.") + add_custom_target("${MICROPY_TARGET}-verify" ALL + COMMAND ${Python_EXECUTABLE} "${PIMORONI_TOOLS_DIR}/py_decl/py_decl.py" --to-json --verify "${CMAKE_CURRENT_BINARY_DIR}/${MICROPY_TARGET}.uf2" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "pydecl: Verifying ${MICROPY_TARGET}.uf2" + DEPENDS ${MICROPY_TARGET} + ) +endif() + +if (EXISTS "${PIMORONI_TOOLS_DIR}/dir2uf2/dir2uf2" AND EXISTS "${PIMORONI_UF2_MANIFEST}" AND EXISTS "${PIMORONI_UF2_DIR}") + MESSAGE("dir2uf2: Using manifest ${PIMORONI_UF2_MANIFEST}.") + MESSAGE("dir2uf2: Using root ${PIMORONI_UF2_DIR}.") + add_custom_target("${MICROPY_TARGET}-with-filesystem.uf2" ALL + COMMAND ${Python_EXECUTABLE} "${PIMORONI_TOOLS_DIR}/dir2uf2/dir2uf2" --fs-compact --sparse --append-to "${MICROPY_TARGET}.uf2" --manifest "${PIMORONI_UF2_MANIFEST}" --filename with-filesystem.uf2 "${PIMORONI_UF2_DIR}" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "dir2uf2: Appending filesystem to ${MICROPY_TARGET}.uf2." + DEPENDS ${MICROPY_TARGET} + DEPENDS "${MICROPY_TARGET}-verify" + ) +else() + MESSAGE("dir2uf2: Could not find manifest ${PIMORONI_UF2_MANIFEST}") + MESSAGE(" and/or root ${PIMORONI_UF2_DIR}.") +endif() \ No newline at end of file diff --git a/micropython/board/manifest_pico2.py b/boards/manifest_pico2.py similarity index 60% rename from micropython/board/manifest_pico2.py rename to boards/manifest_pico2.py index 8a52513..ca9171f 100644 --- a/micropython/board/manifest_pico2.py +++ b/boards/manifest_pico2.py @@ -1,4 +1,5 @@ -MODULES_PY = "../../../pimoroni-pico/micropython/modules_py" +# micropython/ports/rp2/../../../ +MODULES_PY = "{PORT_DIR}/../../../pimoroni-pico/micropython/modules_py" # SD Card require("sdcard") diff --git a/micropython/board/PIMORONI_PICO_PLUS2/board.json b/boards/pimoroni_pico_plus2/board.json similarity index 100% rename from micropython/board/PIMORONI_PICO_PLUS2/board.json rename to boards/pimoroni_pico_plus2/board.json diff --git a/micropython/board/PIMORONI_PICO_PLUS2/manifest.py b/boards/pimoroni_pico_plus2/manifest.py similarity index 100% rename from micropython/board/PIMORONI_PICO_PLUS2/manifest.py rename to boards/pimoroni_pico_plus2/manifest.py diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.cmake b/boards/pimoroni_pico_plus2/mpconfigboard.cmake similarity index 100% rename from micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.cmake rename to boards/pimoroni_pico_plus2/mpconfigboard.cmake diff --git a/micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h b/boards/pimoroni_pico_plus2/mpconfigboard.h similarity index 100% rename from micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h rename to boards/pimoroni_pico_plus2/mpconfigboard.h diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h b/boards/pimoroni_pico_plus2/pimoroni_pico_plus2w_rp2350.h similarity index 100% rename from micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h rename to boards/pimoroni_pico_plus2/pimoroni_pico_plus2w_rp2350.h diff --git a/micropython/board/PIMORONI_PICO_PLUS2/pins.csv b/boards/pimoroni_pico_plus2/pins.csv similarity index 100% rename from micropython/board/PIMORONI_PICO_PLUS2/pins.csv rename to boards/pimoroni_pico_plus2/pins.csv diff --git a/boards/pimoroni_pico_plus2/usermodules.cmake b/boards/pimoroni_pico_plus2/usermodules.cmake new file mode 100644 index 0000000..d3f340d --- /dev/null +++ b/boards/pimoroni_pico_plus2/usermodules.cmake @@ -0,0 +1,3 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../") + +include(usermod-common) \ No newline at end of file diff --git a/micropython/board/PIMORONI_PLASMA2350/board.json b/boards/pimoroni_plasma2350/board.json similarity index 100% rename from micropython/board/PIMORONI_PLASMA2350/board.json rename to boards/pimoroni_plasma2350/board.json diff --git a/micropython/board/PIMORONI_PLASMA2350/manifest.py b/boards/pimoroni_plasma2350/manifest.py similarity index 100% rename from micropython/board/PIMORONI_PLASMA2350/manifest.py rename to boards/pimoroni_plasma2350/manifest.py diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake b/boards/pimoroni_plasma2350/mpconfigboard.cmake similarity index 100% rename from micropython/board/PIMORONI_PLASMA2350/mpconfigboard.cmake rename to boards/pimoroni_plasma2350/mpconfigboard.cmake diff --git a/micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h b/boards/pimoroni_plasma2350/mpconfigboard.h similarity index 100% rename from micropython/board/PIMORONI_PLASMA2350/mpconfigboard.h rename to boards/pimoroni_plasma2350/mpconfigboard.h diff --git a/micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h b/boards/pimoroni_plasma2350/pimoroni_plasma2350w.h similarity index 100% rename from micropython/board/PIMORONI_PLASMA2350/pimoroni_plasma2350w.h rename to boards/pimoroni_plasma2350/pimoroni_plasma2350w.h diff --git a/micropython/board/PIMORONI_PLASMA2350/pins.csv b/boards/pimoroni_plasma2350/pins.csv similarity index 100% rename from micropython/board/PIMORONI_PLASMA2350/pins.csv rename to boards/pimoroni_plasma2350/pins.csv diff --git a/boards/pimoroni_plasma2350/usermodules.cmake b/boards/pimoroni_plasma2350/usermodules.cmake new file mode 100644 index 0000000..d3f340d --- /dev/null +++ b/boards/pimoroni_plasma2350/usermodules.cmake @@ -0,0 +1,3 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../") + +include(usermod-common) \ No newline at end of file diff --git a/micropython/board/PIMORONI_TINY2350/board.json b/boards/pimoroni_tiny2350/board.json similarity index 100% rename from micropython/board/PIMORONI_TINY2350/board.json rename to boards/pimoroni_tiny2350/board.json diff --git a/micropython/board/PIMORONI_TINY2350/manifest.py b/boards/pimoroni_tiny2350/manifest.py similarity index 100% rename from micropython/board/PIMORONI_TINY2350/manifest.py rename to boards/pimoroni_tiny2350/manifest.py diff --git a/micropython/board/PIMORONI_TINY2350/mpconfigboard.cmake b/boards/pimoroni_tiny2350/mpconfigboard.cmake similarity index 100% rename from micropython/board/PIMORONI_TINY2350/mpconfigboard.cmake rename to boards/pimoroni_tiny2350/mpconfigboard.cmake diff --git a/micropython/board/PIMORONI_TINY2350/mpconfigboard.h b/boards/pimoroni_tiny2350/mpconfigboard.h similarity index 100% rename from micropython/board/PIMORONI_TINY2350/mpconfigboard.h rename to boards/pimoroni_tiny2350/mpconfigboard.h diff --git a/boards/pimoroni_tiny2350/usermodules.cmake b/boards/pimoroni_tiny2350/usermodules.cmake new file mode 100644 index 0000000..d3f340d --- /dev/null +++ b/boards/pimoroni_tiny2350/usermodules.cmake @@ -0,0 +1,3 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../") + +include(usermod-common) \ No newline at end of file diff --git a/micropython/board/RPI_PICO2/manifest.py b/boards/rpi_pico2/manifest.py similarity index 100% rename from micropython/board/RPI_PICO2/manifest.py rename to boards/rpi_pico2/manifest.py diff --git a/micropython/board/RPI_PICO2/mpconfigboard.cmake b/boards/rpi_pico2/mpconfigboard.cmake similarity index 100% rename from micropython/board/RPI_PICO2/mpconfigboard.cmake rename to boards/rpi_pico2/mpconfigboard.cmake diff --git a/micropython/board/RPI_PICO2/mpconfigboard.h b/boards/rpi_pico2/mpconfigboard.h similarity index 100% rename from micropython/board/RPI_PICO2/mpconfigboard.h rename to boards/rpi_pico2/mpconfigboard.h diff --git a/micropython/board/RPI_PICO2/pins.csv b/boards/rpi_pico2/pins.csv similarity index 100% rename from micropython/board/RPI_PICO2/pins.csv rename to boards/rpi_pico2/pins.csv diff --git a/boards/rpi_pico2/usermodules.cmake b/boards/rpi_pico2/usermodules.cmake new file mode 100644 index 0000000..d3f340d --- /dev/null +++ b/boards/rpi_pico2/usermodules.cmake @@ -0,0 +1,3 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../") + +include(usermod-common) \ No newline at end of file diff --git a/micropython/board/RPI_PICO2_W/manifest.py b/boards/rpi_pico2_w/manifest.py similarity index 100% rename from micropython/board/RPI_PICO2_W/manifest.py rename to boards/rpi_pico2_w/manifest.py diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.cmake b/boards/rpi_pico2_w/mpconfigboard.cmake similarity index 100% rename from micropython/board/RPI_PICO2_W/mpconfigboard.cmake rename to boards/rpi_pico2_w/mpconfigboard.cmake diff --git a/micropython/board/RPI_PICO2_W/mpconfigboard.h b/boards/rpi_pico2_w/mpconfigboard.h similarity index 100% rename from micropython/board/RPI_PICO2_W/mpconfigboard.h rename to boards/rpi_pico2_w/mpconfigboard.h diff --git a/micropython/board/RPI_PICO2_W/pins.csv b/boards/rpi_pico2_w/pins.csv similarity index 100% rename from micropython/board/RPI_PICO2_W/pins.csv rename to boards/rpi_pico2_w/pins.csv diff --git a/boards/rpi_pico2_w/usermodules.cmake b/boards/rpi_pico2_w/usermodules.cmake new file mode 100644 index 0000000..d3f340d --- /dev/null +++ b/boards/rpi_pico2_w/usermodules.cmake @@ -0,0 +1,3 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../") + +include(usermod-common) \ No newline at end of file diff --git a/micropython/board/RPI_PICO2B/board.json b/boards/rpi_pico2b/board.json similarity index 100% rename from micropython/board/RPI_PICO2B/board.json rename to boards/rpi_pico2b/board.json diff --git a/micropython/board/RPI_PICO2B/manifest.py b/boards/rpi_pico2b/manifest.py similarity index 100% rename from micropython/board/RPI_PICO2B/manifest.py rename to boards/rpi_pico2b/manifest.py diff --git a/micropython/board/RPI_PICO2B/mpconfigboard.cmake b/boards/rpi_pico2b/mpconfigboard.cmake similarity index 100% rename from micropython/board/RPI_PICO2B/mpconfigboard.cmake rename to boards/rpi_pico2b/mpconfigboard.cmake diff --git a/micropython/board/RPI_PICO2B/mpconfigboard.h b/boards/rpi_pico2b/mpconfigboard.h similarity index 100% rename from micropython/board/RPI_PICO2B/mpconfigboard.h rename to boards/rpi_pico2b/mpconfigboard.h diff --git a/micropython/board/RPI_PICO2B/pico2b.h b/boards/rpi_pico2b/pico2b.h similarity index 100% rename from micropython/board/RPI_PICO2B/pico2b.h rename to boards/rpi_pico2b/pico2b.h diff --git a/micropython/board/RPI_PICO2B/pins.csv b/boards/rpi_pico2b/pins.csv similarity index 100% rename from micropython/board/RPI_PICO2B/pins.csv rename to boards/rpi_pico2b/pins.csv diff --git a/boards/rpi_pico2b/usermodules.cmake b/boards/rpi_pico2b/usermodules.cmake new file mode 100644 index 0000000..d3f340d --- /dev/null +++ b/boards/rpi_pico2b/usermodules.cmake @@ -0,0 +1,3 @@ +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../") + +include(usermod-common) \ No newline at end of file diff --git a/micropython/micropython-pico2.cmake b/boards/usermod-common.cmake similarity index 100% rename from micropython/micropython-pico2.cmake rename to boards/usermod-common.cmake diff --git a/ci/micropython.sh b/ci/micropython.sh index f1a24c4..4b6565b 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -1,5 +1,15 @@ export TERM=${TERM:="xterm-256color"} +MICROPYTHON_FLAVOUR="pimoroni" +MICROPYTHON_VERSION="feature/pico2_w_2025" + +PIMORONI_PICO_FLAVOUR="pimoroni" +PIMORONI_PICO_VERSION="feature/picovector2-and-layers" + +PY_DECL_VERSION="v0.0.3" +DIR2UF2_VERSION="v0.0.9" + + function log_success { echo -e "$(tput setaf 2)$1$(tput sgr0)" } @@ -12,10 +22,19 @@ function log_warning { echo -e "$(tput setaf 1)$1$(tput sgr0)" } -function micropython_clone { - log_inform "Using MicroPython $MICROPYTHON_VERSION" - git clone https://github.com/$MICROPYTHON_FLAVOUR/micropython - cd micropython +function ci_pimoroni_pico_clone { + log_inform "Using Pimoroni Pico $PIMORONI_PICO_FLAVOUR/$PIMORONI_PICO_VERSION" + git clone https://github.com/$PIMORONI_PICO_FLAVOUR/pimoroni-pico "$CI_BUILD_ROOT/pimoroni-pico" + cd "$CI_BUILD_ROOT/pimoroni-pico" || return 1 + git checkout $PIMORONI_PICO_VERSION + git submodule update --init + cd "$CI_BUILD_ROOT" +} + +function ci_micropython_clone { + log_inform "Using MicroPython $MICROPYTHON_FLAVOUR/$MICROPYTHON_VERSION" + git clone https://github.com/$MICROPYTHON_FLAVOUR/micropython "$CI_BUILD_ROOT/micropython" + cd "$CI_BUILD_ROOT/micropython" || return 1 git checkout $MICROPYTHON_VERSION git submodule update --init lib/pico-sdk git submodule update --init lib/cyw43-driver @@ -24,42 +43,94 @@ function micropython_clone { git submodule update --init lib/micropython-lib git submodule update --init lib/tinyusb git submodule update --init lib/btstack - cd ../ + cd "$CI_BUILD_ROOT" } -function micropython_build_mpy_cross { - cd micropython/mpy-cross +function ci_tools_clone { + mkdir -p "$CI_BUILD_ROOT/tools" + git clone https://github.com/gadgetoid/py_decl -b "$PY_DECL_VERSION" "$CI_BUILD_ROOT/tools/py_decl" + git clone https://github.com/gadgetoid/dir2uf2 -b "$DIR2UF2_VERSION" "$CI_BUILD_ROOT/tools/dir2uf2" + python3 -m pip install littlefs-python==0.12.0 +} + +function ci_micropython_build_mpy_cross { + cd "$CI_BUILD_ROOT/micropython/mpy-cross" || return 1 ccache --zero-stats || true - CROSS_COMPILE="ccache " USER_C_MODULES= make + CROSS_COMPILE="ccache " make ccache --show-stats || true - cd ../../ + cd "$CI_BUILD_ROOT" } -function apt_install_build_deps { +function ci_apt_install_build_deps { sudo apt update && sudo apt install ccache } +function ci_prepare_all { + ci_tools_clone + ci_micropython_clone + ci_pimoroni_pico_clone + ci_micropython_build_mpy_cross +} + +function ci_debug { + log_inform "Project root: $CI_PROJECT_ROOT" + log_inform "Build root: $CI_BUILD_ROOT" +} + function micropython_version { - echo "MICROPY_GIT_TAG=$MICROPYTHON_VERSION, $BOARD_NAME $TAG_OR_SHA" >> $GITHUB_ENV + BOARD=$1 + echo "MICROPY_GIT_TAG=$MICROPYTHON_VERSION, $BOARD $TAG_OR_SHA" >> $GITHUB_ENV echo "MICROPY_GIT_HASH=$MICROPYTHON_VERSION-$TAG_OR_SHA" >> $GITHUB_ENV } -function cmake_configure { - cmake -S micropython/ports/rp2 -B build-$BOARD_NAME \ +function ci_cmake_configure { + BOARD=$1 + TOOLS_DIR="$CI_BUILD_ROOT/tools" + MICROPY_BOARD_DIR=$CI_PROJECT_ROOT/boards/$BOARD + if [ ! -f "$MICROPY_BOARD_DIR/mpconfigboard.cmake" ]; then + log_warning "Invalid board: \"$BOARD\". Run with ci_cmake_configure ." + return 1 + fi + BUILD_DIR="$CI_BUILD_ROOT/build-$BOARD" + cmake -S $CI_BUILD_ROOT/micropython/ports/rp2 -B "$BUILD_DIR" \ + -DPICOTOOL_FORCE_FETCH_FROM_GIT=1 \ -DPICO_BUILD_DOCS=0 \ -DPICO_NO_COPRO_DIS=1 \ - -DUSER_C_MODULES=$USER_C_MODULES \ - -DMICROPY_BOARD_DIR=$MICROPY_BOARD_DIR \ - -DMICROPY_BOARD=$MICROPY_BOARD \ - -DMICROPY_BOARD_VARIANT=$MICROPY_BOARD_VARIANT \ + -DPICOTOOL_FETCH_FROM_GIT_PATH="$TOOLS_DIR/picotool" \ + -DPIMORONI_PICO_PATH="$CI_BUILD_ROOT/pimoroni-pico" \ + -DPIMORONI_TOOLS_DIR="$TOOLS_DIR" \ + -DUSER_C_MODULES="$MICROPY_BOARD_DIR/usermodules.cmake" \ + -DMICROPY_BOARD_DIR="$MICROPY_BOARD_DIR" \ + -DMICROPY_BOARD="$BOARD" \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache } -function cmake_build { +function ci_cmake_build { + BOARD=$1 + MICROPY_BOARD_DIR=$CI_PROJECT_ROOT/boards/$BOARD + if [ ! -f "$MICROPY_BOARD_DIR/mpconfigboard.cmake" ]; then + log_warning "Invalid board: \"$BOARD\". Run with ci_cmake_build ." + return 1 + fi + BUILD_DIR="$CI_BUILD_ROOT/build-$BOARD" ccache --zero-stats || true - cmake --build build-$BOARD_NAME -j 2 + cmake --build $BUILD_DIR -j 2 ccache --show-stats || true - cd build-$BOARD_NAME - cp firmware.uf2 $RELEASE_FILE.uf2 + + log_inform "Copying .uf2 to $(pwd)/$BOARD.uf2" + cp "$BUILD_DIR/firmware.uf2" $BOARD.uf2 + + if [ -f "$BUILD_DIR/firmware-with-filesystem.uf2" ]; then + log_inform "Copying -with-filesystem .uf2 to $(pwd)/$BOARD-with-filesystem.uf2" + cp "$BUILD_DIR/firmware-with-filesystem.uf2" $BOARD-with-filesystem.uf2 + fi } + +if [ -z ${CI_USE_ENV+x} ] || [ -z ${CI_PROJECT_ROOT+x} ] || [ -z ${CI_BUILD_ROOT+x} ]; then + SCRIPT_PATH="$(dirname $0)" + CI_PROJECT_ROOT=$(realpath "$SCRIPT_PATH/..") + CI_BUILD_ROOT=$(pwd) +fi + +ci_debug \ No newline at end of file diff --git a/micropython/examples/pico_jumbo/big_blink.py b/examples/pico_jumbo/big_blink.py similarity index 100% rename from micropython/examples/pico_jumbo/big_blink.py rename to examples/pico_jumbo/big_blink.py diff --git a/micropython/examples/pico_jumbo/big_button.py b/examples/pico_jumbo/big_button.py similarity index 100% rename from micropython/examples/pico_jumbo/big_button.py rename to examples/pico_jumbo/big_button.py diff --git a/micropython/examples/pico_jumbo/big_toggle.py b/examples/pico_jumbo/big_toggle.py similarity index 100% rename from micropython/examples/pico_jumbo/big_toggle.py rename to examples/pico_jumbo/big_toggle.py diff --git a/micropython/examples/pico_plus_2/breakouts/bme68x-breakout.py b/examples/pico_plus_2/breakouts/bme68x-breakout.py similarity index 100% rename from micropython/examples/pico_plus_2/breakouts/bme68x-breakout.py rename to examples/pico_plus_2/breakouts/bme68x-breakout.py diff --git a/micropython/examples/pico_plus_2/breakouts/lte-astronauts.py b/examples/pico_plus_2/breakouts/lte-astronauts.py similarity index 100% rename from micropython/examples/pico_plus_2/breakouts/lte-astronauts.py rename to examples/pico_plus_2/breakouts/lte-astronauts.py diff --git a/micropython/examples/pico_plus_2/breakouts/lte-breakout.py b/examples/pico_plus_2/breakouts/lte-breakout.py similarity index 100% rename from micropython/examples/pico_plus_2/breakouts/lte-breakout.py rename to examples/pico_plus_2/breakouts/lte-breakout.py diff --git a/micropython/examples/pico_plus_2/breakouts/lte-catfacts.py b/examples/pico_plus_2/breakouts/lte-catfacts.py similarity index 100% rename from micropython/examples/pico_plus_2/breakouts/lte-catfacts.py rename to examples/pico_plus_2/breakouts/lte-catfacts.py diff --git a/micropython/examples/pico_plus_2/breakouts/rm2-breakout-catfacts.py b/examples/pico_plus_2/breakouts/rm2-breakout-catfacts.py similarity index 100% rename from micropython/examples/pico_plus_2/breakouts/rm2-breakout-catfacts.py rename to examples/pico_plus_2/breakouts/rm2-breakout-catfacts.py diff --git a/micropython/examples/pico_plus_2/breakouts/scd41-breakout.py b/examples/pico_plus_2/breakouts/scd41-breakout.py similarity index 100% rename from micropython/examples/pico_plus_2/breakouts/scd41-breakout.py rename to examples/pico_plus_2/breakouts/scd41-breakout.py diff --git a/micropython/examples/pico_plus_2/breakouts/secrets.py b/examples/pico_plus_2/breakouts/secrets.py similarity index 100% rename from micropython/examples/pico_plus_2/breakouts/secrets.py rename to examples/pico_plus_2/breakouts/secrets.py diff --git a/micropython/examples/pico_plus_2/button.py b/examples/pico_plus_2/button.py similarity index 100% rename from micropython/examples/pico_plus_2/button.py rename to examples/pico_plus_2/button.py diff --git a/micropython/examples/pico_plus_2/onboard_led.py b/examples/pico_plus_2/onboard_led.py similarity index 100% rename from micropython/examples/pico_plus_2/onboard_led.py rename to examples/pico_plus_2/onboard_led.py diff --git a/micropython/examples/pico_plus_2_w/astronauts.py b/examples/pico_plus_2_w/astronauts.py similarity index 100% rename from micropython/examples/pico_plus_2_w/astronauts.py rename to examples/pico_plus_2_w/astronauts.py diff --git a/micropython/examples/pico_plus_2_w/button.py b/examples/pico_plus_2_w/button.py similarity index 100% rename from micropython/examples/pico_plus_2_w/button.py rename to examples/pico_plus_2_w/button.py diff --git a/micropython/examples/pico_plus_2_w/catfacts.py b/examples/pico_plus_2_w/catfacts.py similarity index 100% rename from micropython/examples/pico_plus_2_w/catfacts.py rename to examples/pico_plus_2_w/catfacts.py diff --git a/micropython/examples/pico_plus_2_w/onboard_led.py b/examples/pico_plus_2_w/onboard_led.py similarity index 100% rename from micropython/examples/pico_plus_2_w/onboard_led.py rename to examples/pico_plus_2_w/onboard_led.py diff --git a/micropython/examples/pico_plus_2_w/secrets.py b/examples/pico_plus_2_w/secrets.py similarity index 100% rename from micropython/examples/pico_plus_2_w/secrets.py rename to examples/pico_plus_2_w/secrets.py diff --git a/micropython/examples/plasma_2350/breakouts/rm2-breakout-catfacts.py b/examples/plasma_2350/breakouts/rm2-breakout-catfacts.py similarity index 100% rename from micropython/examples/plasma_2350/breakouts/rm2-breakout-catfacts.py rename to examples/plasma_2350/breakouts/rm2-breakout-catfacts.py diff --git a/micropython/examples/plasma_2350/breakouts/secrets.py b/examples/plasma_2350/breakouts/secrets.py similarity index 100% rename from micropython/examples/plasma_2350/breakouts/secrets.py rename to examples/plasma_2350/breakouts/secrets.py diff --git a/micropython/examples/plasma_2350/breakouts/trackball-breakout.py b/examples/plasma_2350/breakouts/trackball-breakout.py similarity index 100% rename from micropython/examples/plasma_2350/breakouts/trackball-breakout.py rename to examples/plasma_2350/breakouts/trackball-breakout.py diff --git a/micropython/examples/plasma_2350/button_control.py b/examples/plasma_2350/button_control.py similarity index 100% rename from micropython/examples/plasma_2350/button_control.py rename to examples/plasma_2350/button_control.py diff --git a/micropython/examples/plasma_2350/buttons.py b/examples/plasma_2350/buttons.py similarity index 100% rename from micropython/examples/plasma_2350/buttons.py rename to examples/plasma_2350/buttons.py diff --git a/micropython/examples/plasma_2350/rainbow.py b/examples/plasma_2350/rainbow.py similarity index 100% rename from micropython/examples/plasma_2350/rainbow.py rename to examples/plasma_2350/rainbow.py diff --git a/micropython/examples/plasma_2350/rgb_led.py b/examples/plasma_2350/rgb_led.py similarity index 100% rename from micropython/examples/plasma_2350/rgb_led.py rename to examples/plasma_2350/rgb_led.py diff --git a/micropython/examples/plasma_2350/single_colour.py b/examples/plasma_2350/single_colour.py similarity index 100% rename from micropython/examples/plasma_2350/single_colour.py rename to examples/plasma_2350/single_colour.py diff --git a/micropython/examples/plasma_2350_w/cheerlights.py b/examples/plasma_2350_w/cheerlights.py similarity index 100% rename from micropython/examples/plasma_2350_w/cheerlights.py rename to examples/plasma_2350_w/cheerlights.py diff --git a/micropython/examples/plasma_2350_w/html/index.html b/examples/plasma_2350_w/html/index.html similarity index 100% rename from micropython/examples/plasma_2350_w/html/index.html rename to examples/plasma_2350_w/html/index.html diff --git a/micropython/examples/plasma_2350_w/secrets.py b/examples/plasma_2350_w/secrets.py similarity index 100% rename from micropython/examples/plasma_2350_w/secrets.py rename to examples/plasma_2350_w/secrets.py diff --git a/micropython/examples/plasma_2350_w/webpage.py b/examples/plasma_2350_w/webpage.py similarity index 100% rename from micropython/examples/plasma_2350_w/webpage.py rename to examples/plasma_2350_w/webpage.py diff --git a/micropython/examples/tiny_2350/breakouts/bme688-breakout.py b/examples/tiny_2350/breakouts/bme688-breakout.py similarity index 100% rename from micropython/examples/tiny_2350/breakouts/bme688-breakout.py rename to examples/tiny_2350/breakouts/bme688-breakout.py diff --git a/micropython/examples/tiny_2350/breakouts/scd41-breakout.py b/examples/tiny_2350/breakouts/scd41-breakout.py similarity index 100% rename from micropython/examples/tiny_2350/breakouts/scd41-breakout.py rename to examples/tiny_2350/breakouts/scd41-breakout.py diff --git a/micropython/examples/tiny_2350/buttons.py b/examples/tiny_2350/buttons.py similarity index 100% rename from micropython/examples/tiny_2350/buttons.py rename to examples/tiny_2350/buttons.py diff --git a/micropython/examples/tiny_2350/rgb_led.py b/examples/tiny_2350/rgb_led.py similarity index 100% rename from micropython/examples/tiny_2350/rgb_led.py rename to examples/tiny_2350/rgb_led.py From 7a087a85674a111340d59f1183844c615ed05e48 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 13:06:41 +0000 Subject: [PATCH 31/38] CI: Ignore non-existent with-filesystem builds. Move file rename busywork into micropython.sh. --- .github/workflows/micropython.yml | 29 ++++++++++++++--------------- ci/micropython.sh | 12 ++++++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index eefbda6..894a4a3 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -23,7 +23,7 @@ jobs: env: # MicroPython version will be contained in github.event.release.tag_name for releases - RELEASE_FILE: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython + CI_RELEASE_FILENAME: ${{ matrix.name }}-${{ github.event.release.tag_name || github.sha }}-micropython CI_PROJECT_ROOT: ${{ github.workspace }}/src-${{ github.sha }} CI_BUILD_ROOT: ${{ github.workspace }} CI_USE_ENV: 1 @@ -75,29 +75,28 @@ jobs: python3 -m venv "$CI_BUILD_ROOT/.dir2uf2" source "$CI_BUILD_ROOT/.dir2uf2/bin/activate" ci_cmake_build ${{ matrix.name }} - mv "$CI_BUILD_ROOT/${{ matrix.name }}.uf2" "$CI_BUILD_ROOT/$RELEASE_FILE.uf2" - mv "$CI_BUILD_ROOT/${{ matrix.name }}-with-filesystem.uf2" "$CI_BUILD_ROOT/$RELEASE_FILE-with-filesystem.uf2" - name: "Artifacts: Upload .uf2" uses: actions/upload-artifact@v4 with: - name: ${{ env.RELEASE_FILE }}.uf2 - path: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2 - - - name: "Artifacts: Upload .uf2 (With Filesystem)" - uses: actions/upload-artifact@v4 - with: - name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 - path: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}-with-filesystem.uf2 + name: ${{ env.CI_RELEASE_FILENAME }}.uf2 + path: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}.uf2 - name: "Release: Upload .uf2" if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: - files: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}.uf2 + files: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}.uf2 + + - name: "Artifacts: Upload .uf2 (With Filesystem)" + uses: actions/upload-artifact@v4 + with: + if-no-files-found: ignore + name: ${{ env.CI_RELEASE_FILENAME }}-with-filesystem.uf2 + path: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}-with-filesystem.uf2 - name: "Release: Upload .uf2 (With Filesystem)" if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: - files: ${{ env.CI_BUILD_ROOT }}/${{ env.RELEASE_FILE }}-with-filesystem.uf2 \ No newline at end of file + files: ${{ env.CI_BUILD_ROOT }}/${{ env.CI_RELEASE_FILENAME }}-with-filesystem.uf2 \ No newline at end of file diff --git a/ci/micropython.sh b/ci/micropython.sh index 4b6565b..64951ed 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -118,12 +118,16 @@ function ci_cmake_build { cmake --build $BUILD_DIR -j 2 ccache --show-stats || true - log_inform "Copying .uf2 to $(pwd)/$BOARD.uf2" - cp "$BUILD_DIR/firmware.uf2" $BOARD.uf2 + if [ -z ${CI_RELEASE_FILENAME+x} ]; then + $CI_RELEASE_FILENAME=$BOARD + fi + + log_inform "Copying .uf2 to $(pwd)/$CI_RELEASE_FILENAME.uf2" + cp "$BUILD_DIR/firmware.uf2" $CI_RELEASE_FILENAME.uf2 if [ -f "$BUILD_DIR/firmware-with-filesystem.uf2" ]; then - log_inform "Copying -with-filesystem .uf2 to $(pwd)/$BOARD-with-filesystem.uf2" - cp "$BUILD_DIR/firmware-with-filesystem.uf2" $BOARD-with-filesystem.uf2 + log_inform "Copying -with-filesystem .uf2 to $(pwd)/$CI_RELEASE_FILENAME-with-filesystem.uf2" + cp "$BUILD_DIR/firmware-with-filesystem.uf2" $CI_RELEASE_FILENAME-with-filesystem.uf2 fi } From c6602aafa27f192faf47dadd1e721ff837ca8204 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 5 Mar 2025 14:04:08 +0000 Subject: [PATCH 32/38] CI: Enable py_decl filesystem overlap check. --- boards/common.cmake | 12 ++++++++---- boards/pimoroni_pico_plus2/mpconfigboard.cmake | 2 +- boards/pimoroni_plasma2350/mpconfigboard.cmake | 1 + boards/pimoroni_tiny2350/mpconfigboard.cmake | 2 ++ boards/rpi_pico2/mpconfigboard.cmake | 4 +++- boards/rpi_pico2_w/mpconfigboard.cmake | 4 +++- boards/rpi_pico2b/mpconfigboard.cmake | 2 ++ 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/boards/common.cmake b/boards/common.cmake index 50bac0f..c590385 100644 --- a/boards/common.cmake +++ b/boards/common.cmake @@ -7,10 +7,6 @@ find_package (Python COMPONENTS Interpreter Development) message("dir2uf2/py_decl: Using Python ${Python_EXECUTABLE}") MESSAGE("dir2uf2/py_decl: Using pimoroni tools dir ${PIMORONI_TOOLS_DIR}") -# Convert supplies paths to absolute, for a quieter life -get_filename_component(PIMORONI_UF2_MANIFEST ${PIMORONI_UF2_MANIFEST} REALPATH) -get_filename_component(PIMORONI_UF2_DIR ${PIMORONI_UF2_DIR} REALPATH) - if (EXISTS "${PIMORONI_TOOLS_DIR}/py_decl/py_decl.py") MESSAGE("py_decl: py_decl.py found, will verify uf2.") add_custom_target("${MICROPY_TARGET}-verify" ALL @@ -21,6 +17,12 @@ if (EXISTS "${PIMORONI_TOOLS_DIR}/py_decl/py_decl.py") ) endif() +if(DEFINED PIMORONI_UF2_MANIFEST AND DEFINED PIMORONI_UF2_DIR) + +# Convert supplies paths to absolute, for a quieter life +get_filename_component(PIMORONI_UF2_MANIFEST ${PIMORONI_UF2_MANIFEST} REALPATH) +get_filename_component(PIMORONI_UF2_DIR ${PIMORONI_UF2_DIR} REALPATH) + if (EXISTS "${PIMORONI_TOOLS_DIR}/dir2uf2/dir2uf2" AND EXISTS "${PIMORONI_UF2_MANIFEST}" AND EXISTS "${PIMORONI_UF2_DIR}") MESSAGE("dir2uf2: Using manifest ${PIMORONI_UF2_MANIFEST}.") MESSAGE("dir2uf2: Using root ${PIMORONI_UF2_DIR}.") @@ -34,4 +36,6 @@ if (EXISTS "${PIMORONI_TOOLS_DIR}/dir2uf2/dir2uf2" AND EXISTS "${PIMORONI_UF2_MA else() MESSAGE("dir2uf2: Could not find manifest ${PIMORONI_UF2_MANIFEST}") MESSAGE(" and/or root ${PIMORONI_UF2_DIR}.") +endif() + endif() \ No newline at end of file diff --git a/boards/pimoroni_pico_plus2/mpconfigboard.cmake b/boards/pimoroni_pico_plus2/mpconfigboard.cmake index 63092b6..999402a 100644 --- a/boards/pimoroni_pico_plus2/mpconfigboard.cmake +++ b/boards/pimoroni_pico_plus2/mpconfigboard.cmake @@ -36,4 +36,4 @@ set(MICROPY_BLUETOOTH_BTSTACK ON) # MICROPY_PY_BLUETOOTH_CYW43 = 1 set(MICROPY_PY_BLUETOOTH_CYW43 ON) - +include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) diff --git a/boards/pimoroni_plasma2350/mpconfigboard.cmake b/boards/pimoroni_plasma2350/mpconfigboard.cmake index 1516676..34e4205 100644 --- a/boards/pimoroni_plasma2350/mpconfigboard.cmake +++ b/boards/pimoroni_plasma2350/mpconfigboard.cmake @@ -35,3 +35,4 @@ set(MICROPY_BLUETOOTH_BTSTACK ON) # MICROPY_PY_BLUETOOTH_CYW43 = 1 set(MICROPY_PY_BLUETOOTH_CYW43 ON) +include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) diff --git a/boards/pimoroni_tiny2350/mpconfigboard.cmake b/boards/pimoroni_tiny2350/mpconfigboard.cmake index db6a8b3..a8718d6 100644 --- a/boards/pimoroni_tiny2350/mpconfigboard.cmake +++ b/boards/pimoroni_tiny2350/mpconfigboard.cmake @@ -6,3 +6,5 @@ set(PICO_PLATFORM "rp2350") set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) set(MICROPY_C_HEAP_SIZE 4096) + +include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) diff --git a/boards/rpi_pico2/mpconfigboard.cmake b/boards/rpi_pico2/mpconfigboard.cmake index 1e97f02..adbe6ba 100644 --- a/boards/rpi_pico2/mpconfigboard.cmake +++ b/boards/rpi_pico2/mpconfigboard.cmake @@ -13,4 +13,6 @@ if (PICO_CYW43_SUPPORTED) set(PICO_PINS_CSV_NAME pins_cyw43.csv) endif() -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) \ No newline at end of file +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) + +include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) diff --git a/boards/rpi_pico2_w/mpconfigboard.cmake b/boards/rpi_pico2_w/mpconfigboard.cmake index 3dd942c..4ba1101 100644 --- a/boards/rpi_pico2_w/mpconfigboard.cmake +++ b/boards/rpi_pico2_w/mpconfigboard.cmake @@ -11,4 +11,6 @@ set(MICROPY_PY_LWIP ON) include(enable_cyw43.cmake) # Board specific version of the frozen manifest -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) \ No newline at end of file +set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) + +include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) diff --git a/boards/rpi_pico2b/mpconfigboard.cmake b/boards/rpi_pico2b/mpconfigboard.cmake index 6ff6ef9..7114d5d 100644 --- a/boards/rpi_pico2b/mpconfigboard.cmake +++ b/boards/rpi_pico2b/mpconfigboard.cmake @@ -10,3 +10,5 @@ set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) set(MICROPY_C_HEAP_SIZE 4096) set(PICO_NUM_GPIOS 48) + +include(${CMAKE_CURRENT_LIST_DIR}/../common.cmake) From 5ff24aabe70435498e6c9f70f2e1de7ef44117e9 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 11 Mar 2025 10:06:14 +0000 Subject: [PATCH 33/38] CI: Bump to latest rebase. Should include changes to PSRAM, including a 4K flash saving on non-PSRAM builds. --- ci/micropython.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/micropython.sh b/ci/micropython.sh index 64951ed..7ba4c2b 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -1,7 +1,7 @@ export TERM=${TERM:="xterm-256color"} MICROPYTHON_FLAVOUR="pimoroni" -MICROPYTHON_VERSION="feature/pico2_w_2025" +MICROPYTHON_VERSION="feature/pico2_w_2025_3_11" PIMORONI_PICO_FLAVOUR="pimoroni" PIMORONI_PICO_VERSION="feature/picovector2-and-layers" @@ -137,4 +137,4 @@ if [ -z ${CI_USE_ENV+x} ] || [ -z ${CI_PROJECT_ROOT+x} ] || [ -z ${CI_BUILD_ROOT CI_BUILD_ROOT=$(pwd) fi -ci_debug \ No newline at end of file +ci_debug From 4dbd106611e15a236592dbc903b6e6bd24f8cd5c Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 25 Mar 2025 12:54:30 +0000 Subject: [PATCH 34/38] CI: Fix board manifest PORT_DIR var. --- boards/manifest_pico2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/manifest_pico2.py b/boards/manifest_pico2.py index ca9171f..f266753 100644 --- a/boards/manifest_pico2.py +++ b/boards/manifest_pico2.py @@ -1,5 +1,5 @@ # micropython/ports/rp2/../../../ -MODULES_PY = "{PORT_DIR}/../../../pimoroni-pico/micropython/modules_py" +MODULES_PY = "$(PORT_DIR)/../../../pimoroni-pico/micropython/modules_py" # SD Card require("sdcard") From 554817d5fc660c6a1c712c9452101f4501076fcf Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 28 Mar 2025 15:35:45 +0000 Subject: [PATCH 35/38] CI: Bump to latest rebase. Should include refined PSRAM changes, a version bump to LwIP and other MicroPython tweaks. --- ci/micropython.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/micropython.sh b/ci/micropython.sh index 7ba4c2b..fc37520 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -1,7 +1,7 @@ export TERM=${TERM:="xterm-256color"} MICROPYTHON_FLAVOUR="pimoroni" -MICROPYTHON_VERSION="feature/pico2_w_2025_3_11" +MICROPYTHON_VERSION="pico2_w_2025_3_28" PIMORONI_PICO_FLAVOUR="pimoroni" PIMORONI_PICO_VERSION="feature/picovector2-and-layers" From d7a50b9916242d63626785aeb6fbf4a204f7af4b Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 9 Apr 2025 09:56:49 +0100 Subject: [PATCH 36/38] CI: Bump to MicroPython branch with sleep fix. --- ci/micropython.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/micropython.sh b/ci/micropython.sh index fc37520..13bfcf0 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -1,7 +1,7 @@ export TERM=${TERM:="xterm-256color"} MICROPYTHON_FLAVOUR="pimoroni" -MICROPYTHON_VERSION="pico2_w_2025_3_28" +MICROPYTHON_VERSION="pico2_w_2025_04_09" PIMORONI_PICO_FLAVOUR="pimoroni" PIMORONI_PICO_VERSION="feature/picovector2-and-layers" From 3419f0ba0791f7f86ce1a426bef94c9e7986dded Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 10 Sep 2025 15:21:50 +0100 Subject: [PATCH 37/38] CI: Fix ci_cmake_build when CI_RELEASE_FILENAME is unset. --- ci/micropython.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/micropython.sh b/ci/micropython.sh index 13bfcf0..84d2851 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -119,7 +119,7 @@ function ci_cmake_build { ccache --show-stats || true if [ -z ${CI_RELEASE_FILENAME+x} ]; then - $CI_RELEASE_FILENAME=$BOARD + CI_RELEASE_FILENAME="$BOARD" fi log_inform "Copying .uf2 to $(pwd)/$CI_RELEASE_FILENAME.uf2" From c809cf37e22eba80b53ef2a3a5cd3e2463d8c4db Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Fri, 19 Sep 2025 10:39:32 +0100 Subject: [PATCH 38/38] CI: Bump to rebase on MicroPython 1.26. --- ci/micropython.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/micropython.sh b/ci/micropython.sh index 84d2851..a8a2daa 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -1,7 +1,7 @@ export TERM=${TERM:="xterm-256color"} MICROPYTHON_FLAVOUR="pimoroni" -MICROPYTHON_VERSION="pico2_w_2025_04_09" +MICROPYTHON_VERSION="pico2_w_2025_09_19" PIMORONI_PICO_FLAVOUR="pimoroni" PIMORONI_PICO_VERSION="feature/picovector2-and-layers"