Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pico Plus 2: LTE and WiFi Support #10

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types: [created]

env:
MICROPYTHON_VERSION: feature/psram
MICROPYTHON_VERSION: feature/spicy-wifi
MICROPYTHON_FLAVOUR: pimoroni
PIMORONI_PICO_VERSION: feature/sdk-2.0.0

Expand All @@ -21,15 +21,24 @@ 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
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

Expand Down Expand Up @@ -70,7 +79,7 @@ jobs:
- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2020-q2'
release: '13.3.Rel1'

- name: Install CCache
run: |
Expand Down
8 changes: 8 additions & 0 deletions micropython/board/PIMORONI_PICO_PLUS2/manifest-wireless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require("bundle-networking")

# Bluetooth
require("aioble")

include("manifest.py")

freeze("$(BOARD_DIR)/../../modules_py", "lte.py")
79 changes: 75 additions & 4 deletions micropython/board/PIMORONI_PICO_PLUS2/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,79 @@
// 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

#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)

// 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 Pico Plus 2"

#endif
Original file line number Diff line number Diff line change
@@ -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"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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})
136 changes: 136 additions & 0 deletions micropython/board/PIMORONI_PICO_PLUS2/pimoroni_pico_plus2w_rp2350.h
Original file line number Diff line number Diff line change
@@ -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_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
#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
11 changes: 10 additions & 1 deletion micropython/board/PIMORONI_PICO_PLUS2/pins.csv
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,13 @@ GP44,GPIO44
GP45,GPIO45
GP46,GPIO46
GP47,GPIO47
LED,GPIO25
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
SPICE_RESET,GPIO35
SPICE_PWRKEY,GPIO36
8 changes: 8 additions & 0 deletions micropython/board/PIMORONI_PLASMA2350/manifest-wireless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require("bundle-networking")

# Bluetooth
require("aioble")

include("manifest.py")

freeze("$(BOARD_DIR)/../../modules_py", "lte.py")
Loading