diff --git a/.github/workflows/micropython.yml b/.github/workflows/micropython.yml index 5026a8d..28e6fbc 100644 --- a/.github/workflows/micropython.yml +++ b/.github/workflows/micropython.yml @@ -19,26 +19,23 @@ jobs: strategy: matrix: include: - - name: pga2040 - board: pga2040 + - name: presto + board: presto + variant: modules: default - - name: pga2350 - board: pga2350 - modules: default - - name: pga2350-psram # Friendly-name for output files - board: pga2350 # / - variant: PSRAM # //mpconfigvariant_.cmake - modules: default # /modules/.cmake 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 PIMORONI_PICO_DIR: "${{ github.workspace }}/pimoroni-pico" - MICROPY_BOARD_DIR: "${{ github.workspace }}/src-${{ github.sha }}/${{ matrix.BOARD }}" USER_C_MODULES: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.cmake" + USER_FS_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.txt" + USER_FS_SOURCE: "${{ github.workspace }}/src-${{ github.sha }}/modules/littlefs" TAG_OR_SHA: ${{ github.event.release.tag_name || github.sha }} MICROPY_BOARD: ${{ matrix.board }} MICROPY_BOARD_VARIANT: ${{ matrix.variant }} + MICROPY_BOARD_DIR: "${{ github.workspace }}/src-${{ github.sha }}/${{ matrix.BOARD }}" + MICROPY_FROZEN_MANIFEST: "${{ github.workspace }}/src-${{ github.sha }}/modules/${{ matrix.modules }}.py" BOARD_NAME: ${{ matrix.name }} BUILD_TOOLS: src-${{ github.sha }}/ci/micropython.sh @@ -81,12 +78,19 @@ jobs: source $BUILD_TOOLS micropython_clone - - name: "Py_Decl: Checkout py_decl" + - name: "Py_Decl: Checkout" uses: actions/checkout@v4 with: repository: gadgetoid/py_decl ref: v0.0.2 path: py_decl + + - name: "dir2uf2: Checkout" + uses: actions/checkout@v4 + with: + repository: gadgetoid/dir2uf2 + ref: v0.0.7 + path: dir2uf2 - name: "MicroPython: Build MPY Cross" run: | @@ -106,24 +110,47 @@ jobs: source $BUILD_TOOLS cmake_build - - name: "Py_Decl: Verify 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: "dir2uf2: Append filesystem to .uf2" + shell: bash + run: | + python3 -m pip install littlefs-python==0.12.0 + ./dir2uf2/dir2uf2 --fs-compact --append-to build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 --manifest ${{env.USER_FS_MANIFEST}} --filename with-filesystem.uf2 ${{env.USER_FS_SOURCE}}/ + + - 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 + - name: "Artifacts: Upload .uf2 with filesystem" + uses: actions/upload-artifact@v4 + with: + name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 + path: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 + + - name: "Release: Upload .uf2" if: github.event_name == 'release' uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - asset_path: build-${{ matrix.name }}/firmware.uf2 + asset_path: build-${{ matrix.name }}/${{ env.RELEASE_FILE }}.uf2 upload_url: ${{ github.event.release.upload_url }} asset_name: ${{ env.RELEASE_FILE }}.uf2 + asset_content_type: application/octet-stream + + - name: "Release: Upload .uf2 with filesystem" + if: github.event_name == 'release' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + asset_path: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 + upload_url: ${{ github.event.release.upload_url }} + asset_name: ${{ env.RELEASE_FILE }}-with-filesystem.uf2 asset_content_type: application/octet-stream \ No newline at end of file diff --git a/ci/micropython.sh b/ci/micropython.sh index 0a4b53a..2cbff92 100644 --- a/ci/micropython.sh +++ b/ci/micropython.sh @@ -52,6 +52,7 @@ function cmake_configure { -DMICROPY_BOARD_DIR=$MICROPY_BOARD_DIR \ -DMICROPY_BOARD=$MICROPY_BOARD \ -DMICROPY_BOARD_VARIANT=$MICROPY_BOARD_VARIANT \ + -DMICROPY_FROZEN_MANIFEST=$MICROPY_FROZEN_MANIFEST \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache } diff --git a/modules/c/example/example.c b/modules/c/example/example.c deleted file mode 100644 index 68156b8..0000000 --- a/modules/c/example/example.c +++ /dev/null @@ -1,37 +0,0 @@ -#include - -MP_DEFINE_CONST_FUN_OBJ_1(example__del__obj, example__del__); - -MP_DEFINE_CONST_FUN_OBJ_3(example_method_obj, example_method); - -// Class Methods -static const mp_rom_map_elem_t example_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&example__del__obj) }, - { MP_ROM_QSTR(MP_QSTR_mul), MP_ROM_PTR(&example_method_obj) } -}; - -static MP_DEFINE_CONST_DICT(example_locals_dict, example_locals_dict_table); - -MP_DEFINE_CONST_OBJ_TYPE( - Example_type, - MP_QSTR_Example, - MP_TYPE_FLAG_NONE, - make_new, example_make_new, - locals_dict, (mp_obj_dict_t*)&example_locals_dict -); - -// Module Methods -static const mp_map_elem_t example_globals_table[] = { - { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_example) }, // Module name - { MP_OBJ_NEW_QSTR(MP_QSTR_Example), (mp_obj_t)&Example_type }, // Class name & type -}; - -static MP_DEFINE_CONST_DICT(mp_module_example_globals, example_globals_table); - -const mp_obj_module_t example_user_c_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_example_globals, -}; - -// First argument should match the __name__ given in the globals table -MP_REGISTER_MODULE(MP_QSTR_example, example_user_c_module); \ No newline at end of file diff --git a/modules/c/example/example.cpp b/modules/c/example/example.cpp deleted file mode 100644 index b65268f..0000000 --- a/modules/c/example/example.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include // Required for allocating C classes into MicroPython heap with placement new - -class Example { - public: - Example () { - - } - - int mul(int a, int b) { - return a * b; - } - - ~Example () { - - } -}; - -// Explicitly typed variant of MP_OBJ_TO_PTR to make C++ happy -#define MP_OBJ_TO_PTR_T(o, t) ((t *)(o)) - -// Macro for assigning *self in class methods -#define __self__ MP_OBJ_TO_PTR_T(self_in, Example_obj_t) - - -extern "C" { -#include "example.h" - -typedef struct Example_obj_t { - mp_obj_base_t base; - void *pins; - Example *cls; -} Example_obj_t; - -mp_obj_t example_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - Example_obj_t *self = mp_obj_malloc_with_finaliser(Example_obj_t, &Example_type); - - // Use C++ "placement new" to place an instance of our C++ class in - // memory allocated by MicroPython's m_new. - self->cls = new(m_new(Example, 1)) Example(); - - return MP_OBJ_FROM_PTR(self); -} - -mp_obj_t example__del__(mp_obj_t self_in) { - // Explicitly call the destructor - // self->class->~Example(); - - // Or use delete - delete(__self__->cls); - - // Explicitly inform the GC that the memory is free - // Usually this object is deleted and the pointer goes out of scope - // and gets GC'd anyway so we don't *need* to do this. - m_del(Example, __self__->cls, 1); - - return mp_const_none; -} - -mp_obj_t example_method(mp_obj_t self_in, mp_obj_t a_in, mp_obj_t b_in) { - int a = mp_obj_get_int(a_in); - int b = mp_obj_get_int(b_in); - - int c = __self__->cls->mul(a, b); - - return mp_obj_new_int(c); -} -}; \ No newline at end of file diff --git a/modules/c/example/example.h b/modules/c/example/example.h deleted file mode 100644 index 085dcb2..0000000 --- a/modules/c/example/example.h +++ /dev/null @@ -1,8 +0,0 @@ -#include "py/runtime.h" - -extern const mp_obj_type_t Example_type; - -extern mp_obj_t example_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); -extern mp_obj_t example__del__(mp_obj_t self_in); - -extern mp_obj_t example_method(mp_obj_t self_in, mp_obj_t a_in, mp_obj_t b_in); \ No newline at end of file diff --git a/modules/c/example/micropython.cmake b/modules/c/example/micropython.cmake deleted file mode 100644 index 853de6e..0000000 --- a/modules/c/example/micropython.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Create an INTERFACE library for our CPP module. -add_library(usermod_pga_example INTERFACE) - -# Add our source files to the library. -target_sources(usermod_pga_example INTERFACE - ${CMAKE_CURRENT_LIST_DIR}/example.cpp - ${CMAKE_CURRENT_LIST_DIR}/example.c -) - -# Add the current directory as an include directory. -target_include_directories(usermod_pga_example INTERFACE - ${CMAKE_CURRENT_LIST_DIR} -) - -# Link our INTERFACE library to the usermod target. -target_link_libraries(usermod INTERFACE usermod_pga_example) \ No newline at end of file diff --git a/modules/c/presto/micropython.cmake b/modules/c/presto/micropython.cmake new file mode 100644 index 0000000..0a5ef3b --- /dev/null +++ b/modules/c/presto/micropython.cmake @@ -0,0 +1,24 @@ +set(MOD_NAME portal) +string(TOUPPER ${MOD_NAME} MOD_NAME_UPPER) +add_library(usermod_${MOD_NAME} INTERFACE) + +target_sources(usermod_${MOD_NAME} INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.c + ${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701.cpp + ${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/pico_graphics_pen_rgb565.cpp +) +pico_generate_pio_header(usermod_${MOD_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701_parallel.pio) +pico_generate_pio_header(usermod_${MOD_NAME} ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/st7701_timing.pio) + +target_include_directories(usermod_${MOD_NAME} INTERFACE + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_CURRENT_LIST_DIR}/../../../libraries/pico_graphics/ + ${CMAKE_CURRENT_LIST_DIR}/../../../drivers/st7701_portal/ +) + +target_compile_definitions(usermod_${MOD_NAME} INTERFACE + MODULE_PORTAL_ENABLED=1 +) + +target_link_libraries(usermod INTERFACE usermod_${MOD_NAME}) \ No newline at end of file diff --git a/modules/c/presto/presto.c b/modules/c/presto/presto.c new file mode 100644 index 0000000..e4a4134 --- /dev/null +++ b/modules/c/presto/presto.c @@ -0,0 +1,45 @@ +#include "presto.h" + + +/***** Methods *****/ + +MP_DEFINE_CONST_FUN_OBJ_1(Portal___del___obj, Portal___del__); +MP_DEFINE_CONST_FUN_OBJ_2(Portal_update_obj, Portal_update); + +/***** Binding of Methods *****/ + +static const mp_rom_map_elem_t Portal_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&Portal___del___obj) }, + { MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&Portal_update_obj) }, + + { MP_ROM_QSTR(MP_QSTR_WIDTH), MP_ROM_INT(WIDTH) }, + { MP_ROM_QSTR(MP_QSTR_HEIGHT), MP_ROM_INT(HEIGHT) }, +}; + +static MP_DEFINE_CONST_DICT(Portal_locals_dict, Portal_locals_dict_table); + + +MP_DEFINE_CONST_OBJ_TYPE( + Portal_type, + MP_QSTR_Portal, + MP_TYPE_FLAG_NONE, + make_new, Portal_make_new, + locals_dict, (mp_obj_dict_t*)&Portal_locals_dict +); + +/***** Globals Table *****/ +static const mp_map_elem_t portal_globals_table[] = { + { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_portal) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_Portal), (mp_obj_t)&Portal_type }, +}; + +static MP_DEFINE_CONST_DICT(mp_module_portal_globals, portal_globals_table); + +/***** Module Definition *****/ + +const mp_obj_module_t portal_user_cmodule = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&mp_module_portal_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_portal, portal_user_cmodule); \ No newline at end of file diff --git a/modules/c/presto/presto.cpp b/modules/c/presto/presto.cpp new file mode 100644 index 0000000..b9ffc69 --- /dev/null +++ b/modules/c/presto/presto.cpp @@ -0,0 +1,145 @@ +#include "drivers/st7701_portal/st7701.hpp" +#include "libraries/pico_graphics/pico_graphics.hpp" +#include "micropython/modules/util.hpp" +#include +#include + + +#include "hardware/structs/ioqspi.h" +#include "hardware/structs/qmi.h" +#include "hardware/structs/xip_ctrl.h" + + +using namespace pimoroni; + + +extern "C" { +#include "presto.h" +#include "py/builtin.h" +#include + +void __printf_debug_flush() { + for(auto i = 0u; i < 10; i++) { + sleep_ms(1); + mp_event_handle_nowait(); + } +} + +int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args); + +void portal_debug(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + int ret = mp_vprintf(&mp_plat_print, fmt, ap); + va_end(ap); + __printf_debug_flush(); + (void)ret; +} + +/***** Variables Struct *****/ +typedef struct _Portal_obj_t { + mp_obj_base_t base; + ST7701* portal; + uint16_t* next_fb; + uint16_t* curr_fb; +} _Portal_obj_t; + +typedef struct _ModPicoGraphics_obj_t { + mp_obj_base_t base; + PicoGraphics *graphics; + DisplayDriver *display; +} ModPicoGraphics_obj_t; + + + +void portal_core1_entry() { + multicore_fifo_push_blocking(0); // TODO: Remove, debug to signal core has actually started + + ST7701 *portal = (ST7701*)multicore_fifo_pop_blocking(); + + portal->init(); + multicore_fifo_push_blocking(0); // Todo handle issues here?*/ + while (1) __wfe(); +} + +#define stack_size 4096u +static uint32_t core1_stack[stack_size] = {0}; + +mp_obj_t Portal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + _Portal_obj_t *self = nullptr; + + enum { ARG_pio, ARG_sm, ARG_pins, ARG_common_pin, ARG_direction, ARG_counts_per_rev, ARG_count_microsteps, ARG_freq_divider }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_pio, MP_ARG_INT }, + { MP_QSTR_sm, MP_ARG_INT } + }; + + // Parse args. + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + portal_debug("malloc self\n"); + self = mp_obj_malloc_with_finaliser(_Portal_obj_t, &Portal_type); + + portal_debug("set fb pointers\n"); + self->curr_fb = m_new(uint16_t, 28800); // (uint16_t*)0x11000000; + self->next_fb = self->curr_fb; //(uint16_t*)0x11080000; + + portal_debug("m_new_class(ST7701...\n"); + ST7701 *portal = m_new_class(ST7701, WIDTH, HEIGHT, ROTATE_0, + SPIPins{spi1, LCD_CS, LCD_CLK, LCD_DAT, PIN_UNUSED, LCD_DC, BACKLIGHT}, + self->next_fb, + LCD_D0); + + self->portal = portal; + + portal_debug("launch core1\n"); + multicore_reset_core1(); + //multicore_launch_core1(portal_core1_entry); + // multicore_launch_core1 probably uses malloc for its stack, and will return but apparently not launch core1 on MicroPython + multicore_launch_core1_with_stack(portal_core1_entry, core1_stack, stack_size); + portal_debug("waiting for core1...\n"); + multicore_fifo_pop_blocking(); + portal_debug("core1 running...\n"); + + portal_debug("signal core1\n"); + multicore_fifo_push_blocking((uintptr_t)self->portal); + int res = multicore_fifo_pop_blocking(); + portal_debug("core1 returned\n"); + + //portal_debug("portal->init(): "); + //portal->init(); + //portal_debug("ok\n"); + + if(res != 0) { + mp_raise_msg(&mp_type_RuntimeError, "Portal: failed to start ST7701 on Core1."); + } + + return MP_OBJ_FROM_PTR(self); +} + +extern mp_obj_t Portal_update(mp_obj_t self_in, mp_obj_t graphics_in) { + _Portal_obj_t *self = MP_OBJ_TO_PTR2(self_in, _Portal_obj_t); + ModPicoGraphics_obj_t *picographics = MP_OBJ_TO_PTR2(graphics_in, ModPicoGraphics_obj_t); + + // Wait for any pending flip to finish + self->portal->wait_for_vsync(); + + self->portal->set_framebuffer(self->next_fb); + + // Flip the buffers + std::swap(self->next_fb, self->curr_fb); + + // Make sure PicoGraphics is drawing into our current front buffer + picographics->graphics->frame_buffer = (uint8_t *)self->next_fb; + + return mp_const_none; +} + +mp_obj_t Portal___del__(mp_obj_t self_in) { + _Portal_obj_t *self = MP_OBJ_TO_PTR2(self_in, _Portal_obj_t); + m_del_class(ST7701, self->portal); + return mp_const_none; +} + +} \ No newline at end of file diff --git a/modules/c/presto/presto.h b/modules/c/presto/presto.h new file mode 100644 index 0000000..88dfa79 --- /dev/null +++ b/modules/c/presto/presto.h @@ -0,0 +1,21 @@ +// Include MicroPython API. +#include "py/runtime.h" + +/***** Constants *****/ +static const uint BACKLIGHT = 38; + +static const int WIDTH = 480; +static const int HEIGHT = 480; +static const uint LCD_CLK = 26; +static const uint LCD_CS = 28; +static const uint LCD_DAT = 27; +static const uint LCD_DC = -1; +static const uint LCD_D0 = 1; + +/***** Extern of Class Definition *****/ +extern const mp_obj_type_t Portal_type; + +/***** Extern of Class Methods *****/ +extern mp_obj_t Portal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args); +extern mp_obj_t Portal_update(mp_obj_t self_in, mp_obj_t graphics_in); +extern mp_obj_t Portal___del__(mp_obj_t self_in); \ No newline at end of file diff --git a/modules/default.cmake b/modules/default.cmake index 37272f6..5288acc 100644 --- a/modules/default.cmake +++ b/modules/default.cmake @@ -14,13 +14,13 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) -include(c/example/micropython) +include(c/presto/micropython) -# include(micropython-common) -# enable_ulab() +include(micropython-common) +enable_ulab() # C++ Magic Memory -# include(cppmem/micropython) +include(cppmem/micropython) # Disable build-busting C++ exceptions include(micropython-disable-exceptions) \ No newline at end of file diff --git a/modules/default.py b/modules/default.py new file mode 100644 index 0000000..eef495b --- /dev/null +++ b/modules/default.py @@ -0,0 +1,8 @@ +# Include the manifest.py from micropython/ports/rp2/boards/manifest.py +include("$(PORT_DIR)/boards/manifest.py") + +# Include the manifest.py from micropython//manifest.py +include("$(BOARD_DIR)/manifest.py") + +# Include pga/modules/py_frozen +freeze("py_frozen/") \ No newline at end of file diff --git a/modules/frozen.py b/modules/default.txt similarity index 100% rename from modules/frozen.py rename to modules/default.txt diff --git a/modules/littlefs.txt b/modules/littlefs.txt deleted file mode 100644 index f2e897a..0000000 --- a/modules/littlefs.txt +++ /dev/null @@ -1 +0,0 @@ -lib/*/*.py \ No newline at end of file diff --git a/pga2040/manifest.py b/pga2040/manifest.py deleted file mode 100644 index 8505dcb..0000000 --- a/pga2040/manifest.py +++ /dev/null @@ -1,5 +0,0 @@ -# Include the manifest.py from micropython/ports/rp2/boards/manifest.py -include("$(PORT_DIR)/boards/manifest.py") - -# Include frozen.py from pga/modules/frozen.py -include("../modules/frozen.py") \ No newline at end of file diff --git a/pga2040/mpconfigboard.cmake b/pga2040/mpconfigboard.cmake deleted file mode 100644 index c2bc3c5..0000000 --- a/pga2040/mpconfigboard.cmake +++ /dev/null @@ -1,13 +0,0 @@ -# cmake file for the Pimoroni PGA2040 -set(PICO_BOARD "pga2040") -set(PICO_PLATFORM "rp2040") - -# Make sure we find pga2040.h (PICO_BOARD) in the current dir -set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}) - -# Board specific version of the frozen manifest -set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) - -# If USER_C_MODULES or MicroPython customisations use malloc then -# there needs to be some RAM reserved for the C heap -set(MICROPY_C_HEAP_SIZE 4096) diff --git a/pga2040/mpconfigboard.h b/pga2040/mpconfigboard.h deleted file mode 100644 index 6cfced4..0000000 --- a/pga2040/mpconfigboard.h +++ /dev/null @@ -1,6 +0,0 @@ -// Board and hardware specific configuration -#define MICROPY_HW_BOARD_NAME "PGA2040" - -// Portion of onboard flash to reserve for the user filesystem -// PGA2040 has 8MB flash, so reserve 1MiB for the firmware and leave 7MiB -#define MICROPY_HW_FLASH_STORAGE_BYTES (7 * 1024 * 1024) diff --git a/pga2040/pga2040.h b/pga2040/pga2040.h deleted file mode 100644 index 25b9dd2..0000000 --- a/pga2040/pga2040.h +++ /dev/null @@ -1,81 +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 -// ----------------------------------------------------- - -// pico_cmake_set PICO_PLATFORM=rp2040 - -#ifndef _BOARDS_PIMORONI_PGA2040_H -#define _BOARDS_PIMORONI_PGA2040_H - -// For board detection -#define PIMORONI_PGA2040 - -// --- 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 -// 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 = (8 * 1024 * 1024) -#ifndef PICO_FLASH_SIZE_BYTES -#define PICO_FLASH_SIZE_BYTES (8 * 1024 * 1024) -#endif -// All boards have B1 RP2040 -#ifndef PICO_RP2040_B0_SUPPORTED -#define PICO_RP2040_B0_SUPPORTED 0 -#endif - -#endif diff --git a/pga2040/pins.csv b/pga2040/pins.csv deleted file mode 100644 index 16e3340..0000000 --- a/pga2040/pins.csv +++ /dev/null @@ -1,28 +0,0 @@ -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 -GP25,GPIO25 -GP26,GPIO26 -GP27,GPIO27 -GP28,GPIO28 -LED,GPIO25 diff --git a/pga2350/manifest.py b/pga2350/manifest.py deleted file mode 100644 index 8505dcb..0000000 --- a/pga2350/manifest.py +++ /dev/null @@ -1,5 +0,0 @@ -# Include the manifest.py from micropython/ports/rp2/boards/manifest.py -include("$(PORT_DIR)/boards/manifest.py") - -# Include frozen.py from pga/modules/frozen.py -include("../modules/frozen.py") \ No newline at end of file diff --git a/pga2350/mpconfigvariant.cmake b/pga2350/mpconfigvariant.cmake deleted file mode 100644 index e69de29..0000000 diff --git a/pga2350/mpconfigvariant_PSRAM.cmake b/pga2350/mpconfigvariant_PSRAM.cmake deleted file mode 100644 index 8bee1f2..0000000 --- a/pga2350/mpconfigvariant_PSRAM.cmake +++ /dev/null @@ -1,5 +0,0 @@ -# Override the MicroPython board name -list(APPEND MICROPY_DEF_BOARD - "MICROPY_HW_ENABLE_PSRAM=1" - "MICROPY_HW_BOARD_NAME=\"PGA2350 (PSRAM)\"" -) diff --git a/presto/manifest.py b/presto/manifest.py new file mode 100644 index 0000000..4819e73 --- /dev/null +++ b/presto/manifest.py @@ -0,0 +1 @@ +# Board-specific frozen libs go here \ No newline at end of file diff --git a/pga2350/mpconfigboard.cmake b/presto/mpconfigboard.cmake similarity index 83% rename from pga2350/mpconfigboard.cmake rename to presto/mpconfigboard.cmake index d25ae32..bb203bf 100644 --- a/pga2350/mpconfigboard.cmake +++ b/presto/mpconfigboard.cmake @@ -11,4 +11,8 @@ set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) # If USER_C_MODULES or MicroPython customisations use malloc then # there needs to be some RAM reserved for the C heap -set(MICROPY_C_HEAP_SIZE 4096) \ No newline at end of file +set(MICROPY_C_HEAP_SIZE 4096) + +list(APPEND MICROPY_DEF_BOARD + "MICROPY_HW_ENABLE_PSRAM=1" +) \ No newline at end of file diff --git a/pga2350/mpconfigboard.h b/presto/mpconfigboard.h similarity index 62% rename from pga2350/mpconfigboard.h rename to presto/mpconfigboard.h index 802a1a4..ab910a3 100644 --- a/pga2350/mpconfigboard.h +++ b/presto/mpconfigboard.h @@ -3,12 +3,14 @@ // Board and hardware specific configuration #ifndef MICROPY_HW_BOARD_NAME // Might be defined by mpconfigvariant_VARIANT.cmake -#define MICROPY_HW_BOARD_NAME "PGA2350" +#define MICROPY_HW_BOARD_NAME "Presto" #endif // Portion of onboard flash to reserve for the user filesystem // PGA2350 has 16MB flash, so reserve 2MiB for the firmware and leave 14MiB #define MICROPY_HW_FLASH_STORAGE_BYTES (14 * 1024 * 1024) -// Alias the chip select pin specified by pga2350.h -#define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PGA2350_PSRAM_CS_PIN +// Alias the chip select pin specified by presto.h +#define MICROPY_HW_PSRAM_CS_PIN PIMORONI_PRESTO_PSRAM_CS_PIN + +#define MICROPY_PY_THREAD (0) \ No newline at end of file diff --git a/pga2350/pins.csv b/presto/pins.csv similarity index 100% rename from pga2350/pins.csv rename to presto/pins.csv diff --git a/pga2350/pga2350.h b/presto/presto.h similarity index 90% rename from pga2350/pga2350.h rename to presto/presto.h index 9690f13..4bc9521 100644 --- a/pga2350/pga2350.h +++ b/presto/presto.h @@ -9,19 +9,18 @@ // SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES // ----------------------------------------------------- -// This header may be included by other board headers as "boards/pimoroni_pga2350.h" +// This header may be included by other board headers as "boards/pimoroni_presto.h" // pico_cmake_set PICO_PLATFORM=rp2350 -#ifndef _BOARDS_PIMORONI_PGA2350_H -#define _BOARDS_PIMORONI_PGA2350_H +#ifndef _BOARDS_PIMORONI_PRESTO_H +#define _BOARDS_PIMORONI_PRESTO_H // For board detection -#define PIMORONI_PGA2350 -#define PIMORONI_PGA2350_16MB +#define PIMORONI_PRESTO // --- BOARD SPECIFIC --- -#define PIMORONI_PGA2350_PSRAM_CS_PIN 47 +#define PIMORONI_PRESTO_PSRAM_CS_PIN 47 // --- UART --- #ifndef PICO_DEFAULT_UART