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

Add W variant of Tiny FX #6

Merged
merged 5 commits into from
Oct 8, 2024
Merged
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
21 changes: 19 additions & 2 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,21 @@ jobs:
- name: TinyFX
shortname: tiny_fx
board: PIMORONI_TINYFX
- name: TinyFX W
shortname: tiny_fx_w
board: PIMORONI_TINYFX
variant: w

env:
RELEASE_FILE: pimoroni-${{matrix.shortname}}-${{github.event.release.tag_name || github.sha}}-micropython
FIRMWARE_DIR: "$GITHUB_WORKSPACE/picofx/boards"
ROOT_DIR: "$GITHUB_WORKSPACE/picofx"
BOARD_DIR: "$GITHUB_WORKSPACE/picofx/boards/${{matrix.board}}"
EXAMPLES_DIR: "$GITHUB_WORKSPACE/picofx/examples/${{matrix.shortname}}"
EXAMPLES_DIR: "$GITHUB_WORKSPACE/picofx/examples/tiny_fx"
FILESYSTEM_DIR: "$GITHUB_WORKSPACE/picofx/temp"
FILESYSTEM_SUFFIX: "with-libs-and-examples"
BOARD: "PIMORONI_TINYFX"
BOARD_VARIANT: ${{ matrix.variant }}

steps:
- name: Compiler Cache
Expand Down Expand Up @@ -126,6 +131,18 @@ jobs:
run: |
git apply "${{env.FIRMWARE_DIR}}/932f76c6ba64c5a3e68de3324556d9979f09303b.patch"

- name: "HACK: MicroPython RP2 board variant patch"
shell: bash
working-directory: micropython
run: |
git apply "${{env.FIRMWARE_DIR}}/5dff78f38edc0354e854e6c73af61c5064afe9d3.patch"

- name: "HACK: MicroPython RP2 MICROPY_DEF_BOARD patch"
shell: bash
working-directory: micropython
run: |
git apply "${{env.FIRMWARE_DIR}}/11becbe22321ca1d7bd631144976f246175730ce.patch"

- name: Install Arm GNU Toolchain (arm-none-eabi-gcc)
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
Expand All @@ -140,7 +157,7 @@ jobs:
shell: bash
working-directory: micropython/ports/rp2
run: |
cmake -S . -B build -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=${{env.BOARD_DIR}}/micropython.cmake -DMICROPY_BOARD_DIR=${{env.BOARD_DIR}} -DMICROPY_BOARD=${{env.BOARD}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DPICO_BOARD_HEADER_DIRS=${{env.BOARD_DIR}}
cmake -S . -B build -DPICO_BUILD_DOCS=0 -DUSER_C_MODULES=${{env.BOARD_DIR}}/micropython.cmake -DMICROPY_BOARD_DIR=${{env.BOARD_DIR}} -DMICROPY_BOARD=${{env.BOARD}} -DMICROPY_BOARD_VARIANT=${{env.BOARD_VARIANT}} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DPICO_BOARD_HEADER_DIRS=${{env.BOARD_DIR}}

- name: Build MicroPython
shell: bash
Expand Down
30 changes: 30 additions & 0 deletions boards/11becbe22321ca1d7bd631144976f246175730ce.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 11becbe22321ca1d7bd631144976f246175730ce Mon Sep 17 00:00:00 2001
From: Phil Howard <[email protected]>
Date: Wed, 3 Jul 2024 15:15:16 +0100
Subject: [PATCH] rp2/CMakeLists.txt: Add MICROPY_DEF_BOARD to compile
definitions.

Add MICROPY_DEF_BOARD as per esp32 port, allows board variants to override
the board name with:

list(APPEND MICROPY_DEF_BOARD
MICROPY_HW_BOARD_NAME="New Board Name"
)

Signed-off-by: Phil Howard <[email protected]>
---
ports/rp2/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index 8fff4251487f..904925ae3f5e 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -493,6 +493,7 @@ set_source_files_properties(
)

target_compile_definitions(${MICROPY_TARGET} PRIVATE
+ ${MICROPY_DEF_BOARD}
FFCONF_H=\"${MICROPY_OOFATFS_DIR}/ffconf.h\"
LFS1_NO_MALLOC LFS1_NO_DEBUG LFS1_NO_WARN LFS1_NO_ERROR LFS1_NO_ASSERT
LFS2_NO_MALLOC LFS2_NO_DEBUG LFS2_NO_WARN LFS2_NO_ERROR LFS2_NO_ASSERT
101 changes: 101 additions & 0 deletions boards/5dff78f38edc0354e854e6c73af61c5064afe9d3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
From 5dff78f38edc0354e854e6c73af61c5064afe9d3 Mon Sep 17 00:00:00 2001
From: Damien George <[email protected]>
Date: Mon, 24 Jun 2024 12:37:13 +1000
Subject: [PATCH] rp2: Rework board variant support to require mpconfigvariant
file.

Following how the board variants now work in the esp32 port.

Signed-off-by: Damien George <[email protected]>
---
ports/rp2/CMakeLists.txt | 12 ++++++++++++
ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake | 16 ----------------
.../rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake | 1 +
.../WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake | 1 +
.../WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake | 1 +
.../WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake | 1 +
6 files changed, 16 insertions(+), 16 deletions(-)
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake
create mode 100644 ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake

diff --git a/ports/rp2/CMakeLists.txt b/ports/rp2/CMakeLists.txt
index 8f5680092c92..8fff4251487f 100644
--- a/ports/rp2/CMakeLists.txt
+++ b/ports/rp2/CMakeLists.txt
@@ -38,10 +38,22 @@ if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
endif()

+# If a board variant is specified, check that it exists.
+if(MICROPY_BOARD_VARIANT)
+ if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigvariant_${MICROPY_BOARD_VARIANT}.cmake)
+ message(FATAL_ERROR "Invalid MICROPY_BOARD_VARIANT specified: ${MICROPY_BOARD_VARIANT}")
+ endif()
+endif()
+
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST})

# Include board config, it may override MICROPY_FROZEN_MANIFEST
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
+if(NOT MICROPY_BOARD_VARIANT)
+ include(${MICROPY_BOARD_DIR}/mpconfigvariant.cmake OPTIONAL)
+else()
+ include(${MICROPY_BOARD_DIR}/mpconfigvariant_${MICROPY_BOARD_VARIANT}.cmake)
+endif()

# Set the PICO_BOARD if it's not already set (allow a board to override it).
if(NOT PICO_BOARD)
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake
index 848b50f604db..d922644bf626 100644
--- a/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigboard.cmake
@@ -6,19 +6,3 @@ list(APPEND PICO_BOARD_HEADER_DIRS ${MICROPY_BOARD_DIR})

# Freeze board.py
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
-
-# Select the 16MB variant as the default
-set(PICO_BOARD "weactstudio_16MiB")
-
-# Provide different variants for the downloads page
-if(MICROPY_BOARD_VARIANT STREQUAL "FLASH_2M")
- set(PICO_BOARD "weactstudio_2MiB")
-endif()
-
-if(MICROPY_BOARD_VARIANT STREQUAL "FLASH_4M")
- set(PICO_BOARD "weactstudio_4MiB")
-endif()
-
-if(MICROPY_BOARD_VARIANT STREQUAL "FLASH_8M")
- set(PICO_BOARD "weactstudio_8MiB")
-endif()
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake
new file mode 100644
index 000000000000..4e68b2112f1d
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_16MiB")
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake
new file mode 100644
index 000000000000..b8d7202dada5
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_2M.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_2MiB")
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake
new file mode 100644
index 000000000000..75afb1ba4006
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_4M.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_4MiB")
diff --git a/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake
new file mode 100644
index 000000000000..359e47c01161
--- /dev/null
+++ b/ports/rp2/boards/WEACTSTUDIO/mpconfigvariant_FLASH_8M.cmake
@@ -0,0 +1 @@
+set(PICO_BOARD "weactstudio_8MiB")
6 changes: 6 additions & 0 deletions boards/PIMORONI_TINYFX/manifest_w.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require("bundle-networking")

# Bluetooth
require("aioble")

include("manifest.py")
25 changes: 24 additions & 1 deletion boards/PIMORONI_TINYFX/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
// Board and hardware specific configuration
#ifndef MICROPY_HW_BOARD_NAME
// Might be defined by mpconfigvariant.cmake
#define MICROPY_HW_BOARD_NAME "Pimoroni TinyFX"
#define MICROPY_HW_FLASH_STORAGE_BYTES (3 * 1024 * 1024)
#endif

#if defined(MICROPY_PY_NETWORK_CYW43)

// We need space for networking firmware on network builds
// 1536 * 1024 = 1.5MB
#define FIRMWARE_SIZE_BYTES (1536 * 1024)

// CYW43 driver configuration.
#define CYW43_USE_SPI (1)
#define CYW43_LWIP (1)
#define CYW43_GPIO (0)
#define CYW43_SPI_PIO (1)

#else

// 1MB for the firmware
#define FIRMWARE_SIZE_BYTES (1 * 1024 * 1024)

#endif

#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - FIRMWARE_SIZE_BYTES)
Empty file.
38 changes: 38 additions & 0 deletions boards/PIMORONI_TINYFX/mpconfigvariant_w.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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 TinyFX W\""
"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_w.py)

set(PICO_BOARD "pimoroni_tinyfx")
set(PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR})
17 changes: 17 additions & 0 deletions boards/PIMORONI_TINYFX/pimoroni_tinyfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@
#define PICO_DEFAULT_SPI_CSN_PIN 17
#endif

// -- 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

// --- FLASH ---
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

Expand Down
Loading