From 5543f1ef40b6a9232b01e1a3420aba733b04b455 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 27 Feb 2024 11:14:05 +0000 Subject: [PATCH 1/4] CI: Bump MicroPython to rp2-add-rp2350. CI tracking the unmerged RP2350 support branch. --- .github/workflows/micropython.yml | 3 ++- ci/micropython.sh | 6 ++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index e75fdf441..8711bd438 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -7,7 +7,8 @@ on: types: [created] env: - MICROPYTHON_VERSION: v1.23.0 + MICROPYTHON_VERSION: rp2-add-rp2350 + MICROPYTHON_FLAVOUR: dpgeorge jobs: build: diff --git a/ci/micropython.sh b/ci/micropython.sh index 2f598c084..3f044e766 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -13,11 +13,9 @@ function log_warning { } function micropython_clone { - log_inform "Using MicroPython $MICROPYTHON_VERSION" - git clone https://github.com/micropython/micropython + log_inform "Using MicroPython $MICROPYTHON_FLAVOUR/$MICROPYTHON_VERSION" + git clone https://github.com/$MICROPYTHON_FLAVOUR/micropython -b $MICROPYTHON_VERSION --depth=1 cd micropython - git checkout $MICROPYTHON_VERSION - git cherry-pick -n 932f76c6ba64c5a3e68de3324556d9979f09303b git submodule update --init lib/pico-sdk git submodule update --init lib/cyw43-driver git submodule update --init lib/lwip From ec4ca1d42fe9e34c160e2c12e1eff5b9422b0464 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 12 Aug 2024 17:20:17 +0100 Subject: [PATCH 2/4] Wakeup: Port wakeup runtime functionality to SDK 2.0.0. --- .../{pico_sdk.patch => pico_sdk.off.patch} | 0 .../{pico_sdk.patch => pico_sdk.off.patch} | 0 micropython/modules/wakeup/wakeup.c | 36 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) rename micropython/board/PICO_W_ENVIRO/{pico_sdk.patch => pico_sdk.off.patch} (100%) rename micropython/board/PICO_W_INKY/{pico_sdk.patch => pico_sdk.off.patch} (100%) diff --git a/micropython/board/PICO_W_ENVIRO/pico_sdk.patch b/micropython/board/PICO_W_ENVIRO/pico_sdk.off.patch similarity index 100% rename from micropython/board/PICO_W_ENVIRO/pico_sdk.patch rename to micropython/board/PICO_W_ENVIRO/pico_sdk.off.patch diff --git a/micropython/board/PICO_W_INKY/pico_sdk.patch b/micropython/board/PICO_W_INKY/pico_sdk.off.patch similarity index 100% rename from micropython/board/PICO_W_INKY/pico_sdk.patch rename to micropython/board/PICO_W_INKY/pico_sdk.off.patch diff --git a/micropython/modules/wakeup/wakeup.c b/micropython/modules/wakeup/wakeup.c index 69f2422c3..0b9d523e8 100644 --- a/micropython/modules/wakeup/wakeup.c +++ b/micropython/modules/wakeup/wakeup.c @@ -1,4 +1,25 @@ #include "wakeup.h" +#include "hardware/gpio.h" +#include "wakeup.config.hpp" +#include "pico/runtime_init.h" + + +uint32_t runtime_wakeup_gpio_state = 0; + +// Pins to toggle on wakeup +#ifndef PICO_WAKEUP_PIN_MASK +#define PICO_WAKEUP_PIN_MASK ((0b1 << 2) | (0b1 << 6)) +#endif + +// Direction +#ifndef PICO_WAKEUP_PIN_DIR +#define PICO_WAKEUP_PIN_DIR ((0b1 << 2) | (0b1 << 6)) +#endif + +// Value +#ifndef PICO_WAKEUP_PIN_VALUE +#define PICO_WAKEUP_PIN_VALUE ((0b1 << 2) | (0b1 << 6)) +#endif static MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_get_gpio_state_obj, Wakeup_get_gpio_state); static MP_DEFINE_CONST_FUN_OBJ_0(Wakeup_reset_gpio_state_obj, Wakeup_reset_gpio_state); @@ -23,4 +44,17 @@ const mp_obj_module_t wakeup_user_cmodule = { MP_REGISTER_MODULE(MP_QSTR_wakeup, wakeup_user_cmodule, MODULE_WAKEUP_ENABLED); #else MP_REGISTER_MODULE(MP_QSTR_wakeup, wakeup_user_cmodule); -#endif \ No newline at end of file +#endif + +void runtime_init_latch(void) { + runtime_wakeup_gpio_state = gpio_get_all(); + + gpio_init_mask(PICO_WAKEUP_PIN_MASK); + gpio_set_dir_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_DIR); + gpio_put_masked(PICO_WAKEUP_PIN_MASK, PICO_WAKEUP_PIN_VALUE); +}; + +// After runtime_init_early_resets, PICO_RUNTIME_INIT_EARLY_RESETS ? +PICO_RUNTIME_INIT_FUNC_HW(runtime_init_latch, "00101"); +// Too early? +// PICO_RUNTIME_INIT_FUNC_HW(runtime_init_latch, PICO_RUNTIME_INIT_EARLIEST); From a0ef33a5543d748a307b019b189050ea302bf6ab Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Wed, 7 Aug 2024 22:36:59 +0100 Subject: [PATCH 3/4] PicoGraphics: Support for Explorer. --- drivers/st7789/st7789.hpp | 3 ++- micropython/modules/picographics/picographics.c | 1 + micropython/modules/picographics/picographics.cpp | 14 +++++++++++++- micropython/modules/picographics/picographics.h | 3 ++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/st7789/st7789.hpp b/drivers/st7789/st7789.hpp index e4ad2ee6f..52369256f 100644 --- a/drivers/st7789/st7789.hpp +++ b/drivers/st7789/st7789.hpp @@ -58,9 +58,10 @@ namespace pimoroni { cs(pins.cs), dc(pins.dc), wr_sck(pins.wr_sck), rd_sck(pins.rd_sck), d0(pins.d0), bl(pins.bl) { parallel_pio = pio1; + pio_set_gpio_base(parallel_pio, d0 + 8 >= 32 ? 16 : 0); parallel_sm = pio_claim_unused_sm(parallel_pio, true); parallel_offset = pio_add_program(parallel_pio, &st7789_parallel_program); - + //gpio_init(wr_sck); //gpio_set_dir(wr_sck, GPIO_OUT); //gpio_set_function(wr_sck, GPIO_FUNC_SIO); diff --git a/micropython/modules/picographics/picographics.c b/micropython/modules/picographics/picographics.c index b1aeec19e..0074b55f0 100644 --- a/micropython/modules/picographics/picographics.c +++ b/micropython/modules/picographics/picographics.c @@ -157,6 +157,7 @@ static const mp_map_elem_t picographics_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DISPLAY_UNICORN_PACK), MP_ROM_INT(DISPLAY_UNICORN_PACK) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY_SCROLL_PACK), MP_ROM_INT(DISPLAY_SCROLL_PACK) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY_PICO_W_EXPLORER), MP_ROM_INT(DISPLAY_PICO_W_EXPLORER) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY_EXPLORER), MP_ROM_INT(DISPLAY_EXPLORER) }, { MP_ROM_QSTR(MP_QSTR_PEN_1BIT), MP_ROM_INT(PEN_1BIT) }, { MP_ROM_QSTR(MP_QSTR_PEN_P4), MP_ROM_INT(PEN_P4) }, diff --git a/micropython/modules/picographics/picographics.cpp b/micropython/modules/picographics/picographics.cpp index 4fe1e2d04..a55e8ad41 100644 --- a/micropython/modules/picographics/picographics.cpp +++ b/micropython/modules/picographics/picographics.cpp @@ -44,6 +44,13 @@ typedef struct _ModPicoGraphics_obj_t { bool get_display_settings(PicoGraphicsDisplay display, int &width, int &height, int &rotate, int &pen_type, PicoGraphicsBusType &bus_type) { switch(display) { + case DISPLAY_EXPLORER: + width = 320; + height = 240; + bus_type = BUS_PARALLEL; + if(rotate == -1) rotate = (int)Rotation::ROTATE_0; + if(pen_type == -1) pen_type = PEN_RGB565; + break; case DISPLAY_PICO_DISPLAY: width = 240; height = 135; @@ -335,6 +342,10 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size } else if (display == DISPLAY_PICO_W_EXPLORER) { spi_bus = {PIMORONI_SPI_DEFAULT_INSTANCE, 17, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, SPI_DEFAULT_MISO, 9}; } + } else if (bus_type == BUS_PARALLEL) { + if (display == DISPLAY_EXPLORER) { + parallel_bus = {27, 28, 30, 31, 32, 26}; + } } } @@ -349,7 +360,8 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size // TODO grab BUSY and RESET from ARG_extra_pins self->display = m_new_class(Inky73, width, height, (Rotation)rotate, spi_bus); - } else if (display == DISPLAY_TUFTY_2040) { + } else if (display == DISPLAY_TUFTY_2040 + || display == DISPLAY_EXPLORER) { self->display = m_new_class(ST7789, width, height, (Rotation)rotate, parallel_bus); } else if (display == DISPLAY_LCD_160X80) { diff --git a/micropython/modules/picographics/picographics.h b/micropython/modules/picographics/picographics.h index 1812a875f..655d336b7 100644 --- a/micropython/modules/picographics/picographics.h +++ b/micropython/modules/picographics/picographics.h @@ -30,7 +30,8 @@ enum PicoGraphicsDisplay { DISPLAY_STELLAR_UNICORN, DISPLAY_UNICORN_PACK, DISPLAY_SCROLL_PACK, - DISPLAY_PICO_W_EXPLORER + DISPLAY_PICO_W_EXPLORER, + DISPLAY_EXPLORER }; enum PicoGraphicsPenType { From 843db98a489d068e62b27664f7b6dabd8828dac4 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Mon, 16 Sep 2024 12:14:41 +0100 Subject: [PATCH 4/4] CI: Retarget to our psram branch. --- .github/workflows/micropython.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 8711bd438..167489183 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -7,8 +7,8 @@ on: types: [created] env: - MICROPYTHON_VERSION: rp2-add-rp2350 - MICROPYTHON_FLAVOUR: dpgeorge + MICROPYTHON_VERSION: feature/psram + MICROPYTHON_FLAVOUR: pimoroni jobs: build: