SDK 2.0.0 release
diff --git a/.bazelignore b/.bazelignore
new file mode 100644
index 0000000..a086fff
--- /dev/null
+++ b/.bazelignore
@@ -0,0 +1,4 @@
+# Don't accidentally pick up external CMake deps with Bazel build files.
+build
+# Don't treat submodules as part of this project.
+lib
diff --git a/.bazelrc b/.bazelrc
index b5ebd97..a94ccd3 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -2,5 +2,9 @@
build --incompatible_enable_cc_toolchain_resolution
build --@rules_cc//cc/toolchains:experimental_enable_rule_based_toolchains
+# Silence all C/C++ warnings in external code.
+common --per_file_copt=external/.*@-w
+common --host_per_file_copt=external/.*@-w
+
# Produce useful output when the build fails.
common --verbose_failures
diff --git a/.bazelversion b/.bazelversion
index a8907c0..b26a34e 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-7.0.2
+7.2.1
diff --git a/.gitignore b/.gitignore
index c014195..a893fc6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,8 +3,10 @@
cmake-*
.DS_Store
build
+build-*
bazel-*
# Ignore until https://github.com/bazelbuild/bazel/issues/20369 is fixed.
MODULE.bazel.lock
+__pycache__/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a622f05..2ecb515 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,11 @@
pico_register_common_scope_var(PICO_C_COMPILER_IS_CLANG)
pico_register_common_scope_var(PICO_C_COMPILER_IS_GNU)
pico_register_common_scope_var(PICO_C_COMPILER_IS_IAR)
+ pico_register_common_scope_var(PICO_SDK_VERSION_MAJOR)
+ pico_register_common_scope_var(PICO_SDK_VERSION_MINOR)
+ pico_register_common_scope_var(PICO_SDK_VERSION_REVISION)
+ pico_register_common_scope_var(PICO_SDK_VERSION_PRE_RELEASE_ID)
+ pico_register_common_scope_var(PICO_SDK_VERSION_STRING)
message("Build type is ${CMAKE_BUILD_TYPE}")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
@@ -38,6 +43,9 @@
add_sub_list_dirs(PICO_SDK_PRE_LIST_DIRS)
add_sub_list_files(PICO_SDK_PRE_LIST_FILES)
+ # needed by certain functions
+ set(PICO_TOOLS_DIR "${CMAKE_CURRENT_LIST_DIR}/tools" CACHE INTERNAL "")
+
add_subdirectory(tools)
add_subdirectory(src)
diff --git a/MODULE.bazel b/MODULE.bazel
index 883fad7..2094c3b 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,8 +1,12 @@
-module(name = "pico-sdk", version = "1.6.0-rc1")
+module(
+ name = "pico-sdk",
+ version = "2.0.0",
+)
-bazel_dep(name = "platforms", version = "0.0.8")
-
+bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
+bazel_dep(name = "rules_python", version = "0.22.1")
+bazel_dep(name = "picotool", version = "2.0.0")
# Note: rules_cc is special-cased repository; a dependency on rules_cc in a
# module will not ensure that the root Bazel module has that same version of
@@ -15,84 +19,123 @@
# project's MODULE.bazel too.
archive_override(
module_name = "rules_cc",
- urls = "https://github.com/bazelbuild/rules_cc/archive/1acf5213b6170f1f0133e273cb85ede0e732048f.zip",
+ integrity = "sha256-zdQo/pQWKdIAPKSflBxOSWZNwCbc86T7SechKZo/3Xw=",
strip_prefix = "rules_cc-1acf5213b6170f1f0133e273cb85ede0e732048f",
- integrity = "sha256-NddP6xi6LzsIHT8bMSVJ2NtoURbN+l3xpjvmIgB6aSg=",
+ urls = "https://github.com/bazelbuild/rules_cc/archive/1acf5213b6170f1f0133e273cb85ede0e732048f.tar.gz",
)
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "arm_gcc_linux-x86_64",
- url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz",
- strip_prefix = "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "6cd1bbc1d9ae57312bcd169ae283153a9572bd6a8e4eeae2fedfbc33b115fdbb",
+ strip_prefix = "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
+ url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz",
)
http_archive(
name = "arm_gcc_win-x86_64",
- url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip",
- strip_prefix = "arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "51d933f00578aa28016c5e3c84f94403274ea7915539f8e56c13e2196437d18f",
+ strip_prefix = "arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi",
+ url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip",
)
http_archive(
name = "arm_gcc_mac-x86_64",
- url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz",
- strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-arm-none-eabi",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc",
+ strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-arm-none-eabi",
+ url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz",
)
http_archive(
name = "arm_gcc_mac-aarch64",
- url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz",
- strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-arm64-arm-none-eabi",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "39c44f8af42695b7b871df42e346c09fee670ea8dfc11f17083e296ea2b0d279",
+ strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-arm64-arm-none-eabi",
+ url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz",
+)
+
+http_archive(
+ name = "clang_linux-x86_64",
+ build_file = "//bazel/toolchain:clang.BUILD",
+ sha256 = "e12ee0db9226f5b4a4400c5eb2c0f757d7056181b651622b5453acb00105fd87",
+ type = "zip",
+ url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/linux-amd64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799",
+)
+
+http_archive(
+ name = "clang_win-x86_64",
+ build_file = "//bazel/toolchain:clang.BUILD",
+ sha256 = "8c41e8b507f4dfede80842f98a716cac209f552064088fa1b7f4c64a1e547534",
+ type = "zip",
+ # Windows doesn't like `:` in the produced filename, so replace it with `%3A`.
+ url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/windows-amd64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799".replace("git_revision:", "git_revision%3A"),
+)
+
+http_archive(
+ name = "clang_mac-x86_64",
+ build_file = "//bazel/toolchain:clang.BUILD",
+ sha256 = "1d92f52609d3c1e958fd56f5e9a68ab99b2042ddcc6e90a5eb5009cf7ac4897d",
+ type = "zip",
+ url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/mac-amd64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799",
+)
+
+http_archive(
+ name = "clang_mac-aarch64",
+ build_file = "//bazel/toolchain:clang.BUILD",
+ sha256 = "53184680db7e0043a8fba1556c7644b8f5e6c8cdffa4436a92a8e8adb0f45b8d",
+ type = "zip",
+ url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/mac-arm64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799",
)
# TODO: Provide tinyusb as a proper Bazel module.
http_archive(
name = "tinyusb",
- url = "https://github.com/hathach/tinyusb/archive/86c416d4c0fb38432460b3e11b08b9de76941bf5.zip",
- strip_prefix = "tinyusb-86c416d4c0fb38432460b3e11b08b9de76941bf5",
build_file = "//src/rp2_common/tinyusb:tinyusb.BUILD",
- sha256 = "ac57109bba00d26ffa33312d5f334990ec9a9a4d82bf890ed8b825b4610d1da2",
+ sha256 = "d64728aef58b80d5ce3747cad133f520da46e2b7ea3aadfda0e981aba6b658b3",
+ strip_prefix = "tinyusb-4232642899362fa5e9cf0dc59bad6f1f6d32c563",
+ url = "https://github.com/hathach/tinyusb/archive/4232642899362fa5e9cf0dc59bad6f1f6d32c563.tar.gz",
)
# TODO: Provide btstack as a proper Bazel module.
http_archive(
name = "btstack",
- url = "https://github.com/bluekitchen/btstack/archive/72ef1732c954d938091467961e41f4aa9b976b34.zip",
- strip_prefix = "btstack-72ef1732c954d938091467961e41f4aa9b976b34",
build_file = "//src/rp2_common/pico_btstack:btstack.BUILD",
- sha256 = "f45d72b5d404dd2f8e311287de6f2ba3561fc8ae956737eeb611b277aadc2391",
+ sha256 = "64e86d9cf82b346e743fe1d4818b9380712b17abdb3f2c3524e92464b5ef3d19",
+ strip_prefix = "btstack-2b49e57bd1fae85ac32ac1f41cdb7c794de335f6",
+ url = "https://github.com/bluekitchen/btstack/archive/2b49e57bd1fae85ac32ac1f41cdb7c794de335f6.tar.gz",
)
# TODO: Provide btstack as a proper Bazel module.
http_archive(
name = "cyw43-driver",
- url = "https://github.com/georgerobotics/cyw43-driver/archive/8ef38a6d32c54f850bff8f189bdca19ded33792a.zip",
- strip_prefix = "cyw43-driver-8ef38a6d32c54f850bff8f189bdca19ded33792a",
build_file = "//src/rp2_common/pico_cyw43_driver:cyw43-driver.BUILD",
- sha256 = "0b44a19ea58537ee954357606cde5ed20c3a42be77adfebb07b7c0e4740f6228",
+ sha256 = "0fcc7707fef95dd562d5572604713266613a27caeeae2f10afeccee9592a53ce",
+ strip_prefix = "cyw43-driver-faf36381bad1f668a30172b6336c9a970966ef4c",
+ url = "https://github.com/georgerobotics/cyw43-driver/archive/faf36381bad1f668a30172b6336c9a970966ef4c.tar.gz",
)
# TODO: Provide lwip as a proper Bazel module.
http_archive(
name = "lwip",
- url = "https://github.com/lwip-tcpip/lwip/archive/239918ccc173cb2c2a62f41a40fd893f57faf1d6.zip",
- strip_prefix = "lwip-239918ccc173cb2c2a62f41a40fd893f57faf1d6",
build_file = "//src/rp2_common/pico_lwip:lwip.BUILD",
- sha256 = "7ee9e02f2719c0422377e1fcce5a21716ca2e2e855cca56695f9ef7cb020e5dd",
+ sha256 = "72856d557f72911cf6826ef745c23c54822df83a474557823241164a1d1361aa",
+ strip_prefix = "lwip-0a0452b2c39bdd91e252aef045c115f88f6ca773",
+ url = "https://github.com/lwip-tcpip/lwip/archive/0a0452b2c39bdd91e252aef045c115f88f6ca773.tar.gz",
)
register_toolchains(
- "//bazel/toolchain:arm_gcc_linux-x86_64",
- "//bazel/toolchain:arm_gcc_win-x86_64",
- "//bazel/toolchain:arm_gcc_mac-x86_64",
- "//bazel/toolchain:arm_gcc_mac-aarch64",
+ "//bazel/toolchain:linux-x86_64-rp2040",
+ "//bazel/toolchain:linux-x86_64-rp2350",
+ "//bazel/toolchain:win-x86_64-rp2040",
+ "//bazel/toolchain:win-x86_64-rp2350",
+ "//bazel/toolchain:mac-x86_64-rp2040",
+ "//bazel/toolchain:mac-x86_64-rp2350",
+ "//bazel/toolchain:mac-aarch64-rp2040",
+ "//bazel/toolchain:mac-aarch64-rp2350",
+ # Require users to opt-in to the Pico SDK's toolchains.
+ dev_dependency = True,
)
diff --git a/README.md b/README.md
index 6388cf7..6129a00 100644
--- a/README.md
+++ b/README.md
@@ -1,31 +1,31 @@
# Raspberry Pi Pico SDK
The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system
-necessary to write programs for the RP2040-based devices such as the Raspberry Pi Pico
+necessary to write programs for the RP-series microcontroller-based devices such as the Raspberry Pi Pico or Raspberry Pi Pico 2
in C, C++ or assembly language.
The SDK is designed to provide an API and programming environment that is familiar both to non-embedded C developers and embedded C developers alike.
A single program runs on the device at a time and starts with a conventional `main()` method. Standard C/C++ libraries are supported along with
-C level libraries/APIs for accessing all of the RP2040's hardware include PIO (Programmable IO).
+C-level libraries/APIs for accessing all of the RP-series microcontroller's hardware including PIO (Programmable IO).
-Additionally the SDK provides higher level libraries for dealing with timers, synchronization, USB (TinyUSB) and multi-core programming
-along with various utilities.
+Additionally, the SDK provides higher level libraries for dealing with timers, synchronization, Wi-Fi and Bluetooth networking, USB and multicore programming. These libraries should be comprehensive enough that your application code rarely, if at all, needs to access hardware registers directly. However, if you do need or prefer to access the raw hardware registers, you will also find complete and fully-commented register definition headers in the SDK. There's no need to look up addresses in the datasheet.
-The SDK can be used to build anything from simple applications, to fully fledged runtime environments such as MicroPython, to low level software
-such as RP2040's on-chip bootrom itself.
+The SDK can be used to build anything from simple applications, fully-fledged runtime environments such as MicroPython, to low level software
+such as the RP-series microcontroller's on-chip bootrom itself.
+
+The design goal for entire SDK is to be simple but powerful.
Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found in [pico-extras](https://github.com/raspberrypi/pico-extras).
# Documentation
-See [Getting Started with the Raspberry Pi Pico](https://rptl.io/pico-get-started) for information on how to setup your
-hardware, IDE/environment and for how to build and debug software for the Raspberry Pi Pico
-and other RP2040-based devices.
+See [Getting Started with the Raspberry Pi Pico-Series](https://rptl.io/pico-get-started) for information on how to setup your
+hardware, IDE/environment and how to build and debug software for the Raspberry Pi Pico and other RP-series microcontroller based devices.
See [Connecting to the Internet with Raspberry Pi Pico W](https://rptl.io/picow-connect) to learn more about writing
applications for your Raspberry Pi Pico W that connect to the internet.
-See [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) to learn more about programming using the
+See [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-c-sdk) to learn more about programming using the
SDK, to explore more advanced features, and for complete PDF-based API documentation.
See [Online Raspberry Pi Pico SDK API docs](https://rptl.io/pico-doxygen) for HTML-based API documentation.
@@ -42,10 +42,16 @@
# Quick-start your own project
-These instructions are extremely terse, and Linux-based only. For detailed steps,
-instructions for other platforms, and just in general, we recommend you see [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk)
+## Using Visual Studio Code
-1. Install CMake (at least version 3.13), and GCC cross compiler
+You can install the [Raspberry Pi Pico Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico) in VS Code.
+
+## Unix command line
+
+These instructions are extremely terse, and Linux-based only. For detailed steps,
+instructions for other platforms, and just in general, we recommend you see [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-c-sdk)
+
+1. Install CMake (at least version 3.13), and a GCC cross compiler
```
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
```
@@ -137,7 +143,7 @@
# rest of your project
```
-1. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
+1. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
About the simplest you can do is a single source file (e.g. hello_world.c)
@@ -146,7 +152,7 @@
#include "pico/stdlib.h"
int main() {
- setup_default_uart();
+ stdio_init_all();
printf("Hello, world!\n");
return 0;
}
@@ -176,12 +182,11 @@
$ cmake ..
```
- When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the `cmake` command above, e.g. `cmake -DPICO_BOARD=pico_w ..`
- to configure the SDK and build options accordingly for that particular board.
+ When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the `cmake` command above, e.g. `cmake -DPICO_BOARD=pico2 ..` or `cmake -DPICO_BOARD=pico_w ..` to configure the SDK and build options accordingly for that particular board.
- Doing so sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain
+ Specifying `PICO_BOARD=<booardname>` sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain
cases also enables the use of additional libraries (e.g. wireless support when building for `PICO_BOARD=pico_w`) which cannot
- be built without a board which provides the requisite functionality.
+ be built without a board which provides the requisite hardware functionality.
For a list of boards defined in the SDK itself, look in [this directory](src/boards/include/boards) which has a
header for each named board.
@@ -191,4 +196,8 @@
$ make hello_world
```
-1. You now have `hello_world.elf` to load via a debugger, or `hello_world.uf2` that can be installed and run on your Raspberry Pi Pico via drag and drop.
+1. You now have `hello_world.elf` to load via a debugger, or `hello_world.uf2` that can be installed and run on your Raspberry Pi Pico-series device via drag and drop.
+
+# RISC-V support on RP2350
+
+See [Raspberry Pi Pico-series C/C++ SDK](https://rptl.io/pico-c-sdk) for information on setting up a build environment for RISC-V on RP2350.
\ No newline at end of file
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/WORKSPACE
diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel
index e4ab8f3..ff093d4 100644
--- a/bazel/BUILD.bazel
+++ b/bazel/BUILD.bazel
@@ -55,3 +55,9 @@
cc_library(
name = "empty_cc_lib",
)
+
+# A library incompatible with everything. Use to mark an invalid configuration.
+cc_library(
+ name = "incompatible_cc_lib",
+ target_compatible_with = ["@platforms//:incompatible"],
+)
diff --git a/bazel/README.md b/bazel/README.md
index 1db0c93..6520e7a 100644
--- a/bazel/README.md
+++ b/bazel/README.md
@@ -7,9 +7,10 @@
```python
bazel_dep(
name = "pico-sdk",
- version = "1.6.0-rc1",
+ version = "2.0.0",
)
```
+
Second, in the same file you'll need to add an explicit dependency on
`rules_cc`, as it's a special-cased Bazel module:
```python
@@ -35,10 +36,14 @@
to the `MODULE.bazel` for your project:
```python
register_toolchains(
- "@pico-sdk//bazel/toolchain:arm_gcc_linux-x86_64",
- "@pico-sdk//bazel/toolchain:arm_gcc_win-x86_64",
- "@pico-sdk//bazel/toolchain:arm_gcc_mac-x86_64",
- "@pico-sdk//bazel/toolchain:arm_gcc_mac-aarch64",
+ "@pico-sdk//bazel/toolchain:linux-x86_64-rp2040",
+ "@pico-sdk//bazel/toolchain:linux-x86_64-rp2350",
+ "@pico-sdk//bazel/toolchain:win-x86_64-rp2040",
+ "@pico-sdk//bazel/toolchain:win-x86_64-rp2350",
+ "@pico-sdk//bazel/toolchain:mac-x86_64-rp2040",
+ "@pico-sdk//bazel/toolchain:mac-x86_64-rp2350",
+ "@pico-sdk//bazel/toolchain:mac-aarch64-rp2040",
+ "@pico-sdk//bazel/toolchain:mac-aarch64-rp2350",
)
```
@@ -82,7 +87,7 @@
firmware image.
```console
-$ bazel build --platforms=@pico-sdk//bazel/platform:rp2040 \
+$ bazelisk build --platforms=@pico-sdk//bazel/platform:rp2040 \
--aspects @pico-sdk//tools:uf2_aspect.bzl%pico_uf2_aspect \
--output_groups=+pico_uf2_files \
//...
@@ -97,6 +102,13 @@
We strongly recommend you set up
[Bazelisk](https://bazel.build/install/bazelisk).
+You will also need a working compiler configured if you wish to build Picotool
+or pioasm.
+
+* Linux: `sudo apt-get install build-essential` or similar.
+* macOS: `xcode-select --install`
+* Windows: [Install MSVC](https://visualstudio.microsoft.com/vs/features/cplusplus/)
+
### Building
To build all of the Pico SDK, run the following command:
```console
@@ -111,6 +123,23 @@
Currently, the following features are not supported:
-* "None" variants of pico_double, pico_float, and pico_printf are not yet
- supported.
* The pioasm parser cannot be built from source via Bazel.
+* Windows MSVC wildcard build (`bazel build //...`) does not work when targeting
+ host.
+* Bazel does not yet provide RISC-V support for Pico 2/RP2350.
+* Pico W wireless libraries have link issues.
+
+## Contributing
+When making changes to the Bazel build, please run the Bazel validation script
+to ensure all supported configurations build properly:
+
+```console
+$ ./tools/run_all_bazel_checks.py
+```
+
+If you need to check against a local version of Picotool, you can run the script
+with `--picotool-dir`:
+
+```console
+$ ./tools/run_all_bazel_checks.py --picotool-dir=/path/to/picotool
+```
diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel
index 50530ec..4ab2ccc 100644
--- a/bazel/config/BUILD.bazel
+++ b/bazel/config/BUILD.bazel
@@ -2,7 +2,17 @@
package(default_visibility = ["//visibility:public"])
-# PICO_BAZEL_CONFIG: PICO_BOARD, The board name being built for, type=string, default=pico, group=build
+# PICO_BAZEL_CONFIG: PICO_TOOLCHAIN, The toolchain to use, type=string, default=gcc, group=build
+string_flag(
+ name = "PICO_TOOLCHAIN",
+ build_setting_default = "gcc",
+ values = [
+ "gcc",
+ "clang",
+ ],
+)
+
+# PICO_BAZEL_CONFIG: PICO_BOARD, Board name being built for, type=string, default=pico or pico2, group=build, docref=cmake-platform-board-config
string_flag(
name = "PICO_BOARD",
build_setting_default = "pico",
@@ -14,7 +24,7 @@
build_setting_default = False,
)
-# PICO_BAZEL_CONFIG: PICO_NO_GC_SECTIONS, Disable -ffunction-sections -fdata-sections and --gc-sections, type=bool, default=0, advanced=true, group=pico_standard_link
+# PICO_BAZEL_CONFIG: PICO_NO_GC_SECTIONS, Disable `-ffunction-sections` `-fdata-sections` and `--gc-sections`, type=bool, default=0, advanced=true, group=pico_standard_link
bool_flag(
name = "PICO_NO_GC_SECTIONS",
build_setting_default = False,
@@ -23,57 +33,124 @@
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2_FILE, Boot stage 2 file to use; this should point to a filegroup with the .S file to use, type=string, group=build
label_flag(
name = "PICO_DEFAULT_BOOT_STAGE2_FILE",
- build_setting_default = "//src/rp2_common/boot_stage2:build_selected_boot2",
+ build_setting_default = "//src/rp2_common:build_selected_boot2",
)
-# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2, Simpler alternative to specifying PICO_DEFAULT_BOOT_STAGE2_FILE where the file is src/rp2_common/boot_stage2/{PICO_DEFAULT_BOOT_STAGE2}.S, type=string, default=compile_time_choice, group=build
+# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2, Simpler alternative to specifying PICO_DEFAULT_BOOT_STAGE2_FILE where the latter is set to src/rp2_common/boot_stage2/{PICO_DEFAULT_BOOT_STAGE2}.S, type=string, default=compile_time_choice, group=build
string_flag(
name = "PICO_DEFAULT_BOOT_STAGE2",
build_setting_default = "compile_time_choice",
)
-# PICO_BAZEL_CONFIG: PICO_BOOT_STAGE2_LINK_IMAGE, [Bazel only] The final boot_stage2 image target to link in. Use this to fully override/replace boot_stage2, default=@pico-sdk//src/rp2_common/boot_stage2:boot_stage2, group=build
+# PICO_BAZEL_CONFIG: PICO_BOOT_STAGE2_LINK_IMAGE, [Bazel only] The final boot_stage2 image target to link in. Use this to fully override/replace boot_stage2, default=@pico-sdk//src/rp2_common:boot_stage2, group=build
label_flag(
name = "PICO_BOOT_STAGE2_LINK_IMAGE",
- build_setting_default = "//src/rp2_common/boot_stage2:boot_stage2",
+ build_setting_default = "//src/rp2_common:boot_stage2",
)
-# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_EXCEPTIONS, Enabled CXX exception handling, type=bool, default=0, group=pico_cxx_options
+# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_EXCEPTIONS, Enable CXX exception handling, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_EXCEPTIONS",
build_setting_default = False,
)
-# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_RTTI, Enabled CXX rtti, type=bool, default=0, group=pico_cxx_options
+# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_RTTI, Enable CXX rtti, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_RTTI",
build_setting_default = False,
)
-# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_CXA_ATEXIT, Enabled cxa-atexit, type=bool, default=0, group=pico_cxx_options
+# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_CXA_ATEXIT, Enable cxa-atexit, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_CXA_ATEXIT",
build_setting_default = False,
)
-# PICO_BAZEL_CONFIG: PICO_STDIO_UART, OPTION: Globally enable stdio UART, type=bool, default=1, group=pico_stdlib
+# PICO_BAZEL_CONFIG: PICO_STDIO_UART, Option to globally enable stdio UART for all targets by default, type=bool, default=1, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_UART",
build_setting_default = True,
)
-# PICO_BAZEL_CONFIG: PICO_STDIO_USB, OPTION: Globally enable stdio USB, type=bool, default=0, group=pico_stdlib
+# PICO_BAZEL_CONFIG: PICO_STDIO_USB, Option to globally enable stdio USB for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_USB",
build_setting_default = False,
)
-# PICO_BAZEL_CONFIG: PICO_STDIO_SEMIHOSTING, OPTION: Globally enable stdio semihosting, type=bool, default=0, group=pico_stdlib
+# PICO_BAZEL_CONFIG: PICO_STDIO_SEMIHOSTING, Option to globally enable stdio semi-hosting for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_SEMIHOSTING",
build_setting_default = False,
)
+# PICO_BAZEL_CONFIG: PICO_STDIO_RTT, Option to globally enable stdio RTT for all targets by default, type=bool, default=0, group=pico_stdlib
+bool_flag(
+ name = "PICO_STDIO_RTT",
+ build_setting_default = False,
+)
+
+# PICO_BAZEL_CONFIG: PICO_MULTICORE_ENABLED, OPTION: Enable multicore handling, type=bool, default=1, group=pico_stdlib
+bool_flag(
+ name = "PICO_MULTICORE_ENABLED",
+ build_setting_default = True,
+)
+
+# PICO_BAZEL_CONFIG: PICO_DEFAULT_DOUBLE_IMPL, The default implementation for pico_double to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. dcp is only supported on rp2350, type=string, default=auto, group=build
+string_flag(
+ name = "PICO_DEFAULT_DOUBLE_IMPL",
+ build_setting_default = "auto",
+ values = [
+ "auto",
+ "compiler",
+ "dcp",
+ "rp2040",
+ "none",
+ ],
+)
+
+# PICO_BAZEL_CONFIG: PICO_DEFAULT_FLOAT_IMPL, The default implementation for pico_float to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. vfp and dcp are only supported on rp2350, type=string, default=auto, group=build
+string_flag(
+ name = "PICO_DEFAULT_FLOAT_IMPL",
+ build_setting_default = "auto",
+ values = [
+ "auto",
+ "compiler",
+ "dcp",
+ "rp2040",
+ "vfp",
+ "none",
+ ],
+)
+
+# PICO_BAZEL_CONFIG: PICO_DEFAULT_DIVIDER_IMPL, The default implementation for pico_divider to link. hardware uses accelerated divide instructions while compiler allows the compiler to decide how to handle divide instructions. auto uses the platform default (hardware on RP2040 and compiler on RP2350), type=string, default=auto, group=build
+string_flag(
+ name = "PICO_DEFAULT_DIVIDER_IMPL",
+ build_setting_default = "auto",
+ values = [
+ "auto",
+ "hardware",
+ "compiler",
+ ],
+)
+
+# PICO_BAZEL_CONFIG: PICO_DEFAULT_PRINTF_IMPL, The default implementation for pico_printf to link. compiler lets the compiler control printf behavior while pico provides a pico-specific implementation, type=string, default=double, group=build
+string_flag(
+ name = "PICO_DEFAULT_PRINTF_IMPL",
+ build_setting_default = "pico",
+ values = [
+ "pico",
+ "compiler",
+ "none",
+ ],
+)
+
+# PICO_BAZEL_CONFIG: PICO_BINARY_INFO_ENABLED, Whether to include binary info in final firmware, type=bool, default=1, group=pico_stdlib
+bool_flag(
+ name = "PICO_BINARY_INFO_ENABLED",
+ build_setting_default = True,
+)
+
# PICO_BAZEL_CONFIG: PICO_CMSIS_PATH, Label of a cc_ibrary providing CMSIS core, default="included stub CORE only impl", group=build
label_flag(
name = "PICO_CMSIS_PATH",
@@ -98,10 +175,17 @@
build_setting_default = "@tinyusb//:tinyusb",
)
-# PICO_BAZEL_CONFIG: PICO_DEFAULT_BINARY_INFO, [Bazel only] The library that provides custom_pico_binary_info to link into all binaries, default=//src/rp2_common/pico_standard_link:default_binary_info, group=pico_standard_link
+# TODO: Bazel build for mbedtls at @mbedtls//:mbedtls.
+# PICO_BAZEL_CONFIG: PICO_MBEDTLS_LIB, [Bazel only] The library that provides mbedtls, default=@mbedtls//:mbedtls, group=build
+label_flag(
+ name = "PICO_MBEDTLS_LIB",
+ build_setting_default = "//bazel:incompatible_cc_lib",
+)
+
+# PICO_BAZEL_CONFIG: PICO_DEFAULT_BINARY_INFO, [Bazel only] The library that provides custom_pico_binary_info to link into all binaries, default=//src/rp2_common/pico_standard_binary_info:default_binary_info, group=pico_standard_link
label_flag(
name = "PICO_DEFAULT_BINARY_INFO",
- build_setting_default = "//src/rp2_common/pico_standard_link:default_binary_info",
+ build_setting_default = "//src/rp2_common/pico_standard_binary_info:default_binary_info",
)
# PICO_BAZEL_CONFIG: PICO_BAZEL_BUILD_TYPE, The type of build (e.g. Debug or Release) to embed in binary info, type=string, default=pico, group=build
@@ -110,10 +194,10 @@
build_setting_default = "Debug",
)
-# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_standard_link:default_linker_script, group=pico_standard_link
+# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_crt0:default_linker_script, group=pico_standard_link
label_flag(
name = "PICO_DEFAULT_LINKER_SCRIPT",
- build_setting_default = "//src/rp2_common/pico_standard_link:default_linker_script",
+ build_setting_default = "//src/rp2_common/pico_crt0:default_linker_script",
)
# PICO_BAZEL_CONFIG: PICO_NO_TARGET_NAME, Don't define PICO_TARGET_NAME, type=bool, default=0, group=build
@@ -128,7 +212,7 @@
build_setting_default = "//bazel:no_extra_headers",
)
-# PICO_BAZEL_CONFIG: PICO_CONFIG_PLATFORM_HEADER, [Bazel only] The cc_library that provides "pico_config_platform_headers.h" and defines PICO_BOARD, default=//src/common/pico_base:default_platform_headers, group=pico_base
+# PICO_BAZEL_CONFIG: PICO_CONFIG_PLATFORM_HEADER, [Bazel only] The cc_library that provides "pico_config_platform_headers.h" and defines PICO_BOARD, default=//src/common/pico_base_headers:default_platform_headers, group=pico_base
label_flag(
name = "PICO_CONFIG_PLATFORM_HEADER",
build_setting_default = "//src/boards:default",
@@ -140,6 +224,18 @@
build_setting_default = "//bazel:generate_config_header",
)
+# PICO_BAZEL_CONFIG: PICO_CLIB, [Bazel only] The flavor of libc porting layer to use. auto infers the correct value to use from PICO_TOOLCHAIN, group=pico_standard_link
+string_flag(
+ name = "PICO_CLIB",
+ build_setting_default = "auto",
+ values = [
+ "auto",
+ "llvm_libc",
+ "newlib",
+ "picolibc",
+ ],
+)
+
# PICO_BAZEL_CONFIG: PICO_BTSTACK_CONFIG, [Bazel only] The cc_library that provides btstack_config.h, default=//bazel:empty_cc_lib, group=wireless
label_flag(
name = "PICO_BTSTACK_CONFIG",
diff --git a/bazel/constraint/BUILD.bazel b/bazel/constraint/BUILD.bazel
index e11d442..05cccb9 100644
--- a/bazel/constraint/BUILD.bazel
+++ b/bazel/constraint/BUILD.bazel
@@ -21,6 +21,13 @@
constraint_setting = ":sdk_target",
)
+# This constraint value is used to guide parts of the build that are specific
+# to the rp2350.
+constraint_value(
+ name = "rp2350",
+ constraint_setting = ":sdk_target",
+)
+
constraint_setting(
name = "wireless_support",
default_constraint_value = "no_wireless",
@@ -42,6 +49,16 @@
)
config_setting(
+ name = "pico_toolchain_clang_enabled",
+ flag_values = {"//bazel/config:PICO_TOOLCHAIN": "clang"},
+)
+
+config_setting(
+ name = "pico_toolchain_gcc_enabled",
+ flag_values = {"//bazel/config:PICO_TOOLCHAIN": "gcc"},
+)
+
+config_setting(
name = "pico_baremetal_enabled",
flag_values = {"//bazel/config:PICO_BARE_METAL": "True"},
)
@@ -82,6 +99,81 @@
)
config_setting(
+ name = "pico_stdio_rtt_enabled",
+ flag_values = {"//bazel/config:PICO_STDIO_RTT": "True"},
+)
+
+config_setting(
+ name = "pico_multicore_enabled",
+ flag_values = {"//bazel/config:PICO_MULTICORE_ENABLED": "True"},
+)
+
+config_setting(
+ name = "pico_float_auto_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "auto"},
+)
+
+config_setting(
+ name = "pico_float_compiler_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "compiler"},
+)
+
+config_setting(
+ name = "pico_float_dcp_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "dcp"},
+)
+
+config_setting(
+ name = "pico_float_rp2040_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "rp2040"},
+)
+
+config_setting(
+ name = "pico_float_vfp_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "vfp"},
+)
+
+config_setting(
+ name = "pico_double_auto_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "auto"},
+)
+
+config_setting(
+ name = "pico_double_compiler_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "compiler"},
+)
+
+config_setting(
+ name = "pico_double_dcp_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "dcp"},
+)
+
+config_setting(
+ name = "pico_double_rp2040_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "rp2040"},
+)
+
+config_setting(
+ name = "pico_divider_hardware_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_DIVIDER_IMPL": "hardware"},
+)
+
+config_setting(
+ name = "pico_divider_auto_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_DIVIDER_IMPL": "auto"},
+)
+
+config_setting(
+ name = "pico_printf_pico_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "pico"},
+)
+
+config_setting(
+ name = "pico_printf_compiler_enabled",
+ flag_values = {"//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "compiler"},
+)
+
+config_setting(
name = "pico_use_default_max_page_size_enabled",
flag_values = {"//bazel/config:PICO_USE_DEFAULT_MAX_PAGE_SIZE": "True"},
)
@@ -92,16 +184,31 @@
)
config_setting(
+ name = "pico_clib_llvm_libc_enabled",
+ flag_values = {"//bazel/config:PICO_CLIB": "llvm_libc"},
+)
+
+config_setting(
+ name = "pico_clib_newlib_enabled",
+ flag_values = {"//bazel/config:PICO_CLIB": "newlib"},
+)
+
+config_setting(
+ name = "pico_clib_picolibc_enabled",
+ flag_values = {"//bazel/config:PICO_CLIB": "picolibc"},
+)
+
+config_setting(
name = "pico_btstack_config_unset",
- flag_values = {"//bazel/config:PICO_BTSTACK_CONFIG": "@pico-sdk//bazel:empty_cc_lib"},
+ flag_values = {"//bazel/config:PICO_BTSTACK_CONFIG": "//bazel:empty_cc_lib"},
)
config_setting(
name = "pico_lwip_config_unset",
- flag_values = {"//bazel/config:PICO_LWIP_CONFIG": "@pico-sdk//bazel:empty_cc_lib"},
+ flag_values = {"//bazel/config:PICO_LWIP_CONFIG": "//bazel:empty_cc_lib"},
)
config_setting(
name = "pico_freertos_unset",
- flag_values = {"//bazel/config:PICO_FREERTOS_LIB": "@pico-sdk//bazel:empty_cc_lib"},
+ flag_values = {"//bazel/config:PICO_FREERTOS_LIB": "//bazel:empty_cc_lib"},
)
diff --git a/bazel/generate_version_header.py b/bazel/generate_version_header.py
index bd47b7c..79be833 100644
--- a/bazel/generate_version_header.py
+++ b/bazel/generate_version_header.py
@@ -35,7 +35,7 @@
return parser.parse_args()
-_EXPANSION_REGEX = re.compile("(?:\$\{)([a-zA-Z]\w*)(?:\})")
+_EXPANSION_REGEX = re.compile(r"(?:\$\{)([a-zA-Z]\w*)(?:\})")
def generate_version_header(version_string, template, output):
diff --git a/bazel/platform/BUILD.bazel b/bazel/platform/BUILD.bazel
index 467c0b1..39187b2 100644
--- a/bazel/platform/BUILD.bazel
+++ b/bazel/platform/BUILD.bazel
@@ -4,6 +4,14 @@
name = "rp2040",
constraint_values = [
"@pico-sdk//bazel/constraint:rp2040",
- "@platforms//cpu:armv6-m", # This is just FYI.
+ "@platforms//cpu:armv6-m",
+ ],
+)
+
+platform(
+ name = "rp2350",
+ constraint_values = [
+ "@pico-sdk//bazel/constraint:rp2350",
+ "@platforms//cpu:armv8-m",
],
)
diff --git a/bazel/toolchain/BUILD.bazel b/bazel/toolchain/BUILD.bazel
index 775ee18..9e0f771 100644
--- a/bazel/toolchain/BUILD.bazel
+++ b/bazel/toolchain/BUILD.bazel
@@ -7,6 +7,24 @@
package(default_visibility = ["//visibility:public"])
cc_args(
+ name = "armv6m-none-eabi",
+ actions = [
+ "@rules_cc//cc/toolchains/actions:compile_actions",
+ "@rules_cc//cc/toolchains/actions:link_actions",
+ ],
+ args = ["--target=armv6m-none-eabi"],
+)
+
+cc_args(
+ name = "armv8m.main-none-eabi",
+ actions = [
+ "@rules_cc//cc/toolchains/actions:compile_actions",
+ "@rules_cc//cc/toolchains/actions:link_actions",
+ ],
+ args = ["--target=armv8m.main-none-eabi"],
+)
+
+cc_args(
name = "cortex-m0",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
@@ -19,20 +37,50 @@
)
cc_args(
- name = "bazel_no_absolute_paths",
- actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
+ name = "cortex-m33",
+ actions = [
+ "@rules_cc//cc/toolchains/actions:compile_actions",
+ "@rules_cc//cc/toolchains/actions:link_actions",
+ ],
args = [
- "-fno-canonical-system-headers",
- "-no-canonical-prefixes",
+ "-mcpu=cortex-m33",
+ "-march=armv8-m.main+fp+dsp",
+ "-mfloat-abi=softfp",
+ "-mthumb",
+ "-mcmse",
],
)
+cc_args(
+ name = "no-canonical-system-headers",
+ actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
+ args = ["-fno-canonical-system-headers"],
+)
+
+cc_args(
+ name = "no-canonical-prefixes",
+ actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
+ args = ["-no-canonical-prefixes"],
+)
+
+cc_args(
+ name = "nostdlibxx",
+ actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
+ args = ["-nostdlib++"],
+)
+
+cc_args(
+ name = "nostartfiles",
+ actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
+ args = ["-nostartfiles"],
+)
+
cc_args_list(
- name = "all_unconditional_args",
- args = [
- ":cortex-m0",
- ":bazel_no_absolute_paths",
- ],
+ name = "bazel_no_absolute_paths",
+ args = select({
+ "//bazel/constraint:pico_toolchain_clang_enabled": [],
+ "//conditions:default": [":no-canonical-system-headers"],
+ }) + [":no-canonical-prefixes"],
)
cc_args(
@@ -151,7 +199,13 @@
"@arm_gcc_{}-{}//:arm-none-eabi-objcopy".format(host_os, host_cpu),
"@arm_gcc_{}-{}//:arm-none-eabi-strip".format(host_os, host_cpu),
],
- args = ["@pico-sdk//bazel/toolchain:all_unconditional_args"],
+ args = select({
+ "//bazel/constraint:rp2040": [":cortex-m0"],
+ "//bazel/constraint:rp2350": [":cortex-m33"],
+ "//conditions:default": [],
+ }) + [
+ ":bazel_no_absolute_paths",
+ ],
compiler = "gcc", # Useful for distinguishing gcc vs clang.
cxx_builtin_include_directories = [
"%sysroot%/arm-none-eabi/include/newlib-nano",
@@ -168,9 +222,48 @@
],
sysroot = "external/arm_gcc_{}-{}".format(host_os, host_cpu),
tags = ["manual"], # Don't try to build this in wildcard builds.
- target_compatible_with = [
- "@pico-sdk//bazel/constraint:rp2040",
+ toolchain_features = [
+ "@pico-sdk//bazel/toolchain:legacy_features",
+ "@pico-sdk//bazel/toolchain:override_debug",
+ "@pico-sdk//bazel/toolchain:gc_sections",
+ "@pico-sdk//bazel/toolchain:cxx_no_exceptions",
+ "@pico-sdk//bazel/toolchain:cxx_no_rtti",
+ "@pico-sdk//bazel/toolchain:cxx_no_cxa_atexit",
+ "@pico-sdk//bazel/toolchain:override_max_page_size",
],
+) for host_os, host_cpu in HOSTS]
+
+[cc_toolchain(
+ name = "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
+ action_type_configs = [
+ "@clang_{}-{}//:llvm-ar".format(host_os, host_cpu),
+ "@clang_{}-{}//:clang".format(host_os, host_cpu),
+ "@clang_{}-{}//:clang++".format(host_os, host_cpu),
+ "@clang_{}-{}//:lld".format(host_os, host_cpu),
+ "@clang_{}-{}//:llvm-objcopy".format(host_os, host_cpu),
+ "@clang_{}-{}//:llvm-strip".format(host_os, host_cpu),
+ ],
+ args = select({
+ "//bazel/constraint:rp2040": [
+ ":armv6m-none-eabi",
+ ":cortex-m0",
+ ],
+ "//bazel/constraint:rp2350": [
+ ":armv8m.main-none-eabi",
+ ":cortex-m33",
+ ],
+ "//conditions:default": [],
+ }) + [
+ ":bazel_no_absolute_paths",
+ ":nostdlibxx",
+ ":nostartfiles",
+ ],
+ compiler = "clang", # Useful for distinguishing gcc vs clang.
+ exec_compatible_with = [
+ _HOST_CPU_CONSTRAINTS[host_cpu],
+ _HOST_OS_CONSTRAINTS[host_os],
+ ],
+ tags = ["manual"], # Don't try to build this in wildcard builds.
toolchain_features = [
"@pico-sdk//bazel/toolchain:legacy_features",
"@pico-sdk//bazel/toolchain:override_debug",
@@ -183,7 +276,7 @@
) for host_os, host_cpu in HOSTS]
[toolchain(
- name = "arm_gcc_{}-{}".format(host_os, host_cpu),
+ name = "{}-{}-rp2040".format(host_os, host_cpu),
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
@@ -191,6 +284,25 @@
target_compatible_with = [
"@pico-sdk//bazel/constraint:rp2040",
],
- toolchain = ":arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
+ toolchain = select({
+ "//bazel/constraint:pico_toolchain_clang_enabled": "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
+ "//conditions:default": ":arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
+ }),
+ toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+) for host_os, host_cpu in HOSTS]
+
+[toolchain(
+ name = "{}-{}-rp2350".format(host_os, host_cpu),
+ exec_compatible_with = [
+ _HOST_CPU_CONSTRAINTS[host_cpu],
+ _HOST_OS_CONSTRAINTS[host_os],
+ ],
+ target_compatible_with = [
+ "@pico-sdk//bazel/constraint:rp2350",
+ ],
+ toolchain = select({
+ "//bazel/constraint:pico_toolchain_clang_enabled": "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
+ "//conditions:default": ":arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
+ }),
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
) for host_os, host_cpu in HOSTS]
diff --git a/bazel/toolchain/clang.BUILD b/bazel/toolchain/clang.BUILD
new file mode 100644
index 0000000..426fc33
--- /dev/null
+++ b/bazel/toolchain/clang.BUILD
@@ -0,0 +1,170 @@
+load("@rules_cc//cc/toolchains:action_type_config.bzl", "cc_action_type_config")
+load("@rules_cc//cc/toolchains:tool.bzl", "cc_tool")
+
+package(default_visibility = ["//visibility:public"])
+
+cc_tool(
+ name = "llvm-ar_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/llvm-ar.exe",
+ "//conditions:default": "//:bin/llvm-ar",
+ }),
+ data = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+cc_action_type_config(
+ name = "llvm-ar",
+ action_types = ["@rules_cc//cc/toolchains/actions:ar_actions"],
+ tools = [":llvm-ar_tool"],
+)
+
+cc_tool(
+ name = "clang_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/clang.exe",
+ "//conditions:default": "//:bin/clang",
+ }),
+ data = glob([
+ "include/armv*-unknown-none-eabi/**",
+ "lib/clang/*/include/**",
+ ]) + select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+cc_action_type_config(
+ name = "clang",
+ action_types = [
+ "@rules_cc//cc/toolchains/actions:assembly_actions",
+ "@rules_cc//cc/toolchains/actions:c_compile",
+ ],
+ tools = [":clang_tool"],
+)
+
+cc_tool(
+ name = "clang++_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/clang++.exe",
+ "//conditions:default": "//:bin/clang++",
+ }),
+ data = glob([
+ "include/armv*-unknown-none-eabi/**",
+ "include/c++/**",
+ "lib/clang/*/include/**",
+ ]) + select({
+ # Windows doesn't have llvm.exe.
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+cc_action_type_config(
+ name = "clang++",
+ action_types = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"],
+ tools = [":clang++_tool"],
+)
+
+# This tool is actually just clang++ under the hood, but this specifies a
+# different set of data files to pull into the sandbox at runtime.
+cc_tool(
+ name = "lld_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/clang++.exe",
+ "//conditions:default": "//:bin/clang++",
+ }),
+ data = glob([
+ "lib/armv*-unknown-none-eabi/**",
+ "lib/clang/*/lib/armv*-unknown-none-eabi/**",
+ ]) + select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+cc_action_type_config(
+ name = "lld",
+ action_types = ["@rules_cc//cc/toolchains/actions:link_actions"],
+ tools = [":lld_tool"],
+)
+
+cc_tool(
+ name = "llvm-objcopy_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/llvm-objcopy.exe",
+ "//conditions:default": "//:bin/llvm-objcopy",
+ }),
+ data = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+cc_action_type_config(
+ name = "llvm-objcopy",
+ action_types = ["@rules_cc//cc/toolchains/actions:objcopy_embed_data"],
+ tools = [":llvm-objcopy_tool"],
+)
+
+cc_tool(
+ name = "llvm-strip_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/llvm-strip.exe",
+ "//conditions:default": "//:bin/llvm-strip",
+ }),
+ data = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+cc_action_type_config(
+ name = "llvm-strip",
+ action_types = ["@rules_cc//cc/toolchains/actions:strip"],
+ tools = [":llvm-strip_tool"],
+)
+
+cc_tool(
+ name = "llvm-objdump_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/llvm-objdump.exe",
+ "//conditions:default": "//:bin/llvm-objdump",
+ }),
+ data = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+# There is not yet a well-known action type for llvm-objdump.
+
+cc_tool(
+ name = "llvm-profdata_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/llvm-profdata.exe",
+ "//conditions:default": "//:bin/llvm-profdata",
+ }),
+ data = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+# There is not yet a well-known action type for llvm-profdata.
+
+cc_tool(
+ name = "llvm-cov_tool",
+ src = select({
+ "@platforms//os:windows": "//:bin/llvm-cov.exe",
+ "//conditions:default": "//:bin/llvm-cov",
+ }),
+ data = select({
+ "@platforms//os:windows": [],
+ "//conditions:default": ["//:bin/llvm"],
+ }),
+)
+
+# There is not yet a well-known action type for llvm-cov.
diff --git a/bazel/util/transition.bzl b/bazel/util/transition.bzl
index d0baf0d..5346c25 100644
--- a/bazel/util/transition.bzl
+++ b/bazel/util/transition.bzl
@@ -113,6 +113,26 @@
},
)
+# This transition sets SDK configuration options required to build test binaries
+# for the pico_float_test suite of tests.
+pico_float_test_binary = declare_transtion(
+ attrs = {
+ "pico_printf_impl": attr.string(),
+ "extra_copts": attr.string_list(),
+ # This could be shared, but we don't in order to make it clearer that
+ # a transition is in use.
+ "_allowlist_function_transition": attr.label(
+ default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
+ ),
+ },
+ flag_overrides = {
+ "@pico-sdk//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "pico_printf_impl",
+ },
+ append_to_flags = {
+ "//command_line_option:copt": "extra_copts",
+ },
+)
+
# This is a general purpose transition that applies the listed copt flags to
# all transitive dependencies.
extra_copts_for_all_deps = declare_transtion(
diff --git a/cmake/generic_board.cmake b/cmake/generic_board.cmake
new file mode 100644
index 0000000..5238f20
--- /dev/null
+++ b/cmake/generic_board.cmake
@@ -0,0 +1,38 @@
+# For boards without their own cmake file, we look for a header file
+
+# PICO_CMAKE_CONFIG: PICO_BOARD_HEADER_DIRS, List of directories to look for <PICO_BOARD>.h in. This may be specified the user environment, type=list, group=build
+if (DEFINED ENV{PICO_BOARD_HEADER_DIRS})
+ set(PICO_BOARD_HEADER_DIRS $ENV{PICO_BOARD_HEADER_DIRS})
+ message("Using PICO_BOARD_HEADER_DIRS from environment ('${PICO_BOARD_HEADER_DIRS}')")
+endif()
+set(PICO_BOARD_HEADER_DIRS ${PICO_BOARD_HEADER_DIRS} CACHE STRING "PICO board header directories" FORCE)
+
+list(APPEND PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/../src/boards/include/boards)
+pico_find_in_paths(PICO_BOARD_HEADER_FILE PICO_BOARD_HEADER_DIRS ${PICO_BOARD}.h)
+
+if (EXISTS ${PICO_BOARD_HEADER_FILE})
+ message("Using board configuration from ${PICO_BOARD_HEADER_FILE}")
+ list(APPEND PICO_CONFIG_HEADER_FILES ${PICO_BOARD_HEADER_FILE})
+
+ # we parse the header file to configure the defaults
+ file(STRINGS ${PICO_BOARD_HEADER_FILE} HEADER_FILE_CONTENTS)
+
+ while(HEADER_FILE_CONTENTS)
+ list(POP_FRONT HEADER_FILE_CONTENTS LINE)
+ if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
+ set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
+ endif()
+ if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set_default[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
+ if (NOT DEFINED "${CMAKE_MATCH_1}")
+ set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
+ endif()
+ endif()
+ endwhile()
+else()
+ set(msg "Unable to find definition of board '${PICO_BOARD}' (specified by PICO_BOARD):\n")
+ list(JOIN PICO_BOARD_HEADER_DIRS ", " DIRS)
+ string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.h in ${DIRS} (additional paths specified by PICO_BOARD_HEADER_DIRS)\n")
+ list(JOIN PICO_BOARD_CMAKE_DIRS ", " DIRS)
+ string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.cmake in ${DIRS} (additional paths specified by PICO_BOARD_CMAKE_DIRS)")
+ message(FATAL_ERROR ${msg})
+endif()
diff --git a/cmake/pico_pre_load_platform.cmake b/cmake/pico_pre_load_platform.cmake
index 3bce8e6..7a2c2ab 100644
--- a/cmake/pico_pre_load_platform.cmake
+++ b/cmake/pico_pre_load_platform.cmake
@@ -1,21 +1,135 @@
-# PICO_CMAKE_CONFIG: PICO_PLATFORM, platform to build for e.g. rp2040/host, type=string, default=rp2040 or environment value, group=build
-if (DEFINED ENV{PICO_PLATFORM} AND (NOT PICO_PLATFORM))
+# PICO_BOARD is the root of config as it can define PICO_PLATFORM and other build vars
+
+# PICO_CMAKE_CONFIG: PICO_BOARD, Board name being built for. This may be specified in the user environment, type=string, default=pico or pico2, group=build, docref=cmake-platform-board-config
+if (DEFINED ENV{PICO_BOARD} AND NOT PICO_BOARD)
+ set(PICO_BOARD $ENV{PICO_BOARD})
+ message("Initializing PICO_BOARD from environment ('${PICO_BOARD}')")
+endif()
+
+# PICO_CMAKE_CONFIG: PICO_PLATFORM, Platform to build for e.g. rp2040/rp2350/rp2350-arm-s/rp2350-riscv/host. This may be specified in the user environment, type=string, default=based on PICO_BOARD or environment value, group=build, docref=cmake-platform-board-config
+if (DEFINED ENV{PICO_PLATFORM} AND NOT PICO_PLATFORM)
set(PICO_PLATFORM $ENV{PICO_PLATFORM})
- message("Using PICO_PLATFORM from environment ('${PICO_PLATFORM}')")
-else()
+ message("Initializing PICO_PLATFORM from environment ('${PICO_PLATFORM}')")
+endif()
+set(PICO_SAVED_PLATFORM "${PICO_PLATFORM}")
+
+# If PICO_PLATFORM is specified byt not PICO_BOARD, we'll make a stab at defaulting
+if (NOT PICO_DEFAULT_BOARD_rp2040)
+ set(PICO_DEFAULT_BOARD_rp2040 "pico")
+endif()
+if (NOT PICO_DEFAULT_BOARD_rp2350)
+ set(PICO_DEFAULT_BOARD_rp2350 "pico2")
+endif()
+if (NOT PICO_DEFAULT_BOARD_rp2350-arm-s)
+ set(PICO_DEFAULT_BOARD_rp2350-arm-s "pico2")
+endif()
+if (NOT PICO_DEFAULT_BOARD_rp2350-riscv)
+ set(PICO_DEFAULT_BOARD_rp2350-riscv "pico2")
+endif()
+if (NOT PICO_DEFAULT_BOARD_host)
+ set(PICO_DEFAULT_BOARD_host "none")
+endif()
+
+if (NOT PICO_DEFAULT_PLATFORM)
+ set(PICO_DEFAULT_PLATFORM "rp2040")
+endif()
+
+if (NOT PICO_BOARD)
if (NOT PICO_PLATFORM)
- set(PICO_PLATFORM "rp2040")
- pico_message("Defaulting PICO_PLATFORM to ${PICO_PLATFORM} since not specified.")
- else()
- message("PICO platform is ${PICO_PLATFORM}.")
+ # if we have neither BOARD nor PLATFORM default PLATFORM silently, so we don't end up with a board of "none"
+ # on platform that does have a default board (we want default PLATFORM and BOARD in that case)
+ set(PICO_PLATFORM ${PICO_DEFAULT_PLATFORM})
+ # set PICO_SAVED_PLATFORM so we don't print "Defaulting" again below
+ set(PICO_SAVED_PLATFORM ${PICO_DEFAULT_PLATFORM})
+ pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' since not specified.")
endif()
-endif ()
+ if (PICO_DEFAULT_BOARD_${PICO_PLATFORM})
+ set(PICO_BOARD ${PICO_DEFAULT_BOARD_${PICO_PLATFORM}})
+ else()
+ set(PICO_BOARD "none")
+ endif()
+ pico_message("Defaulting target board (PICO_BOARD) to '${PICO_BOARD}' since not specified.")
+else()
+ message("Target board (PICO_BOARD) is '${PICO_BOARD}'.")
+endif()
+set(PICO_BOARD ${PICO_BOARD} CACHE STRING "PICO target board (e.g. pico, pico2)" FORCE)
-set(PICO_PLATFORM ${PICO_PLATFORM} CACHE STRING "PICO Build platform (e.g. rp2040, host)")
+# PICO_CMAKE_CONFIG: PICO_BOARD_CMAKE_DIRS, List of directories to look for <PICO_BOARD>.cmake in. This may be specified in the user environment, type=list, group=build
+if (DEFINED ENV{PICO_BOARD_CMAKE_DIRS})
+ set(PICO_BOARD_CMAKE_DIRS $ENV{PICO_BOARD_CMAKE_DIRS})
+ message("Using PICO_BOARD_CMAKE_DIRS from environment ('${PICO_BOARD_CMAKE_DIRS}')")
+endif()
-# PICO_CMAKE_CONFIG: PICO_CMAKE_PRELOAD_PLATFORM_FILE, custom CMake file to use to set up the platform environment, type=string, group=build
-set(PICO_CMAKE_PRELOAD_PLATFORM_FILE "" CACHE INTERNAL "")
-set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/platforms" CACHE INTERNAL "")
+list(APPEND PICO_BOARD_CMAKE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../src/boards)
+
+pico_find_in_paths(PICO_BOARD_CMAKE_FILE PICO_BOARD_CMAKE_DIRS ${PICO_BOARD}.cmake)
+if (EXISTS "${PICO_BOARD_CMAKE_FILE}")
+ message("Using CMake board configuration from ${PICO_BOARD_CMAKE_FILE}")
+ include(${PICO_BOARD_CMAKE_FILE} board_config)
+else()
+ include(generic_board)
+endif()
+
+list(APPEND PICO_INCLUDE_DIRS ${PICO_SDK_PATH}/src/boards/include) # so boards/foo.h can be explicitly included
+
+# PICO_CMAKE_CONFIG: PICO_DEFAULT_RP2350_PLATFORM, Default actual platform to build for if rp2350 is specified for PICO_PLATFORM e.g. rp2350-arm-s/rp2350-riscv, type=string, default=rp2350-arm-s, group=build
+if (DEFINED ENV{PICO_DEFAULT_RP2350_PLATFORM} AND NOT PICO_DEFAULT_RP2350_PLATFORM)
+ set(PICO_DEFAULT_RP2350_PLATFORM $ENV{PICO_DEFAULT_RP2350_PLATFORM})
+endif()
+if (NOT PICO_DEFAULT_RP2350_PLATFORM)
+ set(PICO_DEFAULT_RP2350_PLATFORM "rp2350-arm-s")
+endif()
+
+if (NOT COMMAND pico_expand_pico_platform)
+ function(pico_expand_pico_platform FUNC DO_MESSAGE)
+ if (${FUNC} STREQUAL "rp2350")
+ if (DO_MESSAGE)
+ message("Auto-converting non-specific PICO_PLATFORM='rp2350' to 'rp2350-arm-s'")
+ endif()
+ set(${FUNC} "${PICO_DEFAULT_RP2350_PLATFORM}" PARENT_SCOPE)
+ endif()
+ endfunction()
+endif()
+
+if (NOT PICO_PLATFORM)
+ set(PICO_PLATFORM ${PICO_DEFAULT_PLATFORM})
+ pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' since not specified.")
+else()
+ if (NOT PICO_SAVED_PLATFORM)
+ pico_expand_pico_platform(PICO_PLATFORM 1)
+ pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' based on PICO_BOARD setting.")
+ else()
+ string(REGEX REPLACE "-.*" "" PICO_PLATFORM_PREFIX ${PICO_PLATFORM})
+ string(REGEX REPLACE "-.*" "" PICO_SAVED_PLATFORM_PREFIX ${PICO_SAVED_PLATFORM})
+ if (PICO_PLATFORM_PREFIX STREQUAL PICO_SAVED_PLATFORM_PREFIX)
+ # the PICO_PLATFORM specified based on the board is compatible based on the one we were
+ # already using, so use that
+ pico_expand_pico_platform(PICO_SAVED_PLATFORM 0)
+ set(PICO_PLATFORM ${PICO_SAVED_PLATFORM})
+ message("Pico Platform (PICO_PLATFORM) is '${PICO_PLATFORM}'.")
+ else()
+ message(FATAL_ERROR "PICO_PLATFORM is specified to be '${PICO_SAVED_PLATFORM}', but PICO_BOARD='${PICO_BOARD}' uses \
+ '${PICO_PLATFORM}' which is incompatible. You need to delete the CMake cache or build directory and reconfigure to proceed. \
+ The best practice is to use separate build directories for different platforms.")
+ endif()
+ endif()
+endif()
+unset(PICO_SAVED_PLATFORM)
+
+if (PICO_PREVIOUS_PLATFORM AND NOT PICO_PREVIOUS_PLATFORM STREQUAL PICO_PLATFORM)
+ message(FATAL_ERROR "PICO_PLATFORM has been modified from '${PICO_SAVED_PLATFORM}' to '${PICO_PLATFORM}.\
+ You need to delete the CMake cache or build directory and reconfigure to proceed.\
+ The best practice is to use separate build directories for different platforms.")
+endif()
+set(PICO_PLATFORM ${PICO_PLATFORM} CACHE STRING "PICO Build platform (e.g. rp2040, rp2350, rp2350-riscv, host)" FORCE)
+set(PICO_PREVIOUS_PLATFORM ${PICO_PLATFORM} CACHE STRING "Saved PICO Build platform (e.g. rp2040, rp2350, rp2350-riscv, host)" INTERNAL)
+
+# PICO_CMAKE_CONFIG: PICO_CMAKE_PRELOAD_PLATFORM_FILE, Custom CMake file to use to set up the platform environment, type=string, group=build
+set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_FILE} CACHE INTERNAL "")
+if (NOT PICO_CMAKE_PRELOAD_PLATFORM_DIR)
+ set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/platforms")
+endif()
+set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${PICO_CMAKE_PRELOAD_PLATFORM_DIR}" CACHE INTERNAL "")
if (NOT PICO_CMAKE_PRELOAD_PLATFORM_FILE)
set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")
diff --git a/cmake/pico_pre_load_toolchain.cmake b/cmake/pico_pre_load_toolchain.cmake
index a8fbbdb..b41b386 100644
--- a/cmake/pico_pre_load_toolchain.cmake
+++ b/cmake/pico_pre_load_toolchain.cmake
@@ -1,9 +1,11 @@
-# PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, type=string, default=none (i.e. search system paths), group=build
+# PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, type=string, default=none (i.e. search system paths), group=build, docref=cmake-toolchain-config
set(PICO_TOOLCHAIN_PATH "${PICO_TOOLCHAIN_PATH}" CACHE INTERNAL "")
# Set a default build type if none was specified
set(default_build_type "Release")
+list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PREFIX_PATH)
+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Defaulting build type to '${default_build_type}' since not specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build, options are: 'Debug', 'Release', 'MinSizeRel', 'RelWithDebInfo'." FORCE)
@@ -16,28 +18,59 @@
error("Default build type is NOT supported")
endif()
-# PICO_CMAKE_CONFIG: PICO_COMPILER, Optionally specifies a different compiler (other than pico_arm_gcc.cmake) - this is not yet fully supported, type=string, group=build
-# If PICO_COMPILER is specified, set toolchain file to ${PICO_COMPILER}.cmake.
-if (DEFINED PICO_COMPILER)
- if (DEFINED CMAKE_TOOLCHAIN_FILE)
- get_filename_component(toolchain "${CMAKE_TOOLCHAIN_FILE}" NAME_WE)
- if (NOT "${PICO_COMPILER}" STREQUAL "${toolchain}")
- message(WARNING "CMAKE_TOOLCHAIN_FILE is already defined to ${toolchain}.cmake, you\
- need to delete cache and reconfigure if you want to switch compiler.")
- endif ()
- else ()
- set(toolchain_dir "${CMAKE_CURRENT_LIST_DIR}/preload/toolchains")
- set(toolchain_file "${toolchain_dir}/${PICO_COMPILER}.cmake")
- if (EXISTS "${toolchain_file}")
- set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}" CACHE INTERNAL "")
- else ()
- # todo improve message
- message(FATAL_ERROR "Toolchain file \"${PICO_COMPILER}.cmake\" does not exist, please\
- select one from \"cmake/toolchains\" folder.")
- endif ()
- endif ()
- message("PICO compiler is ${PICO_COMPILER}")
+if (NOT (DEFINED PICO_COMPILER OR DEFINED CMAKE_TOOLCHAIN_FILE))
+ if (DEFINED PICO_DEFAULT_COMPILER)
+ pico_message("Defaulting compiler (PICO_COMPILER) to '${PICO_DEFAULT_COMPILER}' since not specified.")
+ set(PICO_COMPILER ${PICO_DEFAULT_COMPILER})
+ endif()
endif ()
+# PICO_CMAKE_CONFIG: PICO_COMPILER, Specifies the compiler family to use, type=string, group=build, default=PICO_DEFAULT_COMPILER which is set based on PICO_PLATFORM, docref=cmake-toolchain-config
+# If PICO_COMPILER is specified, set toolchain file to ${PICO_COMPILER}.cmake.
+if (DEFINED PICO_COMPILER)
+ # maintain backwards compatibility with RP2040 SDK compilers
+ set(ORIG_PICO_COMPILER "${PICO_COMPILER}")
+ if (PICO_COMPILER STREQUAL "pico_arm_gcc")
+ if (PICO_PLATFORM STREQUAL "rp2040")
+ set(PICO_COMPILER "pico_arm_cortex_m0plus_gcc")
+ elseif(PICO_PLATFORM STREQUAL "rp2350")
+ set(PICO_COMPILER "pico_arm_cortex_m33_gcc")
+ endif()
+ elseif(PICO_COMPILER STREQUAL "pico_arm_clang")
+ if (PICO_PLATFORM STREQUAL "rp2040")
+ set(PICO_COMPILER "pico_arm_cortex_m0plus_clang")
+ elseif(PICO_PLATFORM STREQUAL "rp2350-arm-s")
+ set(PICO_COMPILER "pico_arm_cortex_m33_clang")
+ elseif(PICO_PLATFORM STREQUAL "rp2350-arm-ns")
+ set(PICO_COMPILER "pico_arm_cortex_m33_clang")
+ endif()
+ endif()
+ if (NOT PICO_COMPILER STREQUAL ORIG_PICO_COMPILER)
+ message("Accepting PICO_COMPILER value '${ORIG_PICO_COMPILER}' for compatibility, but using '${PICO_COMPILER}' instead")
+ endif()
+ if (NOT DEFINED PICO_TOOLCHAIN_DIR)
+ set(PICO_TOOLCHAIN_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/toolchains")
+ endif()
+ set(toolchain_file "${PICO_TOOLCHAIN_DIR}/${PICO_COMPILER}.cmake")
+ if (EXISTS "${toolchain_file}")
+ set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}")
+ else ()
+ # todo improve message
+ message(FATAL_ERROR "Toolchain file \"${PICO_COMPILER}.cmake\" does not exist, please\
+ select one from \"cmake/toolchains\" folder.")
+ endif ()
+ message("Configuring toolchain based on PICO_COMPILER '${PICO_COMPILER}'")
+endif ()
+
+if (PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE)
+ if (NOT "${PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE}" STREQUAL "${CMAKE_TOOLCHAIN_FILE}")
+ message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE was previously defined to ${PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE}, and now\
+ is being changed to ${CMAKE_TOOLCHAIN_FILE}. You\
+ need to delete the CMake cache and reconfigure if you want to switch compiler.\
+ The best practice is to use separate build directories for different platforms or compilers.")
+ endif ()
+endif ()
+
+set(PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE INTERNAL "Saved CMAKE_TOOLCHAIN_FILE" FORCE)
unset(PICO_COMPILER CACHE)
diff --git a/cmake/preload/platforms/combined-docs.cmake b/cmake/preload/platforms/combined-docs.cmake
new file mode 100644
index 0000000..5683d77
--- /dev/null
+++ b/cmake/preload/platforms/combined-docs.cmake
@@ -0,0 +1,3 @@
+set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc")
+set(PICO_CHIP rp2350)
+
diff --git a/cmake/preload/platforms/pico/pico.cmake b/cmake/preload/platforms/pico/pico.cmake
deleted file mode 100644
index 6e49411..0000000
--- a/cmake/preload/platforms/pico/pico.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-if (NOT (DEFINED PICO_COMPILER OR DEFINED CMAKE_TOOLCHAIN_FILE))
- pico_message("Defaulting PICO platform compiler to pico_arm_gcc since not specified.")
- set(PICO_COMPILER "pico_arm_gcc")
-endif ()
-
-
-
diff --git a/cmake/preload/platforms/rp2040.cmake b/cmake/preload/platforms/rp2040.cmake
index 3406bfc..e8151dc 100644
--- a/cmake/preload/platforms/rp2040.cmake
+++ b/cmake/preload/platforms/rp2040.cmake
@@ -1 +1,2 @@
-include(${CMAKE_CURRENT_LIST_DIR}/pico/pico.cmake)
\ No newline at end of file
+set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m0plus_gcc")
+set(PICO_CHIP rp2040)
diff --git a/cmake/preload/platforms/rp2350-arm-s.cmake b/cmake/preload/platforms/rp2350-arm-s.cmake
new file mode 100644
index 0000000..5683d77
--- /dev/null
+++ b/cmake/preload/platforms/rp2350-arm-s.cmake
@@ -0,0 +1,3 @@
+set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc")
+set(PICO_CHIP rp2350)
+
diff --git a/cmake/preload/platforms/rp2350-riscv.cmake b/cmake/preload/platforms/rp2350-riscv.cmake
new file mode 100644
index 0000000..2d15db4
--- /dev/null
+++ b/cmake/preload/platforms/rp2350-riscv.cmake
@@ -0,0 +1,3 @@
+set(PICO_DEFAULT_COMPILER "pico_riscv_gcc")
+set(PICO_CHIP rp2350)
+
diff --git a/cmake/preload/toolchains/find_compiler.cmake b/cmake/preload/toolchains/find_compiler.cmake
deleted file mode 100644
index 6052369..0000000
--- a/cmake/preload/toolchains/find_compiler.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-# Toolchain file is processed multiple times, however, it cannot access CMake cache on some runs.
-# We store the search path in an environment variable so that we can always access it.
-if (NOT "${PICO_TOOLCHAIN_PATH}" STREQUAL "")
- set(ENV{PICO_TOOLCHAIN_PATH} "${PICO_TOOLCHAIN_PATH}")
-endif ()
-
-# Find the compiler executable and store its path in a cache entry ${compiler_path}.
-# If not found, issue a fatal message and stop processing. PICO_TOOLCHAIN_PATH can be provided from
-# commandline as additional search path.
-function(pico_find_compiler compiler_path compiler_exe)
- # Search user provided path first.
- find_program(
- ${compiler_path} ${compiler_exe}
- PATHS ENV PICO_TOOLCHAIN_PATH
- PATH_SUFFIXES bin
- NO_DEFAULT_PATH
- )
-
- # If not then search system paths.
- if ("${${compiler_path}}" STREQUAL "${compiler_path}-NOTFOUND")
- if (DEFINED ENV{PICO_TOOLCHAIN_PATH})
- message(WARNING "PICO_TOOLCHAIN_PATH specified ($ENV{PICO_TOOLCHAIN_PATH}), but ${compiler_exe} not found there")
- endif()
- find_program(${compiler_path} ${compiler_exe})
- endif ()
- if ("${${compiler_path}}" STREQUAL "${compiler_path}-NOTFOUND")
- set(PICO_TOOLCHAIN_PATH "" CACHE PATH "Path to search for compiler.")
- message(FATAL_ERROR "Compiler '${compiler_exe}' not found, you can specify search path with\
- \"PICO_TOOLCHAIN_PATH\".")
- endif ()
-endfunction()
diff --git a/cmake/preload/toolchains/pico_arm_clang.cmake b/cmake/preload/toolchains/pico_arm_clang.cmake
deleted file mode 100644
index 2e600c8..0000000
--- a/cmake/preload/toolchains/pico_arm_clang.cmake
+++ /dev/null
@@ -1,47 +0,0 @@
-# NOTE: THIS IS A WIP ONLY PICO_ARM_GCC IS CURRENTLY SUPPORTED, however should work with LLVM Embedded Toolchain for ARM
-# version 14.0.0 https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/tag/release-14.0.0
-# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
-# i.e. CMake<Lang>Information and whatnot
-include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
-
-# include our Platform/pico.cmake
-set(CMAKE_SYSTEM_NAME PICO)
-set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
-
-# Find CLANG
-pico_find_compiler(PICO_COMPILER_CC clang)
-pico_find_compiler(PICO_COMPILER_CXX clang)
-#pico_find_compiler(PICO_COMPILER_ASM armasm)
-set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
-pico_find_compiler(PICO_OBJCOPY llvm-objcopy)
-pico_find_compiler(PICO_OBJDUMP llvm-objdump)
-
-# Specify the cross compiler.
-set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
-set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
-set(CMAKE_C_OUTPUT_EXTENSION .o)
-
-# todo should we be including CMakeASMInformation anyway - i guess that is host side
-set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
-set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
-set(CMAKE_INCLUDE_FLAG_ASM "-I")
-set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
-set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
-
-# Add target system root to cmake find path.
-get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
-get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
-
-# Look for includes and libraries only in the target system prefix.
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-
-option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
-
-# Oz is preferred for Clang (verses CMake default -Os) see also https://gitlab.kitware.com/cmake/cmake/-/issues/22458
-set(CMAKE_C_FLAGS_MINSIZEREL "-Oz -DNDEBUG")
-
-set(ARM_TOOLCHAIN_COMMON_FLAGS "--target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m --sysroot ${PICO_COMPILER_DIR}/../lib/clang-runtimes/armv6m_soft_nofp")
-include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
diff --git a/cmake/preload/toolchains/pico_arm_clang_arm.cmake b/cmake/preload/toolchains/pico_arm_clang_arm.cmake
index b943f1b..bf06d34 100644
--- a/cmake/preload/toolchains/pico_arm_clang_arm.cmake
+++ b/cmake/preload/toolchains/pico_arm_clang_arm.cmake
@@ -1,7 +1,7 @@
# NOTE: THIS IS A WIP ONLY PICO_ARM_GCC IS CURRENTLY SUPPORTED
# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
# i.e. CMake<Lang>Information and whatnot
-include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/util/find_compiler.cmake)
# include our Platform/PICO.cmake
set(CMAKE_SYSTEM_NAME PICO)
@@ -37,7 +37,5 @@
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
-
set(ARM_TOOLCHAIN_COMMON_FLAGS " --cpu=Cortex-M0plus")
-include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/util/set_flags.cmake)
diff --git a/cmake/preload/toolchains/pico_arm_cortex_m0plus_clang.cmake b/cmake/preload/toolchains/pico_arm_cortex_m0plus_clang.cmake
new file mode 100644
index 0000000..5ebde3e
--- /dev/null
+++ b/cmake/preload/toolchains/pico_arm_cortex_m0plus_clang.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
+
+# these are all the directories under LLVM embedded toolchain for ARM (newlib or pibolibc) and under llvm_libc
+set(PICO_CLANG_RUNTIMES armv6m_soft_nofp armv6m-unknown-none-eabi)
+
+set(PICO_COMMON_LANG_FLAGS "--target=armv6m-none-eabi -mfloat-abi=soft -march=armv6m")
+
+include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_clang_common.cmake)
diff --git a/cmake/preload/toolchains/pico_arm_cortex_m0plus_gcc.cmake b/cmake/preload/toolchains/pico_arm_cortex_m0plus_gcc.cmake
new file mode 100644
index 0000000..55bfffe
--- /dev/null
+++ b/cmake/preload/toolchains/pico_arm_cortex_m0plus_gcc.cmake
@@ -0,0 +1,7 @@
+set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
+
+set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi)
+# on ARM -mcpu should not be mixed with -march
+set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m0plus -mthumb")
+
+include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)
\ No newline at end of file
diff --git a/cmake/preload/toolchains/pico_arm_cortex_m23_gcc.cmake b/cmake/preload/toolchains/pico_arm_cortex_m23_gcc.cmake
new file mode 100644
index 0000000..4bd6b24
--- /dev/null
+++ b/cmake/preload/toolchains/pico_arm_cortex_m23_gcc.cmake
@@ -0,0 +1,15 @@
+# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
+# i.e. CMake<Lang>Information and whatnot
+
+set(CMAKE_SYSTEM_PROCESSOR cortex-m23)
+set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi)
+
+# todo amy should this be -mfloat-abi=hard?
+set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m23 -mthumb -march=armv8-m.base")
+# todo probably need a setting here, also do we want `softfp`?
+set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mfloat-abi=softfp")
+if (NOT PICO_NO_CMSE)
+ set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mcmse")
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)
\ No newline at end of file
diff --git a/cmake/preload/toolchains/pico_arm_cortex_m33_clang.cmake b/cmake/preload/toolchains/pico_arm_cortex_m33_clang.cmake
new file mode 100644
index 0000000..d35bdbc
--- /dev/null
+++ b/cmake/preload/toolchains/pico_arm_cortex_m33_clang.cmake
@@ -0,0 +1,8 @@
+set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
+
+# these are all the directories under LLVM embedded toolchain for ARM (newlib or pibolibc) and under llvm_libc
+set(PICO_CLANG_RUNTIMES armv8m.main_soft_nofp armv8m.main-unknown-none-eabi)
+
+set(PICO_COMMON_LANG_FLAGS "-mcpu=cortex-m33 --target=armv8m.main-none-eabi -mfloat-abi=softfp -march=armv8m.main+fp+dsp")
+
+include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_clang_common.cmake)
diff --git a/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake b/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake
new file mode 100644
index 0000000..0ba3351
--- /dev/null
+++ b/cmake/preload/toolchains/pico_arm_cortex_m33_gcc.cmake
@@ -0,0 +1,10 @@
+set(CMAKE_SYSTEM_PROCESSOR cortex-m33)
+set(PICO_DEFAULT_GCC_TRIPLE arm-none-eabi)
+
+set(PICO_COMMON_LANG_FLAGS " -mcpu=cortex-m33 -mthumb -march=armv8-m.main+fp+dsp")
+set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mfloat-abi=softfp")
+if (NOT PICO_NO_CMSE)
+ set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} -mcmse")
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)
\ No newline at end of file
diff --git a/cmake/preload/toolchains/pico_arm_gcc.cmake b/cmake/preload/toolchains/pico_arm_gcc.cmake
deleted file mode 100644
index ad5d33f..0000000
--- a/cmake/preload/toolchains/pico_arm_gcc.cmake
+++ /dev/null
@@ -1,52 +0,0 @@
-# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
-# i.e. CMake<Lang>Information and whatnot
-include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
-
-# include our Platform/PICO.cmake
-set(CMAKE_SYSTEM_NAME PICO)
-set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
-
-if (NOT PICO_GCC_TRIPLE)
- if (DEFINED ENV{PICO_GCC_TRIPLE})
- set(PICO_GCC_TRIPLE $ENV{PICO_GCC_TRIPLE})
- message("PICO_GCC_TRIPLE set from environment: $ENV{PICO_GCC_TRIPLE}")
- else()
- set(PICO_GCC_TRIPLE arm-none-eabi)
- #pico_message_debug("PICO_GCC_TRIPLE defaulted to arm-none-eabi")
- endif()
-endif()
-
-# Find GCC for ARM.
-pico_find_compiler(PICO_COMPILER_CC ${PICO_GCC_TRIPLE}-gcc)
-pico_find_compiler(PICO_COMPILER_CXX ${PICO_GCC_TRIPLE}-g++)
-set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
-pico_find_compiler(PICO_OBJCOPY ${PICO_GCC_TRIPLE}-objcopy)
-pico_find_compiler(PICO_OBJDUMP ${PICO_GCC_TRIPLE}-objdump)
-
-# Specify the cross compiler.
-set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
-set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
-set(CMAKE_C_OUTPUT_EXTENSION .o)
-
-# todo should we be including CMakeASMInformation anyway - i guess that is host side
-set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
-set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
-set(CMAKE_INCLUDE_FLAG_ASM "-I")
-set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
-set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
-
-# Add target system root to cmake find path.
-get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
-get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
-
-# Look for includes and libraries only in the target system prefix.
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-
-option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
-
-# on ARM -mcpu should not be mixed with -march
-set(ARM_TOOLCHAIN_COMMON_FLAGS " -mcpu=cortex-m0plus -mthumb")
-include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
diff --git a/cmake/preload/toolchains/pico_riscv_gcc.cmake b/cmake/preload/toolchains/pico_riscv_gcc.cmake
new file mode 100644
index 0000000..d8a4548
--- /dev/null
+++ b/cmake/preload/toolchains/pico_riscv_gcc.cmake
@@ -0,0 +1,7 @@
+set(CMAKE_SYSTEM_PROCESSOR hazard3)
+
+set(PICO_DEFAULT_GCC_TRIPLE riscv32-unknown-elf riscv32-corev-elf)
+
+set(PICO_COMMON_LANG_FLAGS " -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32")
+
+include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)
diff --git a/cmake/preload/toolchains/pico_riscv_gcc_zcb_zcmp.cmake b/cmake/preload/toolchains/pico_riscv_gcc_zcb_zcmp.cmake
new file mode 100644
index 0000000..ffb067d
--- /dev/null
+++ b/cmake/preload/toolchains/pico_riscv_gcc_zcb_zcmp.cmake
@@ -0,0 +1,10 @@
+# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
+# i.e. CMake<Lang>Information and whatnot
+
+set(CMAKE_SYSTEM_PROCESSOR hazard3)
+
+set(PICO_DEFAULT_GCC_TRIPLE riscv32-unknown-elf riscv32-corev-elf)
+
+set(PICO_COMMON_LANG_FLAGS " -march=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb_zcmp -mabi=ilp32")
+
+include(${CMAKE_CURRENT_LIST_DIR}/util/pico_arm_gcc_common.cmake)
diff --git a/cmake/preload/toolchains/set_flags.cmake b/cmake/preload/toolchains/set_flags.cmake
deleted file mode 100644
index 7f208db..0000000
--- a/cmake/preload/toolchains/set_flags.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-
-get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
-foreach(LANG IN ITEMS C CXX ASM)
- set(CMAKE_${LANG}_FLAGS_INIT "${ARM_TOOLCHAIN_COMMON_FLAGS}")
- unset(CMAKE_${LANG}_FLAGS_DEBUG CACHE)
- if (PICO_DEOPTIMIZED_DEBUG)
- set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
- else()
- set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og")
- endif()
- set(CMAKE_${LANG}_LINK_FLAGS "-Wl,--build-id=none")
-
- # try_compile is where the feature testing is done, and at that point,
- # pico_standard_link is not ready to be linked in to provide essential
- # functions like _exit. So pass -nostdlib so it doesn't link in an exit()
- # function at all.
- if(IS_IN_TRY_COMPILE)
- set(CMAKE_${LANG}_LINK_FLAGS "${CMAKE_${LANG}_LINK_FLAGS} -nostdlib")
- endif()
-endforeach()
diff --git a/cmake/preload/toolchains/util/find_compiler.cmake b/cmake/preload/toolchains/util/find_compiler.cmake
new file mode 100644
index 0000000..62519bd
--- /dev/null
+++ b/cmake/preload/toolchains/util/find_compiler.cmake
@@ -0,0 +1,41 @@
+# Toolchain file is processed multiple times, however, it cannot access CMake cache on some runs.
+# We store the search path in an environment variable so that we can always access it.
+if (NOT "${PICO_TOOLCHAIN_PATH}" STREQUAL "")
+ set(ENV{PICO_TOOLCHAIN_PATH} "${PICO_TOOLCHAIN_PATH}")
+endif ()
+
+# Find the compiler executable and store its path in a cache entry ${compiler_path}.
+# If not found, issue a fatal message and stop processing. PICO_TOOLCHAIN_PATH can be provided from
+# commandline as additional search path.
+function(pico_find_compiler compiler_path compiler_exes)
+ # Search user provided path first.
+ find_program(
+ ${compiler_path} NAMES ${compiler_exes}
+ PATHS ENV PICO_TOOLCHAIN_PATH
+ PATH_SUFFIXES bin
+ NO_DEFAULT_PATH
+ )
+
+ # If not then search system paths.
+ if ("${${compiler_path}}" STREQUAL "${compiler_path}-NOTFOUND")
+ if (DEFINED ENV{PICO_TOOLCHAIN_PATH})
+ message(WARNING "PICO_TOOLCHAIN_PATH specified ($ENV{PICO_TOOLCHAIN_PATH}), but ${compiler_exe} not found there")
+ endif()
+ find_program(${compiler_path} NAMES ${compiler_exes})
+ endif ()
+ if ("${${compiler_path}}" STREQUAL "${compiler_path}-NOTFOUND")
+ set(PICO_TOOLCHAIN_PATH "" CACHE PATH "Path to search for compiler.")
+ list(JOIN compiler_exes " / " compiler_exes)
+ message(FATAL_ERROR "Compiler '${compiler_exes}' not found, you can specify search path with\
+ \"PICO_TOOLCHAIN_PATH\".")
+ endif ()
+endfunction()
+
+# Find the compiler executable and store its path in a cache entry ${compiler_path}.
+# If not found, issue a fatal message and stop processing. PICO_TOOLCHAIN_PATH can be provided from
+# commandline as additional search path.
+function(pico_find_compiler_with_triples compiler_path triples compiler_suffix)
+ list(TRANSFORM triples APPEND "-${compiler_suffix}")
+ pico_find_compiler(${compiler_path} "${triples}")
+ set(${compiler_path} ${${compiler_path}} PARENT_SCOPE)
+endfunction()
diff --git a/cmake/preload/toolchains/util/pico_arm_clang_common.cmake b/cmake/preload/toolchains/util/pico_arm_clang_common.cmake
new file mode 100644
index 0000000..5cb4e2d
--- /dev/null
+++ b/cmake/preload/toolchains/util/pico_arm_clang_common.cmake
@@ -0,0 +1,97 @@
+include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
+
+# include our Platform/PICO.cmake
+set(CMAKE_SYSTEM_NAME PICO)
+
+# Find Clang
+pico_find_compiler(PICO_COMPILER_CC clang)
+pico_find_compiler(PICO_COMPILER_CXX clang++)
+set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
+pico_find_compiler(PICO_OBJCOPY llvm-objcopy)
+pico_find_compiler(PICO_OBJDUMP llvm-objdump)
+
+# Specify the cross compiler.
+set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
+set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
+set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
+
+# workaround for projects that don't enable ASM
+set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+set(CMAKE_INCLUDE_FLAG_ASM "-I")
+
+set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
+set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
+
+foreach(LANG IN ITEMS C CXX ASM)
+ set(CMAKE_${LANG}_OUTPUT_EXTENSION .o)
+endforeach()
+
+# Add target system root to cmake find path.
+get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
+get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
+
+# Look for includes and libraries only in the target system prefix.
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+# Oz is preferred for Clang (verses CMake default -Os) see also https://gitlab.kitware.com/cmake/cmake/-/issues/22458
+foreach(LANG IN ITEMS C CXX ASM)
+ set(CMAKE_${LANG}_FLAGS_MINSIZEREL_INIT "-Oz -DNDEBUG")
+endforeach()
+
+list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES PICO_CLIB)
+
+foreach(PICO_CLANG_RUNTIME IN LISTS PICO_CLANG_RUNTIMES)
+ # LLVM embedded-toolchain for ARM style
+ find_path(PICO_COMPILER_SYSROOT NAMES include/stdio.h
+ HINTS
+ ${PICO_COMPILER_DIR}/../lib/clang-runtimes/arm-none-eabi/${PICO_CLANG_RUNTIME}
+ ${PICO_COMPILER_DIR}/../lib/clang-runtimes/${PICO_CLANG_RUNTIME}
+ )
+
+ if (PICO_COMPILER_SYSROOT)
+ if (NOT PICO_CLIB)
+ # this is a bit of a hack; to try to autodetect the C library used:
+ # `picolibc.h` seems to exist on the newer versions of LLVM embedded toolchain for ARM using picolibc whereas
+ # `newlib.h` appears in all versions, so isn't very useful
+ if (EXISTS "${PICO_COMPILER_SYSROOT}/include/picolibc.h")
+ message("Setting default C library to picolibc as LLVM appears to be using it")
+ set(PICO_CLIB "picolibc" CACHE INTERNAL "")
+ endif()
+ endif()
+ break()
+ endif()
+ # llvm_libc style
+ find_path(PICO_COMPILER_SYSROOT NAMES stdio.h
+ HINTS
+ ${PICO_COMPILER_DIR}/../include/${PICO_CLANG_RUNTIME}
+ )
+ if (PICO_COMPILER_SYSROOT)
+ if (NOT PICO_CLIB)
+ message("Setting default C library to llvm_libc as LLVM appears to be using it")
+ set(PICO_CLIB "llvm_libc" CACHE INTERNAL "")
+ endif()
+ break()
+ endif()
+endforeach()
+
+# moving this here as a reminder from pico_standard_link; it was commented out theee, but if ever needed,
+# it belongs here as part of LINKER_FLAGS_INIT
+#target_link_options(pico_standard_link INTERFACE "LINKER:-fuse-ld=lld")
+
+if (PICO_CLIB STREQUAL "llvm_libc")
+ # TODO: Remove -nostdlib++ once we include libc++ in the toolchain.
+ # TODO: Move -nostartfiles to the appropriate library.
+ foreach(TYPE IN ITEMS EXE SHARED MODULE)
+ set(CMAKE_${TYPE}_LINKER_FLAGS_INIT "-nostdlib++ -nostartfiles")
+ endforeach()
+else()
+ if (NOT PICO_COMPILER_SYSROOT)
+ message(FATAL_ERROR "Could not find an llvm runtime for '${PICO_CLANG_RUNTIME}'")
+ endif()
+
+ set(PICO_COMMON_LANG_FLAGS "${PICO_COMMON_LANG_FLAGS} --sysroot ${PICO_COMPILER_SYSROOT}")
+endif()
+include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
diff --git a/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake b/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake
new file mode 100644
index 0000000..053e1b1
--- /dev/null
+++ b/cmake/preload/toolchains/util/pico_arm_gcc_common.cmake
@@ -0,0 +1,57 @@
+include(${CMAKE_CURRENT_LIST_DIR}/find_compiler.cmake)
+
+# include our Platform/PICO.cmake
+set(CMAKE_SYSTEM_NAME PICO)
+
+# PICO_CMAKE_CONFIG: PICO_GCC_TRIPLE, List of GCC_TRIPLES -- usually only one -- to try when searching for a compiler. This may be specified the user environment, type=int, default=PICO_DEFAULT_GCC_TRIPLE which is set based on PICO_COMPILER, group=pico_base, doxref=cmake-toolchain-config
+if (NOT PICO_GCC_TRIPLE)
+ if (DEFINED ENV{_SAVED_PICO_GCC_TRIPLE})
+ # saved within the same cmake invocation
+ set(PICO_GCC_TRIPLE $ENV{_SAVED_PICO_GCC_TRIPLE})
+ elseif (DEFINED ENV{PICO_GCC_TRIPLE})
+ set(PICO_GCC_TRIPLE $ENV{PICO_GCC_TRIPLE})
+ message("Initializing PICO_GCC_TRIPLE from environment ('${PICO_GCC_TRIPLE}')")
+ elseif(DEFINED PICO_DEFAULT_GCC_TRIPLE)
+ message("Defaulting PICO_GCC_TRIPLE to '${PICO_DEFAULT_GCC_TRIPLE}'")
+ set(PICO_GCC_TRIPLE ${PICO_DEFAULT_GCC_TRIPLE})
+ else()
+ message(FATAL_ERROR "PICO_DEFAULT_GCC_TRIPLE is not defined")
+ endif()
+endif()
+set(PICO_GCC_TRIPLE "${PICO_GCC_TRIPLE}" CACHE INTERNAL "")
+set(ENV{_SAVED_PICO_GCC_TRIPLE} "${PICO_GCC_TRIPLE}")
+
+# Find GCC
+pico_find_compiler_with_triples(PICO_COMPILER_CC "${PICO_GCC_TRIPLE}" gcc)
+pico_find_compiler_with_triples(PICO_COMPILER_CXX "${PICO_GCC_TRIPLE}" g++)
+set(PICO_COMPILER_ASM "${PICO_COMPILER_CC}" CACHE INTERNAL "")
+pico_find_compiler_with_triples(PICO_OBJCOPY "${PICO_GCC_TRIPLE}" objcopy)
+pico_find_compiler_with_triples(PICO_OBJDUMP "${PICO_GCC_TRIPLE}" objdump)
+
+# Specify the cross compiler.
+set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
+set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
+set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
+
+# workaround for projects that don't enable ASM
+set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+set(CMAKE_INCLUDE_FLAG_ASM "-I")
+
+set(CMAKE_OBJCOPY ${PICO_OBJCOPY} CACHE FILEPATH "")
+set(CMAKE_OBJDUMP ${PICO_OBJDUMP} CACHE FILEPATH "")
+
+foreach(LANG IN ITEMS C CXX ASM)
+ set(CMAKE_${LANG}_OUTPUT_EXTENSION .o)
+endforeach()
+
+# Add target system root to cmake find path.
+get_filename_component(PICO_COMPILER_DIR "${PICO_COMPILER_CC}" DIRECTORY)
+get_filename_component(CMAKE_FIND_ROOT_PATH "${PICO_COMPILER_DIR}" DIRECTORY)
+
+# Look for includes and libraries only in the target system prefix.
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake)
diff --git a/cmake/preload/toolchains/util/set_flags.cmake b/cmake/preload/toolchains/util/set_flags.cmake
new file mode 100644
index 0000000..5a70670
--- /dev/null
+++ b/cmake/preload/toolchains/util/set_flags.cmake
@@ -0,0 +1,26 @@
+option(PICO_DEOPTIMIZED_DEBUG "Build debug builds with -O0" 0)
+option(PICO_DEBUG_INFO_IN_RELEASE "Include debug info in release builds" 1)
+
+get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
+foreach(LANG IN ITEMS C CXX ASM)
+ set(CMAKE_${LANG}_FLAGS_INIT "${PICO_COMMON_LANG_FLAGS}")
+ unset(CMAKE_${LANG}_FLAGS_DEBUG CACHE)
+ if (PICO_DEOPTIMIZED_DEBUG)
+ set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-O0")
+ else()
+ set(CMAKE_${LANG}_FLAGS_DEBUG_INIT "-Og")
+ endif()
+ if (PICO_DEBUG_INFO_IN_RELEASE)
+ set(CMAKE_${LANG}_FLAGS_RELEASE_INIT "-g")
+ set(CMAKE_${LANG}_FLAGS_MINSIZEREL_INIT "-g")
+ endif()
+ set(CMAKE_${LANG}_LINK_FLAGS "-Wl,--build-id=none")
+
+ # try_compile is where the feature testing is done, and at that point,
+ # pico_standard_link is not ready to be linked in to provide essential
+ # functions like _exit. So pass -nostdlib so it doesn't link in an exit()
+ # function at all.
+ if(IS_IN_TRY_COMPILE)
+ set(CMAKE_${LANG}_LINK_FLAGS "${CMAKE_${LANG}_LINK_FLAGS} -nostdlib")
+ endif()
+endforeach()
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index 45fd1d6..3171c5d 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -40,13 +40,26 @@
endif()
set(DOXY_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doxygen")
- set(DOXY_INPUT_DIRS "${PICO_DOXYGEN_PATHS}")
- set(DOXY_EXCLUDE_DIRS "${PICO_DOXYGEN_EXCLUDE_PATHS}")
+ string(REPLACE ";" " " DOXY_INPUT_DIRS "${PICO_DOXYGEN_PATHS}")
+ string(REPLACE ";" " " DOXY_EXCLUDE_DIRS "${PICO_DOXYGEN_EXCLUDE_PATHS}")
+ string(REPLACE ";" " " DOXY_PREDEFINED "${PICO_DOXYGEN_PRE_DEFINES}")
+ string(REPLACE ";" " " DOXY_ENABLED_SECTIONS "${PICO_DOXYGEN_ENABLED_SECTIONS}")
set(DOXY_EXAMPLE_DIR "${PICO_EXAMPLES_PATH}")
-
+ # auto genereate additional section enables from library paths
+ foreach (DIR IN LISTS PICO_DOXYGEN_PATHS)
+ get_filename_component(NAME "${DIR}" NAME)
+ if (NOT DIR STREQUAL "src")
+ set(DOXY_ENABLED_SECTIONS "${DOXY_ENABLED_SECTIONS} ${NAME}")
+ endif()
+ endforeach ()
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
+ if (PICO_PLATFORM STREQUAL "rp2040")
+ set(PICO_DOXYGEN_TAG "(RP2040)")
+ elseif (PICO_PLATFORM STREQUAL "rp2350-arm-s" OR PICO_PLATFORM STREQUAL "rp2350-riscv")
+ set(PICO_DOXYGEN_TAG "(RP2350)")
+ endif()
configure_file(${doxyfile_in} ${doxyfile} @ONLY)
add_custom_target(docs
diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in
index 5dc4be7..916877b 100644
--- a/docs/Doxyfile.in
+++ b/docs/Doxyfile.in
@@ -1,6 +1,6 @@
PROJECT_NAME = "Raspberry Pi Pico SDK"
PROJECT_BRIEF = "Raspberry Pi Pico SDK documentation"
-PROJECT_NUMBER = @PICO_SDK_VERSION_STRING@
+PROJECT_NUMBER = @PICO_SDK_VERSION_STRING@ @PICO_DOXYGEN_TAG@
#STRIP_FROM_PATH = @PROJECT_SOURCE_DIR@
STRIP_FROM_PATH = @DOXY_INPUT_DIRS@
@@ -50,15 +50,19 @@
EXTRACT_ALL = NO
ALWAYS_DETAILED_SEC = NO
-#REPEAT_BRIEF = NO
+#REPEAT_BRIEF = NO
+ENABLE_PREPROCESSING = YES
# Need these next options to ensure that functions with modifiers do not confuse the Doxygen parser.
# And any further function modifiers here.
MACRO_EXPANSION = YES
-PREDEFINED = __not_in_flash_func(x) \
- __time_critical_func(x) \
+PREDEFINED = __not_in_flash_func(x)= \
+ __time_critical_func(x)= \
__not_in_flash(x)= \
__no_inline_not_in_flash(x)= \
__attribute__(x)= \
- DOXYGEN_GENERATION=
+ DOXYGEN_GENERATION= \
+ @DOXY_PREDEFINED@
+
+ENABLED_SECTIONS = @DOXY_ENABLED_SECTIONS@
\ No newline at end of file
diff --git a/docs/index.h b/docs/index.h
index d6edc00..ded921d 100644
--- a/docs/index.h
+++ b/docs/index.h
@@ -6,67 +6,88 @@
// Here to organize documentation order
+// for some reason cond/endcond work better here than if/endif
+
/**
* \defgroup hardware Hardware APIs
- * This group of libraries provides a thin and efficient C API / abstractions to access the RP2040 hardware without having to read and write
+ * This group of libraries provides a thin and efficient C API / abstractions to access the RP-series microcontroller hardware without having to read and write
* hardware registers directly.
* @{
- * \defgroup hardware_adc hardware_adc
- * \defgroup hardware_base hardware_base
- * \defgroup hardware_claim hardware_claim
- * \defgroup hardware_clocks hardware_clocks
- * \defgroup hardware_divider hardware_divider
- * \defgroup hardware_dma hardware_dma
- * \defgroup hardware_exception hardware_exception
- * \defgroup hardware_flash hardware_flash
- * \defgroup hardware_gpio hardware_gpio
- * \defgroup hardware_i2c hardware_i2c
- * \defgroup hardware_interp hardware_interp
- * \defgroup hardware_irq hardware_irq
- * \defgroup hardware_pio hardware_pio
- * \defgroup hardware_pll hardware_pll
- * \defgroup hardware_pwm hardware_pwm
- * \defgroup hardware_resets hardware_resets
- * \defgroup hardware_rtc hardware_rtc
- * \defgroup hardware_spi hardware_spi
- * \defgroup hardware_sync hardware_sync
- * \defgroup hardware_timer hardware_timer
- * \defgroup hardware_uart hardware_uart
- * \defgroup hardware_vreg hardware_vreg
- * \defgroup hardware_watchdog hardware_watchdog
- * \defgroup hardware_xosc hardware_xosc
+ * \cond hardware_adc \defgroup hardware_adc hardware_adc \endcond
+ * \cond hardware_base \defgroup hardware_base hardware_base \endcond
+ * \cond hardware_bootlock \defgroup hardware_bootlock hardware_bootlock \endcond
+ * \cond hardware_claim \defgroup hardware_claim hardware_claim \endcond
+ * \cond hardware_clocks \defgroup hardware_clocks hardware_clocks \endcond
+ * \cond hardware_divider \defgroup hardware_divider hardware_divider \endcond
+ * \cond hardware_dcp \defgroup hardware_dcp hardware_dcp \endcond
+ * \cond hardware_dma \defgroup hardware_dma hardware_dma \endcond
+ * \cond hardware_exception \defgroup hardware_exception hardware_exception \endcond
+ * \cond hardware_flash \defgroup hardware_flash hardware_flash \endcond
+ * \cond hardware_gpio \defgroup hardware_gpio hardware_gpio \endcond
+ * \cond hardware_hazard3 \defgroup hardware_hazard3 hardware_hazard3 \endcond
+ * \cond hardware_i2c \defgroup hardware_i2c hardware_i2c \endcond
+ * \cond hardware_interp \defgroup hardware_interp hardware_interp \endcond
+ * \cond hardware_irq \defgroup hardware_irq hardware_irq \endcond
+ * \cond hardware_pio \defgroup hardware_pio hardware_pio \endcond
+ * \cond hardware_pll \defgroup hardware_pll hardware_pll \endcond
+ * \cond hardware_powman \defgroup hardware_powman hardware_powman \endcond
+ * \cond hardware_pwm \defgroup hardware_pwm hardware_pwm \endcond
+ * \cond hardware_pwm \defgroup hardware_pwm hardware_pwm \endcond
+ * \cond hardware_resets \defgroup hardware_resets hardware_resets \endcond
+ * \cond hardware_riscv \defgroup hardware_riscv hardware_riscv \endcond
+ * \cond hardware_riscv_platform_timer \defgroup hardware_riscv_platform_timer hardware_riscv_platform_timer \endcond
+ * \cond hardware_rtc \defgroup hardware_rtc hardware_rtc \endcond
+ * \cond hardware_rcp \defgroup hardware_rcp hardware_rcp \endcond
+ * \cond hardware_spi \defgroup hardware_spi hardware_spi \endcond
+ * \cond hardware_sha256 \defgroup hardware_sha256 hardware_sha256 \endcond
+ * \cond hardware_sync \defgroup hardware_sync hardware_sync \endcond
+ * \cond hardware_ticks \defgroup hardware_ticks hardware_ticks \endcond
+ * \cond hardware_timer \defgroup hardware_timer hardware_timer \endcond
+ * \cond hardware_uart \defgroup hardware_uart hardware_uart \endcond
+ * \cond hardware_vreg \defgroup hardware_vreg hardware_vreg \endcond
+ * \cond hardware_watchdog \defgroup hardware_watchdog hardware_watchdog \endcond
+ * \cond hardware_xosc \defgroup hardware_xosc hardware_xosc \endcond
+ * \cond hardware_powman hardware_powman
+ * \cond hardware_hazard3 hardware_hazard3
+ * \cond hardware_riscv hardware_riscv
+
* @}
*
* \defgroup high_level High Level APIs
* This group of libraries provide higher level functionality that isn't hardware related or provides a richer
* set of functionality above the basic hardware interfaces
* @{
- * \defgroup pico_async_context pico_async_context
- * \defgroup pico_flash pico_flash
- * \defgroup pico_i2c_slave pico_i2c_slave
- * \defgroup pico_multicore pico_multicore
- * \defgroup pico_rand pico_rand
- * \defgroup pico_stdlib pico_stdlib
- * \defgroup pico_sync pico_sync
- * \defgroup pico_time pico_time
- * \defgroup pico_unique_id pico_unique_id
- * \defgroup pico_util pico_util
+ * \cond pico_aon_timer \defgroup pico_aon_timer pico_aon_timer \endcond
+ * \cond pico_async_context \defgroup pico_async_context pico_async_context \endcond
+ * \cond pico_bootsel_via_double_reset \defgroup pico_bootsel_via_double_reset pico_bootsel_via_double_reset \endcond
+ * \cond pico_flash \defgroup pico_flash pico_flash \endcond
+ * \cond pico_i2c_slave \defgroup pico_i2c_slave pico_i2c_slave \endcond
+ * \cond pico_multicore \defgroup pico_multicore pico_multicore \endcond
+ * \cond pico_rand \defgroup pico_rand pico_rand \endcond
+ * \cond pico_sha256 \defgroup pico_sha256 pico_sha256 \endcond
+ * \cond pico_stdlib \defgroup pico_stdlib pico_stdlib \endcond
+ * \cond pico_sync \defgroup pico_sync pico_sync \endcond
+ * \cond pico_time \defgroup pico_time pico_time \endcond
+ * \cond pico_unique_id \defgroup pico_unique_id pico_unique_id \endcond
+ * \cond pico_util \defgroup pico_util pico_util \endcond
* @}
*
* \defgroup third_party Third-party Libraries
* Third party libraries for implementing high level functionality.
* @{
+ * \cond tinyusb
* \defgroup tinyusb_device tinyusb_device
* \defgroup tinyusb_host tinyusb_host
+ * \endcond
* @}
*
* \defgroup networking Networking Libraries
* Functions for implementing networking
* @{
- * \defgroup pico_btstack pico_btstack
- * \defgroup pico_lwip pico_lwip
- * \defgroup pico_cyw43_driver pico_cyw43_driver
- * \defgroup pico_cyw43_arch pico_cyw43_arch
+ * \cond pico_btstack \defgroup pico_btstack pico_btstack \endcond
+ * \cond pico_lwip \defgroup pico_lwip pico_lwip \endcond
+ * \cond pico_cyw43_driver \defgroup pico_cyw43_driver pico_cyw43_driver \endcond
+ * \cond pico_cyw43_arch \defgroup pico_cyw43_arch pico_cyw43_arch \endcond
* @}
*
* \defgroup runtime Runtime Infrastructure
@@ -74,30 +95,36 @@
* language level and C library functions, as well as CMake INTERFACE libraries
* abstracting the compilation and link steps in the SDK
* @{
- * \defgroup boot_stage2 boot_stage2
- * \defgroup pico_base pico_base
- * \defgroup pico_binary_info pico_binary_info
- * \defgroup pico_bit_ops pico_bit_ops
- * \defgroup pico_bootrom pico_bootrom
- * \defgroup pico_bootsel_via_double_reset pico_bootsel_via_double_reset
- * \defgroup pico_cxx_options pico_cxx_options
- * \defgroup pico_divider pico_divider
- * \defgroup pico_double pico_double
- * \defgroup pico_float pico_float
- * \defgroup pico_int64_ops pico_int64_ops
- * \defgroup pico_malloc pico_malloc
- * \defgroup pico_mem_ops pico_mem_ops
- * \defgroup pico_platform pico_platform
- * \defgroup pico_printf pico_printf
- * \defgroup pico_runtime pico_runtime
- * \defgroup pico_stdio pico_stdio
- * \defgroup pico_standard_link pico_standard_link
+ * \cond boot_stage2 \defgroup boot_stage2 boot_stage2 \endcond
+ * \cond pico_atomic \defgroup pico_atomic pico_atomic \endcond
+ * \cond pico_base_headers \defgroup pico_base pico_base \endcond
+ * \cond pico_binary_info \defgroup pico_binary_info pico_binary_info \endcond
+ * \cond pico_bootrom \defgroup pico_bootrom pico_bootrom \endcond
+ * \cond pico_bit_ops \defgroup pico_bit_ops pico_bit_ops \endcond
+ * \cond pico_cxx_options \defgroup pico_cxx_options pico_cxx_options \endcond
+ * \cond pico_clib_interface \defgroup pico_clib_interface pico_clib_interface \endcond
+ * \cond pico_crt0 \defgroup pico_crt0 pico_crt0 \endcond
+ * \cond pico_divider \defgroup pico_divider pico_divider \endcond
+ * \cond pico_double \defgroup pico_double pico_double \endcond
+ * \cond pico_float \defgroup pico_float pico_float \endcond
+ * \cond pico_int64_ops \defgroup pico_int64_ops pico_int64_ops \endcond
+ * \cond pico_malloc \defgroup pico_malloc pico_malloc \endcond
+ * \cond pico_mem_ops \defgroup pico_mem_ops pico_mem_ops \endcond
+ * \cond pico_platform \defgroup pico_platform pico_platform \endcond
+ * \cond pico_printf \defgroup pico_printf pico_printf \endcond
+ * \cond pico_runtime \defgroup pico_runtime pico_runtime \endcond
+ * \cond pico_runtime_init \defgroup pico_runtime_init pico_runtime_init \endcond
+ * \cond pico_stdio \defgroup pico_stdio pico_stdio \endcond
+ * \cond pico_standard_binary_info \defgroup pico_standard_binary_info pico_standard_binary_info \endcond
+ * \cond pico_standard_link \defgroup pico_standard_link pico_standard_link \endcond
* @}
*
* \defgroup misc External API Headers
* Headers for interfaces that are shared with code outside of the SDK
* @{
- * \defgroup boot_picoboot boot_picoboot
- * \defgroup boot_uf2 boot_uf2
+ * \cond boot_picobin_headers \defgroup boot_picobin_headers boot_picobin_headers \endcond
+ * \cond boot_picoboot_headers \defgroup boot_picoboot_headers boot_picoboot_headers \endcond
+ * \cond boot_uf2_headers \defgroup boot_uf2_headers boot_uf2_headers \endcond
+ * \cond pico_usb_reset_interface_headers \defgroup pico_usb_reset_interface_headers pico_usb_reset_interface_headers \endcond
* @}
*/
diff --git a/docs/mainpage.md b/docs/mainpage.md
index 01e5411..307fbb3 100644
--- a/docs/mainpage.md
+++ b/docs/mainpage.md
@@ -1,16 +1,16 @@
# Raspberry Pi Pico SDK
-The Raspberry Pi Pico SDK (Software Development Kit), henceforth SDK, provides the headers, libraries and build system necessary to write programs for RP2040-based devices such as the Raspberry Pi Pico in C, C++ or assembly language. The SDK is designed to provide an API (Application Programming Interface) and programming environment that is familiar both to non-embedded C developers and embedded C developers alike.
+The Raspberry Pi Pico SDK (Software Development Kit), henceforth SDK, provides the headers, libraries and build system necessary to write programs for RP-series microcontroller devices such as the Raspberry Pi Pico in C, C++ or assembly language. The SDK is designed to provide an API (Application Programming Interface) and programming environment that is familiar both to non-embedded C developers and embedded C developers alike.
-A single program runs on the device at a time with a conventional `main()` method. Standard C/C++ libraries are supported along with APIs for accessing the RP2040’s hardware, including DMA, IRQs, and the wide variety of fixed-function peripherals and PIO (Programmable IO).
+A single program runs on the device at a time with a conventional `main()` method. Standard C/C++ libraries are supported along with APIs for accessing the microcontroller's hardware, including DMA, IRQs, and the wide variety of fixed-function peripherals and PIO (Programmable IO).
-Additionally the SDK provides higher-level libraries for dealing with timers, USB, synchronization and multi-core programming, along with additional high-level functionality built using PIO, such as audio. The SDK can be used to build anything from simple applications, or full-fledged runtime environments such as MicroPython, to low-level software such as the RP2040’s on-chip bootrom itself.
+Additionally the SDK provides higher-level libraries for dealing with timers, USB, synchronization and multi-core programming, along with additional high-level functionality built using PIO, such as audio. The SDK can be used to build anything from simple applications, or full-fledged runtime environments such as MicroPython, to low-level software such as the microcontroller's on-chip bootrom itself.
This documentation is generated from the SDK source tree using Doxygen. It provides basic information on the APIs used for each library, but does not provide usage information. Please refer to the Databooks for usage and more technical information.
## SDK Design
-The RP2040 is a powerful chip, however it is an embedded environment, so both RAM and program space are at premium. Additionally the trade-offs between performance and other factors (e.g. edge-case error handling, runtime vs compile-time configuration) are necessarily much more visible to the developer than they might be on other higher-level platforms.
+The RP-series microcontroller range are powerful chips, however they are used in an embedded environment, so both RAM and program space are at premium. Additionally the trade-offs between performance and other factors (e.g. edge-case error handling, runtime vs compile-time configuration) are necessarily much more visible to the developer than they might be on other higher-level platforms.
The intention within the SDK has been for features to just work out of the box, with sensible defaults, but also to give the developer as much control and power as possible (if they want it) to fine-tune every aspect of the application they are building and the libraries used.
@@ -20,7 +20,7 @@
Apart from being a widely-used build system for C/C++ development, CMake is fundamental to the way the SDK is structured, and how applications are configured and built.
-The SDK builds an executable which is bare-metal, i.e. it includes the entirety of the code needed to run on the device (other than floating-point and other optimized code contained in the bootrom within the RP2040).
+The SDK builds an executable which is bare-metal, i.e. it includes the entirety of the code needed to run on the device (other than device specific floating-point and other optimized code contained in the bootrom within the microcontroller).
## Examples
diff --git a/docs/weblinks_page.md b/docs/weblinks_page.md
index 7b84fc9..4f96db7 100644
--- a/docs/weblinks_page.md
+++ b/docs/weblinks_page.md
@@ -4,6 +4,8 @@
- [RP2040 Datasheet](https://rptl.io/rp2040-datasheet)
- [Raspberry Pi Pico Datasheet](https://rptl.io/pico-datasheet)
+ - [RP235x Datasheet](https://rptl.io/rp2040-datasheet)
+ - [Raspberry Pi Pico2 Datasheet](https://rptl.io/pico-datasheet)
- [Raspberry Pi Pico W Datasheet](https://rptl.io/picow-datasheet)
- [Hardware design with RP2040](https://rptl.io/rp2040-design)
- [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk)
diff --git a/lib/cyw43-driver b/lib/cyw43-driver
index 7ee0b7b..faf3638 160000
--- a/lib/cyw43-driver
+++ b/lib/cyw43-driver
@@ -1 +1 @@
-Subproject commit 7ee0b7bd4a4fd13b5e03a0bab7f80491ae37e9ab
+Subproject commit faf36381bad1f668a30172b6336c9a970966ef4c
diff --git a/lib/mbedtls b/lib/mbedtls
index a77287f..5a764e5 160000
--- a/lib/mbedtls
+++ b/lib/mbedtls
@@ -1 +1 @@
-Subproject commit a77287f8fa6b76f74984121fdafc8563147435c8
+Subproject commit 5a764e5555c64337ed17444410269ff21cb617b1
diff --git a/lib/tinyusb b/lib/tinyusb
index 86c416d..4232642 160000
--- a/lib/tinyusb
+++ b/lib/tinyusb
@@ -1 +1 @@
-Subproject commit 86c416d4c0fb38432460b3e11b08b9de76941bf5
+Subproject commit 4232642899362fa5e9cf0dc59bad6f1f6d32c563
diff --git a/pico_sdk_init.cmake b/pico_sdk_init.cmake
index 5153e2b..48b44db 100644
--- a/pico_sdk_init.cmake
+++ b/pico_sdk_init.cmake
@@ -41,13 +41,6 @@
include(pico_utils)
message("PICO_SDK_PATH is ${CMAKE_CURRENT_LIST_DIR}")
-
- include(pico_pre_load_platform)
-
- # We want to configure correct toolchain prior to project load
- # todo perhaps this should be included by the platform instead?
- include(pico_pre_load_toolchain)
-
macro(pico_sdk_init)
if (NOT CMAKE_PROJECT_NAME)
message(WARNING "pico_sdk_init() should be called after the project is created (and languages added)")
@@ -90,4 +83,10 @@
SET(${VAR} ${${VAR}} PARENT_SCOPE)
endforeach()
endmacro()
+
+ include(pico_pre_load_platform)
+
+ # We want to configure correct toolchain prior to project load
+ # todo perhaps this should be included by the platform instead?
+ include(pico_pre_load_toolchain)
endif()
diff --git a/pico_sdk_version.cmake b/pico_sdk_version.cmake
index bb7b050..37145ce 100644
--- a/pico_sdk_version.cmake
+++ b/pico_sdk_version.cmake
@@ -1,18 +1,18 @@
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
-# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
-set(PICO_SDK_VERSION_MAJOR 1)
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
-# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
-set(PICO_SDK_VERSION_MINOR 5)
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
-# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
-set(PICO_SDK_VERSION_REVISION 2)
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
-# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
-set(PICO_SDK_VERSION_PRE_RELEASE_ID develop)
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
+set(PICO_SDK_VERSION_MAJOR 2)
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
+set(PICO_SDK_VERSION_MINOR 0)
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
+set(PICO_SDK_VERSION_REVISION 0)
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base
+#set(PICO_SDK_VERSION_PRE_RELEASE_ID develop)
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
-# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
set(PICO_SDK_VERSION_STRING "${PICO_SDK_VERSION_MAJOR}.${PICO_SDK_VERSION_MINOR}.${PICO_SDK_VERSION_REVISION}")
if (PICO_SDK_VERSION_PRE_RELEASE_ID)
diff --git a/src/BUILD.bazel b/src/BUILD.bazel
new file mode 100644
index 0000000..6f121f8
--- /dev/null
+++ b/src/BUILD.bazel
@@ -0,0 +1,26 @@
+package(default_visibility = ["//visibility:public"])
+
+# This shim exists as a way to break internal header dependency cycles
+# that occur within the dependency chain of the pico_platform target below.
+alias(
+ name = "pico_platform_internal",
+ actual = select({
+ "//bazel/constraint:host": "//src/host/pico_platform:pico_platform_internal",
+ "//conditions:default": "//src/rp2_common:pico_platform_internal",
+ }),
+ visibility = [
+ "//src/common/boot_picobin_headers:__pkg__",
+ "//src/common/boot_picoboot_headers:__pkg__",
+ "//src/common/hardware_claim:__pkg__",
+ "//src/common/pico_base_headers:__pkg__",
+ "//src/common/pico_binary_info:__pkg__",
+ ],
+)
+
+alias(
+ name = "pico_platform",
+ actual = select({
+ "//bazel/constraint:host": "//src/host/pico_platform",
+ "//conditions:default": "//src/rp2_common:pico_platform",
+ }),
+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1316c56..f21db2d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,9 +1,15 @@
cmake_policy(SET CMP0079 NEW) # allow inserting of dependencies into our INTERFACE libraries
-set(PICO_PLATFORM_CMAKE_FILE "" CACHE INTERNAL "")
+set(PICO_PLATFORM_CMAKE_FILE "${PICO_PLATFORM_CMAKE_FILE}" CACHE INTERNAL "")
set(PICO_DOXYGEN_PATHS "" CACHE INTERNAL "") # generated each time
+set(PICO_DOXYGEN_EXCLUDE_PATHS "" CACHE INTERNAL "") # generated each time
+set(PICO_DOXYGEN_PRE_DEFINES "" CACHE INTERNAL "") # generated each time
+set(PICO_DOXYGEN_ENABLED_SECTIONS "" CACHE INTERNAL "") # generated each time
+if (NOT PICO_PLATFORM_CMAKE_DIR)
+ set(PICO_PLATFORM_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
+endif()
if (NOT PICO_PLATFORM_CMAKE_FILE)
- set(PICO_PLATFORM_CMAKE_FILE ${CMAKE_CURRENT_LIST_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")
+ set(PICO_PLATFORM_CMAKE_FILE ${PICO_PLATFORM_CMAKE_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")
endif ()
if (NOT EXISTS "${PICO_PLATFORM_CMAKE_FILE}")
@@ -11,17 +17,28 @@
Either specify a valid PICO_PLATFORM (or PICO_PLATFORM_CMAKE_FILE).")
endif ()
-# Initialize board related build/compile settings
-include(${CMAKE_CURRENT_LIST_DIR}/board_setup.cmake)
-
# call add_subdirectory(subdir) unless SKIP_SUBDIR evaluates to true
+# second argument is optional path
function(pico_add_subdirectory subdir)
# todo add option to disable skip flag
string(TOUPPER ${subdir} subdir_upper)
+ # we do not include any path part of the subdir
+ get_filename_component(subdir_upper ${subdir_upper} NAME)
set(replace_flag SKIP_${subdir_upper})
if (NOT ${replace_flag})
- add_subdirectory(${subdir})
- else ()
+ string(TOUPPER ${subdir} subdir_upper)
+ set(replace_flag SKIP_${subdir_upper})
+ if (${ARGC} GREATER 1)
+ # argv1 is the root where the subdir is relative to
+ add_subdirectory(${ARGV1}/${subdir} ${subdir})
+ # todo make this optional?
+ pico_add_doxygen(${ARGV1}/${subdir})
+ else()
+ add_subdirectory(${subdir})
+ # todo make this optional?
+ pico_add_doxygen(${subdir})
+ endif()
+ else()
message("Not including ${subdir} because ${replace_flag} defined.")
endif ()
pico_promote_common_scope_vars()
@@ -57,11 +74,12 @@
# add map file generation for the given target
function(pico_add_map_output TARGET)
+ pico_get_runtime_output_directory(${TARGET} output_path)
get_target_property(target_type ${TARGET} TYPE)
if ("EXECUTABLE" STREQUAL "${target_type}")
- target_link_options(${TARGET} PRIVATE "LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
+ target_link_options(${TARGET} PRIVATE "LINKER:-Map=${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
else ()
- target_link_options(${TARGET} INTERFACE "LINKER:-Map=$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
+ target_link_options(${TARGET} INTERFACE "LINKER:-Map=${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:OUTPUT_NAME>>,$<TARGET_PROPERTY:OUTPUT_NAME>,$<TARGET_PROPERTY:NAME>>${CMAKE_EXECUTABLE_SUFFIX}.map")
endif ()
endfunction()
@@ -102,7 +120,7 @@
if (NOT TARGET hardware_${NAME}_headers)
add_library(hardware_${NAME}_headers INTERFACE)
- target_include_directories(hardware_${NAME}_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ target_include_directories(hardware_${NAME}_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(hardware_${NAME}_headers INTERFACE pico_base_headers)
if (NOT PICO_NO_HARDWARE)
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs hardware_claim_headers)
@@ -122,7 +140,7 @@
add_library(hardware_${NAME}_headers INTERFACE)
# a headers only target should still have an explicit _headers library for consistency
- target_include_directories(hardware_${NAME}_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ target_include_directories(hardware_${NAME}_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(hardware_${NAME}_headers INTERFACE pico_base_headers)
if (NOT PICO_NO_HARDWARE)
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs)
@@ -154,12 +172,30 @@
endif()
endmacro()
+function(pico_add_doxygen_pre_define PRE_DEFINE)
+ list(APPEND PICO_DOXYGEN_PRE_DEFINES "${PRE_DEFINE}")
+ set(PICO_DOXYGEN_PRE_DEFINES "${PICO_DOXYGEN_PRE_DEFINES}" CACHE INTERNAL "")
+endfunction()
+
+function(pico_add_doxygen_enabled_section ENABLED_SECTION)
+ list(APPEND PICO_DOXYGEN_ENABLED_SECTIONS "${ENABLED_SECTION}")
+ set(PICO_DOXYGEN_ENABLED_SECTIONS "${PICO_DOXYGEN_ENABLED_SECTIONS}" CACHE INTERNAL "")
+endfunction()
+
function(pico_add_doxygen SOURCE_DIR)
- set(PICO_DOXYGEN_PATHS "${PICO_DOXYGEN_PATHS} ${SOURCE_DIR}" CACHE INTERNAL "")
+ if (NOT IS_ABSOLUTE "${SOURCE_DIR}")
+ get_filename_component(SOURCE_DIR "${SOURCE_DIR}" ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ endif()
+ list(APPEND PICO_DOXYGEN_PATHS "${SOURCE_DIR}")
+ set(PICO_DOXYGEN_PATHS "${PICO_DOXYGEN_PATHS}" CACHE INTERNAL "")
endfunction()
function(pico_add_doxygen_exclude SOURCE_DIR)
- set(PICO_DOXYGEN_EXCLUDE_PATHS "${PICO_DOXYGEN_EXCLUDE_PATHS} ${SOURCE_DIR}" CACHE INTERNAL "")
+ if (NOT IS_ABSOLUTE "${SOURCE_DIR}")
+ get_filename_component(SOURCE_DIR "${SOURCE_DIR}" ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ endif()
+ list(APPEND PICO_DOXYGEN_EXCLUDE_PATHS "${SOURCE_DIR}")
+ set(PICO_DOXYGEN_EXCLUDE_PATHS "${PICO_DOXYGEN_EXCLUDE_PATHS}" CACHE INTERNAL "")
endfunction()
include(${PICO_PLATFORM_CMAKE_FILE})
diff --git a/src/board_setup.cmake b/src/board_setup.cmake
deleted file mode 100644
index 48839f7..0000000
--- a/src/board_setup.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-# PICO_CMAKE_CONFIG: PICO_BOARD, The board name being built for. This is overridable from the user environment, type=string, default=pico, group=build
-if (DEFINED ENV{PICO_BOARD})
- set(PICO_BOARD $ENV{PICO_BOARD})
- message("Using PICO_BOARD from environment ('${PICO_BOARD}')")
-else()
- if (NOT PICO_BOARD)
- set(PICO_BOARD "pico")
- pico_message("Defaulting PICO target board to ${PICO_BOARD} since not specified.")
- else()
- message("PICO target board is ${PICO_BOARD}.")
- endif()
-endif()
-set(PICO_BOARD ${PICO_BOARD} CACHE STRING "PICO target board (e.g. pico)" FORCE)
-
-# PICO_CMAKE_CONFIG: PICO_BOARD_CMAKE_DIRS, Directories to look for <PICO_BOARD>.cmake in. This is overridable from the user environment, type=list, group=build
-if (DEFINED ENV{PICO_BOARD_CMAKE_DIRS})
- set(PICO_BOARD_CMAKE_DIRS $ENV{PICO_BOARD_CMAKE_DIRS})
- message("Using PICO_BOARD_CMAKE_DIRS from environment ('${PICO_BOARD_CMAKE_DIRS}')")
-endif()
-
-list(APPEND PICO_BOARD_CMAKE_DIRS ${CMAKE_CURRENT_LIST_DIR}/boards)
-
-pico_find_in_paths(PICO_BOARD_CMAKE_FILE PICO_BOARD_CMAKE_DIRS ${PICO_BOARD}.cmake)
-if (EXISTS "${PICO_BOARD_CMAKE_FILE}")
- message("Using CMake board configuration from ${PICO_BOARD_CMAKE_FILE}")
- include(${PICO_BOARD_CMAKE_FILE} board_config)
-else()
- include(boards/generic_board.cmake)
-endif()
-
-list(APPEND PICO_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/boards/include) # so boards/foo.h can be explicitly included
diff --git a/src/boards/BUILD.bazel b/src/boards/BUILD.bazel
index ba0dfa2..94d1b3e 100644
--- a/src/boards/BUILD.bazel
+++ b/src/boards/BUILD.bazel
@@ -5,41 +5,84 @@
# Known board choices:
BOARD_CHOICES = [
+ "0xcb_helios",
+ "adafruit_feather_rp2040_usb_host",
"adafruit_feather_rp2040",
"adafruit_itsybitsy_rp2040",
"adafruit_kb2040",
"adafruit_macropad_rp2040",
"adafruit_qtpy_rp2040",
"adafruit_trinkey_qt2040",
+ "amethyst_fpga",
+ "archi",
"arduino_nano_rp2040_connect",
+ "cytron_maker_pi_rp2040",
"datanoisetv_rp2040_dsp",
+ "defcon32_badge",
"eetree_gamekit_rp2040",
"garatronic_pybstick26_rp2040",
+ "gen4_rp2350_24",
+ "gen4_rp2350_24ct",
+ "gen4_rp2350_24t",
+ "gen4_rp2350_28",
+ "gen4_rp2350_28ct",
+ "gen4_rp2350_28t",
+ "gen4_rp2350_32",
+ "gen4_rp2350_32ct",
+ "gen4_rp2350_32t",
+ "gen4_rp2350_35",
+ "gen4_rp2350_35ct",
+ "gen4_rp2350_35t",
+ "hellbender_2350A_devboard",
+ "ilabs_challenger_rp2350_bconnect",
+ "ilabs_challenger_rp2350_wifi_ble",
+ "ilabs_opendec02",
+ "melopero_perpetuo_rp2350_lora",
"melopero_shake_rp2040",
+ "metrotech_xerxes_rp2040",
+ "net8086_usb_interposer",
"none",
"nullbits_bit_c_pro",
- "pico",
+ "phyx_rick_tny_rp2350",
+ "pi-plates_micropi",
"pico_w",
+ "pico",
+ "pico2",
"pimoroni_badger2040",
"pimoroni_interstate75",
"pimoroni_keybow2040",
"pimoroni_motor2040",
"pimoroni_pga2040",
+ "pimoroni_pga2350",
+ "pimoroni_pico_plus2_rp2350",
"pimoroni_picolipo_16mb",
"pimoroni_picolipo_4mb",
"pimoroni_picosystem",
"pimoroni_plasma2040",
+ "pimoroni_plasma2350",
"pimoroni_servo2040",
- "pimoroni_tiny2040",
"pimoroni_tiny2040_2mb",
+ "pimoroni_tiny2040",
+ "pimoroni_tiny2350",
"pololu_3pi_2040_robot",
+ "pololu_zumo_2040_robot",
"seeed_xiao_rp2040",
- "solderparty_rp2040_stamp",
+ "seeed_xiao_rp2350",
"solderparty_rp2040_stamp_carrier",
"solderparty_rp2040_stamp_round_carrier",
+ "solderparty_rp2040_stamp",
+ "solderparty_rp2350_stamp_xl",
+ "solderparty_rp2350_stamp",
"sparkfun_micromod",
+ "sparkfun_promicro_rp2350",
"sparkfun_promicro",
"sparkfun_thingplus",
+ "switchscience_picossci2_conta_base",
+ "switchscience_picossci2_dev_board",
+ "switchscience_picossci2_micro",
+ "switchscience_picossci2_rp2350_breakout",
+ "switchscience_picossci2_tiny",
+ "tinycircuits_thumby_color_rp2350",
"vgaboard",
"waveshare_rp2040_lcd_0.96",
"waveshare_rp2040_lcd_1.28",
@@ -47,14 +90,11 @@
"waveshare_rp2040_plus_16mb",
"waveshare_rp2040_plus_4mb",
"waveshare_rp2040_zero",
- "wiznet_w5100s_evb_pico",
- "cytron_maker_pi_rp2040",
- "metrotech_xerxes_rp2040",
- "pololu_zumo_2040_robot",
"weact_studio_rp2040_16mb",
"weact_studio_rp2040_2mb",
"weact_studio_rp2040_4mb",
"weact_studio_rp2040_8mb",
+ "wiznet_w5100s_evb_pico",
]
BOARD_CHOICE_FILES = ["include/boards/" + c + ".h" for c in BOARD_CHOICES]
diff --git a/src/boards/generic_board.cmake b/src/boards/generic_board.cmake
deleted file mode 100644
index 3307e78..0000000
--- a/src/boards/generic_board.cmake
+++ /dev/null
@@ -1,23 +0,0 @@
-# For boards without their own cmake file, simply include a header
-
-# PICO_CMAKE_CONFIG: PICO_BOARD_HEADER_DIRS, Directories to look for <PICO_BOARD>.h in. This is overridable from the user environment, type=list, group=build
-if (DEFINED ENV{PICO_BOARD_HEADER_DIRS})
- set(PICO_BOARD_HEADER_DIRS $ENV{PICO_BOARD_HEADER_DIRS})
- message("Using PICO_BOARD_HEADER_DIRS from environment ('${PICO_BOARD_HEADER_DIRS}')")
-endif()
-set(PICO_BOARD_HEADER_DIRS ${PICO_BOARD_HEADER_DIRS} CACHE STRING "PICO board header directories" FORCE)
-
-list(APPEND PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/include/boards)
-pico_find_in_paths(PICO_BOARD_HEADER_FILE PICO_BOARD_HEADER_DIRS ${PICO_BOARD}.h)
-
-if (EXISTS ${PICO_BOARD_HEADER_FILE})
- message("Using board configuration from ${PICO_BOARD_HEADER_FILE}")
- list(APPEND PICO_CONFIG_HEADER_FILES ${PICO_BOARD_HEADER_FILE})
-else()
- set(msg "Unable to find definition of board '${PICO_BOARD}' (specified by PICO_BOARD):\n")
- list(JOIN PICO_BOARD_HEADER_DIRS ", " DIRS)
- string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.h in ${DIRS} (additional paths specified by PICO_BOARD_HEADER_DIRS)\n")
- list(JOIN PICO_BOARD_CMAKE_DIRS ", " DIRS)
- string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.cmake in ${DIRS} (additional paths specified by PICO_BOARD_CMAKE_DIRS)")
- message(FATAL_ERROR ${msg})
-endif()
diff --git a/src/boards/include/boards/0xcb_helios.h b/src/boards/include/boards/0xcb_helios.h
index e9df358..e06c552 100644
--- a/src/boards/include/boards/0xcb_helios.h
+++ b/src/boards/include/boards/0xcb_helios.h
@@ -12,6 +12,8 @@
//------------------------------------------------------------------------------------------
// Board definition for the 0xCB Helios
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_0XCB_HELIOS_H
#define _BOARDS_0XCB_HELIOS_H
@@ -71,10 +73,10 @@
#endif
// board has 16M onboard flash
+// 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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
diff --git a/src/boards/include/boards/adafruit_feather_rp2040.h b/src/boards/include/boards/adafruit_feather_rp2040.h
index 2da8e70..c9a6d61 100644
--- a/src/boards/include/boards/adafruit_feather_rp2040.h
+++ b/src/boards/include/boards/adafruit_feather_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_H
@@ -81,10 +83,10 @@
#define PICO_FLASH_SPI_CLKDIV 4
#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
diff --git a/src/boards/include/boards/adafruit_feather_rp2040_usb_host.h b/src/boards/include/boards/adafruit_feather_rp2040_usb_host.h
index 79193e3..6175b94 100644
--- a/src/boards/include/boards/adafruit_feather_rp2040_usb_host.h
+++ b/src/boards/include/boards/adafruit_feather_rp2040_usb_host.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H
#define _BOARDS_ADAFRUIT_FEATHER_RP2040_USB_HOST_H
@@ -77,6 +79,7 @@
#define PICO_FLASH_SPI_CLKDIV 4
#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
diff --git a/src/boards/include/boards/adafruit_itsybitsy_rp2040.h b/src/boards/include/boards/adafruit_itsybitsy_rp2040.h
index c56f079..ee5cf9c 100644
--- a/src/boards/include/boards/adafruit_itsybitsy_rp2040.h
+++ b/src/boards/include/boards/adafruit_itsybitsy_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H
#define _BOARDS_ADAFRUIT_ITSYBITSY_RP2040_H
@@ -84,10 +86,10 @@
#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
diff --git a/src/boards/include/boards/adafruit_kb2040.h b/src/boards/include/boards/adafruit_kb2040.h
index 9353082..f63fc77 100644
--- a/src/boards/include/boards/adafruit_kb2040.h
+++ b/src/boards/include/boards/adafruit_kb2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ADAFRUIT_KB2040_H
#define _BOARDS_ADAFRUIT_KB2040_H
@@ -76,10 +78,10 @@
#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
diff --git a/src/boards/include/boards/adafruit_macropad_rp2040.h b/src/boards/include/boards/adafruit_macropad_rp2040.h
index 3c0c525..672ada9 100644
--- a/src/boards/include/boards/adafruit_macropad_rp2040.h
+++ b/src/boards/include/boards/adafruit_macropad_rp2040.h
@@ -12,6 +12,8 @@
#ifndef _BOARDS_ADAFRUIT_MACROPAD_RP2040_H
#define _BOARDS_ADAFRUIT_MACROPAD_RP2040_H
+// pico_cmake_set PICO_PLATFORM=rp2040
+
// For board detection
#define ADAFRUIT_MACROPAD_RP2040
@@ -171,10 +173,10 @@
#define PICO_FLASH_SPI_CLKDIV 4
#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_FLOAT_SUPPORT_ROM_V1
#define PICO_FLOAT_SUPPORT_ROM_V1 0
diff --git a/src/boards/include/boards/adafruit_qtpy_rp2040.h b/src/boards/include/boards/adafruit_qtpy_rp2040.h
index 24184c2..722d230 100644
--- a/src/boards/include/boards/adafruit_qtpy_rp2040.h
+++ b/src/boards/include/boards/adafruit_qtpy_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ADAFRUIT_QTPY_RP2040_H
#define _BOARDS_ADAFRUIT_QTPY_RP2040_H
@@ -83,10 +85,10 @@
#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
diff --git a/src/boards/include/boards/adafruit_trinkey_qt2040.h b/src/boards/include/boards/adafruit_trinkey_qt2040.h
index f9b49df..06e2949 100644
--- a/src/boards/include/boards/adafruit_trinkey_qt2040.h
+++ b/src/boards/include/boards/adafruit_trinkey_qt2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ADAFRUIT_TRINKEY_QT2040_H
#define _BOARDS_ADAFRUIT_TRINKEY_QT2040_H
@@ -61,10 +63,10 @@
#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
diff --git a/src/boards/include/boards/amethyst_fpga.h b/src/boards/include/boards/amethyst_fpga.h
new file mode 100644
index 0000000..d41dff4
--- /dev/null
+++ b/src/boards/include/boards/amethyst_fpga.h
@@ -0,0 +1,105 @@
+/*
+ * 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
+// -----------------------------------------------------
+
+// FIXME delete this file before release (board file for Amethyst FPGA platform)
+
+#ifndef _BOARDS_AMETHYST_FPGA_H
+#define _BOARDS_AMETHYST_FPGA_H
+
+#if !PICO_RP2350
+#error "Invalid PICO_PLATFORM for amethyst_fpga.h: must be rp2350 or rp2350-riscv"
+#endif
+
+// For board detection
+#define RASPBERRYPI_AMETHYST_FPGA
+
+#define PICO_NO_FPGA_CHECK 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 0
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 46
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 47
+#endif
+// Match bootrom UART baud rate of 1 Mbaud:
+#ifndef PICO_DEFAULT_UART_BAUD_RATE
+#define PICO_DEFAULT_UART_BAUD_RATE 1000000
+#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 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
+
+#define PICO_SD_CLK_PIN 18
+#define PICO_SD_CMD_PIN 19
+#define PICO_SD_DAT0_PIN 20
+
+#define PICO_ON_FPGA 1
+
+#define PICO_SCANVIDEO_COLOR_PIN_COUNT 16
+#define PICO_SCANVIDEO_DPI_PIXEL_RSHIFT 0u
+#define PICO_SCANVIDEO_DPI_PIXEL_GSHIFT 6u
+#define PICO_SCANVIDEO_DPI_PIXEL_BSHIFT 11u
+
+#define PICO_SCANVIDEO_48MHZ 1
+#define PICO_AUDIO_I2S_DATA_PIN 29
+#define PICO_AUDIO_I2S_CLOCK_PIN_BASE 30
+
+#define PICO_AUDIO_PWM_L_PIN 28
+#define PICO_AUDIO_PWM_R_PIN 27
+
+// --- 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
+#endif
diff --git a/src/boards/include/boards/archi.h b/src/boards/include/boards/archi.h
index 4cf0356..13b7d7e 100644
--- a/src/boards/include/boards/archi.h
+++ b/src/boards/include/boards/archi.h
@@ -11,6 +11,8 @@
// This header may be included by other board headers as "boards/archi.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ARCHI_H
#define _BOARDS_ARCHI_H
@@ -102,9 +104,9 @@
#define PICO_FLASH_SPI_CLKDIV 4
#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
-
#endif
diff --git a/src/boards/include/boards/arduino_nano_rp2040_connect.h b/src/boards/include/boards/arduino_nano_rp2040_connect.h
index 39c6564..9cd3035 100644
--- a/src/boards/include/boards/arduino_nano_rp2040_connect.h
+++ b/src/boards/include/boards/arduino_nano_rp2040_connect.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H
#define _BOARDS_ARDUINO_NANO_RP2040_CONNECT_H
@@ -72,10 +74,10 @@
#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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/cytron_maker_pi_rp2040.h b/src/boards/include/boards/cytron_maker_pi_rp2040.h
index 77dd424..9d2f0eb 100644
--- a/src/boards/include/boards/cytron_maker_pi_rp2040.h
+++ b/src/boards/include/boards/cytron_maker_pi_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_CYTRON_MAKER_PI_RP2040_H
#define _BOARDS_CYTRON_MAKER_PI_RP2040_H
@@ -177,10 +179,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/datanoisetv_rp2040_dsp.h b/src/boards/include/boards/datanoisetv_rp2040_dsp.h
index 49a357b..ae583ba 100644
--- a/src/boards/include/boards/datanoisetv_rp2040_dsp.h
+++ b/src/boards/include/boards/datanoisetv_rp2040_dsp.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/datanoisetv_rp2040_dsp.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_DATANOISETV_RP2040_DSP_H
#define _BOARDS_DATANOISETV_RP2040_DSP_H
@@ -38,10 +40,10 @@
#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
-
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
#endif
diff --git a/src/boards/include/boards/defcon32_badge.h b/src/boards/include/boards/defcon32_badge.h
new file mode 100644
index 0000000..6e99ca5
--- /dev/null
+++ b/src/boards/include/boards/defcon32_badge.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
+// -----------------------------------------------------
+
+// NOTE: since there is no UART on the badge, you should probably pass:
+// -DPICO_BOARD=defcon32_badge -DPICO_STDIO_USB=1 -DPICO_STDIO_UART+0
+// when building to set up stdio over USB CDC by default
+#define PICO_DEFAULT_UART 0
+#define PICO_DEFAULT_UART_TX_PIN 30
+#define PICO_DEFAULT_UART_RX_PIN 31
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_DEFCON32_BADGE_H
+#define _BOARDS_DEFCON32_BADGE_H
+
+// For board detection
+#define DEFCON32_BADGE
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 1
+
+#define DEFCON32_BADGE_SRAM_CS_PIN 0
+#define DEFCON32_BADGE_TOUCH_INT_PIN 1
+#define DEFCON32_BADGE_I2C_SDA_PIN 2
+#define DEFCON32_BADGE_I2C_SDL_PIN 3
+#define DEFCON32_BADGE_WS2812_PIN 4
+#define DEFCON32_BADGE_DISPLAY_RS_PIN 5
+#define DEFCON32_BADGE_DISPLAY_DO_PIN 6
+#define DEFCON32_BADGE_IR_SD_PIN 7
+#define DEFCON32_BADGE_DISPLAY_SCK_PIN 8
+#define DEFCON32_BADGE_DISPLAY_CS_PIN 9
+#define DEFCON32_BADGE_DISPLAY_BL_PIN 10
+#define DEFCON32_BADGE_SYS_POWER_CONTROL_PIN 11
+#define DEFCON32_BADGE_SPI_MISO_PIN 12
+#define DEFCON32_BADGE_SD_CS_PIN 13
+#define DEFCON32_BADGE_SPI_CK_PIN 14
+#define DEFCON32_BADGE_SPI_MOSI_PIN 15
+#define DEFCON32_BADGE_SW_RIGHT_PIN 16
+#define DEFCON32_BADGE_SW_DOWN_PIN 17
+#define DEFCON32_BADGE_SW_UP_PIN 18
+#define DEFCON32_BADGE_SW_LEFT_PIN 19
+#define DEFCON32_BADGE_SW_B_PIN 20
+#define DEFCON32_BADGE_SW_A_PIN 21
+#define DEFCON32_BADGE_SW_START_PIN 22
+#define DEFCON32_BADGE_SW_SELECT_PIN 23
+#define DEFCON32_BADGE_SW_FN_PIN 24
+#define DEFCON32_BADGE_SPEAKER_OUT_PIN 25
+#define DEFCON32_BADGE_IR_RX_PIN 27
+#define DEFCON32_BADGE_IR_TX_PIN 28
+
+// --- LED ---
+// no PICO_DEFAULT_LED_PIN
+#ifndef PICO_DEFAULT_WS2812_PIN
+#define PICO_DEFAULT_WS2812_PIN DEFCON32_BADGE_WS2812_PIN
+#endif
+
+// --- I2C ---
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 1
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN DEFCON32_BADGE_I2C_SDA_PIN
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN DEFCON32_BADGE_I2C_SDL_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 DEFCON32_BADGE_SPI_CK_PIN
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN DEFCON32_BADGE_SPI_MISO_PIN
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN DEFCON32_BADGE_SPI_MOSI_PIN
+#endif
+// multiple devices, so this doesn't make much sense
+// no PICO_DEFAULT_SPI_CSN_PIN
+
+#ifndef PICO_AUDIO_PWM_L_PIN
+#define PICO_AUDIO_PWM_L_PIN DEFCON32_BADGE_SPEAKER_OUT_PIN
+#endif
+
+#ifndef PICO_AUDIO_PWM_MONO_PIN
+#define PICO_AUDIO_PWM_MONO_PIN PICO_AUDIO_PWM_L_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
+
+#endif
+
+
diff --git a/src/boards/include/boards/eetree_gamekit_rp2040.h b/src/boards/include/boards/eetree_gamekit_rp2040.h
index f007147..3df8719 100644
--- a/src/boards/include/boards/eetree_gamekit_rp2040.h
+++ b/src/boards/include/boards/eetree_gamekit_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_EETREE_GAMEKIT_RP2040_H
#define _BOARDS_EETREE_GAMEKIT_RP2040_H
@@ -67,6 +69,7 @@
#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
diff --git a/src/boards/include/boards/garatronic_pybstick26_rp2040.h b/src/boards/include/boards/garatronic_pybstick26_rp2040.h
index d1c0298..d245c82 100644
--- a/src/boards/include/boards/garatronic_pybstick26_rp2040.h
+++ b/src/boards/include/boards/garatronic_pybstick26_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_GARATRONIC_PYBSTICK26_RP2040_H
#define _BOARDS_GARATRONIC_PYBSTICK26_RP2040_H
@@ -68,10 +70,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (1 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (1 * 1024 * 1024)
#endif
-
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
// Linear regulator on Pybstick26
//#define PICO_SMPS_MODE_PIN 23
diff --git a/src/boards/include/boards/gen4_rp2350_24.h b/src/boards/include/boards/gen4_rp2350_24.h
new file mode 100644
index 0000000..c569c15
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_24.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_24
+#define _BOARDS_GEN4_RP2350_24
+
+// For board detection
+#define GEN4_RP2350_24
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_NONE
+#define LCD_TOUCH_POINTS 0
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_24ct.h b/src/boards/include/boards/gen4_rp2350_24ct.h
new file mode 100644
index 0000000..2f6f154
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_24ct.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_24CT
+#define _BOARDS_GEN4_RP2350_24CT
+
+// For board detection
+#define GEN4_RP2350_24CT // CLB variants are exactly the same in operation
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_CTP_FT
+#define LCD_TOUCH_POINTS 2
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_24t.h b/src/boards/include/boards/gen4_rp2350_24t.h
new file mode 100644
index 0000000..2d01017
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_24t.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_24T
+#define _BOARDS_GEN4_RP2350_24T
+
+// For board detection
+#define GEN4_RP2350_24T
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_4WIRE
+#define LCD_TOUCH_POINTS 1
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_28.h b/src/boards/include/boards/gen4_rp2350_28.h
new file mode 100644
index 0000000..804b2a9
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_28.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_28
+#define _BOARDS_GEN4_RP2350_28
+
+// For board detection
+#define GEN4_RP2350_28
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_NONE
+#define LCD_TOUCH_POINTS 0
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_28ct.h b/src/boards/include/boards/gen4_rp2350_28ct.h
new file mode 100644
index 0000000..1714ef1
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_28ct.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_28CT
+#define _BOARDS_GEN4_RP2350_28CT
+
+// For board detection
+#define GEN4_RP2350_28CT // CLB variants are exactly the same in operation
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_CTP_FT
+#define LCD_TOUCH_POINTS 2
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_28t.h b/src/boards/include/boards/gen4_rp2350_28t.h
new file mode 100644
index 0000000..b61c230
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_28t.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_28T
+#define _BOARDS_GEN4_RP2350_28T
+
+// For board detection
+#define GEN4_RP2350_28T
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_4WIRE
+#define LCD_TOUCH_POINTS 1
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_32.h b/src/boards/include/boards/gen4_rp2350_32.h
new file mode 100644
index 0000000..9660a47
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_32.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_32
+#define _BOARDS_GEN4_RP2350_32
+
+// For board detection
+#define GEN4_RP2350_32
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_NONE
+#define LCD_TOUCH_POINTS 0
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_32ct.h b/src/boards/include/boards/gen4_rp2350_32ct.h
new file mode 100644
index 0000000..9f883d4
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_32ct.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
+// -----------------------------------------------------
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_32CT
+#define _BOARDS_GEN4_RP2350_32CT
+
+// For board detection
+#define GEN4_RP2350_32CT // CLB variants are exactly the same in operation
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_CTP_FT
+#define LCD_TOUCH_POINTS 5
+#define LCD_TOUCH_MIRROR_Y
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_32t.h b/src/boards/include/boards/gen4_rp2350_32t.h
new file mode 100644
index 0000000..04f4e0c
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_32t.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_32T
+#define _BOARDS_GEN4_RP2350_32T
+
+// For board detection
+#define GEN4_RP2350_32T
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_4WIRE
+#define LCD_TOUCH_POINTS 1
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_35.h b/src/boards/include/boards/gen4_rp2350_35.h
new file mode 100644
index 0000000..d333c22
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_35.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_35
+#define _BOARDS_GEN4_RP2350_35
+
+// For board detection
+#define GEN4_RP2350_35
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 320
+#define LCD_HEIGHT 480
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_NONE
+#define LCD_TOUCH_POINTS 0
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_35ct.h b/src/boards/include/boards/gen4_rp2350_35ct.h
new file mode 100644
index 0000000..778e199
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_35ct.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
+// -----------------------------------------------------
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_35CT
+#define _BOARDS_GEN4_RP2350_35CT
+
+// For board detection
+#define GEN4_RP2350_35CT // CLB variants are exactly the same in operation
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 320
+#define LCD_HEIGHT 480
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_CTP_FT
+#define LCD_TOUCH_POINTS 5
+#define LCD_TOUCH_MIRROR_Y
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/gen4_rp2350_35t.h b/src/boards/include/boards/gen4_rp2350_35t.h
new file mode 100644
index 0000000..8323372
--- /dev/null
+++ b/src/boards/include/boards/gen4_rp2350_35t.h
@@ -0,0 +1,118 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_GEN4_RP2350_35T
+#define _BOARDS_GEN4_RP2350_35T
+
+// For board detection
+#define GEN4_RP2350_35T
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- UART ---
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 1
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 5
+#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 8
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 9
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 1
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 42
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 43
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 44
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 45
+#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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// 4DLCD Interface
+
+#define PORTRAIT 0
+#define LANDSCAPE 1
+#define PORTRAIT_R 2
+#define LANDSCAPE_R 3
+
+#define LCD_ORIENTATION PORTRAIT
+#define LCD_WIDTH 320
+#define LCD_HEIGHT 480
+#define LCD_BACKLIGHT 17
+#define LCD_RS_PIN 18
+#define LCD_WR_PIN 19
+#define LCD_RD_PIN 20
+#define LCD_DATA0_PIN 21
+#define LCD_RESET 37
+#define LCD_TOUCH_INT 38
+#define LCD_TOUCH_SCL 39
+#define LCD_TOUCH_SDA 46
+#define LCD_TOUCH_RST 47
+#define LCD_TOUCH_YD LCD_TOUCH_INT
+#define LCD_TOUCH_XL LCD_TOUCH_SCL
+#define LCD_TOUCH_YU LCD_TOUCH_RST
+#define LCD_TOUCH_XR LCD_TOUCH_SDA
+#define LCD_TOUCH_I2C i2c1
+#define LCD_TOUCH_4WIRE
+#define LCD_TOUCH_POINTS 1
+
+#define LCD_SD_CLK 10
+#define LCD_SD_CMD 11
+#define LCD_SD_D0 12
+#define LCD_SD_D1 13
+#define LCD_SD_D2 14
+#define LCD_SD_D3 15
+
+#endif
diff --git a/src/boards/include/boards/hellbender_2350A_devboard.h b/src/boards/include/boards/hellbender_2350A_devboard.h
new file mode 100644
index 0000000..03895e1
--- /dev/null
+++ b/src/boards/include/boards/hellbender_2350A_devboard.h
@@ -0,0 +1,98 @@
+/*
+ * 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
+// -----------------------------------------------------
+
+#ifndef _BOARDS_HB_2350A_H
+#define _BOARDS_HB_2350A_H
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+// For board detection
+#define HELLBENDER_2350A_DEVBOARD
+
+// Pin aliases
+#define HB_2350A_XIP_CS1_PIN 0
+#define HB_2350A_IMU_INT_PIN 1
+#define HB_2350A_USER_QWIIC_SDA_PIN 2
+#define HB_2350A_USER_QWIIC_SCL_PIN 3
+#define HB_2350A_RTC_INT_PIN 8
+#define HB_2350A_SDCARD_CS_PIN 9
+#define HB_2350A_LORA_IO1_PIN 10
+#define HB_2350A_LORA_IO3_PIN 11
+#define HB_2350A_LORA_CS_PIN 21
+#define HB_2350A_RTC_CLKIN_PIN 22
+#define HB_2350A_IMU_CLKOUT_PIN 23
+#define HB_2350A_LORA_BUSY_PIN 24
+#define HB_2350A_FUSB307_INT_PIN 25
+#define HB_2350A_LORA_RESET_PIN 29
+
+// --- UART ---
+// Note, conflicts with HSTX range
+#ifndef PICO_DEFAULT_UART
+#define PICO_DEFAULT_UART 0
+#endif
+#ifndef PICO_DEFAULT_UART_TX_PIN
+#define PICO_DEFAULT_UART_TX_PIN 12
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 13
+#endif
+
+// 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 6
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 7
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 20
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 21
+#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
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 1
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/ilabs_challenger_rp2350_bconnect.h b/src/boards/include/boards/ilabs_challenger_rp2350_bconnect.h
new file mode 100644
index 0000000..b0bbebe
--- /dev/null
+++ b/src/boards/include/boards/ilabs_challenger_rp2350_bconnect.h
@@ -0,0 +1,94 @@
+/*
+ * 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/ilabs_challenger_rp2350_bconnect.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_CHALLENGER_RP2350_BCONNECT_H
+#define _BOARDS_CHALLENGER_RP2350_BCONNECT_H
+
+// For board detection
+#define ILABS_CHALLENGER_RP2350_BCONNECT
+
+// --- 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 12
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 13
+#endif
+
+// PICO_DEFAULT_LED_PIN
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 7
+#endif
+
+// PICO_DEFAULT_WS2812_PIN
+#ifndef PICO_DEFAULT_WS2812_PIN
+#define PICO_DEFAULT_WS2812_PIN 22
+#endif
+
+// --- I2C ---
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 0
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 20
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 21
+#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
+
+#ifndef PICO_RP2040_B0_SUPPORTED
+#define PICO_RP2040_B0_SUPPORTED 1
+#endif
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/ilabs_challenger_rp2350_wifi_ble.h b/src/boards/include/boards/ilabs_challenger_rp2350_wifi_ble.h
new file mode 100644
index 0000000..29ac3df
--- /dev/null
+++ b/src/boards/include/boards/ilabs_challenger_rp2350_wifi_ble.h
@@ -0,0 +1,148 @@
+/*
+ * 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/ilabs_challenger_rp2350_wifi_ble.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_CHALLENGER_RP2350_WIFI_BLE_H
+#define _BOARDS_CHALLENGER_RP2350_WIFI_BLE_H
+
+// For board detection
+#define ILABS_CHALLENGER_RP2350_WIFI_BLE
+
+// --- 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 12
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 13
+#endif
+
+// PICO_DEFAULT_LED_PIN
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 7
+#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 20
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 21
+#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
+
+#ifndef PICO_RP2040_B0_SUPPORTED
+#define PICO_RP2040_B0_SUPPORTED 1
+#endif
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+// Board specific helper macros
+// Types of valid modules on the board
+#define ESP32C6_MINI_1 1
+#define ESP32C3_MINI_1 2
+
+// Specifies the default module used on this board
+#ifndef ILABS_ONBOARD_ESP_MODULE
+#define ILABS_ONBOARD_ESP_MODULE ESP32C6_MINI_1
+#endif
+
+// ESP module control signals
+#ifndef ILABS_DEFAULT_ESP_MODULE_RST_PIN
+#define ILABS_DEFAULT_ESP_MODULE_RST_PIN 15
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_MODULE_BOOT_MODE_PIN
+#define ILABS_DEFAULT_ESP_MODULE_BOOT_MODE_PIN 14
+#endif
+
+// ESP module UART definitions
+#ifndef ILABS_ESP_AT_UART
+#define ILABS_ESP_AT_UART 1
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_AT_TX_PIN
+#define ILABS_DEFAULT_ESP_AT_TX_PIN 4
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_AT_RX_PIN
+#define ILABS_DEFAULT_ESP_AT_RX_PIN 5
+#endif
+
+// ESP module SPI definitions
+#ifndef ILABS_DEFAULT_ESP_SPI
+#define ILABS_DEFAULT_ESP_SPI 1
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_SPI_MISO_PIN
+#define ILABS_DEFAULT_ESP_SPI_MISO_PIN 8
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_SPI_MOSI_PIN
+#define ILABS_DEFAULT_ESP_SPI_MOSI_PIN 11
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_SPI_SCK_PIN
+#define ILABS_DEFAULT_ESP_SPI_SCK_PIN 10
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_SPI_SS_PIN
+#define ILABS_DEFAULT_ESP_SPI_SS_PIN 9
+#endif
+
+#ifndef ILABS_DEFAULT_ESP_SPI_HS_PIN
+#define ILABS_DEFAULT_ESP_SPI_HS_PIN 22
+#endif
+
+#endif
diff --git a/src/boards/include/boards/ilabs_opendec02.h b/src/boards/include/boards/ilabs_opendec02.h
index 3fa7197..197a024 100644
--- a/src/boards/include/boards/ilabs_opendec02.h
+++ b/src/boards/include/boards/ilabs_opendec02.h
@@ -12,6 +12,8 @@
//------------------------------------------------------------------------------------------
// Board definition for the opendec02 open source dcc decoder
//
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_ILABS_OPENDEC02_H
#define _BOARDS_ILABS_OPENDEC02_H
@@ -48,10 +50,10 @@
#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
diff --git a/src/boards/include/boards/melopero_perpetuo_rp2350_lora.h b/src/boards/include/boards/melopero_perpetuo_rp2350_lora.h
new file mode 100644
index 0000000..cc358de
--- /dev/null
+++ b/src/boards/include/boards/melopero_perpetuo_rp2350_lora.h
@@ -0,0 +1,99 @@
+/*
+ * 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/melopero_perpetuo_rp2350_lora.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_MELOPERO_PERPETUO_RP2350_LORA_H
+#define _BOARDS_MELOPERO_PERPETUO_RP2350_LORA_H
+
+// For board detection
+#define MELOPERO_PERPETUO_RP2350_LORA
+
+// --- 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 16
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 17
+#endif
+
+// --- LED ---
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 23
+#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 24
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 25
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 22
+#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 20
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 21
+#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
+
+// Board specific
+#define MELOPERO_PERPETUO_ENABLE_WS2812 14
+#define MELOPERO_PERPETUO_WS2812 15
+#define MELOPERO_PERPETUO_LED 23
+#define MELOPERO_PERPETUO_ENABLE_VSEN 0
+#define MELOPERO_PERPETUO_FUEL_ALERT 3
+#define MELOPERO_PERPETUO_CHARGER_STAT1 1
+#define MELOPERO_PERPETUO_CHARGER_STAT2 2
+
+
+#endif
diff --git a/src/boards/include/boards/melopero_shake_rp2040.h b/src/boards/include/boards/melopero_shake_rp2040.h
index d07ca61..49059c9 100644
--- a/src/boards/include/boards/melopero_shake_rp2040.h
+++ b/src/boards/include/boards/melopero_shake_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_MELOPERO_SHAKE_RP2040_H
#define _BOARDS_MELOPERO_SHAKE_RP2040_H
@@ -80,10 +82,10 @@
#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
-
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
#endif
diff --git a/src/boards/include/boards/metrotech_xerxes_rp2040.h b/src/boards/include/boards/metrotech_xerxes_rp2040.h
index 16f1113..a78e3ea 100644
--- a/src/boards/include/boards/metrotech_xerxes_rp2040.h
+++ b/src/boards/include/boards/metrotech_xerxes_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_METROTECH_XERXES_RP2040_H
#define _BOARDS_METROTECH_XERXES_RP2040_H
@@ -145,6 +147,7 @@
#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 16
#endif // !PICO_XOSC_STARTUP_DELAY_MULTIPLIER
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
/**
* @brief 16MiB, Flash size in bytes
diff --git a/src/boards/include/boards/net8086_usb_interposer.h b/src/boards/include/boards/net8086_usb_interposer.h
index efa57d9..4de560f 100644
--- a/src/boards/include/boards/net8086_usb_interposer.h
+++ b/src/boards/include/boards/net8086_usb_interposer.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_NET8086_USB_INTERPOSER_H
#define _BOARDS_NET8086_USB_INTERPOSER_H
@@ -60,6 +62,7 @@
#define PICO_FLASH_SPI_CLKDIV 4
#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
diff --git a/src/boards/include/boards/nullbits_bit_c_pro.h b/src/boards/include/boards/nullbits_bit_c_pro.h
index 169e0c1..58bb1ad 100644
--- a/src/boards/include/boards/nullbits_bit_c_pro.h
+++ b/src/boards/include/boards/nullbits_bit_c_pro.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/nullbits_bit_c_pro.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_NULLBITS_BIT_C_PRO_H
#define _BOARDS_NULLBITS_BIT_C_PRO_H
@@ -98,10 +100,10 @@
#endif
// Bit-C PRO has 4MB SPI flash
+// 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
-
// All boards have B1+ RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/phyx_rick_tny_rp2350.h b/src/boards/include/boards/phyx_rick_tny_rp2350.h
new file mode 100644
index 0000000..eb9e678
--- /dev/null
+++ b/src/boards/include/boards/phyx_rick_tny_rp2350.h
@@ -0,0 +1,87 @@
+/*
+ * 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/phyx_rick_tny_rp2350.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_PHYX_RICK_TNY_RP2350_H
+#define _BOARDS_PHYX_RICK_TNY_RP2350_H
+
+// For board detection
+#define PHYX_RICK_TNY_RP2350
+
+// --- 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 16
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 17
+#endif
+
+// no PICO_DEFAULT_LED_PIN
+
+// --- Neopixel ---
+#ifndef PICO_DEFAULT_WS2812_PIN
+#define PICO_DEFAULT_WS2812_PIN 11
+#endif
+
+// --- I2C ---
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 0
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 6
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 7
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 22
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 23
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 20
+#endif
+// no PICO_DEFAULT_SPI_CSN_PIN
+
+
+// --- 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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/pi-plates_micropi.h b/src/boards/include/boards/pi-plates_micropi.h
index 4e081e5..9c0dd62 100644
--- a/src/boards/include/boards/pi-plates_micropi.h
+++ b/src/boards/include/boards/pi-plates_micropi.h
@@ -11,6 +11,8 @@
// Board definition for the Pi-Plates MICROPi processor board
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PI_PLATES_MICROPI_H
#define _BOARDS_PI_PLATES_MICROPI_H
@@ -70,6 +72,7 @@
#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) //change to (16 * 1024 * 1024) on final product
#endif
diff --git a/src/boards/include/boards/pico.h b/src/boards/include/boards/pico.h
index 139c0d3..800feb3 100644
--- a/src/boards/include/boards/pico.h
+++ b/src/boards/include/boards/pico.h
@@ -11,6 +11,8 @@
// This header may be included by other board headers as "boards/pico.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PICO_H
#define _BOARDS_PICO_H
@@ -70,10 +72,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
#define PICO_SMPS_MODE_PIN 23
diff --git a/src/boards/include/boards/pico2.h b/src/boards/include/boards/pico2.h
new file mode 100644
index 0000000..4146f39
--- /dev/null
+++ b/src/boards/include/boards/pico2.h
@@ -0,0 +1,100 @@
+/*
+ * 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/pico.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_PICO2_H
+#define _BOARDS_PICO2_H
+
+// For board detection
+#define RASPBERRYPI_PICO2
+
+// --- 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 ---
+#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 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)
+#define PICO_SMPS_MODE_PIN 23
+
+// 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 29
+#endif
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/pico_w.h b/src/boards/include/boards/pico_w.h
index ba80a49..9e7464c 100644
--- a/src/boards/include/boards/pico_w.h
+++ b/src/boards/include/boards/pico_w.h
@@ -9,6 +9,9 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM = rp2040
+// pico_cmake_set PICO_CYW43_SUPPORTED = 1
+
// This header may be included by other board headers as "boards/pico_w.h"
#ifndef _BOARDS_PICO_W_H
@@ -68,10 +71,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// note the SMSP mode pin is on WL_GPIO1
// #define PICO_SMPS_MODE_PIN
diff --git a/src/boards/include/boards/pimoroni_badger2040.h b/src/boards/include/boards/pimoroni_badger2040.h
index 0749450..d05c4d4 100644
--- a/src/boards/include/boards/pimoroni_badger2040.h
+++ b/src/boards/include/boards/pimoroni_badger2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_BADGER2040_H
#define _BOARDS_PIMORONI_BADGER2040_H
@@ -104,10 +106,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_interstate75.h b/src/boards/include/boards/pimoroni_interstate75.h
index 5b5bf06..e7baa07 100644
--- a/src/boards/include/boards/pimoroni_interstate75.h
+++ b/src/boards/include/boards/pimoroni_interstate75.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_INTERSTATE75_H
#define _BOARDS_PIMORONI_INTERSTATE75_H
@@ -94,10 +96,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_keybow2040.h b/src/boards/include/boards/pimoroni_keybow2040.h
index baf0c40..0831402 100644
--- a/src/boards/include/boards/pimoroni_keybow2040.h
+++ b/src/boards/include/boards/pimoroni_keybow2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_KEYBOW2040_H
#define _BOARDS_PIMORONI_KEYBOW2040_H
@@ -83,10 +85,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_motor2040.h b/src/boards/include/boards/pimoroni_motor2040.h
index 00fd91a..e183090 100644
--- a/src/boards/include/boards/pimoroni_motor2040.h
+++ b/src/boards/include/boards/pimoroni_motor2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_MOTOR2040_H
#define _BOARDS_PIMORONI_MOTOR2040_H
@@ -126,10 +128,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_pga2040.h b/src/boards/include/boards/pimoroni_pga2040.h
index 980f168..25b9dd2 100644
--- a/src/boards/include/boards/pimoroni_pga2040.h
+++ b/src/boards/include/boards/pimoroni_pga2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_PGA2040_H
#define _BOARDS_PIMORONI_PGA2040_H
@@ -67,10 +69,10 @@
#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
diff --git a/src/boards/include/boards/pimoroni_pga2350.h b/src/boards/include/boards/pimoroni_pga2350.h
new file mode 100644
index 0000000..9690f13
--- /dev/null
+++ b/src/boards/include/boards/pimoroni_pga2350.h
@@ -0,0 +1,92 @@
+/*
+ * 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_pga2350.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_PIMORONI_PGA2350_H
+#define _BOARDS_PIMORONI_PGA2350_H
+
+// For board detection
+#define PIMORONI_PGA2350
+#define PIMORONI_PGA2350_16MB
+
+// --- BOARD SPECIFIC ---
+#define PIMORONI_PGA2350_PSRAM_CS_PIN 47
+
+// --- 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 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 = (16 * 1024 * 1024)
+#ifndef PICO_FLASH_SIZE_BYTES
+#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
+#endif
+
+// no PICO_SMPS_MODE_PIN
+// no PICO_VBUS_PIN
+// no PICO_VSYS_PIN
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/pimoroni_pico_plus2_rp2350.h b/src/boards/include/boards/pimoroni_pico_plus2_rp2350.h
new file mode 100644
index 0000000..13328f3
--- /dev/null
+++ b/src/boards/include/boards/pimoroni_pico_plus2_rp2350.h
@@ -0,0 +1,106 @@
+/*
+ * 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_plus2_rp2350.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_PIMORONI_PICO_PLUS2_RP2350_H
+#define _BOARDS_PIMORONI_PICO_PLUS2_RP2350_H
+
+// For board detection
+#define PIMORONI_PICO_PLUS2_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
+
+// --- 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
diff --git a/src/boards/include/boards/pimoroni_picolipo_16mb.h b/src/boards/include/boards/pimoroni_picolipo_16mb.h
index dfad767..ad5bdf3 100644
--- a/src/boards/include/boards/pimoroni_picolipo_16mb.h
+++ b/src/boards/include/boards/pimoroni_picolipo_16mb.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_PICOLIPO_16MB_H
#define _BOARDS_PIMORONI_PICOLIPO_16MB_H
@@ -72,10 +74,10 @@
#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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_picolipo_4mb.h b/src/boards/include/boards/pimoroni_picolipo_4mb.h
index aea767d..981156f 100644
--- a/src/boards/include/boards/pimoroni_picolipo_4mb.h
+++ b/src/boards/include/boards/pimoroni_picolipo_4mb.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_PICOLIPO_4MB_H
#define _BOARDS_PIMORONI_PICOLIPO_4MB_H
@@ -72,10 +74,10 @@
#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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_picosystem.h b/src/boards/include/boards/pimoroni_picosystem.h
index 0717b05..bacbd57 100644
--- a/src/boards/include/boards/pimoroni_picosystem.h
+++ b/src/boards/include/boards/pimoroni_picosystem.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_PICOSYSTEM_H
#define _BOARDS_PIMORONI_PICOSYSTEM_H
@@ -89,10 +91,10 @@
#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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_plasma2040.h b/src/boards/include/boards/pimoroni_plasma2040.h
index 2cdb4c5..c9937ef 100644
--- a/src/boards/include/boards/pimoroni_plasma2040.h
+++ b/src/boards/include/boards/pimoroni_plasma2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_PLASMA2040_H
#define _BOARDS_PIMORONI_PLASMA2040_H
@@ -81,10 +83,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_plasma2350.h b/src/boards/include/boards/pimoroni_plasma2350.h
new file mode 100644
index 0000000..9fb63eb
--- /dev/null
+++ b/src/boards/include/boards/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 = (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
diff --git a/src/boards/include/boards/pimoroni_servo2040.h b/src/boards/include/boards/pimoroni_servo2040.h
index 17fd76f..21f7049 100644
--- a/src/boards/include/boards/pimoroni_servo2040.h
+++ b/src/boards/include/boards/pimoroni_servo2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_SERVO2040_H
#define _BOARDS_PIMORONI_SERVO2040_H
@@ -102,10 +104,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_tiny2040.h b/src/boards/include/boards/pimoroni_tiny2040.h
index f407008..34e21f9 100644
--- a/src/boards/include/boards/pimoroni_tiny2040.h
+++ b/src/boards/include/boards/pimoroni_tiny2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_TINY2040_H
#define _BOARDS_PIMORONI_TINY2040_H
@@ -90,10 +92,10 @@
#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
diff --git a/src/boards/include/boards/pimoroni_tiny2040_2mb.h b/src/boards/include/boards/pimoroni_tiny2040_2mb.h
index 7aa07b2..8e411cf 100644
--- a/src/boards/include/boards/pimoroni_tiny2040_2mb.h
+++ b/src/boards/include/boards/pimoroni_tiny2040_2mb.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_PIMORONI_TINY2040_2MB_H
#define _BOARDS_PIMORONI_TINY2040_2MB_H
@@ -90,10 +92,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/pimoroni_tiny2350.h b/src/boards/include/boards/pimoroni_tiny2350.h
new file mode 100644
index 0000000..f6472a6
--- /dev/null
+++ b/src/boards/include/boards/pimoroni_tiny2350.h
@@ -0,0 +1,99 @@
+/*
+ * 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_tiny2350.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_PIMORONI_TINY2350_H
+#define _BOARDS_PIMORONI_TINY2350_H
+
+// For board detection
+#define PIMORONI_TINY2350
+#define PIMORONI_TINY2350_8MB
+
+// --- BOARD SPECIFIC ---
+#define TINY2350_LED_R_PIN 18
+#define TINY2350_LED_G_PIN 19
+#define TINY2350_LED_B_PIN 20
+
+#define TINY2350_USER_SW_PIN 23
+
+// --- 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 ---
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN TINY2350_LED_G_PIN
+#endif
+// no PICO_DEFAULT_WS2812_PIN
+
+// --- I2C ---
+// routed to Qw/St connector
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 0
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 12
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 13
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 6
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 7
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 5
+#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
diff --git a/src/boards/include/boards/pololu_3pi_2040_robot.h b/src/boards/include/boards/pololu_3pi_2040_robot.h
index 94be451..53e0db4 100644
--- a/src/boards/include/boards/pololu_3pi_2040_robot.h
+++ b/src/boards/include/boards/pololu_3pi_2040_robot.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_POLOLU_3PI_2040_ROBOT_H
#define _BOARDS_POLOLU_3PI_2040_ROBOT_H
@@ -18,6 +20,7 @@
#define PICO_DEFAULT_LED_PIN 25
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#define PICO_FLASH_SPI_CLKDIV 2
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
// All boards have at least the B1 revision
diff --git a/src/boards/include/boards/pololu_zumo_2040_robot.h b/src/boards/include/boards/pololu_zumo_2040_robot.h
index 7eb1cf0..756b45a 100644
--- a/src/boards/include/boards/pololu_zumo_2040_robot.h
+++ b/src/boards/include/boards/pololu_zumo_2040_robot.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_POLOLU_ZUMO_2040_ROBOT_H
#define _BOARDS_POLOLU_ZUMO_2040_ROBOT_H
@@ -18,6 +20,7 @@
#define PICO_DEFAULT_LED_PIN 25
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
#define PICO_FLASH_SPI_CLKDIV 2
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
// All boards have at least the B1 revision
diff --git a/src/boards/include/boards/seeed_xiao_rp2040.h b/src/boards/include/boards/seeed_xiao_rp2040.h
index 2fd3687..efdb4cb 100644
--- a/src/boards/include/boards/seeed_xiao_rp2040.h
+++ b/src/boards/include/boards/seeed_xiao_rp2040.h
@@ -9,6 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_SEEED_XIAO_RP2040_H
#define _BOARDS_SEEED_XIAO_RP2040_H
@@ -88,10 +90,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/seeed_xiao_rp2350.h b/src/boards/include/boards/seeed_xiao_rp2350.h
new file mode 100644
index 0000000..5c58594
--- /dev/null
+++ b/src/boards/include/boards/seeed_xiao_rp2350.h
@@ -0,0 +1,149 @@
+/*
+ * 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=rp2350
+
+#ifndef _BOARDS_SEEED_XIAO_RP2350_H
+#define _BOARDS_SEEED_XIAO_RP2350_H
+
+// For board detection
+#define SEEED_XIAO_RP2350
+
+//------------- 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
+
+#ifndef PICO_UART1_TX_PIN
+#define PICO_UART1_TX_PIN 20
+#endif
+
+#ifndef PICO_UART1_RX_PIN
+#define PICO_UART1_RX_PIN 21
+#endif
+
+//------------- LED -------------//
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 25
+#endif
+
+#ifndef PICO_DEFAULT_WS2812_PIN
+#define PICO_DEFAULT_WS2812_PIN 22
+#endif
+
+#ifndef PICO_DEFAULT_WS2812_POWER_PIN
+#define PICO_DEFAULT_WS2812_POWER_PIN 23
+#endif
+
+//------------- I2C -------------//
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 1
+#endif
+
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 6
+#endif
+
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 7
+#endif
+
+#ifndef PICO_I2C0_SDA_PIN
+#define PICO_I2C0_SDA_PIN 16
+#endif
+
+#ifndef PICO_I2C0_SCL_PIN
+#define PICO_I2C0_SCL_PIN 17
+#endif
+
+//------------- SPI -------------//
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 2
+#endif
+
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 3
+#endif
+
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 4
+#endif
+
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 5
+#endif
+
+#ifndef PICO_SPI1_CSN_PIN
+#define PICO_SPI1_CSN_PIN 9
+#endif
+
+#ifndef PICO_SPI1_SCK_PIN
+#define PICO_SPI1_SCK_PIN 10
+#endif
+
+#ifndef PICO_SPI1_TX_PIN
+#define PICO_SPI1_TX_PIN 11
+#endif
+
+#ifndef PICO_SPI1_RX_PIN
+#define PICO_SPI1_RX_PIN 12
+#endif
+
+//------------- ADC -------------//
+#ifndef PICO_ADC_A0_PIN
+#define PICO_ADC_A0_PIN 26
+#endif
+
+#ifndef PICO_ADC_A1_PIN
+#define PICO_ADC_A1_PIN 27
+#endif
+
+#ifndef PICO_ADC_A2_PIN
+#define PICO_ADC_A2_PIN 28
+#endif
+
+#ifndef PICO_ADC_BAT_PIN
+#define PICO_ADC_BAT_PIN 29
+#endif
+#ifndef PICO_ADC_BAT_EN_PIN
+#define PICO_ADC_BAT_EN_PIN 19
+#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
+
+#endif
diff --git a/src/boards/include/boards/solderparty_rp2040_stamp.h b/src/boards/include/boards/solderparty_rp2040_stamp.h
index fb3c5b9..af107f6 100644
--- a/src/boards/include/boards/solderparty_rp2040_stamp.h
+++ b/src/boards/include/boards/solderparty_rp2040_stamp.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/solderparty_rp2040_stamp.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_SOLDERPARTY_RP2040_STAMP_H
#define _BOARDS_SOLDERPARTY_RP2040_STAMP_H
@@ -71,10 +73,10 @@
#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 production boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/solderparty_rp2040_stamp_carrier.h b/src/boards/include/boards/solderparty_rp2040_stamp_carrier.h
index aac45f4..811f13c 100644
--- a/src/boards/include/boards/solderparty_rp2040_stamp_carrier.h
+++ b/src/boards/include/boards/solderparty_rp2040_stamp_carrier.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/solderparty_rp2040_stamp_carrier.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_SOLDERPARTY_RP2040_STAMP_CARRIER_H
#define _BOARDS_SOLDERPARTY_RP2040_STAMP_CARRIER_H
diff --git a/src/boards/include/boards/solderparty_rp2040_stamp_round_carrier.h b/src/boards/include/boards/solderparty_rp2040_stamp_round_carrier.h
index bb9d335..3dc0f60 100644
--- a/src/boards/include/boards/solderparty_rp2040_stamp_round_carrier.h
+++ b/src/boards/include/boards/solderparty_rp2040_stamp_round_carrier.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/solderparty_rp2040_stamp_round_carrier.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_SOLDERPARTY_RP2040_STAMP_ROUND_CARRIER_H
#define _BOARDS_SOLDERPARTY_RP2040_STAMP_ROUND_CARRIER_H
diff --git a/src/boards/include/boards/solderparty_rp2350_stamp.h b/src/boards/include/boards/solderparty_rp2350_stamp.h
new file mode 100644
index 0000000..fee982c
--- /dev/null
+++ b/src/boards/include/boards/solderparty_rp2350_stamp.h
@@ -0,0 +1,89 @@
+/*
+ * 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/solderparty_rp2350_stamp.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SOLDERPARTY_RP2350_STAMP_H
+#define _BOARDS_SOLDERPARTY_RP2350_STAMP_H
+
+// For board detection
+#define SOLDERPARTY_RP2350_STAMP
+
+// --- 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
+
+// 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 = (16 * 1024 * 1024)
+#ifndef PICO_FLASH_SIZE_BYTES
+#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
+#endif
+
+#ifndef PICO_RP2040_B0_SUPPORTED
+#define PICO_RP2040_B0_SUPPORTED 1
+#endif
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/solderparty_rp2350_stamp_xl.h b/src/boards/include/boards/solderparty_rp2350_stamp_xl.h
new file mode 100644
index 0000000..97fa0bf
--- /dev/null
+++ b/src/boards/include/boards/solderparty_rp2350_stamp_xl.h
@@ -0,0 +1,89 @@
+/*
+ * 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/solderparty_rp2350_stamp_xl.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SOLDERPARTY_RP2350_STAMP_XL_H
+#define _BOARDS_SOLDERPARTY_RP2350_STAMP_XL_H
+
+// For board detection
+#define SOLDERPARTY_RP2350_STAMP_XL
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 0
+
+// --- 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
+
+// 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 = (16 * 1024 * 1024)
+#ifndef PICO_FLASH_SIZE_BYTES
+#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
+#endif
+
+#ifndef PICO_RP2040_B0_SUPPORTED
+#define PICO_RP2040_B0_SUPPORTED 1
+#endif
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/sparkfun_micromod.h b/src/boards/include/boards/sparkfun_micromod.h
index 0c6e568..5806bd1 100644
--- a/src/boards/include/boards/sparkfun_micromod.h
+++ b/src/boards/include/boards/sparkfun_micromod.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/sparkfun_micromod.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_SPARKFUN_MICROMOD_H
#define _BOARDS_SPARKFUN_MICROMOD_H
@@ -73,10 +75,10 @@
#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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
diff --git a/src/boards/include/boards/sparkfun_promicro.h b/src/boards/include/boards/sparkfun_promicro.h
index 45bb4a2..da48c45 100644
--- a/src/boards/include/boards/sparkfun_promicro.h
+++ b/src/boards/include/boards/sparkfun_promicro.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/sparkfun_promicro.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_SPARKFUN_PROMICRO_H
#define _BOARDS_SPARKFUN_PROMICRO_H
@@ -30,7 +32,7 @@
#define PICO_DEFAULT_UART_RX_PIN 1
#endif
-// The PRO Micro doesnt have a plain LED, but a WS2812
+// The PRO Micro doesn't have a plain LED, but a WS2812
//#ifndef PICO_DEFAULT_LED_PIN
//#define PICO_DEFAULT_LED_PIN 25
//#endif
@@ -73,10 +75,10 @@
#endif
// board has 16M onboard flash
+// 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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
diff --git a/src/boards/include/boards/sparkfun_promicro_rp2350.h b/src/boards/include/boards/sparkfun_promicro_rp2350.h
new file mode 100644
index 0000000..fd12de5
--- /dev/null
+++ b/src/boards/include/boards/sparkfun_promicro_rp2350.h
@@ -0,0 +1,88 @@
+/*
+ * 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
+// -----------------------------------------------------
+//
+//------------------------------------------------------------------------------------------
+// Board definition for the SparkFun ProMicro RP2350
+//
+// This header may be included by other board headers as "boards/sparkfun_promicro_rp2350.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SPARKFUN_PROMICRO_RP2350_H
+#define _BOARDS_SPARKFUN_PROMICRO_RP2350_H
+
+// For board detection
+#define SPARKFUN_PROMICRO_RP2350
+
+// --- 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
+
+// The PRO Micro doesn't have a plain LED, but a WS2812
+#ifndef PICO_DEFAULT_WS2812_PIN
+#define PICO_DEFAULT_WS2812_PIN 25
+#endif
+
+// Default I2C - for the onboard qwiic connector
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 0
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 16
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 17
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 22
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 23
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 20
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 21
+#endif
+
+#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
+
+#ifndef PICO_FLASH_SPI_CLKDIV
+#define PICO_FLASH_SPI_CLKDIV 2
+#endif
+
+// board has 16M onboard flash
+// 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
+
+// --- RP2350 VARIANT ---
+#define PICO_RP2350A 1
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/sparkfun_thingplus.h b/src/boards/include/boards/sparkfun_thingplus.h
index 3d7d69a..1ed52b8 100644
--- a/src/boards/include/boards/sparkfun_thingplus.h
+++ b/src/boards/include/boards/sparkfun_thingplus.h
@@ -14,6 +14,8 @@
//
// This header may be included by other board headers as "boards/sparkfun_thingplus.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_SPARKFUN_THINGPLUS_H
#define _BOARDS_SPARKFUN_THINGPLUS_H
@@ -72,10 +74,10 @@
#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 thing plus has a SD Card.
#define PICO_SD_CLK_PIN 14
#define PICO_SD_CMD_PIN 15
diff --git a/src/boards/include/boards/switchscience_picossci2_conta_base.h b/src/boards/include/boards/switchscience_picossci2_conta_base.h
new file mode 100644
index 0000000..fcd7d85
--- /dev/null
+++ b/src/boards/include/boards/switchscience_picossci2_conta_base.h
@@ -0,0 +1,86 @@
+/*
+ * 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/switchscience_picossci2_conta_base.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SWITCHSCIENCE_PICOSSCI2_CONTA_BASE_H
+#define _BOARDS_SWITCHSCIENCE_PICOSSCI2_CONTA_BASE_H
+
+// For board detection
+#define SWITCHSCIENCE_PICOSSCI2_CONTA_BASE_H
+
+// --- 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 ---
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 25
+#endif
+
+// --- I2C ---
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 1
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 6
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 7
+#endif
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 2
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 3
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 4
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 5
+#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
+
+#endif
diff --git a/src/boards/include/boards/switchscience_picossci2_dev_board.h b/src/boards/include/boards/switchscience_picossci2_dev_board.h
new file mode 100644
index 0000000..432d2d9
--- /dev/null
+++ b/src/boards/include/boards/switchscience_picossci2_dev_board.h
@@ -0,0 +1,87 @@
+/*
+ * 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/switchscience_picossci2_dev_board.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SWITCHSCIENCE_PICOSSCI2_DEV_BOARD_H
+#define _BOARDS_SWITCHSCIENCE_PICOSSCI2_DEV_BOARD_H
+
+// For board detection
+#define SWITCHSCIENCE_PICOSSCI2_DEV_BOARD
+
+// --- 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 ---
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 25
+#endif
+
+// --- 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
+
+// board has 4MB onboard flash
+// 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
+
+#endif
diff --git a/src/boards/include/boards/switchscience_picossci2_micro.h b/src/boards/include/boards/switchscience_picossci2_micro.h
new file mode 100644
index 0000000..5d66499
--- /dev/null
+++ b/src/boards/include/boards/switchscience_picossci2_micro.h
@@ -0,0 +1,73 @@
+/*
+ * 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/switchscience_picossci2_micro.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SWITCHSCIENCE_PICOSSCI2_MICRO_H
+#define _BOARDS_SWITCHSCIENCE_PICOSSCI2_MICRO_H
+
+// For board detection
+#define SWITCHSCIENCE_PICOSSCI2_MICRO
+
+// --- 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
+
+// --- Picossci2 Micro doesn't have an LED connected to GPIO ---
+
+// --- SPI ---
+#ifndef PICO_DEFAULT_SPI
+#define PICO_DEFAULT_SPI 0
+#endif
+#ifndef PICO_DEFAULT_SPI_SCK_PIN
+#define PICO_DEFAULT_SPI_SCK_PIN 22
+#endif
+#ifndef PICO_DEFAULT_SPI_TX_PIN
+#define PICO_DEFAULT_SPI_TX_PIN 23
+#endif
+#ifndef PICO_DEFAULT_SPI_RX_PIN
+#define PICO_DEFAULT_SPI_RX_PIN 20
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 21
+#endif
+
+// --- FLASH ---
+
+#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
+
+#ifndef PICO_FLASH_SPI_CLKDIV
+#define PICO_FLASH_SPI_CLKDIV 2
+#endif
+
+// board has 4MB onboard flash
+// 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
+
+#endif
diff --git a/src/boards/include/boards/switchscience_picossci2_rp2350_breakout.h b/src/boards/include/boards/switchscience_picossci2_rp2350_breakout.h
new file mode 100644
index 0000000..0ac128b
--- /dev/null
+++ b/src/boards/include/boards/switchscience_picossci2_rp2350_breakout.h
@@ -0,0 +1,86 @@
+/*
+ * 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/switchscience_picossci2_rp2350_breakout.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SWITCHSCIENCE_PICOSSCI2_RP2350_BREAKOUT_H
+#define _BOARDS_SWITCHSCIENCE_PICOSSCI2_RP2350_BREAKOUT_H
+
+// For board detection
+#define SWITCHSCIENCE_PICOSSCI2_RP2350_BREAKOUT_H
+
+// --- 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 ---
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 25
+#endif
+
+// --- 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
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/switchscience_picossci2_tiny.h b/src/boards/include/boards/switchscience_picossci2_tiny.h
new file mode 100644
index 0000000..48e3a9e
--- /dev/null
+++ b/src/boards/include/boards/switchscience_picossci2_tiny.h
@@ -0,0 +1,86 @@
+/*
+ * 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/switchscience_picossci2_tiny.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_SWITCHSCIENCE_PICOSSCI2_TINY_H
+#define _BOARDS_SWITCHSCIENCE_PICOSSCI2_TINY_H
+
+// For board detection
+#define SWITCHSCIENCE_PICOSSCI2_TINY_H
+
+// --- 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 28
+#endif
+#ifndef PICO_DEFAULT_UART_RX_PIN
+#define PICO_DEFAULT_UART_RX_PIN 29
+#endif
+
+// --- LED ---
+#ifndef PICO_DEFAULT_LED_PIN
+#define PICO_DEFAULT_LED_PIN 25
+#endif
+
+// --- I2C ---
+#ifndef PICO_DEFAULT_I2C
+#define PICO_DEFAULT_I2C 1
+#endif
+#ifndef PICO_DEFAULT_I2C_SDA_PIN
+#define PICO_DEFAULT_I2C_SDA_PIN 2
+#endif
+#ifndef PICO_DEFAULT_I2C_SCL_PIN
+#define PICO_DEFAULT_I2C_SCL_PIN 3
+#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 20
+#endif
+#ifndef PICO_DEFAULT_SPI_CSN_PIN
+#define PICO_DEFAULT_SPI_CSN_PIN 21
+#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
+
+#endif
diff --git a/src/boards/include/boards/tinycircuits_thumby_color_rp2350.h b/src/boards/include/boards/tinycircuits_thumby_color_rp2350.h
new file mode 100644
index 0000000..0a3c14a
--- /dev/null
+++ b/src/boards/include/boards/tinycircuits_thumby_color_rp2350.h
@@ -0,0 +1,100 @@
+/*
+ * 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/tinycircuits_thumby_color_rp2350.h"
+
+// pico_cmake_set PICO_PLATFORM=rp2350
+
+#ifndef _BOARDS_TINYCIRCUITS_THUMBY_COLOR_RP2350_H
+#define _BOARDS_TINYCIRCUITS_THUMBY_COLOR_RP2350_H
+
+// For board detection
+#define TINYCIRCUITS_THUMBY_COLOR_RP2350
+
+// --- 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 ---
+#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 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 = (16 * 1024 * 1024)
+#ifndef PICO_FLASH_SIZE_BYTES
+#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
+#endif
+// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
+#define PICO_SMPS_MODE_PIN 23
+
+// 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 29
+#endif
+
+#ifndef PICO_RP2350_A2_SUPPORTED
+#define PICO_RP2350_A2_SUPPORTED 1
+#endif
+
+#endif
diff --git a/src/boards/include/boards/waveshare_rp2040_lcd_0.96.h b/src/boards/include/boards/waveshare_rp2040_lcd_0.96.h
index ff0e84b..0791870 100644
--- a/src/boards/include/boards/waveshare_rp2040_lcd_0.96.h
+++ b/src/boards/include/boards/waveshare_rp2040_lcd_0.96.h
@@ -9,6 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_WAVESHARE_RP2040_LCD_0_96_H
#define _BOARDS_WAVESHARE_RP2040_LCD_0_96_H
@@ -88,10 +89,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
#define PICO_SMPS_MODE_PIN 23
diff --git a/src/boards/include/boards/waveshare_rp2040_lcd_1.28.h b/src/boards/include/boards/waveshare_rp2040_lcd_1.28.h
index eea4525..816aec2 100644
--- a/src/boards/include/boards/waveshare_rp2040_lcd_1.28.h
+++ b/src/boards/include/boards/waveshare_rp2040_lcd_1.28.h
@@ -9,6 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_WAVESHARE_RP2040_LCD_1_28_H
#define _BOARDS_WAVESHARE_RP2040_LCD_1_28_H
@@ -91,10 +92,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/waveshare_rp2040_one.h b/src/boards/include/boards/waveshare_rp2040_one.h
index 3f6c6c4..389d299 100644
--- a/src/boards/include/boards/waveshare_rp2040_one.h
+++ b/src/boards/include/boards/waveshare_rp2040_one.h
@@ -9,6 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_WAVESHARE_RP2040_ONE_H
#define _BOARDS_WAVESHARE_RP2040_ONE_H
@@ -67,10 +68,10 @@
#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
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/waveshare_rp2040_plus_16mb.h b/src/boards/include/boards/waveshare_rp2040_plus_16mb.h
index 6f5e144..2d32acc 100644
--- a/src/boards/include/boards/waveshare_rp2040_plus_16mb.h
+++ b/src/boards/include/boards/waveshare_rp2040_plus_16mb.h
@@ -9,6 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_WAVESHARE_RP2040_PLUS_16MB_H
#define _BOARDS_WAVESHARE_RP2040_PLUS_16MB_H
@@ -69,10 +70,10 @@
#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
-
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
#define PICO_SMPS_MODE_PIN 23
diff --git a/src/boards/include/boards/waveshare_rp2040_plus_4mb.h b/src/boards/include/boards/waveshare_rp2040_plus_4mb.h
index d8dd8f6..f5be657 100644
--- a/src/boards/include/boards/waveshare_rp2040_plus_4mb.h
+++ b/src/boards/include/boards/waveshare_rp2040_plus_4mb.h
@@ -9,6 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_WAVESHARE_RP2040_PLUS_4MB_H
#define _BOARDS_WAVESHARE_RP2040_PLUS_4MB_H
@@ -69,10 +70,10 @@
#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)
#define PICO_SMPS_MODE_PIN 23
diff --git a/src/boards/include/boards/waveshare_rp2040_zero.h b/src/boards/include/boards/waveshare_rp2040_zero.h
index 8dadd55..85be7c7 100644
--- a/src/boards/include/boards/waveshare_rp2040_zero.h
+++ b/src/boards/include/boards/waveshare_rp2040_zero.h
@@ -9,6 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
+// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_WAVESHARE_RP2040_ZERO_H
#define _BOARDS_WAVESHARE_RP2040_ZERO_H
@@ -67,10 +68,10 @@
#define PICO_FLASH_SPI_CLKDIV 4
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// All boards have B1 RP2040
#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
diff --git a/src/boards/include/boards/weact_studio_rp2040_16mb.h b/src/boards/include/boards/weact_studio_rp2040_16mb.h
index bd45b1f..c8d3aa2 100644
--- a/src/boards/include/boards/weact_studio_rp2040_16mb.h
+++ b/src/boards/include/boards/weact_studio_rp2040_16mb.h
@@ -11,6 +11,8 @@
// This header may be included by other board headers as "boards/weact_studio_rp2040_16mb.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_WEACT_STUDIO_RP2040_16MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_16MB_H
@@ -73,8 +75,8 @@
#define PICO_RP2040_B0_SUPPORTED 0
#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
-
#endif
diff --git a/src/boards/include/boards/weact_studio_rp2040_2mb.h b/src/boards/include/boards/weact_studio_rp2040_2mb.h
index d058ce3..4b0c005 100644
--- a/src/boards/include/boards/weact_studio_rp2040_2mb.h
+++ b/src/boards/include/boards/weact_studio_rp2040_2mb.h
@@ -11,6 +11,8 @@
// This header may be included by other board headers as "boards/weact_studio_rp2040_2mb.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_WEACT_STUDIO_RP2040_2MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_2MB_H
@@ -73,8 +75,8 @@
#define PICO_RP2040_B0_SUPPORTED 0
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
#endif
diff --git a/src/boards/include/boards/weact_studio_rp2040_4mb.h b/src/boards/include/boards/weact_studio_rp2040_4mb.h
index 6b49a4f..405620d 100644
--- a/src/boards/include/boards/weact_studio_rp2040_4mb.h
+++ b/src/boards/include/boards/weact_studio_rp2040_4mb.h
@@ -11,6 +11,8 @@
// This header may be included by other board headers as "boards/weact_studio_rp2040_4mb.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_WEACT_STUDIO_RP2040_4MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_4MB_H
@@ -73,8 +75,8 @@
#define PICO_RP2040_B0_SUPPORTED 0
#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
-
#endif
diff --git a/src/boards/include/boards/weact_studio_rp2040_8mb.h b/src/boards/include/boards/weact_studio_rp2040_8mb.h
index bdddd22..72778c1 100644
--- a/src/boards/include/boards/weact_studio_rp2040_8mb.h
+++ b/src/boards/include/boards/weact_studio_rp2040_8mb.h
@@ -11,6 +11,8 @@
// This header may be included by other board headers as "boards/weact_studio_rp2040_8mb.h"
+// pico_cmake_set PICO_PLATFORM=rp2040
+
#ifndef _BOARDS_WEACT_STUDIO_RP2040_8MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_8MB_H
@@ -73,8 +75,8 @@
#define PICO_RP2040_B0_SUPPORTED 0
#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
-
#endif
diff --git a/src/boards/include/boards/wiznet_w5100s_evb_pico.h b/src/boards/include/boards/wiznet_w5100s_evb_pico.h
index 585f1d1..0640ead 100644
--- a/src/boards/include/boards/wiznet_w5100s_evb_pico.h
+++ b/src/boards/include/boards/wiznet_w5100s_evb_pico.h
@@ -9,7 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
-
+// pico_cmake_set PICO_PLATFORM=rp2040
#ifndef _BOARDS_WIZNET_W5100S_EVB_PICO_H
#define _BOARDS_WIZNET_W5100S_EVB_PICO_H
@@ -89,10 +89,10 @@
#define PICO_FLASH_SPI_CLKDIV 2
#endif
+// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (2 * 1024 * 1024)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
#endif
-
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
#define PICO_SMPS_MODE_PIN 23
diff --git a/src/boards/pico_w.cmake b/src/boards/pico_w.cmake
deleted file mode 100644
index 7aeaaee..0000000
--- a/src/boards/pico_w.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-set(PICO_CYW43_SUPPORTED "1")
-pico_register_common_scope_var(PICO_CYW43_SUPPORTED)
-include(${CMAKE_CURRENT_LIST_DIR}/generic_board.cmake)
diff --git a/src/cmake/no_hardware.cmake b/src/cmake/no_hardware.cmake
new file mode 100644
index 0000000..95a034b
--- /dev/null
+++ b/src/cmake/no_hardware.cmake
@@ -0,0 +1,26 @@
+macro(pico_set_float_implementation TARGET IMPL)
+ # ignore
+endmacro()
+
+macro(pico_set_double_implementation TARGET IMPL)
+ # ignore
+endmacro()
+
+macro(pico_set_binary_type TARGET IMPL)
+ # ignore
+endmacro()
+
+macro(pico_set_boot_stage2 TARGET IMPL)
+ # ignore
+endmacro()
+
+set(PICO_HOST_DIR "${CMAKE_CURRENT_LIST_DIR}/host" CACHE INTERNAL "")
+function(pico_define_boot_stage2 NAME)
+ add_executable(${NAME} ${PICO_HOST_DIR}/boot_stage2.c)
+endfunction()
+
+function(pico_add_extra_outputs TARGET)
+endfunction()
+
+set(PICO_NO_HARDWARE "1" CACHE INTERNAL "")
+set(PICO_ON_DEVICE "0" CACHE INTERNAL "")
\ No newline at end of file
diff --git a/src/cmake/on_device.cmake b/src/cmake/on_device.cmake
new file mode 100644
index 0000000..3b2d886
--- /dev/null
+++ b/src/cmake/on_device.cmake
@@ -0,0 +1,97 @@
+# include targets for all for PICO on device
+
+enable_language(ASM)
+
+function(pico_get_runtime_output_directory TARGET output_path_name)
+ get_target_property(${TARGET}_runtime_directory ${TARGET} RUNTIME_OUTPUT_DIRECTORY)
+ if (${TARGET}_runtime_directory)
+ get_filename_component(output_path "${${TARGET}_runtime_directory}"
+ REALPATH BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${output_path}")
+ set(output_path "${output_path}/")
+ else()
+ set(output_path "")
+ endif()
+ set(${output_path_name} ${output_path} PARENT_SCOPE)
+endfunction()
+
+function(pico_add_hex_output TARGET)
+ pico_get_runtime_output_directory(${TARGET} output_path)
+ add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${TARGET}> ${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.hex VERBATIM)
+endfunction()
+
+function(pico_add_bin_output TARGET)
+ pico_get_runtime_output_directory(${TARGET} output_path)
+ add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${TARGET}> ${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.bin VERBATIM)
+endfunction()
+
+function(pico_add_dis_output TARGET)
+ pico_get_runtime_output_directory(${TARGET} output_path)
+
+ # PICO_CMAKE_CONFIG: PICO_NO_COPRO_DIS, Disable disassembly listing postprocessing that disassembles RP2350 coprocessor instructions, type=bool, default=0, group=build
+ if (NOT (PICO_NO_COPRO_DIS OR PICO_NO_PICOTOOL))
+ pico_init_picotool()
+ if(picotool_FOUND)
+ # add custom disassembly if we have picotool
+ set(EXTRA_COMMAND COMMAND picotool coprodis --quiet ${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.dis ${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.dis)
+ endif()
+ endif()
+
+ add_custom_command(TARGET ${TARGET} POST_BUILD
+ COMMAND ${CMAKE_OBJDUMP} -h $<TARGET_FILE:${TARGET}> > ${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.dis
+ COMMAND ${CMAKE_OBJDUMP} -d $<TARGET_FILE:${TARGET}> >> ${output_path}$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>>,$<TARGET_PROPERTY:${TARGET},OUTPUT_NAME>,$<TARGET_PROPERTY:${TARGET},NAME>>.dis
+ ${EXTRA_COMMAND} || ${CMAKE_COMMAND} -E echo "WARNING: Disassembly is not correct"
+ VERBATIM
+ )
+endfunction()
+
+function(pico_add_extra_outputs TARGET)
+ # Disassembly will be nonsense for encrypted binaries,
+ # so disassemble before picotool processing
+ pico_add_dis_output(${TARGET})
+
+ # Picotool processing (signing/encrypting/etc)
+ # PICO_CMAKE_CONFIG: PICO_NO_PICOTOOL, Disable use/requirement for picotool meaning that UF2 output and signing/hashing and coprocoessor disassembly will all be unavailable, type=bool, default=0, group=build
+ if (NOT PICO_NO_PICOTOOL)
+ picotool_postprocess_binary(${TARGET} IS_ENCRYPTED)
+ endif()
+
+ if (PICO_32BIT)
+ pico_add_hex_output(${TARGET})
+ endif()
+ pico_add_bin_output(${TARGET})
+ pico_add_map_output(${TARGET})
+
+ # PICO_CMAKE_CONFIG: PICO_NO_TARGET_NAME, Don't define PICO_TARGET_NAME, type=bool, default=0, group=build
+ # PICO_BUILD_DEFINE: PICO_TARGET_NAME, The name of the build target being compiled (unless PICO_NO_TARGET_NAME set in build), type=string, default=target name, group=build
+ if (NOT PICO_NO_TARGET_NAME)
+ target_compile_definitions(${TARGET} PRIVATE
+ PICO_TARGET_NAME="${TARGET}"
+ )
+ endif()
+
+ if (PICO_SYMLINK_ELF_AS_FILENAME)
+ add_custom_target(${TARGET}_symlinked)
+ add_dependencies(${TARGET}_symlinked ${TARGET})
+
+ add_custom_command(TARGET ${TARGET}_symlinked POST_BUILD
+ COMMAND rm -f "${PICO_SYMLINK_ELF_AS_FILENAME}"
+ COMMAND ln -s -r $<TARGET_FILE:${TARGET}> "${PICO_SYMLINK_ELF_AS_FILENAME}"
+ COMMENT "Symlinking from ${PICO_SYMLINK_ELF_AS_FILENAME} to ${TARGET}"
+ )
+ endif ()
+ # PICO_CMAKE_CONFIG: PICO_NO_UF2, Disable UF2 output, type=bool, default=0, group=build
+ if (NOT (PICO_NO_UF2 OR PICO_NO_PICOTOOL))
+ pico_add_uf2_output(${TARGET})
+ endif()
+endfunction()
+
+# PICO_CMAKE_CONFIG: PICO_NO_HARDWARE, Option as to whether the build is not targeting an RP2040 or RP2350 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build
+# PICO_BUILD_DEFINE: PICO_NO_HARDWARE, Whether the build is not targeting an RP2040 or RP2350 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build
+set(PICO_NO_HARDWARE "0" CACHE INTERNAL "")
+# PICO_CMAKE_CONFIG: PICO_ON_DEVICE, Option as to whether the build is targeting an RP2040 or RP2350 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build
+# PICO_BUILD_DEFINE: PICO_ON_DEVICE, Whether the build is targeting an RP2040 or RP2350 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build
+set(PICO_ON_DEVICE "1" CACHE INTERNAL "")
+
+set(CMAKE_EXECUTABLE_SUFFIX .elf)
+set(CMAKE_EXECUTABLE_SUFFIX "${CMAKE_EXECUTABLE_SUFFIX}" PARENT_SCOPE)
\ No newline at end of file
diff --git a/src/cmake/rp2_common.cmake b/src/cmake/rp2_common.cmake
new file mode 100644
index 0000000..494b120
--- /dev/null
+++ b/src/cmake/rp2_common.cmake
@@ -0,0 +1,162 @@
+# Used for RP2040 and RP2350
+
+include(cmake/on_device.cmake)
+
+# PICO_CMAKE_CONFIG: PICO_NO_FLASH, Option to default all binaries to not use flash i.e. run from SRAM, type=bool, default=0, group=build, docref=cmake-binary-type-config
+option(PICO_NO_FLASH "Default binaries to not not use flash")
+# PICO_CMAKE_CONFIG: PICO_COPY_TO_RAM, Option to default all binaries to copy code from flash to SRAM before running, type=bool, default=0, group=build, docref=cmake-binary-type-config
+option(PICO_COPY_TO_RAM "Default binaries to copy code to RAM when booting from flash")
+
+# COMMON
+pico_add_subdirectory(common/boot_picobin_headers)
+pico_add_subdirectory(common/boot_picoboot_headers)
+pico_add_subdirectory(common/boot_uf2_headers)
+pico_add_subdirectory(common/pico_base_headers)
+pico_add_subdirectory(common/pico_usb_reset_interface_headers)
+
+# PICO_CMAKE_CONFIG: PICO_BARE_METAL, Flag to exclude anything except base headers from the build, type=bool, default=0, group=build
+if (NOT PICO_BARE_METAL)
+ pico_add_subdirectory(common/pico_bit_ops_headers)
+ pico_add_subdirectory(common/pico_binary_info)
+ pico_add_subdirectory(common/pico_divider_headers)
+ pico_add_subdirectory(common/pico_sync)
+ pico_add_subdirectory(common/pico_time)
+ pico_add_subdirectory(common/pico_util)
+ pico_add_subdirectory(common/pico_stdlib_headers)
+endif()
+pico_add_subdirectory(common/hardware_claim)
+#
+# RP2040/RP2350 specific From standard build variants
+pico_add_subdirectory(${RP2_VARIANT_DIR}/pico_platform)
+pico_add_subdirectory(${RP2_VARIANT_DIR}/hardware_regs)
+pico_add_subdirectory(${RP2_VARIANT_DIR}/hardware_structs)
+pico_add_subdirectory(${RP2_VARIANT_DIR}/boot_stage2)
+
+pico_add_subdirectory(rp2_common/hardware_base)
+# HAL items which expose a public (inline rp2_common) functions/macro API above the raw hardware
+pico_add_subdirectory(rp2_common/hardware_adc)
+pico_add_subdirectory(rp2_common/hardware_boot_lock)
+pico_add_subdirectory(rp2_common/hardware_clocks)
+pico_add_subdirectory(rp2_common/hardware_divider)
+pico_add_subdirectory(rp2_common/hardware_dma)
+pico_add_subdirectory(rp2_common/hardware_exception)
+pico_add_subdirectory(rp2_common/hardware_flash)
+pico_add_subdirectory(rp2_common/hardware_gpio)
+pico_add_subdirectory(rp2_common/hardware_i2c)
+pico_add_subdirectory(rp2_common/hardware_interp)
+pico_add_subdirectory(rp2_common/hardware_irq)
+pico_add_subdirectory(rp2_common/hardware_pio)
+pico_add_subdirectory(rp2_common/hardware_pll)
+pico_add_subdirectory(rp2_common/hardware_pwm)
+pico_add_subdirectory(rp2_common/hardware_resets)
+if (PICO_RP2040 OR PICO_COMBINED_DOCS)
+ pico_add_subdirectory(rp2_common/hardware_rtc)
+endif()
+pico_add_subdirectory(rp2_common/hardware_spi)
+pico_add_subdirectory(rp2_common/hardware_sync)
+pico_add_subdirectory(rp2_common/hardware_sync_spin_lock)
+pico_add_subdirectory(rp2_common/hardware_ticks)
+pico_add_subdirectory(rp2_common/hardware_timer)
+pico_add_subdirectory(rp2_common/hardware_uart)
+pico_add_subdirectory(rp2_common/hardware_vreg)
+pico_add_subdirectory(rp2_common/hardware_watchdog)
+pico_add_subdirectory(rp2_common/hardware_xosc)
+
+if (PICO_RP2350 OR PICO_COMBINED_DOCS)
+ pico_add_subdirectory(rp2_common/hardware_powman)
+ # Note in spite of the name this is usable on Arm as well as RISC-V:
+ pico_add_subdirectory(rp2_common/hardware_riscv_platform_timer)
+ pico_add_subdirectory(rp2_common/hardware_sha256)
+endif()
+
+if (PICO_RP2350 OR PICO_COMBINED_DOCS)
+ pico_add_subdirectory(rp2_common/hardware_dcp)
+ pico_add_subdirectory(rp2_common/hardware_rcp)
+endif()
+
+if (PICO_RISCV OR PICO_COMBINED_DOCS)
+ pico_add_subdirectory(rp2_common/hardware_riscv)
+ pico_add_subdirectory(rp2_common/hardware_hazard3)
+endif()
+
+# Helper functions to connect to data/functions in the bootrom
+pico_add_subdirectory(rp2_common/pico_bootrom)
+
+pico_add_subdirectory(rp2_common/pico_platform_compiler)
+pico_add_subdirectory(rp2_common/pico_platform_sections)
+pico_add_subdirectory(rp2_common/pico_platform_panic)
+
+if (NOT PICO_BARE_METAL)
+ # NOTE THE ORDERING HERE IS IMPORTANT AS SOME TARGETS CHECK ON EXISTENCE OF OTHER TARGETS
+ pico_add_subdirectory(rp2_common/pico_aon_timer)
+ pico_add_subdirectory(rp2_common/pico_bootsel_via_double_reset)
+ pico_add_subdirectory(rp2_common/pico_multicore)
+ pico_add_subdirectory(rp2_common/pico_unique_id)
+
+ pico_add_subdirectory(rp2_common/pico_atomic)
+ pico_add_subdirectory(rp2_common/pico_bit_ops)
+ pico_add_subdirectory(rp2_common/pico_divider)
+ pico_add_subdirectory(rp2_common/pico_double)
+ pico_add_subdirectory(rp2_common/pico_int64_ops)
+ pico_add_subdirectory(rp2_common/pico_flash)
+ pico_add_subdirectory(rp2_common/pico_float)
+ pico_add_subdirectory(rp2_common/pico_mem_ops)
+ pico_add_subdirectory(rp2_common/pico_malloc)
+ pico_add_subdirectory(rp2_common/pico_printf)
+ pico_add_subdirectory(rp2_common/pico_rand)
+
+ if (PICO_RP2350 OR PICO_COMBINED_DOCS)
+ pico_add_subdirectory(rp2_common/pico_sha256)
+ endif()
+
+ pico_add_subdirectory(rp2_common/pico_stdio_semihosting)
+ pico_add_subdirectory(rp2_common/pico_stdio_uart)
+ pico_add_subdirectory(rp2_common/pico_stdio_rtt)
+
+ if (NOT PICO_RISCV)
+ pico_add_subdirectory(rp2_common/cmsis)
+ endif()
+ pico_add_subdirectory(rp2_common/tinyusb)
+ pico_add_subdirectory(rp2_common/pico_stdio_usb)
+ pico_add_subdirectory(rp2_common/pico_i2c_slave)
+
+ # networking libraries - note dependency order is important
+ pico_add_subdirectory(rp2_common/pico_async_context)
+ pico_add_subdirectory(rp2_common/pico_btstack)
+ pico_add_subdirectory(rp2_common/pico_cyw43_driver)
+ pico_add_subdirectory(rp2_common/pico_lwip)
+ pico_add_subdirectory(rp2_common/pico_cyw43_arch)
+ pico_add_subdirectory(rp2_common/pico_mbedtls)
+
+ pico_add_subdirectory(rp2_common/pico_time_adapter)
+
+ pico_add_subdirectory(rp2_common/pico_crt0)
+ pico_add_subdirectory(rp2_common/pico_clib_interface)
+ pico_add_subdirectory(rp2_common/pico_cxx_options)
+ pico_add_subdirectory(rp2_common/pico_standard_binary_info)
+ pico_add_subdirectory(rp2_common/pico_standard_link)
+
+ pico_add_subdirectory(rp2_common/pico_fix)
+
+ # at the end as it includes a lot of other stuff
+ pico_add_subdirectory(rp2_common/pico_runtime_init)
+ pico_add_subdirectory(rp2_common/pico_runtime)
+
+ # this requires all the pico_stdio_ libraries
+ pico_add_subdirectory(rp2_common/pico_stdio)
+ # this requires runtime
+ pico_add_subdirectory(rp2_common/pico_stdlib)
+endif()
+
+# configure doxygen directories
+#pico_add_doxygen(${COMMON_DIR})
+#pico_add_doxygen(${RP2_VARIANT_DIR})
+pico_add_doxygen_exclude(${RP2_VARIANT_DIR}/hardware_regs) # very very big
+# but we DO want dreq.h; it doesn't change much, so lets just use configure_file
+configure_file(${RP2_VARIANT_DIR}/hardware_regs/include/hardware/regs/dreq.h ${CMAKE_CURRENT_BINARY_DIR}/extra_doxygen/dreq.h COPYONLY)
+# also intctrl.h
+configure_file(${RP2_VARIANT_DIR}/hardware_regs/include/hardware/regs/intctrl.h ${CMAKE_CURRENT_BINARY_DIR}/extra_doxygen/intctrl.h COPYONLY)
+pico_add_doxygen(${CMAKE_CURRENT_BINARY_DIR}/extra_doxygen)
+
+#pico_add_doxygen(rp2_common)
+pico_add_doxygen_exclude(rp2_common/cmsis) # very big
diff --git a/src/combined-docs.cmake b/src/combined-docs.cmake
new file mode 100644
index 0000000..3af6c90
--- /dev/null
+++ b/src/combined-docs.cmake
@@ -0,0 +1,32 @@
+# This is not a platform proper; but is used to build a merged set of documentation
+
+set(PICO_RP2040 "1" CACHE INTERNAL "")
+set(PICO_RP2350 "1" CACHE INTERNAL "")
+set(PICO_RISCV "1" CACHE INTERNAL "")
+set(PICO_ARM "1" CACHE INTERNAL "")
+set(PICO_COMBINED_DOCS "1" CACHE INTERNAL "")
+# have to pick one for platform stuff, so lets go with rp2350
+set(RP2_VARIANT_DIR ${CMAKE_CURRENT_LIST_DIR}/rp2350)
+# pick latest version
+set(PICO_PIO_VERSION "1" CACHE INTERNAL "")
+set(PICO_CMSIS_DEVICE "RP2350" CACHE INTERNAL "")
+
+# Add RP2040 structs too, since there are distinct enums in there
+pico_add_doxygen(rp2040/hardware_structs)
+# but we DO want dreq.h; it doesn't change much, so lets just use configure_file
+# (note we don't add rp2040/hardware_regs because of the size)
+configure_file(rp2040/hardware_regs/include/hardware/regs/dreq.h ${CMAKE_CURRENT_BINARY_DIR}/extra_doxygen/dreq_rp2040.h COPYONLY)
+# also intctrl.h
+configure_file(rp2040/hardware_regs/include/hardware/regs/intctrl.h ${CMAKE_CURRENT_BINARY_DIR}/extra_doxygen/intctrl_rp2040.h COPYONLY)
+pico_add_doxygen(${CMAKE_CURRENT_BINARY_DIR}/extra_doxygen)
+
+pico_add_doxygen_pre_define("PICO_RP2040=1")
+pico_add_doxygen_pre_define("PICO_RP2350=1")
+pico_add_doxygen_pre_define("PICO_COMBINED_DOCS=1")
+pico_add_doxygen_pre_define("NUM_DOORBELLS=1") # we have functions that are gated by this
+pico_add_doxygen_enabled_section(combined_docs)
+pico_add_doxygen_enabled_section(rp2040_specific)
+pico_add_doxygen_enabled_section(rp2350_specific)
+
+include(cmake/rp2_common.cmake)
+
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
deleted file mode 100644
index 38cf238..0000000
--- a/src/common/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-pico_add_subdirectory(boot_picoboot)
-pico_add_subdirectory(boot_uf2)
-pico_add_subdirectory(pico_base)
-pico_add_subdirectory(pico_usb_reset_interface)
-
-# PICO_CMAKE_CONFIG: PICO_BARE_METAL, Flag to exclude anything except base headers from the build, type=bool, default=0, group=build
-if (NOT PICO_BARE_METAL)
- pico_add_subdirectory(pico_bit_ops)
- pico_add_subdirectory(pico_binary_info)
- pico_add_subdirectory(pico_divider)
- pico_add_subdirectory(pico_sync)
- pico_add_subdirectory(pico_time)
- pico_add_subdirectory(pico_util)
- pico_add_subdirectory(pico_stdlib)
-endif()
-
-pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
-
-pico_promote_common_scope_vars()
\ No newline at end of file
diff --git a/src/common/boot_picobin_headers/BUILD.bazel b/src/common/boot_picobin_headers/BUILD.bazel
new file mode 100644
index 0000000..2adc556
--- /dev/null
+++ b/src/common/boot_picobin_headers/BUILD.bazel
@@ -0,0 +1,10 @@
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "boot_picobin_headers",
+ hdrs = ["include/boot/picobin.h"],
+ includes = ["include"],
+ deps = [
+ "//src:pico_platform_internal",
+ ],
+)
diff --git a/src/common/boot_picobin_headers/CMakeLists.txt b/src/common/boot_picobin_headers/CMakeLists.txt
new file mode 100644
index 0000000..fb600b1
--- /dev/null
+++ b/src/common/boot_picobin_headers/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(boot_picobin_headers INTERFACE)
+target_include_directories(boot_picobin_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/src/common/boot_picobin_headers/include/boot/picobin.h b/src/common/boot_picobin_headers/include/boot/picobin.h
new file mode 100644
index 0000000..44ce990
--- /dev/null
+++ b/src/common/boot_picobin_headers/include/boot/picobin.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _BOOT_PICOBIN_H
+#define _BOOT_PICOBIN_H
+
+#ifndef NO_PICO_PLATFORM
+#include "pico/platform.h"
+#else
+#ifndef _u
+#define _u(x) x ## u
+#endif
+#endif
+
+/** \file picobin.h
+* \defgroup boot_picobin_headers boot_picobin_headers
+*
+* \brief Constants for PICOBIN format
+*/
+
+// these are designed to not look like (likely) 16/32-bit ARM or RISC-V instructions or look like valid pointers
+#define PICOBIN_BLOCK_MARKER_START _u(0xffffded3)
+#define PICOBIN_BLOCK_MARKER_END _u(0xab123579)
+
+#define PICOBIN_MAX_BLOCK_SIZE _u(0x280)
+#define PICOBIN_MAX_IMAGE_DEF_BLOCK_SIZE _u(0x180)
+#define PICOBIN_MAX_PARTITION_TABLE_BLOCK_SIZE _u(0x280)
+
+// note bit 6 is used to make parity even
+#define PICOBIN_BLOCK_ITEM_1BS_NEXT_BLOCK_OFFSET _u(0x41)
+#define PICOBIN_BLOCK_ITEM_1BS_IMAGE_TYPE _u(0x42)
+#define PICOBIN_BLOCK_ITEM_1BS_VECTOR_TABLE _u(0x03)
+#define PICOBIN_BLOCK_ITEM_1BS_ENTRY_POINT _u(0x44)
+#define PICOBIN_BLOCK_ITEM_1BS_ROLLING_WINDOW_DELTA _u(0x05)
+#define PICOBIN_BLOCK_ITEM_LOAD_MAP _u(0x06)
+#define PICOBIN_BLOCK_ITEM_1BS_HASH_DEF _u(0x47)
+#define PICOBIN_BLOCK_ITEM_1BS_VERSION _u(0x48)
+#define PICOBIN_BLOCK_ITEM_SIGNATURE _u(0x09)
+#define PICOBIN_BLOCK_ITEM_PARTITION_TABLE _u(0x0a)
+#define PICOBIN_BLOCK_ITEM_HASH_VALUE _u(0x4b)
+#define PICOBIN_BLOCK_ITEM_SALT _u(0x0c)
+
+#define PICOBIN_BLOCK_ITEM_2BS_IGNORED (_u(0x80) | _u(0x7e))
+#define PICOBIN_BLOCK_ITEM_2BS_LAST (_u(0x80) | _u(0x7f))
+
+// ----
+
+#define PICOBIN_INDEX_TO_BITS(y, x) (y ## _ ## x << y ## _LSB)
+
+#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_LSB _u(0)
+#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_BITS _u(0x000f)
+#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_INVALID _u(0x0)
+#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_EXE _u(0x1)
+#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_DATA _u(0x2)
+#define PICOBIN_IMAGE_TYPE_IMAGE_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_IMAGE_TYPE, x)
+
+#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_LSB _u(4)
+#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_BITS _u(0x0030)
+#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_UNSPECIFIED _u(0x0)
+#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_NS _u(0x1)
+#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_S _u(0x2)
+#define PICOBIN_IMAGE_TYPE_EXE_SECURITY_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_SECURITY, x)
+
+#define PICOBIN_IMAGE_TYPE_EXE_CPU_LSB _u(8)
+#define PICOBIN_IMAGE_TYPE_EXE_CPU_BITS _u(0x0700)
+#define PICOBIN_IMAGE_TYPE_EXE_CPU_ARM _u(0)
+#define PICOBIN_IMAGE_TYPE_EXE_CPU_RISCV _u(1)
+#define PICOBIN_IMAGE_TYPE_EXE_CPU_VARMULET _u(2)
+#define PICOBIN_IMAGE_TYPE_EXE_CPU_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CPU, x)
+
+#define PICOBIN_IMAGE_TYPE_EXE_CHIP_LSB _u(12)
+#define PICOBIN_IMAGE_TYPE_EXE_CHIP_BITS _u(0x7000)
+#define PICOBIN_IMAGE_TYPE_EXE_CHIP_RP2040 _u(0)
+#define PICOBIN_IMAGE_TYPE_EXE_CHIP_RP2350 _u(1)
+#define PICOBIN_IMAGE_TYPE_EXE_CHIP_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_IMAGE_TYPE_EXE_CHIP, x)
+
+#define PICOBIN_IMAGE_TYPE_EXE_TBYB_BITS _u(0x8000)
+
+// todo assert no overlap ^
+
+#define PICOBIN_PARTITION_PERMISSIONS_LSB _u(26)
+#define PICOBIN_PARTITION_PERMISSIONS_BITS _u(0xfc000000)
+
+#define PICOBIN_PARTITION_PERMISSION_S_R_BITS _u(0x04000000)
+#define PICOBIN_PARTITION_PERMISSION_S_W_BITS _u(0x08000000)
+#define PICOBIN_PARTITION_PERMISSION_NS_R_BITS _u(0x10000000)
+#define PICOBIN_PARTITION_PERMISSION_NS_W_BITS _u(0x20000000)
+#define PICOBIN_PARTITION_PERMISSION_NSBOOT_R_BITS _u(0x40000000)
+#define PICOBIN_PARTITION_PERMISSION_NSBOOT_W_BITS _u(0x80000000)
+
+#define PICOBIN_PARTITION_LOCATION_FIRST_SECTOR_LSB _u(0)
+#define PICOBIN_PARTITION_LOCATION_FIRST_SECTOR_BITS _u(0x00001fff)
+#define PICOBIN_PARTITION_LOCATION_LAST_SECTOR_LSB _u(13)
+#define PICOBIN_PARTITION_LOCATION_LAST_SECTOR_BITS _u(0x03ffe000)
+
+#define PICOBIN_PARTITION_FLAGS_HAS_ID_BITS _u(0x00000001)
+#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_LSB _u(1)
+#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_BITS _u(0x00000006)
+#define PICOBIN_PARTITION_FLAGS_LINK_VALUE_LSB _u(3)
+#define PICOBIN_PARTITION_FLAGS_LINK_VALUE_BITS _u(0x00000078)
+
+#define PICOBIN_PARTITION_MAX_EXTRA_FAMILIES _u(3)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_NUM_EXTRA_FAMILIES_LSB _u(7)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_NUM_EXTRA_FAMILIES_BITS _u(0x00000180)
+// these are an optimization when booting in either ARM or RISC-V, to avoid looking at partitions
+// which are known not to contain the right sort of binary, OR as a way to prevent
+// auto-architecture-switch. NOTE: the first partition that can be booted, will be,
+// so if you have a RISC-V binary in the first partition, and auto-arhcitecture-switch enabled, then
+// even if booting under ARM, with an ARM binary in a later partition, the RISC-V binary
+// will be booted by default; setting PICOBIN_PARTITION_FLAGS_IGNORED_DURING_ARM_BOOT_BITS
+// on the partition, will have the RISC-V binary containing partition ignored under ARM
+// boot
+#define PICOBIN_PARTITION_FLAGS_IGNORED_DURING_ARM_BOOT_BITS _u(0x00000200)
+#define PICOBIN_PARTITION_FLAGS_IGNORED_DURING_RISCV_BOOT_BITS _u(0x00000400)
+#define PICOBIN_PARTITION_FLAGS_UF2_DOWNLOAD_AB_NON_BOOTABLE_OWNER_AFFINITY _u(0x00000800)
+#define PICOBIN_PARTITION_FLAGS_HAS_NAME_BITS _u(0x00001000)
+#define PICOBIN_PARTITION_FLAGS_UF2_DOWNLOAD_NO_REBOOT_BITS _u(0x00002000)
+// we have a bit for each well known family-id .. note we expect there to be more in the future with new chips,
+// but we have plenty of space for now.
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_DEFAULT_FAMILIES_LSB _u(14)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_DEFAULT_FAMILY_RP2040_BITS _u(0x00004000)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_DEFAULT_FAMILY_ABSOLUTE_BITS _u(0x00008000)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_DEFAULT_FAMILY_DATA_BITS _u(0x00010000)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_DEFAULT_FAMILY_RP2350_ARM_S_BITS _u(0x00020000)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_DEFAULT_FAMILY_RP2350_RISCV_BITS _u(0x00040000)
+#define PICOBIN_PARTITION_FLAGS_ACCEPTS_DEFAULT_FAMILY_RP2350_ARM_NS_BITS _u(0x00080000)
+
+#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_NONE _u(0)
+#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_A_PARTITION _u(1)
+#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_OWNER_PARTITION _u(2)
+#define PICOBIN_PARTITION_FLAGS_LINK_TYPE_AS_BITS(x) PICOBIN_INDEX_TO_BITS(PICOBIN_PARTITION_FLAGS_LINK_TYPE, x)
+
+
+#define PICOBIN_HASH_SHA256 _u(0x01)
+
+#define PICOBIN_SIGNATURE_SECP256K1 _u(0x01)
+
+#ifndef __ASSEMBLER__
+
+#include <stdbool.h>
+
+typedef struct {
+ // these must all be word aligned
+ uint32_t storage_address_rel;
+ uint32_t runtime_address;
+ uint32_t size;
+} picobin_load_map_entry;
+
+typedef struct {
+ uint32_t header;
+ picobin_load_map_entry entries[];
+} picobin_load_map;
+
+static inline unsigned int picobin_load_map_entry_count(const picobin_load_map *lm) {
+ return (lm->header << 1) >> 25;
+}
+
+static inline bool picobin_load_map_is_relative(const picobin_load_map *lm) {
+ return (int32_t)lm->header >= 0;
+}
+
+#endif
+
+#endif
diff --git a/src/common/boot_picoboot/BUILD.bazel b/src/common/boot_picoboot/BUILD.bazel
deleted file mode 100644
index 5007a23..0000000
--- a/src/common/boot_picoboot/BUILD.bazel
+++ /dev/null
@@ -1,8 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-cc_library(
- name = "boot_picoboot",
- hdrs = ["include/boot/picoboot.h"],
- includes = ["include"],
- deps = ["//src/common/pico_base:pico_platform"],
-)
diff --git a/src/common/boot_picoboot/CMakeLists.txt b/src/common/boot_picoboot/CMakeLists.txt
deleted file mode 100644
index 463fde4..0000000
--- a/src/common/boot_picoboot/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library(boot_picoboot_headers INTERFACE)
-target_include_directories(boot_picoboot_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/src/common/boot_picoboot/include/boot/picoboot.h b/src/common/boot_picoboot/include/boot/picoboot.h
deleted file mode 100644
index fa9d463..0000000
--- a/src/common/boot_picoboot/include/boot/picoboot.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _BOOT_PICOBOOT_H
-#define _BOOT_PICOBOOT_H
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <assert.h>
-
-#ifndef NO_PICO_PLATFORM
-#include "pico/platform.h"
-#endif
-
-/** \file picoboot.h
-* \defgroup boot_picoboot boot_picoboot
-*
-* \brief Header file for the PICOBOOT USB interface exposed by an RP2040 in BOOTSEL mode.
-*/
-
-#define PICOBOOT_MAGIC 0x431fd10bu
-
-// --------------------------------------------
-// CONTROL REQUESTS FOR THE PICOBOOT INTERFACE
-// --------------------------------------------
-
-// size 0 OUT - unstall EPs and reset
-#define PICOBOOT_IF_RESET 0x41
-
-// size 16 IN - return the status of the last command
-#define PICOBOOT_IF_CMD_STATUS 0x42
-
-// --------------------------------------------------
-// COMMAND REQUESTS SENT TO THE PICOBOOT OUT ENDPOINT
-// --------------------------------------------------
-//
-// picoboot_cmd structure of size 32 is sent to OUT endpoint
-// transfer_length bytes are transferred via IN/OUT
-// device responds on success with 0 length ACK packet set via OUT/IN
-// device may stall the transferring endpoint in case of error
-
-enum picoboot_cmd_id {
- PC_EXCLUSIVE_ACCESS = 0x1,
- PC_REBOOT = 0x2,
- PC_FLASH_ERASE = 0x3,
- PC_READ = 0x84, // either RAM or FLASH
- PC_WRITE = 5, // either RAM or FLASH (does no erase)
- PC_EXIT_XIP = 0x6,
- PC_ENTER_CMD_XIP = 0x7,
- PC_EXEC = 0x8,
- PC_VECTORIZE_FLASH = 0x9
-};
-
-enum picoboot_status {
- PICOBOOT_OK = 0,
- PICOBOOT_UNKNOWN_CMD = 1,
- PICOBOOT_INVALID_CMD_LENGTH = 2,
- PICOBOOT_INVALID_TRANSFER_LENGTH = 3,
- PICOBOOT_INVALID_ADDRESS = 4,
- PICOBOOT_BAD_ALIGNMENT = 5,
- PICOBOOT_INTERLEAVED_WRITE = 6,
- PICOBOOT_REBOOTING = 7,
- PICOBOOT_UNKNOWN_ERROR = 8,
-};
-
-struct __packed picoboot_reboot_cmd {
- uint32_t dPC; // 0 means reset into bootrom
- uint32_t dSP;
- uint32_t dDelayMS;
-};
-
-// used for EXEC, VECTORIZE_FLASH
-struct __packed picoboot_address_only_cmd {
- uint32_t dAddr;
-};
-
-// used for READ, WRITE, FLASH_ERASE
-struct __packed picoboot_range_cmd {
- uint32_t dAddr;
- uint32_t dSize;
-};
-
-enum picoboot_exclusive_type {
- NOT_EXCLUSIVE = 0,
- EXCLUSIVE,
- EXCLUSIVE_AND_EJECT
-};
-
-struct __packed picoboot_exclusive_cmd {
- uint8_t bExclusive;
-};
-
-// little endian
-struct __packed __aligned(4) picoboot_cmd {
- uint32_t dMagic;
- uint32_t dToken; // an identifier for this token to correlate with a status response
- uint8_t bCmdId; // top bit set for IN
- uint8_t bCmdSize; // bytes of actual data in the arg part of this structure
- uint16_t _unused;
- uint32_t dTransferLength; // length of IN/OUT transfer (or 0) if none
- union {
- uint8_t args[16];
- struct picoboot_reboot_cmd reboot_cmd;
- struct picoboot_range_cmd range_cmd;
- struct picoboot_address_only_cmd address_only_cmd;
- struct picoboot_exclusive_cmd exclusive_cmd;
- };
-};
-
-static_assert(32 == sizeof(struct picoboot_cmd), "picoboot_cmd must be 32 bytes big");
-
-struct __packed __aligned(4) picoboot_cmd_status {
- uint32_t dToken;
- uint32_t dStatusCode;
- uint8_t bCmdId;
- uint8_t bInProgress;
- uint8_t _pad[6];
-};
-
-static_assert(16 == sizeof(struct picoboot_cmd_status), "picoboot_cmd_status must be 16 bytes big");
-#endif
diff --git a/src/common/boot_picoboot_headers/BUILD.bazel b/src/common/boot_picoboot_headers/BUILD.bazel
new file mode 100644
index 0000000..ec09b7d
--- /dev/null
+++ b/src/common/boot_picoboot_headers/BUILD.bazel
@@ -0,0 +1,11 @@
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "boot_picoboot_headers",
+ hdrs = [
+ "include/boot/picoboot.h",
+ "include/boot/picoboot_constants.h",
+ ],
+ includes = ["include"],
+ deps = ["//src:pico_platform_internal"],
+)
diff --git a/src/common/boot_picoboot_headers/CMakeLists.txt b/src/common/boot_picoboot_headers/CMakeLists.txt
new file mode 100644
index 0000000..ad32efd
--- /dev/null
+++ b/src/common/boot_picoboot_headers/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(boot_picoboot_headers INTERFACE)
+target_include_directories(boot_picoboot_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/src/common/boot_picoboot_headers/include/boot/picoboot.h b/src/common/boot_picoboot_headers/include/boot/picoboot.h
new file mode 100644
index 0000000..8645d52
--- /dev/null
+++ b/src/common/boot_picoboot_headers/include/boot/picoboot.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _BOOT_PICOBOOT_H
+#define _BOOT_PICOBOOT_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <assert.h>
+
+#ifndef NO_PICO_PLATFORM
+#include "pico/platform.h"
+#endif
+
+/** \file picoboot.h
+* \defgroup boot_picoboot_headers boot_picoboot_headers
+*
+* \brief Header file for the PICOBOOT USB interface exposed by an RP2xxx chip in BOOTSEL mode
+*/
+
+#include "picoboot_constants.h"
+
+#define PICOBOOT_MAGIC 0x431fd10bu
+
+// --------------------------------------------
+// CONTROL REQUESTS FOR THE PICOBOOT INTERFACE
+// --------------------------------------------
+
+// size 0 OUT - un-stall EPs and reset
+#define PICOBOOT_IF_RESET 0x41
+
+// size 16 IN - return the status of the last command
+#define PICOBOOT_IF_CMD_STATUS 0x42
+
+// --------------------------------------------------
+// COMMAND REQUESTS SENT TO THE PICOBOOT OUT ENDPOINT
+// --------------------------------------------------
+//
+// picoboot_cmd structure of size 32 is sent to OUT endpoint
+// transfer_length bytes are transferred via IN/OUT
+// device responds on success with 0 length ACK packet set via OUT/IN
+// device may stall the transferring endpoint in case of error
+
+enum picoboot_cmd_id {
+ PC_EXCLUSIVE_ACCESS = 0x1,
+ PC_REBOOT = 0x2,
+ PC_FLASH_ERASE = 0x3,
+ PC_READ = 0x84, // either RAM or FLASH
+ PC_WRITE = 0x5, // either RAM or FLASH (does no erase)
+ PC_EXIT_XIP = 0x6,
+ PC_ENTER_CMD_XIP = 0x7,
+ PC_EXEC = 0x8,
+ PC_VECTORIZE_FLASH = 0x9,
+ // RP2350 only below here
+ PC_REBOOT2 = 0xa,
+ PC_GET_INFO = 0x8b,
+ PC_OTP_READ = 0x8c,
+ PC_OTP_WRITE = 0xd,
+ //PC_EXEC2 = 0xe, // currently unused
+};
+
+enum picoboot_status {
+ PICOBOOT_OK = 0,
+ PICOBOOT_UNKNOWN_CMD = 1,
+ PICOBOOT_INVALID_CMD_LENGTH = 2,
+ PICOBOOT_INVALID_TRANSFER_LENGTH = 3,
+ PICOBOOT_INVALID_ADDRESS = 4,
+ PICOBOOT_BAD_ALIGNMENT = 5,
+ PICOBOOT_INTERLEAVED_WRITE = 6,
+ PICOBOOT_REBOOTING = 7,
+ PICOBOOT_UNKNOWN_ERROR = 8,
+ PICOBOOT_INVALID_STATE = 9,
+ PICOBOOT_NOT_PERMITTED = 10,
+ PICOBOOT_INVALID_ARG = 11,
+ PICOBOOT_BUFFER_TOO_SMALL = 12,
+ PICOBOOT_PRECONDITION_NOT_MET = 13,
+ PICOBOOT_MODIFIED_DATA = 14,
+ PICOBOOT_INVALID_DATA = 15,
+ PICOBOOT_NOT_FOUND = 16,
+ PICOBOOT_UNSUPPORTED_MODIFICATION = 17,
+};
+
+struct __packed picoboot_reboot_cmd {
+ uint32_t dPC; // 0 means reset into regular boot path
+ uint32_t dSP;
+ uint32_t dDelayMS;
+};
+
+
+// note this (with pc_sp) union member has the same layout as picoboot_reboot_cmd except with extra dFlags
+struct __packed picoboot_reboot2_cmd {
+ uint32_t dFlags;
+ uint32_t dDelayMS;
+ uint32_t dParam0;
+ uint32_t dParam1;
+};
+
+// used for EXEC, VECTORIZE_FLASH
+struct __packed picoboot_address_only_cmd {
+ uint32_t dAddr;
+};
+
+// used for READ, WRITE, FLASH_ERASE
+struct __packed picoboot_range_cmd {
+ uint32_t dAddr;
+ uint32_t dSize;
+};
+
+struct __packed picoboot_exec2_cmd {
+ uint32_t image_base;
+ uint32_t image_size;
+ uint32_t workarea_base;
+ uint32_t workarea_size;
+};
+
+enum picoboot_exclusive_type {
+ NOT_EXCLUSIVE = 0,
+ EXCLUSIVE,
+ EXCLUSIVE_AND_EJECT
+};
+
+struct __packed picoboot_exclusive_cmd {
+ uint8_t bExclusive;
+};
+
+struct __packed picoboot_otp_cmd {
+ uint16_t wRow; // OTP row
+ uint16_t wRowCount; // number of rows to transfer
+ uint8_t bEcc; // use error correction (16 bit per register vs 24 (stored as 32) bit raw)
+};
+
+
+struct __packed picoboot_get_info_cmd {
+ uint8_t bType;
+ uint8_t bParam;
+ uint16_t wParam;
+ uint32_t dParams[3];
+};
+
+// little endian
+struct __packed __aligned(4) picoboot_cmd {
+ uint32_t dMagic;
+ uint32_t dToken; // an identifier for this token to correlate with a status response
+ uint8_t bCmdId; // top bit set for IN
+ uint8_t bCmdSize; // bytes of actual data in the arg part of this structure
+ uint16_t _unused;
+ uint32_t dTransferLength; // length of IN/OUT transfer (or 0) if none
+ union {
+ uint8_t args[16];
+ struct picoboot_reboot_cmd reboot_cmd;
+ struct picoboot_range_cmd range_cmd;
+ struct picoboot_address_only_cmd address_only_cmd;
+ struct picoboot_exclusive_cmd exclusive_cmd;
+ struct picoboot_reboot2_cmd reboot2_cmd;
+ struct picoboot_otp_cmd otp_cmd;
+ struct picoboot_get_info_cmd get_info_cmd;
+ struct picoboot_exec2_cmd exec2_cmd;
+ };
+};
+static_assert(32 == sizeof(struct picoboot_cmd), "picoboot_cmd must be 32 bytes big");
+
+struct __packed __aligned(4) picoboot_cmd_status {
+ uint32_t dToken;
+ uint32_t dStatusCode;
+ uint8_t bCmdId;
+ uint8_t bInProgress;
+ uint8_t _pad[6];
+};
+
+static_assert(16 == sizeof(struct picoboot_cmd_status), "picoboot_cmd_status must be 16 bytes big");
+
+#endif
diff --git a/src/common/boot_picoboot_headers/include/boot/picoboot_constants.h b/src/common/boot_picoboot_headers/include/boot/picoboot_constants.h
new file mode 100644
index 0000000..ac78ea2
--- /dev/null
+++ b/src/common/boot_picoboot_headers/include/boot/picoboot_constants.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _BOOT_PICOBOOT_CONSTANTS_H
+#define _BOOT_PICOBOOT_CONSTANTS_H
+
+#define REBOOT2_TYPE_MASK 0x0f
+
+// note these match REBOOT_TYPE in pico/bootrom_constants.h (also 0 is used for PC_SP for backwards compatibility with RP2040)
+// values 0-7 are secure/non-secure
+#define REBOOT2_FLAG_REBOOT_TYPE_NORMAL 0x0 // param0 = diagnostic partition
+#define REBOOT2_FLAG_REBOOT_TYPE_BOOTSEL 0x2 // param0 = bootsel_flags, param1 = gpio_config
+#define REBOOT2_FLAG_REBOOT_TYPE_RAM_IMAGE 0x3 // param0 = image_base, param1 = image_end
+#define REBOOT2_FLAG_REBOOT_TYPE_FLASH_UPDATE 0x4 // param0 = update_base
+
+// values 8-15 are secure only
+#define REBOOT2_FLAG_REBOOT_TYPE_PC_SP 0xd
+
+#define REBOOT2_FLAG_REBOOT_TO_ARM 0x10
+#define REBOOT2_FLAG_REBOOT_TO_RISCV 0x20
+
+#define REBOOT2_FLAG_NO_RETURN_ON_SUCCESS 0x100
+
+#define BOOTSEL_FLAG_DISABLE_MSD_INTERFACE 0x01
+#define BOOTSEL_FLAG_DISABLE_PICOBOOT_INTERFACE 0x02
+#define BOOTSEL_FLAG_GPIO_PIN_ACTIVE_LOW 0x10
+#define BOOTSEL_FLAG_GPIO_PIN_SPECIFIED 0x20
+
+#define PICOBOOT_GET_INFO_SYS 1
+#define PICOBOOT_GET_INFO_PARTTION_TABLE 2
+#define PICOBOOT_GET_INFO_UF2_TARGET_PARTITION 3
+#define PICOBOOT_GET_INFO_UF2_STATUS 4
+
+#define UF2_STATUS_IGNORED_FAMILY 0x01
+#define UF2_STATUS_ABORT_EXCLUSIVELY_LOCKED 0x10
+#define UF2_STATUS_ABORT_BAD_ADDRESS 0x20
+#define UF2_STATUS_ABORT_WRITE_ERROR 0x40
+#define UF2_STATUS_ABORT_REBOOT_FAILED 0x80
+#endif
\ No newline at end of file
diff --git a/src/common/boot_uf2/BUILD.bazel b/src/common/boot_uf2/BUILD.bazel
deleted file mode 100644
index a170f69..0000000
--- a/src/common/boot_uf2/BUILD.bazel
+++ /dev/null
@@ -1,7 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-cc_library(
- name = "boot_uf2",
- hdrs = ["include/boot/uf2.h"],
- includes = ["include"],
-)
diff --git a/src/common/boot_uf2/CMakeLists.txt b/src/common/boot_uf2/CMakeLists.txt
deleted file mode 100644
index 6ca5c20..0000000
--- a/src/common/boot_uf2/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_library(boot_uf2_headers INTERFACE)
-target_include_directories(boot_uf2_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/src/common/boot_uf2/include/boot/uf2.h b/src/common/boot_uf2/include/boot/uf2.h
deleted file mode 100644
index e360cf4..0000000
--- a/src/common/boot_uf2/include/boot/uf2.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _BOOT_UF2_H
-#define _BOOT_UF2_H
-
-#include <stdint.h>
-#include <assert.h>
-
-/** \file uf2.h
-* \defgroup boot_uf2 boot_uf2
-*
-* \brief Header file for the UF2 format supported by an RP2040 in BOOTSEL mode.
-*/
-
-#define UF2_MAGIC_START0 0x0A324655u
-#define UF2_MAGIC_START1 0x9E5D5157u
-#define UF2_MAGIC_END 0x0AB16F30u
-
-#define UF2_FLAG_NOT_MAIN_FLASH 0x00000001u
-#define UF2_FLAG_FILE_CONTAINER 0x00001000u
-#define UF2_FLAG_FAMILY_ID_PRESENT 0x00002000u
-#define UF2_FLAG_MD5_PRESENT 0x00004000u
-
-#define RP2040_FAMILY_ID 0xe48bff56
-
-struct uf2_block {
- // 32 byte header
- uint32_t magic_start0;
- uint32_t magic_start1;
- uint32_t flags;
- uint32_t target_addr;
- uint32_t payload_size;
- uint32_t block_no;
- uint32_t num_blocks;
- uint32_t file_size; // or familyID;
- uint8_t data[476];
- uint32_t magic_end;
-};
-
-static_assert(sizeof(struct uf2_block) == 512, "uf2_block not sector sized");
-
-#endif
diff --git a/src/common/boot_uf2_headers/BUILD.bazel b/src/common/boot_uf2_headers/BUILD.bazel
new file mode 100644
index 0000000..e0df04f
--- /dev/null
+++ b/src/common/boot_uf2_headers/BUILD.bazel
@@ -0,0 +1,7 @@
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "boot_uf2_headers",
+ hdrs = ["include/boot/uf2.h"],
+ includes = ["include"],
+)
diff --git a/src/common/boot_uf2_headers/CMakeLists.txt b/src/common/boot_uf2_headers/CMakeLists.txt
new file mode 100644
index 0000000..a314c6f
--- /dev/null
+++ b/src/common/boot_uf2_headers/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_library(boot_uf2_headers INTERFACE)
+target_include_directories(boot_uf2_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/src/common/boot_uf2_headers/include/boot/uf2.h b/src/common/boot_uf2_headers/include/boot/uf2.h
new file mode 100644
index 0000000..271540a
--- /dev/null
+++ b/src/common/boot_uf2_headers/include/boot/uf2.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _BOOT_UF2_H
+#define _BOOT_UF2_H
+
+#include <stdint.h>
+#include <assert.h>
+
+/** \file uf2.h
+* \defgroup boot_uf2_headers boot_uf2_headers
+*
+* \brief Header file for the UF2 format supported by a RP2xxx chip in BOOTSEL mode
+*/
+
+#define UF2_MAGIC_START0 0x0A324655u
+#define UF2_MAGIC_START1 0x9E5D5157u
+#define UF2_MAGIC_END 0x0AB16F30u
+
+#define UF2_FLAG_NOT_MAIN_FLASH 0x00000001u
+#define UF2_FLAG_FILE_CONTAINER 0x00001000u
+#define UF2_FLAG_FAMILY_ID_PRESENT 0x00002000u
+#define UF2_FLAG_MD5_PRESENT 0x00004000u
+
+#define RP2040_FAMILY_ID 0xe48bff56u
+#define ABSOLUTE_FAMILY_ID 0xe48bff57u
+#define DATA_FAMILY_ID 0xe48bff58u
+#define RP2350_ARM_S_FAMILY_ID 0xe48bff59u
+#define RP2350_RISCV_FAMILY_ID 0xe48bff5au
+#define RP2350_ARM_NS_FAMILY_ID 0xe48bff5bu
+#define FAMILY_ID_MAX 0xe48bff5bu
+
+
+struct uf2_block {
+ // 32 byte header
+ uint32_t magic_start0;
+ uint32_t magic_start1;
+ uint32_t flags;
+ uint32_t target_addr;
+ uint32_t payload_size;
+ uint32_t block_no;
+ uint32_t num_blocks;
+ uint32_t file_size; // or familyID;
+ uint8_t data[476];
+ uint32_t magic_end;
+};
+
+static_assert(sizeof(struct uf2_block) == 512, "uf2_block not sector sized");
+
+#endif
diff --git a/src/common/hardware_claim/BUILD.bazel b/src/common/hardware_claim/BUILD.bazel
new file mode 100644
index 0000000..e8ca0f3
--- /dev/null
+++ b/src/common/hardware_claim/BUILD.bazel
@@ -0,0 +1,19 @@
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "hardware_claim",
+ srcs = ["claim.c"],
+ hdrs = ["include/hardware/claim.h"],
+ includes = ["include"],
+ deps = [
+ ] + select({
+ "//bazel/constraint:host": [
+ "//src/host/hardware_sync",
+ ],
+ "//conditions:default": [
+ "//src:pico_platform_internal",
+ "//src/rp2_common/hardware_sync:hardware_sync_headers",
+ "//src/rp2_common/hardware_sync_spin_lock",
+ ],
+ }),
+)
diff --git a/src/rp2_common/hardware_claim/CMakeLists.txt b/src/common/hardware_claim/CMakeLists.txt
similarity index 100%
rename from src/rp2_common/hardware_claim/CMakeLists.txt
rename to src/common/hardware_claim/CMakeLists.txt
diff --git a/src/rp2_common/hardware_claim/claim.c b/src/common/hardware_claim/claim.c
similarity index 100%
rename from src/rp2_common/hardware_claim/claim.c
rename to src/common/hardware_claim/claim.c
diff --git a/src/common/hardware_claim/include/hardware/claim.h b/src/common/hardware_claim/include/hardware/claim.h
new file mode 100644
index 0000000..f950144
--- /dev/null
+++ b/src/common/hardware_claim/include/hardware/claim.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _HARDWARE_CLAIM_H
+#define _HARDWARE_CLAIM_H
+
+#include "pico.h"
+#include "hardware/sync.h"
+
+/** \file claim.h
+ * \defgroup hardware_claim hardware_claim
+ * \brief Lightweight hardware resource management API
+ *
+ * `hardware_claim` provides a simple API for management of hardware resources at runtime.
+ *
+ * This API is usually called by other hardware specific _claiming_ APIs and provides simple
+ * multi-core safe methods to manipulate compact bit-sets representing hardware resources.
+ *
+ * This API allows any other library to cooperatively participate in a scheme by which
+ * both compile time and runtime allocation of resources can co-exist, and conflicts
+ * can be avoided or detected (depending on the use case) without the libraries having
+ * any other knowledge of each other.
+ *
+ * Facilities are providing for:
+ *
+ * 1. Claiming resources (and asserting if they are already claimed)
+ * 2. Freeing (unclaiming) resources
+ * 3. Finding unused resources
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief Atomically claim a resource, panicking if it is already in use
+ * \ingroup hardware_claim
+ *
+ * The resource ownership is indicated by the bit_index bit in an array of bits.
+ *
+ * \param bits pointer to an array of bits (8 bits per byte)
+ * \param bit_index resource to claim (bit index into array of bits)
+ * \param message string to display if the bit cannot be claimed; note this may have a single printf format "%d" for the bit
+ */
+void hw_claim_or_assert(uint8_t *bits, uint bit_index, const char *message);
+
+/*! \brief Atomically claim one resource out of a range of resources, optionally asserting if none are free
+ * \ingroup hardware_claim
+ *
+ * \param bits pointer to an array of bits (8 bits per byte)
+ * \param required true if this method should panic if the resource is not free
+ * \param bit_lsb the lower bound (inclusive) of the resource range to claim from
+ * \param bit_msb the upper bound (inclusive) of the resource range to claim from
+ * \param message string to display if the bit cannot be claimed
+ * \return the bit index representing the claimed or -1 if none are available in the range, and required = false
+ */
+int hw_claim_unused_from_range(uint8_t *bits, bool required, uint bit_lsb, uint bit_msb, const char *message);
+
+/*! \brief Determine if a resource is claimed at the time of the call
+ * \ingroup hardware_claim
+ *
+ * The resource ownership is indicated by the bit_index bit in an array of bits.
+ *
+ * \param bits pointer to an array of bits (8 bits per byte)
+ * \param bit_index resource to check (bit index into array of bits)
+ * \return true if the resource is claimed
+ */
+bool hw_is_claimed(const uint8_t *bits, uint bit_index);
+
+/*! \brief Atomically unclaim a resource
+ * \ingroup hardware_claim
+ *
+ * The resource ownership is indicated by the bit_index bit in an array of bits.
+ *
+ * \param bits pointer to an array of bits (8 bits per byte)
+ * \param bit_index resource to unclaim (bit index into array of bits)
+ */
+void hw_claim_clear(uint8_t *bits, uint bit_index);
+
+/*! \brief Acquire the runtime mutual exclusion lock provided by the `hardware_claim` library
+ * \ingroup hardware_claim
+ *
+ * This method is called automatically by the other `hw_claim_` methods, however it is provided as a convenience
+ * to code that might want to protect other hardware initialization code from concurrent use.
+ *
+ * \note hw_claim_lock() uses a spin lock internally, so disables interrupts on the calling core, and will deadlock
+ * if the calling core already owns the lock.
+ *
+ * \return a token to pass to hw_claim_unlock()
+ */
+uint32_t hw_claim_lock(void);
+
+/*! \brief Release the runtime mutual exclusion lock provided by the `hardware_claim` library
+ * \ingroup hardware_claim
+ *
+ * \note This method MUST be called from the same core that call hw_claim_lock()
+ *
+ * \param token the token returned by the corresponding call to hw_claim_lock()
+ */
+void hw_claim_unlock(uint32_t token);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/common/pico_base/BUILD.bazel b/src/common/pico_base/BUILD.bazel
deleted file mode 100644
index 4204efd..0000000
--- a/src/common/pico_base/BUILD.bazel
+++ /dev/null
@@ -1,154 +0,0 @@
-load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
-
-package(default_visibility = ["//visibility:public"])
-
-# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
-PICO_SDK_VERSION_STRING = module_version() if module_version() != None else "0.0.1-WORKSPACE"
-
-_version_parts = PICO_SDK_VERSION_STRING.split(".")
-
-# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
-PICO_SDK_VERSION_MAJOR = int(_version_parts[0])
-
-# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
-PICO_SDK_VERSION_MINOR = int(_version_parts[1])
-
-_revision_parts = _version_parts[2].split("-")
-
-# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
-PICO_SDK_VERSION_REVISION = int(_revision_parts[0])
-
-# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
-PICO_SDK_VERSION_PRE_RELEASE_ID = _revision_parts[1] if len(_revision_parts) > 1 else None
-
-run_binary(
- name = "version_header",
- srcs = ["include/pico/version.h.in"],
- outs = ["generated_include/pico/version.h"],
- args = [
- "--version-string={}".format(PICO_SDK_VERSION_STRING),
- "--template=$(location include/pico/version.h.in)",
- "--output=$(location generated_include/pico/version.h)",
- ],
- tool = "//bazel:generate_version_header",
- visibility = ["//visibility:private"],
-)
-
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, group=pico_base
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, group=pico_base
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, group=pico_base
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, optional SDK pre-release version identifier, type=string, group=pico_base
-# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version, type=string, group=pico_base
-cc_library(
- name = "version",
- hdrs = ["generated_include/pico/version.h"],
- defines = [
- 'PICO_SDK_VERSION_STRING=\\"{}\\"'.format(PICO_SDK_VERSION_STRING),
- "PICO_SDK_VERSION_MAJOR={}".format(PICO_SDK_VERSION_MAJOR),
- 'PICO_SDK_VERSION_MINOR={}"'.format(PICO_SDK_VERSION_MINOR),
- 'PICO_SDK_VERSION_REVISION={}"'.format(PICO_SDK_VERSION_REVISION),
- ] + [] if PICO_SDK_VERSION_PRE_RELEASE_ID == None else ['PICO_SDK_VERSION_PRE_RELEASE_ID=\\"{}\\"'.format(PICO_SDK_VERSION_PRE_RELEASE_ID)],
- includes = ["generated_include"],
-)
-
-alias(
- name = "platform_defs",
- actual = select({
- "//bazel/constraint:host": "//src/host/pico_platform:platform_defs",
- "//conditions:default": "//src/rp2_common/pico_platform:platform_defs",
- }),
-)
-
-alias(
- name = "pico_platform",
- actual = select({
- "//bazel/constraint:host": "//src/host/pico_platform:pico_platform",
- "//conditions:default": "//src/rp2_common/pico_platform:pico_platform",
- }),
-)
-
-# PICO_BAZEL_CONFIG: PICO_NO_HARDWARE, OPTION: Whether the build is not targeting an RP2040 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build
-# PICO_BUILD_DEFINE: PICO_NO_HARDWARE, Whether the build is not targeting an RP2040 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build
-# PICO_BAZEL_CONFIG: PICO_ON_DEVICE, OPTION: Whether the build is targeting an RP2040 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build
-# PICO_BUILD_DEFINE: PICO_ON_DEVICE, Whether the build is targeting an RP2040 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build
-# PICO_BUILD is undocumented in CMake.
-cc_library(
- name = "common_sdk_defines",
- defines = select({
- "//bazel/constraint:host": [
- "PICO_ON_DEVICE=0",
- "PICO_NO_HARDWARE=1",
- "PICO_BUILD=1",
- ],
- "//conditions:default": [
- "PICO_ON_DEVICE=1",
- "PICO_NO_HARDWARE=0",
- "PICO_BUILD=1",
- ],
- }),
-)
-
-cc_library(
- name = "pico_base_interface",
- hdrs = [
- "include/pico.h",
- "include/pico/assert.h",
- "include/pico/config.h",
- "include/pico/error.h",
- "include/pico/types.h",
- ],
- includes = ["include"],
-
- # Be extra careful about who references this for now; if users depend on
- # this but not `pico_base` they'll end up with undefined symbols.
- # It's generally safe for anything that circularly depends on
- # //src/common/pico_base:pico_base to be added to this allowlist because
- # that implicitly means the transitive dependencies of pico_base will get
- # linked in.
- visibility = [
- "//src/common/pico_binary_info:__pkg__",
- "//src/common/pico_sync:__pkg__",
- "//src/common/pico_time:__pkg__",
- "//src/common/pico_util:__pkg__",
- "//src/host/hardware_timer:__pkg__",
- "//src/host/pico_platform:__pkg__",
- "//src/rp2_common/boot_stage2:__pkg__",
- "//src/rp2_common/hardware_claim:__pkg__",
- "//src/rp2_common/hardware_clocks:__pkg__",
- "//src/rp2_common/hardware_gpio:__pkg__",
- "//src/rp2_common/hardware_irq:__pkg__",
- "//src/rp2_common/hardware_pll:__pkg__",
- "//src/rp2_common/hardware_resets:__pkg__",
- "//src/rp2_common/hardware_sync:__pkg__",
- "//src/rp2_common/hardware_timer:__pkg__",
- "//src/rp2_common/hardware_watchdog:__pkg__",
- "//src/rp2_common/hardware_xosc:__pkg__",
- "//src/rp2_common/pico_bootrom:__pkg__",
- "//src/rp2_common/pico_malloc:__pkg__",
- "//src/rp2_common/pico_platform:__pkg__",
- "//src/rp2_common/pico_printf:__pkg__",
- "//src/rp2_common/pico_runtime:__pkg__",
- "//src/rp2_common/pico_standard_link:__pkg__",
- ],
- deps = [
- ":common_sdk_defines",
- ":version",
- "//bazel/config:PICO_CONFIG_HEADER",
- ],
-)
-
-cc_library(
- name = "pico_base",
- implementation_deps = select({
- "//bazel/constraint:host": [],
- "//conditions:default": [
- "//src/rp2_common/pico_platform:platform_link_deps",
- ],
- }),
- deps = [
- # :pico_platform creates circular dependencies, so break them
- # via an intermediate.
- ":pico_platform",
- ":pico_base_interface",
- ],
-)
diff --git a/src/common/pico_base/CMakeLists.txt b/src/common/pico_base/CMakeLists.txt
deleted file mode 100644
index ef051bb..0000000
--- a/src/common/pico_base/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-if (NOT TARGET pico_base_headers)
- pico_add_library(pico_base NOFLAG)
- target_include_directories(pico_base_headers INTERFACE include ${CMAKE_BINARY_DIR}/generated/pico_base)
-
- # PICO_BUILD_DEFINE: PICO_BOARD, Name of board, type=string, default=CMake PICO_BOARD variable, group=pico_base
- target_compile_definitions(pico_base_headers INTERFACE
- PICO_BOARD="${PICO_BOARD}")
-
- target_link_libraries(pico_base_headers INTERFACE pico_platform_headers)
-
- list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/generate_config_header.cmake)
- pico_promote_common_scope_vars()
-endif()
\ No newline at end of file
diff --git a/src/common/pico_base/generate_config_header.cmake b/src/common/pico_base/generate_config_header.cmake
deleted file mode 100644
index 5cc6aff..0000000
--- a/src/common/pico_base/generate_config_header.cmake
+++ /dev/null
@@ -1,29 +0,0 @@
-# build the auto gen config headers
-
-set(header_content "// AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO_<PLATFORM>_CONFIG_HEADER_FILES\n// DO NOT EDIT!\n")
-string(TOUPPER ${PICO_PLATFORM} PICO_PLATFORM_UPPER)
-
-macro(add_header_content_from_var VAR)
- set(header_content "${header_content}\n\n// based on ${VAR}:\n")
- foreach(var IN LISTS ${VAR})
- set(header_content "${header_content}\n#include \"${var}\"")
- endforeach()
-endmacro()
-
-# PICO_CMAKE_CONFIG: PICO_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for all platforms, type=list, group=pico_base
-add_header_content_from_var(PICO_CONFIG_HEADER_FILES)
-
-# PICO_CMAKE_CONFIG: PICO_RP2040_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for rp2040 platform, type=list, group=pico_base
-# PICO_CMAKE_CONFIG: PICO_HOST_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for host platform, type=list, group=pico_base
-add_header_content_from_var(PICO_${PICO_PLATFORM_UPPER}_CONFIG_HEADER_FILES)
-
-file(GENERATE
- OUTPUT ${CMAKE_BINARY_DIR}/generated/pico_base/pico/config_autogen.h
- CONTENT "${header_content}"
- )
-
-configure_file( ${CMAKE_CURRENT_LIST_DIR}/include/pico/version.h.in ${CMAKE_BINARY_DIR}/generated/pico_base/pico/version.h)
-
-foreach(DIR IN LISTS PICO_INCLUDE_DIRS)
- target_include_directories(pico_base_headers INTERFACE ${DIR})
-endforeach()
diff --git a/src/common/pico_base/include/pico.h b/src/common/pico_base/include/pico.h
deleted file mode 100644
index 5b7dbe9..0000000
--- a/src/common/pico_base/include/pico.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_H
-#define _PICO_H
-
-/** \file pico.h
- * \defgroup pico_base pico_base
- *
- * \brief Core types and macros for the Raspberry Pi Pico SDK. This header is intended to be included by all source code
- * as it includes configuration headers and overrides in the correct order
- *
- * This header may be included by assembly code
-*/
-
-// We may be included by assembly which cant include <cdefs.h>
-#define __PICO_STRING(x) #x
-#define __PICO_XSTRING(x) __PICO_STRING(x)
-#define __PICO_CONCAT1(x, y) x ## y
-
-#include "pico/types.h"
-#include "pico/version.h"
-
-// PICO_CONFIG: PICO_CONFIG_HEADER, unquoted path to header include in place of the default pico/config.h which may be desirable for build systems which can't easily generate the config_autogen header, group=pico_base
-#ifdef PICO_CONFIG_HEADER
-#include __PICO_XSTRING(PICO_CONFIG_HEADER)
-#else
-#include "pico/config.h"
-#endif
-#include "pico/platform.h"
-#include "pico/error.h"
-
-#endif
diff --git a/src/common/pico_base/include/pico/assert.h b/src/common/pico_base/include/pico/assert.h
deleted file mode 100644
index 8910ebd..0000000
--- a/src/common/pico_base/include/pico/assert.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_ASSERT_H
-#define _PICO_ASSERT_H
-
-#include <stdbool.h>
-
-#ifdef __cplusplus
-
-#include <cassert>
-
-extern "C" {
-#else
-#include <assert.h>
-#endif
-
-// PICO_CONFIG: PARAM_ASSERTIONS_ENABLE_ALL, Global assert enable, type=bool, default=0, group=pico_base
-// PICO_CONFIG: PARAM_ASSERTIONS_DISABLE_ALL, Global assert disable, type=bool, default=0, group=pico_base
-
-#ifndef PARAM_ASSERTIONS_ENABLE_ALL
-#define PARAM_ASSERTIONS_ENABLE_ALL 0
-#endif
-
-#ifndef PARAM_ASSERTIONS_DISABLE_ALL
-#define PARAM_ASSERTIONS_DISABLE_ALL 0
-#endif
-
-#define PARAM_ASSERTIONS_ENABLED(x) ((PARAM_ASSERTIONS_ENABLED_ ## x || PARAM_ASSERTIONS_ENABLE_ALL) && !PARAM_ASSERTIONS_DISABLE_ALL)
-
-#define invalid_params_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) assert(!(test));})
-#define valid_params_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) assert(test);})
-#define hard_assert_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) hard_assert(!(test));})
-
-#ifdef NDEBUG
-extern void hard_assertion_failure(void);
-static inline void hard_assert(bool condition, ...) {
- if (!condition)
- hard_assertion_failure();
-}
-#else
-#define hard_assert assert
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/common/pico_base/include/pico/config.h b/src/common/pico_base/include/pico/config.h
deleted file mode 100644
index 6bd6a97..0000000
--- a/src/common/pico_base/include/pico/config.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_CONFIG_H
-#define _PICO_CONFIG_H
-
-// -----------------------------------------------------
-// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLY CODE SO
-// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
-// OR USE #ifndef __ASSEMBLER__ guards
-// -------------
-
-// PICO_CONFIG_HEADER_FILES and then PICO_SDK_<PLATFORM>_CONFIG_INCLUDE_FILES
-// entries are dumped in order at build time into this generated header
-
-#include "pico/config_autogen.h"
-
-// PICO_CONFIG: PICO_CONFIG_RTOS_ADAPTER_HEADER, unquoted path to header include in the default pico/config.h for RTOS integration defines that must be included in all sources, group=pico_base
-#ifdef PICO_CONFIG_RTOS_ADAPTER_HEADER
-#include __PICO_XSTRING(PICO_CONFIG_RTOS_ADAPTER_HEADER)
-#endif
-
-#endif
diff --git a/src/common/pico_base/include/pico/error.h b/src/common/pico_base/include/pico/error.h
deleted file mode 100644
index 7508f16..0000000
--- a/src/common/pico_base/include/pico/error.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_ERROR_H
-#define _PICO_ERROR_H
-
-#ifndef __ASSEMBLER__
-
-/*!
- * \brief Common return codes from pico_sdk methods that return a status
- * \ingroup pico_base
- */
-enum pico_error_codes {
- PICO_OK = 0,
- PICO_ERROR_NONE = 0,
- PICO_ERROR_TIMEOUT = -1,
- PICO_ERROR_GENERIC = -2,
- PICO_ERROR_NO_DATA = -3,
- PICO_ERROR_NOT_PERMITTED = -4,
- PICO_ERROR_INVALID_ARG = -5,
- PICO_ERROR_IO = -6,
- PICO_ERROR_BADAUTH = -7,
- PICO_ERROR_CONNECT_FAILED = -8,
- PICO_ERROR_INSUFFICIENT_RESOURCES = -9,
-};
-
-#endif // !__ASSEMBLER__
-
-#endif
\ No newline at end of file
diff --git a/src/common/pico_base/include/pico/types.h b/src/common/pico_base/include/pico/types.h
deleted file mode 100644
index 7dbb0b9..0000000
--- a/src/common/pico_base/include/pico/types.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_TYPES_H
-#define _PICO_TYPES_H
-
-#ifndef __ASSEMBLER__
-
-#include "pico/assert.h"
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <stddef.h>
-
-typedef unsigned int uint;
-
-/*! \typedef absolute_time_t
- \brief An opaque 64 bit timestamp in microseconds
-
- The type is used instead of a raw uint64_t to prevent accidentally passing relative times or times in the wrong
- time units where an absolute time is required. It is equivalent to uint64_t in release builds.
-
- \see to_us_since_boot()
- \see update_us_since_boot()
- \ingroup timestamp
-*/
-#ifdef NDEBUG
-typedef uint64_t absolute_time_t;
-#else
-typedef struct {
- uint64_t _private_us_since_boot;
-} absolute_time_t;
-#endif
-
-/*! fn to_us_since_boot
- * \brief convert an absolute_time_t into a number of microseconds since boot.
- * \param t the absolute time to convert
- * \return a number of microseconds since boot, equivalent to t
- * \ingroup timestamp
- */
-static inline uint64_t to_us_since_boot(absolute_time_t t) {
-#ifdef NDEBUG
- return t;
-#else
- return t._private_us_since_boot;
-#endif
-}
-
-/*! fn update_us_since_boot
- * \brief update an absolute_time_t value to represent a given number of microseconds since boot
- * \param t the absolute time value to update
- * \param us_since_boot the number of microseconds since boot to represent. Note this should be representable
- * as a signed 64 bit integer
- * \ingroup timestamp
- */
-static inline void update_us_since_boot(absolute_time_t *t, uint64_t us_since_boot) {
-#ifdef NDEBUG
- *t = us_since_boot;
-#else
- assert(us_since_boot <= INT64_MAX);
- t->_private_us_since_boot = us_since_boot;
-#endif
-}
-
-/*! fn from_us_since_boot
- * \brief convert a number of microseconds since boot to an absolute_time_t
- * \param us_since_boot number of microseconds since boot
- * \return an absolute time equivalent to us_since_boot
- * \ingroup timestamp
- */
-static inline absolute_time_t from_us_since_boot(uint64_t us_since_boot) {
- absolute_time_t t;
- update_us_since_boot(&t, us_since_boot);
- return t;
-}
-
-#ifdef NDEBUG
-#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = value
-#else
-#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = {value}
-#endif
-
-/** \struct datetime_t
- * \ingroup util_datetime
- * \brief Structure containing date and time information
- *
- * When setting an RTC alarm, set a field to -1 tells
- * the RTC to not match on this field
- */
-typedef struct {
- int16_t year; ///< 0..4095
- int8_t month; ///< 1..12, 1 is January
- int8_t day; ///< 1..28,29,30,31 depending on month
- int8_t dotw; ///< 0..6, 0 is Sunday
- int8_t hour; ///< 0..23
- int8_t min; ///< 0..59
- int8_t sec; ///< 0..59
-} datetime_t;
-
-#define bool_to_bit(x) ((uint)!!(x))
-
-#endif
-#endif
diff --git a/src/common/pico_base_headers/BUILD.bazel b/src/common/pico_base_headers/BUILD.bazel
new file mode 100644
index 0000000..5525c30
--- /dev/null
+++ b/src/common/pico_base_headers/BUILD.bazel
@@ -0,0 +1,127 @@
+load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
+
+package(default_visibility = ["//visibility:public"])
+
+# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
+PICO_SDK_VERSION_STRING = module_version() if module_version() != None else "0.0.1-WORKSPACE"
+
+_version_parts = PICO_SDK_VERSION_STRING.split(".")
+
+# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
+PICO_SDK_VERSION_MAJOR = int(_version_parts[0])
+
+# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
+PICO_SDK_VERSION_MINOR = int(_version_parts[1])
+
+_revision_parts = _version_parts[2].split("-")
+
+# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
+PICO_SDK_VERSION_REVISION = int(_revision_parts[0])
+
+# PICO_BAZEL_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base
+PICO_SDK_VERSION_PRE_RELEASE_ID = _revision_parts[1] if len(_revision_parts) > 1 else None
+
+run_binary(
+ name = "version_header",
+ srcs = ["include/pico/version.h.in"],
+ outs = ["generated_include/pico/version.h"],
+ args = [
+ "--version-string={}".format(PICO_SDK_VERSION_STRING),
+ "--template=$(location include/pico/version.h.in)",
+ "--output=$(location generated_include/pico/version.h)",
+ ],
+ tool = "//bazel:generate_version_header",
+ visibility = ["//visibility:private"],
+)
+
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base
+# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
+cc_library(
+ name = "version",
+ hdrs = ["generated_include/pico/version.h"],
+ defines = [
+ 'PICO_SDK_VERSION_STRING=\\"{}\\"'.format(PICO_SDK_VERSION_STRING),
+ "PICO_SDK_VERSION_MAJOR={}".format(PICO_SDK_VERSION_MAJOR),
+ "PICO_SDK_VERSION_MINOR={}".format(PICO_SDK_VERSION_MINOR),
+ "PICO_SDK_VERSION_REVISION={}".format(PICO_SDK_VERSION_REVISION),
+ ] + [] if PICO_SDK_VERSION_PRE_RELEASE_ID == None else ['PICO_SDK_VERSION_PRE_RELEASE_ID=\\"{}\\"'.format(PICO_SDK_VERSION_PRE_RELEASE_ID)],
+ includes = ["generated_include"],
+)
+
+# PICO_BAZEL_CONFIG: PICO_NO_HARDWARE, Option as to whether the build is not targeting an RP2040 or RP2350 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build
+# PICO_BUILD_DEFINE: PICO_NO_HARDWARE, Whether the build is not targeting an RP2040 or RP2350 device, type=bool, default=1 when PICO_PLATFORM is host, 0 otherwise, group=build
+# PICO_BAZEL_CONFIG: PICO_ON_DEVICE, Option as to whether the build is targeting an RP2040 or RP2350 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build
+# PICO_BUILD_DEFINE: PICO_ON_DEVICE, Whether the build is targeting an RP2040 or RP2350 device, type=bool, default=0 when PICO_PLATFORM is host, 1 otherwise, group=build
+# PICO_BUILD is undocumented in CMake.
+cc_library(
+ name = "common_sdk_defines",
+ defines = select({
+ "//bazel/constraint:host": [
+ "PICO_ON_DEVICE=0",
+ "PICO_NO_HARDWARE=1",
+ "PICO_BUILD=1",
+ ],
+ "//conditions:default": [
+ "PICO_ON_DEVICE=1",
+ "PICO_NO_HARDWARE=0",
+ "PICO_BUILD=1",
+ ],
+ }) + select({
+ "//bazel/constraint:rp2040": ["PICO_RP2040=1"],
+ "//bazel/constraint:rp2350": ["PICO_RP2350=1"],
+ "//conditions:default": [],
+ }),
+)
+
+# While this provides the "pico.h" header, nearly everything should
+# instead depend on `//src/rp2_common:pico_platform` to get these headers. If
+# you try to depend on just `pico_base_headers`, you'll end up with missing
+# symbols.
+cc_library(
+ name = "pico_base_headers",
+ hdrs = [
+ "include/pico.h",
+ "include/pico/assert.h",
+ "include/pico/config.h",
+ "include/pico/error.h",
+ "include/pico/types.h",
+ ],
+ includes = ["include"],
+ visibility = [
+ "//src/common:__subpackages__",
+ "//src/host/hardware_sync:__pkg__",
+ "//src/host/hardware_timer:__pkg__",
+ "//src/host/pico_platform:__pkg__",
+ "//src/rp2040/boot_stage2:__pkg__",
+ "//src/rp2040/pico_platform:__pkg__",
+ "//src/rp2350/boot_stage2:__pkg__",
+ "//src/rp2350/pico_platform:__pkg__",
+ "//src/rp2_common/hardware_base:__pkg__",
+ "//src/rp2_common/hardware_boot_lock:__pkg__",
+ "//src/rp2_common/hardware_clocks:__pkg__",
+ "//src/rp2_common/hardware_gpio:__pkg__",
+ "//src/rp2_common/hardware_pll:__pkg__",
+ "//src/rp2_common/hardware_resets:__pkg__",
+ "//src/rp2_common/hardware_sync:__pkg__",
+ "//src/rp2_common/hardware_sync_spin_lock:__pkg__",
+ "//src/rp2_common/hardware_ticks:__pkg__",
+ "//src/rp2_common/hardware_timer:__pkg__",
+ "//src/rp2_common/hardware_watchdog:__pkg__",
+ "//src/rp2_common/hardware_xosc:__pkg__",
+ "//src/rp2_common/pico_crt0:__pkg__",
+ "//src/rp2_common/pico_printf:__pkg__",
+ "//src/rp2_common/pico_runtime:__pkg__",
+ "//src/rp2_common/pico_runtime_init:__pkg__",
+ "//src/rp2_common/pico_time_adapter:__pkg__",
+ "@picotool//:__subpackages__",
+ ],
+ deps = [
+ ":common_sdk_defines",
+ ":version",
+ "//bazel/config:PICO_CONFIG_HEADER",
+ "//src:pico_platform_internal",
+ ],
+)
diff --git a/src/common/pico_base_headers/CMakeLists.txt b/src/common/pico_base_headers/CMakeLists.txt
new file mode 100644
index 0000000..57973fe
--- /dev/null
+++ b/src/common/pico_base_headers/CMakeLists.txt
@@ -0,0 +1,13 @@
+if (NOT TARGET pico_base_headers)
+ pico_add_library(pico_base NOFLAG)
+ target_include_directories(pico_base_headers SYSTEM INTERFACE include ${CMAKE_BINARY_DIR}/generated/pico_base)
+
+ # PICO_BUILD_DEFINE: PICO_BOARD, Name of board, type=string, default=CMake PICO_BOARD variable, group=pico_base
+ target_compile_definitions(pico_base_headers INTERFACE
+ PICO_BOARD="${PICO_BOARD}")
+
+ target_link_libraries(pico_base_headers INTERFACE pico_platform_headers)
+
+ list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/generate_config_header.cmake)
+ pico_promote_common_scope_vars()
+endif()
\ No newline at end of file
diff --git a/src/common/pico_base_headers/generate_config_header.cmake b/src/common/pico_base_headers/generate_config_header.cmake
new file mode 100644
index 0000000..46b4e13
--- /dev/null
+++ b/src/common/pico_base_headers/generate_config_header.cmake
@@ -0,0 +1,33 @@
+# build the auto gen config headers
+
+set(header_content "// AUTOGENERATED FROM PICO_CONFIG_HEADER_FILES and then PICO_<PLATFORM>_CONFIG_HEADER_FILES\n// DO NOT EDIT!\n")
+string(TOUPPER ${PICO_PLATFORM} PICO_PLATFORM_UPPER)
+string(REGEX REPLACE "-" "_" PICO_PLATFORM_UPPER "${PICO_PLATFORM_UPPER}")
+
+macro(add_header_content_from_var VAR)
+ set(header_content "${header_content}\n\n// based on ${VAR}:\n")
+ foreach(var IN LISTS ${VAR})
+ set(header_content "${header_content}\n#include \"${var}\"")
+ endforeach()
+endmacro()
+
+# PICO_CMAKE_CONFIG: PICO_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for all platforms, type=list, group=pico_base
+add_header_content_from_var(PICO_CONFIG_HEADER_FILES)
+
+# PICO_CMAKE_CONFIG: PICO_RP2040_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for the rp2040 platform only, type=list, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_RP2350_ARM_S_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for the rp2350-arm-s platform only, type=list, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_RP2350_RISCV_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for the riscv platform only, type=list, group=pico_base
+# PICO_CMAKE_CONFIG: PICO_HOST_CONFIG_HEADER_FILES, List of extra header files to include from pico/config.h for the host platform only, type=list, group=pico_base
+add_header_content_from_var(PICO_${PICO_PLATFORM_UPPER}_CONFIG_HEADER_FILES)
+pico_register_common_scope_var(PICO_${PICO_PLATFORM_UPPER}_CONFIG_HEADER_FILES)
+
+file(GENERATE
+ OUTPUT ${CMAKE_BINARY_DIR}/generated/pico_base/pico/config_autogen.h
+ CONTENT "${header_content}"
+ )
+
+configure_file( ${CMAKE_CURRENT_LIST_DIR}/include/pico/version.h.in ${CMAKE_BINARY_DIR}/generated/pico_base/pico/version.h)
+
+foreach(DIR IN LISTS PICO_INCLUDE_DIRS)
+ target_include_directories(pico_base_headers SYSTEM INTERFACE ${DIR})
+endforeach()
diff --git a/src/common/pico_base_headers/include/pico.h b/src/common/pico_base_headers/include/pico.h
new file mode 100644
index 0000000..3b0f2f1
--- /dev/null
+++ b/src/common/pico_base_headers/include/pico.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_H
+#define _PICO_H
+
+/** \file pico.h
+ * \defgroup pico_base pico_base
+ *
+ * \brief Core types and macros for the Raspberry Pi Pico SDK.
+ *
+ * This header is intended to be included by all source code
+ * as it includes configuration headers and overrides in the correct order
+ *
+ * This header may be included by assembly code
+*/
+
+// We may be included by assembly which can't include <cdefs.h>
+#define __PICO_STRING(x) #x
+#define __PICO_XSTRING(x) __PICO_STRING(x)
+#define __PICO_CONCAT1(x, y) x ## y
+
+#include "pico/types.h"
+#include "pico/version.h"
+
+// PICO_CONFIG: PICO_CONFIG_HEADER, Unquoted path to header include in place of the default pico/config.h which may be desirable for build systems which can't easily generate the config_autogen header, group=pico_base
+#ifdef PICO_CONFIG_HEADER
+#include __PICO_XSTRING(PICO_CONFIG_HEADER)
+#else
+#include "pico/config.h"
+#endif
+#include "pico/platform.h"
+#include "pico/error.h"
+
+#endif
diff --git a/src/common/pico_base_headers/include/pico/assert.h b/src/common/pico_base_headers/include/pico/assert.h
new file mode 100644
index 0000000..36e25ef
--- /dev/null
+++ b/src/common/pico_base_headers/include/pico/assert.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_ASSERT_H
+#define _PICO_ASSERT_H
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+
+#include <cassert>
+
+extern "C" {
+#else
+#include <assert.h>
+#endif
+
+// PICO_CONFIG: PARAM_ASSERTIONS_ENABLE_ALL, Global assert enable, type=bool, default=0, group=pico_base
+// PICO_CONFIG: PARAM_ASSERTIONS_DISABLE_ALL, Global assert disable, type=bool, default=0, group=pico_base
+
+#ifndef PARAM_ASSERTIONS_ENABLE_ALL
+#define PARAM_ASSERTIONS_ENABLE_ALL 0
+#endif
+
+#ifndef PARAM_ASSERTIONS_DISABLE_ALL
+#define PARAM_ASSERTIONS_DISABLE_ALL 0
+#endif
+
+#define PARAM_ASSERTIONS_ENABLED(x) ((PARAM_ASSERTIONS_ENABLED_ ## x || PARAM_ASSERTIONS_ENABLE_ALL) && !PARAM_ASSERTIONS_DISABLE_ALL)
+
+#define invalid_params_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) assert(!(test));})
+#define valid_params_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) assert(test);})
+#define hard_assert_if(x, test) ({if (PARAM_ASSERTIONS_ENABLED(x)) hard_assert(!(test));})
+#define invalid_params_if_and_return(x, test, rc) ({/*if (PARAM_ASSERTIONS_ENABLED(x)) assert(!(test)); */ if (test) return rc; })
+
+#ifdef NDEBUG
+extern void hard_assertion_failure(void);
+static inline void hard_assert(bool condition, ...) {
+ if (!condition)
+ hard_assertion_failure();
+}
+#else
+#define hard_assert assert
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/common/pico_base_headers/include/pico/config.h b/src/common/pico_base_headers/include/pico/config.h
new file mode 100644
index 0000000..df0a043
--- /dev/null
+++ b/src/common/pico_base_headers/include/pico/config.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_CONFIG_H
+#define _PICO_CONFIG_H
+
+// -----------------------------------------------------
+// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLY CODE SO
+// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
+// OR USE #ifndef __ASSEMBLER__ guards
+// -------------
+
+// PICO_CONFIG_HEADER_FILES and then PICO_SDK_<PLATFORM>_CONFIG_INCLUDE_FILES
+// entries are dumped in order at build time into this generated header
+
+#include "pico/config_autogen.h"
+
+// PICO_CONFIG: PICO_CONFIG_RTOS_ADAPTER_HEADER, Unquoted path to header include in the default pico/config.h for RTOS integration defines that must be included in all sources, group=pico_base
+#ifdef PICO_CONFIG_RTOS_ADAPTER_HEADER
+#include __PICO_XSTRING(PICO_CONFIG_RTOS_ADAPTER_HEADER)
+#endif
+
+#endif
diff --git a/src/common/pico_base_headers/include/pico/error.h b/src/common/pico_base_headers/include/pico/error.h
new file mode 100644
index 0000000..9212eda
--- /dev/null
+++ b/src/common/pico_base_headers/include/pico/error.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_ERROR_H
+#define _PICO_ERROR_H
+
+#ifndef __ASSEMBLER__
+
+/*!
+ * \brief Common return codes from pico_sdk methods that return a status
+ *
+ * All `PICO_ERROR_` values are negative so they can be returned from functions that also
+ * want to return a zero or positive value on success.
+ *
+ * Note these error codes may be returned via bootrom functions too.
+ *
+ * \ingroup pico_base
+ */
+enum pico_error_codes {
+ PICO_OK = 0, ///< No error; the operation succeeded
+ PICO_ERROR_NONE = 0, ///< No error; the operation succeeded
+ PICO_ERROR_GENERIC = -1, ///< An unspecified error occurred
+ PICO_ERROR_TIMEOUT = -2, ///< The function failed due to timeout
+ PICO_ERROR_NO_DATA = -3, ///< Attempt for example to read from an empty buffer/FIFO
+ PICO_ERROR_NOT_PERMITTED = -4, ///< Permission violation e.g. write to read-only flash partition, or security violation
+ PICO_ERROR_INVALID_ARG = -5, ///< Argument is outside of range of supported values`
+ PICO_ERROR_IO = -6, ///< An I/O error occurred
+ PICO_ERROR_BADAUTH = -7, ///< The authorization failed due to bad credentials
+ PICO_ERROR_CONNECT_FAILED = -8, ///< The connection failed
+ PICO_ERROR_INSUFFICIENT_RESOURCES = -9, ///< Dynamic allocation of resources failed
+ PICO_ERROR_INVALID_ADDRESS = -10, ///< Address argument was out-of-bounds or was determined to be an address that the caller may not access
+ PICO_ERROR_BAD_ALIGNMENT = -11, ///< Address was mis-aligned (usually not on word boundary)
+ PICO_ERROR_INVALID_STATE = -12, ///< Something happened or failed to happen in the past, and consequently we (currently) can't service the request
+ PICO_ERROR_BUFFER_TOO_SMALL = -13, ///< A user-allocated buffer was too small to hold the result or working state of this function
+ PICO_ERROR_PRECONDITION_NOT_MET = -14, ///< The call failed because another function must be called first
+ PICO_ERROR_MODIFIED_DATA = -15, ///< Cached data was determined to be inconsistent with the actual version of the data
+ PICO_ERROR_INVALID_DATA = -16, ///< A data structure failed to validate
+ PICO_ERROR_NOT_FOUND = -17, ///< Attempted to access something that does not exist; or, a search failed
+ PICO_ERROR_UNSUPPORTED_MODIFICATION = -18, ///< Write is impossible based on previous writes; e.g. attempted to clear an OTP bit
+ PICO_ERROR_LOCK_REQUIRED = -19, ///< A required lock is not owned
+ PICO_ERROR_VERSION_MISMATCH = -20, ///< A version mismatch occurred (e.g. trying to run PIO version 1 code on RP2040)
+ PICO_ERROR_RESOURCE_IN_USE = -21 ///< The call could not proceed because requires resourcesw were unavailable
+};
+
+#endif // !__ASSEMBLER__
+
+#endif
\ No newline at end of file
diff --git a/src/common/pico_base_headers/include/pico/types.h b/src/common/pico_base_headers/include/pico/types.h
new file mode 100644
index 0000000..2e9c396
--- /dev/null
+++ b/src/common/pico_base_headers/include/pico/types.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_TYPES_H
+#define _PICO_TYPES_H
+
+#ifndef __ASSEMBLER__
+
+#include "pico/assert.h"
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+typedef unsigned int uint;
+
+// PICO_CONFIG: PICO_OPAQUE_ABSOLUTE_TIME_T, Enable opaque type for absolute_time_t to help catch inadvertent confusing uint64_t delays with absolute times, default=0, advanced=true, group=pico_base
+#ifndef PICO_OPAQUE_ABSOLUTE_TIME_T
+#define PICO_OPAQUE_ABSOLUTE_TIME_T 0
+#endif
+
+/*! \typedef absolute_time_t
+ \brief An opaque 64 bit timestamp in microseconds
+
+ The type is used instead of a raw uint64_t to prevent accidentally passing relative times or times in the wrong
+ time units where an absolute time is required.
+
+ note: As of SDK 2.0.0 this type defaults to being a uin64_t (i.e. no protection); it is enabled
+ by setting PICO_OPAQUE_ABSOLUTE_TIME_T to 1
+
+ \see to_us_since_boot()
+ \see update_us_since_boot()
+ \ingroup timestamp
+*/
+#if PICO_OPAQUE_ABSOLUTE_TIME_T
+typedef struct {
+ uint64_t _private_us_since_boot;
+} absolute_time_t;
+#else
+typedef uint64_t absolute_time_t;
+#endif
+
+/*! fn to_us_since_boot
+ * \brief convert an absolute_time_t into a number of microseconds since boot.
+ * \param t the absolute time to convert
+ * \return a number of microseconds since boot, equivalent to t
+ * \ingroup timestamp
+ */
+static inline uint64_t to_us_since_boot(absolute_time_t t) {
+#ifdef PICO_DEBUG_ABSOLUTE_TIME_T
+ return t._private_us_since_boot;
+#else
+ return t;
+#endif
+}
+
+/*! fn update_us_since_boot
+ * \brief update an absolute_time_t value to represent a given number of microseconds since boot
+ * \param t the absolute time value to update
+ * \param us_since_boot the number of microseconds since boot to represent. Note this should be representable
+ * as a signed 64 bit integer
+ * \ingroup timestamp
+ */
+static inline void update_us_since_boot(absolute_time_t *t, uint64_t us_since_boot) {
+#ifdef PICO_DEBUG_ABSOLUTE_TIME_T
+ assert(us_since_boot <= INT64_MAX);
+ t->_private_us_since_boot = us_since_boot;
+#else
+ *t = us_since_boot;
+#endif
+}
+
+/*! fn from_us_since_boot
+ * \brief convert a number of microseconds since boot to an absolute_time_t
+ * \param us_since_boot number of microseconds since boot
+ * \return an absolute time equivalent to us_since_boot
+ * \ingroup timestamp
+ */
+static inline absolute_time_t from_us_since_boot(uint64_t us_since_boot) {
+ absolute_time_t t;
+ update_us_since_boot(&t, us_since_boot);
+ return t;
+}
+
+#ifdef NDEBUG
+#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = value
+#else
+#define ABSOLUTE_TIME_INITIALIZED_VAR(name, value) name = {value}
+#endif
+
+// PICO_CONFIG: PICO_INCLUDE_RTC_DATETIME, Whether to include the datetime_t type used with the RP2040 RTC hardware, default=1 on RP2040, group=util_datetime
+#ifndef PICO_INCLUDE_RTC_DATETIME
+#define PICO_INCLUDE_RTC_DATETIME PICO_RP2040
+#endif
+
+#if PICO_INCLUDE_RTC_DATETIME
+/** \struct datetime_t
+ * \ingroup util_datetime
+ * \brief Structure containing date and time information
+ *
+ * When setting an RTC alarm, set a field to -1 tells
+ * the RTC to not match on this field
+ */
+typedef struct {
+ int16_t year; ///< 0..4095
+ int8_t month; ///< 1..12, 1 is January
+ int8_t day; ///< 1..28,29,30,31 depending on month
+ int8_t dotw; ///< 0..6, 0 is Sunday
+ int8_t hour; ///< 0..23
+ int8_t min; ///< 0..59
+ int8_t sec; ///< 0..59
+} datetime_t;
+#endif
+
+#define bool_to_bit(x) ((uint)!!(x))
+
+#endif
+#endif
diff --git a/src/common/pico_base/include/pico/version.h.in b/src/common/pico_base_headers/include/pico/version.h.in
similarity index 100%
rename from src/common/pico_base/include/pico/version.h.in
rename to src/common/pico_base_headers/include/pico/version.h.in
diff --git a/src/common/pico_binary_info/BUILD.bazel b/src/common/pico_binary_info/BUILD.bazel
index c4fa71b..fa660e7 100644
--- a/src/common/pico_binary_info/BUILD.bazel
+++ b/src/common/pico_binary_info/BUILD.bazel
@@ -1,5 +1,16 @@
+load("//bazel/util:sdk_define.bzl", "pico_sdk_define")
+
package(default_visibility = ["//visibility:public"])
+pico_sdk_define(
+ name = "LIB_PICO_BINARY_INFO",
+ define_name = "LIB_PICO_BINARY_INFO",
+ from_flag = "//bazel/config:PICO_BINARY_INFO_ENABLED",
+)
+
+# The actual sources and defines for pico_binary_info are provided
+# in the //src/rp2_common/pico_standard_link package.
+
cc_library(
name = "pico_binary_info",
hdrs = [
@@ -10,7 +21,8 @@
],
includes = ["include"],
deps = [
- "//src/common/pico_base:pico_base_interface",
- "//src/common/pico_base:pico_platform",
+ ":LIB_PICO_BINARY_INFO",
+ "//src:pico_platform_internal",
+ "//src/common/pico_base_headers",
],
)
diff --git a/src/common/pico_binary_info/CMakeLists.txt b/src/common/pico_binary_info/CMakeLists.txt
index bcaad6f..d2bfd69 100644
--- a/src/common/pico_binary_info/CMakeLists.txt
+++ b/src/common/pico_binary_info/CMakeLists.txt
@@ -1,11 +1,10 @@
add_library(pico_binary_info_headers INTERFACE)
-target_include_directories(pico_binary_info_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+target_include_directories(pico_binary_info_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+add_library(pico_binary_info INTERFACE)
if (COMMAND pico_add_platform_library)
pico_add_platform_library(pico_binary_info)
-else()
- add_library(pico_binary_info INTERFACE)
endif()
target_link_libraries(pico_binary_info INTERFACE pico_binary_info_headers)
diff --git a/src/common/pico_binary_info/binary_info.bzl b/src/common/pico_binary_info/binary_info.bzl
index a07a2c6..dd74a90 100644
--- a/src/common/pico_binary_info/binary_info.bzl
+++ b/src/common/pico_binary_info/binary_info.bzl
@@ -28,12 +28,12 @@
"@pico-sdk//bazel/constraint:pico_no_target_name_enabled": [],
"//conditions:default": _build_target_name_defines,
}),
- srcs = ["@pico-sdk//src/rp2_common/pico_standard_link:binary_info_srcs"],
+ srcs = ["@pico-sdk//src/rp2_common/pico_standard_binary_info:binary_info_srcs"],
deps = [
- "@pico-sdk//src/rp2_common/pico_standard_link:PICO_BAZEL_BUILD_TYPE",
- "@pico-sdk//src/common/pico_base:version",
+ "@pico-sdk//src/rp2_common/pico_standard_binary_info:PICO_BAZEL_BUILD_TYPE",
+ "@pico-sdk//src/common/pico_base_headers:version",
"@pico-sdk//src/common/pico_binary_info",
- "@pico-sdk//src/rp2_common/boot_stage2:config",
+ "@pico-sdk//src/rp2_common:boot_stage2_config",
],
alwayslink = True,
)
diff --git a/src/common/pico_binary_info/include/pico/binary_info.h b/src/common/pico_binary_info/include/pico/binary_info.h
index 58fb4c7..594e8f7 100644
--- a/src/common/pico_binary_info/include/pico/binary_info.h
+++ b/src/common/pico_binary_info/include/pico/binary_info.h
@@ -10,7 +10,7 @@
/** \file binary_info.h
* \defgroup pico_binary_info pico_binary_info
*
- * \brief Binary info is intended for embedding machine readable information with the binary in FLASH.
+ * \brief Binary info is intended for embedding machine readable information with the binary in FLASH
*
* Example uses include:
*
@@ -22,6 +22,8 @@
#include "pico/binary_info/defs.h"
#include "pico/binary_info/structure.h"
+
+// PICO_CONFIG: PICO_NO_BINARY_INFO, Don't include "binary info" in the output binary, type=bool, default=0 except for `PICO_PLATFORM` `host`, group=pico_runtime_init
#if !PICO_ON_DEVICE && !defined(PICO_NO_BINARY_INFO)
#define PICO_NO_BINARY_INFO 1
#endif
diff --git a/src/common/pico_binary_info/include/pico/binary_info/code.h b/src/common/pico_binary_info/include/pico/binary_info/code.h
index bd72edf..bc2126f 100644
--- a/src/common/pico_binary_info/include/pico/binary_info/code.h
+++ b/src/common/pico_binary_info/include/pico/binary_info/code.h
@@ -71,6 +71,33 @@
.value = _value, \
}
+#define __bi_ptr_int32_with_name(_tag, _id, _label, _value) \
+ static const struct _binary_info_ptr_int32_with_name __bi_lineno_var_name = { \
+ .core = { \
+ .type = __bi_enclosure_check(BINARY_INFO_TYPE_PTR_INT32_WITH_NAME), \
+ .tag = _tag, \
+ },\
+ .id = _id, \
+ .value = &_value, \
+ .label = _label, \
+ }
+
+#define bi_ptr_int32(_tag, _id, _var, _default) __attribute__((section(".data"))) static int _var = _default; __bi_ptr_int32_with_name(_tag, _id, __STRING(_var), _var)
+
+#define __bi_ptr_string_with_name(_tag, _id, _label, _value, _len) \
+ static const struct _binary_info_ptr_string_with_name __bi_lineno_var_name = { \
+ .core = { \
+ .type = __bi_enclosure_check(BINARY_INFO_TYPE_PTR_STRING_WITH_NAME), \
+ .tag = _tag, \
+ },\
+ .id = _id, \
+ .value = _value, \
+ .label = _label, \
+ .len = _len, \
+ }
+
+#define bi_ptr_string(_tag, _id, _var, _default, _max_len) static char _var[_max_len] = _default; __bi_ptr_string_with_name(_tag, _id, __STRING(_var), _var, _max_len)
+
#define bi_block_device(_tag, _name, _address, _size, _extra, _flags) \
static const struct _binary_info_block_device __bi_lineno_var_name = { \
.core = { \
@@ -93,6 +120,15 @@
.pin_encoding = _encoding \
}
+#define __bi_encoded_pins_64_with_func(_encoding) \
+ static const struct _binary_info_pins64_with_func __bi_lineno_var_name = { \
+ .core = { \
+ .type = __bi_enclosure_check(BINARY_INFO_TYPE_PINS64_WITH_FUNC), \
+ .tag = BINARY_INFO_TAG_RASPBERRY_PI, \
+ },\
+ .pin_encoding = _encoding \
+ }
+
#define __bi_pins_with_name(_mask, _label) \
static const struct _binary_info_pins_with_name __bi_lineno_var_name = { \
.core = { \
@@ -103,6 +139,16 @@
.label = _label \
}
+#define __bi_pins_64_with_name(_mask, _label) \
+ static const struct _binary_info_pins64_with_name __bi_lineno_var_name = { \
+ .core = { \
+ .type = __bi_enclosure_check(BINARY_INFO_TYPE_PINS64_WITH_NAME), \
+ .tag = BINARY_INFO_TAG_RASPBERRY_PI, \
+ },\
+ .pin_mask = _mask, \
+ .label = _label \
+ }
+
#define __bi_named_group(_parent_tag, _parent_id, _group_tag, _group_id, _label, _flags) \
static const struct _binary_info_named_group __bi_lineno_var_name = { \
.core = { \
@@ -128,6 +174,12 @@
#define bi_program_feature_group(tag, id, name) __bi_named_group(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PROGRAM_FEATURE, tag, id, name, 0)
#define bi_program_feature_group_with_flags(tag, id, name, flags) __bi_named_group(BINARY_INFO_TAG_RASPBERRY_PI, BINARY_INFO_ID_RP_PROGRAM_FEATURE, tag, id, name, flags)
+
+#ifndef PICO_BINARY_INFO_USE_PINS_64
+#define PICO_BINARY_INFO_USE_PINS_64 (NUM_BANK0_GPIOS > 32)
+#endif
+
+#if !PICO_BINARY_INFO_USE_PINS_64
#define bi_1pin_with_func(p0, func) __bi_encoded_pins_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 7) | ((p0) << 12))
#define bi_2pins_with_func(p0, p1, func) __bi_encoded_pins_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 7) | ((p1) << 12) | ((p1) << 17))
#define bi_3pins_with_func(p0, p1, p2, func) __bi_encoded_pins_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 7) | ((p1) << 12) | ((p2) << 17) | ((p2) << 22))
@@ -138,9 +190,26 @@
#define bi_pin_mask_with_name(pmask, label) __bi_pins_with_name((pmask), (label))
// names are separated by | ... i.e. "name1|name2|name3"
#define bi_pin_mask_with_names(pmask, label) __bi_pins_with_name((pmask), (label))
-#define bi_1pin_with_name(p0, name) bi_pin_mask_with_name(1u << (p0), name)
-#define bi_2pins_with_names(p0, name0, p1, name1) bi_pin_mask_with_names((1u << (p0)) | (1u << (p1)), name0 "|" name1)
-#define bi_3pins_with_names(p0, name0, p1, name1, p2, name2) bi_pin_mask_with_names((1u << (p0)) | (1u << (p1)) | (1u << (p2)), name0 "|" name1 "|" name2)
-#define bi_4pins_with_names(p0, name0, p1, name1, p2, name2, p3, name3) bi_pin_mask_with_names((1u << (p0)) | (1u << (p1)) | (1u << (p2)) | (1u << (p3)), name0 "|" name1 "|" name2 "|" name3)
+#else
+#define bi_1pin_with_func(p0, func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 8) | ((p0) << 16))
+#define bi_2pins_with_func(p0, p1, func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 8) | ((p1) << 16) | ((p1) << 24))
+#define bi_3pins_with_func(p0, p1, p2, func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 8) | ((p1) << 16) | ((p2) << 24) | ((uint64_t)(p2) << 32))
+#define bi_4pins_with_func(p0, p1, p2, p3, func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 8) | ((p1) << 16) | ((p2) << 24) | ((uint64_t)(p3) << 32) | ((uint64_t)(p3) << 40))
+#define bi_5pins_with_func(p0, p1, p2, p3, p4, func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 8) | ((p1) << 16) | ((p2) << 24) | ((uint64_t)(p3) << 32) | ((uint64_t)(p4) << 40) | ((uint64_t)(p4) << 48))
+#define bi_pin_range_with_func(plo, phi, func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_RANGE | ((func << 3)) | ((plo) << 8) | ((phi) << 16))
+
+#define bi_pin_mask_with_name(pmask, label) __bi_pins_64_with_name((uint64_t)(pmask), (label))
+// names are separated by | ... i.e. "name1|name2|name3"
+#define bi_pin_mask_with_names(pmask, label) __bi_pins_64_with_name((uint64_t)(pmask), (label))
+#endif
+
+// 6 and 7 pins require pins_64
+#define bi_6pins_with_func(p0, p1, p2, p3, p4, p5, func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 8) | ((p1) << 16) | ((p2) << 24) | ((uint64_t)(p3) << 32) | ((uint64_t)(p4) << 40) | ((uint64_t)(p5) << 48) | ((uint64_t)(p5) << 56))
+#define bi_7pins_with_func(p0, p1, p2, p3, p4, p5, p6,func) __bi_encoded_pins_64_with_func(BI_PINS_ENCODING_MULTI | ((func << 3)) | ((p0) << 8) | ((p1) << 16) | ((p2) << 24) | ((uint64_t)(p3) << 32) | ((uint64_t)(p4) << 40) | ((uint64_t)(p5) << 48) | ((uint64_t)(p6) << 56))
+
+#define bi_1pin_with_name(p0, name) bi_pin_mask_with_name(1ull << (p0), name)
+#define bi_2pins_with_names(p0, name0, p1, name1) bi_pin_mask_with_names((1ull << (p0)) | (1ull << (p1)), name0 "|" name1)
+#define bi_3pins_with_names(p0, name0, p1, name1, p2, name2) bi_pin_mask_with_names((1ull << (p0)) | (1ull << (p1)) | (1ull << (p2)), name0 "|" name1 "|" name2)
+#define bi_4pins_with_names(p0, name0, p1, name1, p2, name2, p3, name3) bi_pin_mask_with_names((1ull << (p0)) | (1ull << (p1)) | (1ull << (p2)) | (1ull << (p3)), name0 "|" name1 "|" name2 "|" name3)
#endif
diff --git a/src/common/pico_binary_info/include/pico/binary_info/structure.h b/src/common/pico_binary_info/include/pico/binary_info/structure.h
index 4808048..1cda5a9 100644
--- a/src/common/pico_binary_info/include/pico/binary_info/structure.h
+++ b/src/common/pico_binary_info/include/pico/binary_info/structure.h
@@ -33,8 +33,11 @@
#define BINARY_INFO_TYPE_BLOCK_DEVICE 7
#define BINARY_INFO_TYPE_PINS_WITH_FUNC 8
#define BINARY_INFO_TYPE_PINS_WITH_NAME 9
-#define BINARY_INFO_TYPE_PINS_WITH_NAMES 9
#define BINARY_INFO_TYPE_NAMED_GROUP 10
+#define BINARY_INFO_TYPE_PTR_INT32_WITH_NAME 11
+#define BINARY_INFO_TYPE_PTR_STRING_WITH_NAME 12
+#define BINARY_INFO_TYPE_PINS64_WITH_FUNC 13
+#define BINARY_INFO_TYPE_PINS64_WITH_NAME 14
// note plan is to reserve c1 = 0->31 for "collision tags"; i.e.
// for which you should always use random IDs with the binary_info,
@@ -94,6 +97,21 @@
bi_ptr_of(const char) value;
} binary_info_id_and_string_t;
+typedef struct __packed _binary_info_ptr_int32_with_name {
+ struct _binary_info_core core;
+ int32_t id;
+ bi_ptr_of(const int) value;
+ bi_ptr_of(const char) label;
+} binary_info_ptr_int32_with_name_t;
+
+typedef struct __packed _binary_info_ptr_string_with_name {
+ struct _binary_info_core core;
+ int32_t id;
+ bi_ptr_of(const char) value;
+ bi_ptr_of(const char) label;
+ uint32_t len;
+} binary_info_ptr_string_with_name_t;
+
typedef struct __packed _binary_info_block_device {
struct _binary_info_core core;
bi_ptr_of(const char) name; // optional static name (independent of what is formatted)
@@ -113,12 +131,25 @@
uint32_t pin_encoding;
} binary_info_pins_with_func_t;
+typedef struct __packed _binary_info_pins64_with_func {
+ struct _binary_info_core core;
+ // p6_8 : p5_8 : p4_8 : p3_8 : p2_8 : p1_8 : p0_8 : func_5 : 010_3 //individual pins p0,p1,p2 ... if fewer than 7 then duplicate p
+ // phi_8 : plo_8 : func_5 : 001_3 // pin range plo-phi inclusive
+ uint64_t pin_encoding;
+} binary_info_pins64_with_func_t;
+
typedef struct __packed _binary_info_pins_with_name {
struct _binary_info_core core;
uint32_t pin_mask;
bi_ptr_of(const char) label;
} binary_info_pins_with_name_t;
+typedef struct __packed _binary_info_pins64_with_name {
+ struct _binary_info_core core;
+ uint64_t pin_mask;
+ bi_ptr_of(const char) label;
+} binary_info_pins64_with_name_t;
+
#define BI_NAMED_GROUP_SHOW_IF_EMPTY 0x0001 // default is to hide
#define BI_NAMED_GROUP_SEPARATE_COMMAS 0x0002 // default is newlines
#define BI_NAMED_GROUP_SORT_ALPHA 0x0004 // default is no sort
@@ -134,8 +165,7 @@
} binary_info_named_group_t;
enum {
- BINARY_INFO_BLOCK_DEV_FLAG_READ =
- 1 << 0, // if not readable, then it is basically hidden, but tools may choose to avoid overwriting it
+ BINARY_INFO_BLOCK_DEV_FLAG_READ = 1 << 0, // if not readable, then it is basically hidden, but tools may choose to avoid overwriting it
BINARY_INFO_BLOCK_DEV_FLAG_WRITE = 1 << 1,
BINARY_INFO_BLOCK_DEV_FLAG_REFORMAT = 1 << 2, // may be reformatted..
diff --git a/src/common/pico_bit_ops/BUILD.bazel b/src/common/pico_bit_ops/BUILD.bazel
deleted file mode 100644
index 0d55f1e..0000000
--- a/src/common/pico_bit_ops/BUILD.bazel
+++ /dev/null
@@ -1,29 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-# This exists to break dependency cycles between
-# this library and the bit ops implementations.
-# Application code should always use :pico_bit_ops instead.
-cc_library(
- name = "pico_bit_ops_headers",
- hdrs = ["include/pico/bit_ops.h"],
- includes = ["include"],
- visibility = [
- "//src/host/pico_bit_ops:__pkg__",
- "//src/rp2_common/pico_bit_ops:__pkg__",
- ],
- deps = [
- "//src/common/pico_base",
- ],
-)
-
-cc_library(
- name = "pico_bit_ops",
- hdrs = ["include/pico/bit_ops.h"],
- includes = ["include"],
- deps = [
- "//src/common/pico_base",
- ] + select({
- "//bazel/constraint:host": ["//src/host/pico_bit_ops"],
- "//conditions:default": ["//src/rp2_common/pico_bit_ops"],
- }),
-)
diff --git a/src/common/pico_bit_ops/CMakeLists.txt b/src/common/pico_bit_ops/CMakeLists.txt
deleted file mode 100644
index 603a520..0000000
--- a/src/common/pico_bit_ops/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-if (NOT TARGET pico_bit_ops_headers)
- add_library(pico_bit_ops_headers INTERFACE)
- target_include_directories(pico_bit_ops_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
- target_link_libraries(pico_bit_ops_headers INTERFACE pico_base_headers)
-endif()
\ No newline at end of file
diff --git a/src/common/pico_bit_ops/include/pico/bit_ops.h b/src/common/pico_bit_ops/include/pico/bit_ops.h
deleted file mode 100644
index d3a1dd5..0000000
--- a/src/common/pico_bit_ops/include/pico/bit_ops.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_BIT_OPS_H
-#define _PICO_BIT_OPS_H
-
-#include "pico.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** \file bit_ops.h
-* \defgroup pico_bit_ops pico_bit_ops
-*
-* \brief Optimized bit manipulation functions.
-* Additionally provides replacement implementations of the compiler built-ins __builtin_popcount, __builtin_clz
-* and __bulitin_ctz
-*/
-
-/*! \brief Reverse the bits in a 32 bit word
- * \ingroup pico_bit_ops
- *
- * \param bits 32 bit input
- * \return the 32 input bits reversed
- */
-uint32_t __rev(uint32_t bits);
-
-/*! \brief Reverse the bits in a 64 bit double word
- * \ingroup pico_bit_ops
- *
- * \param bits 64 bit input
- * \return the 64 input bits reversed
- */
-uint64_t __revll(uint64_t bits);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/common/pico_bit_ops_headers/BUILD.bazel b/src/common/pico_bit_ops_headers/BUILD.bazel
new file mode 100644
index 0000000..5e6eca2
--- /dev/null
+++ b/src/common/pico_bit_ops_headers/BUILD.bazel
@@ -0,0 +1,29 @@
+package(default_visibility = ["//visibility:public"])
+
+# This exists to break dependency cycles between
+# this library and the bit ops implementations.
+# Application code should always use :pico_bit_ops instead.
+cc_library(
+ name = "pico_bit_ops_interface",
+ hdrs = ["include/pico/bit_ops.h"],
+ includes = ["include"],
+ visibility = [
+ "//src/host/pico_bit_ops:__pkg__",
+ "//src/rp2_common/pico_bit_ops:__pkg__",
+ ],
+ deps = [
+ "//src/common/pico_base_headers",
+ ],
+)
+
+cc_library(
+ name = "pico_bit_ops_headers",
+ hdrs = ["include/pico/bit_ops.h"],
+ includes = ["include"],
+ deps = [
+ "//src/common/pico_base_headers",
+ ] + select({
+ "//bazel/constraint:host": ["//src/host/pico_bit_ops"],
+ "//conditions:default": ["//src/rp2_common/pico_bit_ops"],
+ }),
+)
diff --git a/src/common/pico_bit_ops_headers/CMakeLists.txt b/src/common/pico_bit_ops_headers/CMakeLists.txt
new file mode 100644
index 0000000..ff2e900
--- /dev/null
+++ b/src/common/pico_bit_ops_headers/CMakeLists.txt
@@ -0,0 +1,5 @@
+if (NOT TARGET pico_bit_ops_headers)
+ add_library(pico_bit_ops_headers INTERFACE)
+ target_include_directories(pico_bit_ops_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ target_link_libraries(pico_bit_ops_headers INTERFACE pico_base_headers)
+endif()
\ No newline at end of file
diff --git a/src/common/pico_bit_ops_headers/include/pico/bit_ops.h b/src/common/pico_bit_ops_headers/include/pico/bit_ops.h
new file mode 100644
index 0000000..4324e52
--- /dev/null
+++ b/src/common/pico_bit_ops_headers/include/pico/bit_ops.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_BIT_OPS_H
+#define _PICO_BIT_OPS_H
+
+#include "pico.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \file bit_ops.h
+* \defgroup pico_bit_ops pico_bit_ops
+*
+* \brief Optimized bit manipulation functions
+*
+* Additionally provides replacement implementations of the compiler built-ins __builtin_popcount, __builtin_clz
+* and __bulitin_ctz
+*/
+
+/*! \brief Reverse the bits in a 32 bit word
+ * \ingroup pico_bit_ops
+ *
+ * \param bits 32 bit input
+ * \return the 32 input bits reversed
+ */
+uint32_t __rev(uint32_t bits);
+
+/*! \brief Reverse the bits in a 64 bit double word
+ * \ingroup pico_bit_ops
+ *
+ * \param bits 64 bit input
+ * \return the 64 input bits reversed
+ */
+uint64_t __revll(uint64_t bits);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/common/pico_divider/BUILD.bazel b/src/common/pico_divider/BUILD.bazel
deleted file mode 100644
index ed77bcc..0000000
--- a/src/common/pico_divider/BUILD.bazel
+++ /dev/null
@@ -1,13 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-cc_library(
- name = "pico_divider",
- hdrs = ["include/pico/divider.h"],
- includes = ["include"],
- deps = [
- "//src/common/pico_base",
- ] + select({
- "//bazel/constraint:host": ["//src/host/hardware_divider"],
- "//conditions:default": ["//src/rp2_common/pico_divider"],
- }),
-)
diff --git a/src/common/pico_divider/CMakeLists.txt b/src/common/pico_divider/CMakeLists.txt
deleted file mode 100644
index aed07d2..0000000
--- a/src/common/pico_divider/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-if (NOT TARGET pico_divider_headers)
- add_library(pico_divider_headers INTERFACE)
- target_include_directories(pico_divider_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
- target_link_libraries(pico_divider_headers INTERFACE pico_base_headers)
-endif()
\ No newline at end of file
diff --git a/src/common/pico_divider/include/pico/divider.h b/src/common/pico_divider/include/pico/divider.h
deleted file mode 100644
index 574ad38..0000000
--- a/src/common/pico_divider/include/pico/divider.h
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_DIVIDER_H
-#define _PICO_DIVIDER_H
-
-#include "pico.h"
-#include "hardware/divider.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \defgroup pico_divider pico_divider
- * \brief Optimized 32 and 64 bit division functions accelerated by the RP2040 hardware divider.
- * Additionally provides integration with the C `/` and `%` operators
- */
-
-/** \file pico/divider.h
-* \brief High level APIs including combined quotient and remainder functions for 32 and 64 bit accelerated by the hardware divider
-* \ingroup pico_divider
-*
-* These functions all call __aeabi_idiv0 or __aebi_ldiv0 on division by zero
-* passing the largest applicably signed value
-*
-* Functions with unsafe in their name do not save/restore divider state, so are unsafe to call from interrupts. Unsafe functions are slightly faster.
-*/
-
-/**
- * \brief Integer divide of two signed 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient
- */
-int32_t div_s32s32(int32_t a, int32_t b);
-
-/**
- * \brief Integer divide of two signed 32-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- */
-static inline int32_t divmod_s32s32_rem(int32_t a, int32_t b, int32_t *rem) {
- divmod_result_t r = hw_divider_divmod_s32(a, b);
- *rem = to_remainder_s32(r);
- return to_quotient_s32(r);
-}
-
-/**
- * \brief Integer divide of two signed 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in low word/r0, remainder in high word/r1
- */
-divmod_result_t divmod_s32s32(int32_t a, int32_t b);
-
-/**
- * \brief Integer divide of two unsigned 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return Quotient
- */
-uint32_t div_u32u32(uint32_t a, uint32_t b);
-
-/**
- * \brief Integer divide of two unsigned 32-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- */
-static inline uint32_t divmod_u32u32_rem(uint32_t a, uint32_t b, uint32_t *rem) {
- divmod_result_t r = hw_divider_divmod_u32(a, b);
- *rem = to_remainder_u32(r);
- return to_quotient_u32(r);
-}
-
-/**
- * \brief Integer divide of two unsigned 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in low word/r0, remainder in high word/r1
- */
-divmod_result_t divmod_u32u32(uint32_t a, uint32_t b);
-
-/**
- * \brief Integer divide of two signed 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return Quotient
- */
-int64_t div_s64s64(int64_t a, int64_t b);
-
-/**
- * \brief Integer divide of two signed 64-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- */
-int64_t divmod_s64s64_rem(int64_t a, int64_t b, int64_t *rem);
-
-/**
- * \brief Integer divide of two signed 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in result (r0,r1), remainder in regs (r2, r3)
- */
-int64_t divmod_s64s64(int64_t a, int64_t b);
-
-/**
- * \brief Integer divide of two unsigned 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return Quotient
- */
-uint64_t div_u64u64(uint64_t a, uint64_t b);
-
-/**
- * \brief Integer divide of two unsigned 64-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- */
-uint64_t divmod_u64u64_rem(uint64_t a, uint64_t b, uint64_t *rem);
-
-
-/**
- * \brief Integer divide of two signed 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in result (r0,r1), remainder in regs (r2, r3)
- */
-uint64_t divmod_u64u64(uint64_t a, uint64_t b);
-
-// -----------------------------------------------------------------------
-// these "unsafe" functions are slightly faster, but do not save the divider state,
-// so are not generally safe to be called from interrupts
-// -----------------------------------------------------------------------
-
-/**
- * \brief Unsafe integer divide of two signed 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient
- *
- * Do not use in interrupts
- */
-int32_t div_s32s32_unsafe(int32_t a, int32_t b);
-
-/**
- * \brief Unsafe integer divide of two signed 32-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- *
- * Do not use in interrupts
- */
-int32_t divmod_s32s32_rem_unsafe(int32_t a, int32_t b, int32_t *rem);
-
-/**
- * \brief Unsafe integer divide of two unsigned 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in low word/r0, remainder in high word/r1
- *
- * Do not use in interrupts
- */
-int64_t divmod_s32s32_unsafe(int32_t a, int32_t b);
-
-/**
- * \brief Unsafe integer divide of two unsigned 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return Quotient
- *
- * Do not use in interrupts
- */
-uint32_t div_u32u32_unsafe(uint32_t a, uint32_t b);
-
-/**
- * \brief Unsafe integer divide of two unsigned 32-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- *
- * Do not use in interrupts
- */
-uint32_t divmod_u32u32_rem_unsafe(uint32_t a, uint32_t b, uint32_t *rem);
-
-/**
- * \brief Unsafe integer divide of two unsigned 32-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in low word/r0, remainder in high word/r1
- *
- * Do not use in interrupts
- */
-uint64_t divmod_u32u32_unsafe(uint32_t a, uint32_t b);
-
-/**
- * \brief Unsafe integer divide of two signed 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return Quotient
- *
- * Do not use in interrupts
- */
-int64_t div_s64s64_unsafe(int64_t a, int64_t b);
-
-/**
- * \brief Unsafe integer divide of two signed 64-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- *
- * Do not use in interrupts
- */
-int64_t divmod_s64s64_rem_unsafe(int64_t a, int64_t b, int64_t *rem);
-
-/**
- * \brief Unsafe integer divide of two signed 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in result (r0,r1), remainder in regs (r2, r3)
- *
- * Do not use in interrupts
- */
-int64_t divmod_s64s64_unsafe(int64_t a, int64_t b);
-
-/**
- * \brief Unsafe integer divide of two unsigned 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return Quotient
- *
- * Do not use in interrupts
- */
-uint64_t div_u64u64_unsafe(uint64_t a, uint64_t b);
-
-/**
- * \brief Unsafe integer divide of two unsigned 64-bit values, with remainder
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \param [out] rem The remainder of dividend/divisor
- * \return Quotient result of dividend/divisor
- *
- * Do not use in interrupts
- */
-uint64_t divmod_u64u64_rem_unsafe(uint64_t a, uint64_t b, uint64_t *rem);
-
-/**
- * \brief Unsafe integer divide of two signed 64-bit values
- * \ingroup pico_divider
- *
- * \param a Dividend
- * \param b Divisor
- * \return quotient in result (r0,r1), remainder in regs (r2, r3)
- *
- * Do not use in interrupts
- */
-uint64_t divmod_u64u64_unsafe(uint64_t a, uint64_t b);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/common/pico_divider_headers/BUILD.bazel b/src/common/pico_divider_headers/BUILD.bazel
new file mode 100644
index 0000000..9d27f35
--- /dev/null
+++ b/src/common/pico_divider_headers/BUILD.bazel
@@ -0,0 +1,10 @@
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "pico_divider_headers",
+ hdrs = ["include/pico/divider.h"],
+ includes = ["include"],
+ deps = [
+ "//src/common/pico_base_headers",
+ ],
+)
diff --git a/src/common/pico_divider_headers/CMakeLists.txt b/src/common/pico_divider_headers/CMakeLists.txt
new file mode 100644
index 0000000..3919578
--- /dev/null
+++ b/src/common/pico_divider_headers/CMakeLists.txt
@@ -0,0 +1,5 @@
+if (NOT TARGET pico_divider_headers)
+ add_library(pico_divider_headers INTERFACE)
+ target_include_directories(pico_divider_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ target_link_libraries(pico_divider_headers INTERFACE pico_base_headers hardware_divider_headers)
+endif()
\ No newline at end of file
diff --git a/src/common/pico_divider_headers/include/pico/divider.h b/src/common/pico_divider_headers/include/pico/divider.h
new file mode 100644
index 0000000..45c448d
--- /dev/null
+++ b/src/common/pico_divider_headers/include/pico/divider.h
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_DIVIDER_H
+#define _PICO_DIVIDER_H
+
+#include "pico.h"
+#include "hardware/divider.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \defgroup pico_divider pico_divider
+ * \brief Optimized 32 and 64 bit division functions accelerated by the RP2040 hardware divider
+ *
+ * Additionally provides integration with the C `/` and `%` operators
+ */
+
+/** \file pico/divider.h
+* \brief High level APIs including combined quotient and remainder functions for 32 and 64 bit accelerated by the hardware divider
+* \ingroup pico_divider
+*
+* These functions all call __aeabi_idiv0 or __aebi_ldiv0 on division by zero
+* passing the largest applicably signed value
+*
+* Functions with unsafe in their name do not save/restore divider state, so are unsafe to call from interrupts. Unsafe functions are slightly faster.
+*/
+
+/**
+ * \brief Integer divide of two signed 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient
+ */
+int32_t div_s32s32(int32_t a, int32_t b);
+
+/**
+ * \brief Integer divide of two signed 32-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ */
+static inline int32_t divmod_s32s32_rem(int32_t a, int32_t b, int32_t *rem) {
+ divmod_result_t r = hw_divider_divmod_s32(a, b);
+ *rem = to_remainder_s32(r);
+ return to_quotient_s32(r);
+}
+
+/**
+ * \brief Integer divide of two signed 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in low word/r0, remainder in high word/r1
+ */
+divmod_result_t divmod_s32s32(int32_t a, int32_t b);
+
+/**
+ * \brief Integer divide of two unsigned 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return Quotient
+ */
+uint32_t div_u32u32(uint32_t a, uint32_t b);
+
+/**
+ * \brief Integer divide of two unsigned 32-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ */
+static inline uint32_t divmod_u32u32_rem(uint32_t a, uint32_t b, uint32_t *rem) {
+ divmod_result_t r = hw_divider_divmod_u32(a, b);
+ *rem = to_remainder_u32(r);
+ return to_quotient_u32(r);
+}
+
+/**
+ * \brief Integer divide of two unsigned 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in low word/r0, remainder in high word/r1
+ */
+divmod_result_t divmod_u32u32(uint32_t a, uint32_t b);
+
+/**
+ * \brief Integer divide of two signed 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return Quotient
+ */
+int64_t div_s64s64(int64_t a, int64_t b);
+
+/**
+ * \brief Integer divide of two signed 64-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ */
+int64_t divmod_s64s64_rem(int64_t a, int64_t b, int64_t *rem);
+
+/**
+ * \brief Integer divide of two signed 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in result (r0,r1), remainder in regs (r2, r3)
+ */
+int64_t divmod_s64s64(int64_t a, int64_t b);
+
+/**
+ * \brief Integer divide of two unsigned 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return Quotient
+ */
+uint64_t div_u64u64(uint64_t a, uint64_t b);
+
+/**
+ * \brief Integer divide of two unsigned 64-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ */
+uint64_t divmod_u64u64_rem(uint64_t a, uint64_t b, uint64_t *rem);
+
+
+/**
+ * \brief Integer divide of two signed 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in result (r0,r1), remainder in regs (r2, r3)
+ */
+uint64_t divmod_u64u64(uint64_t a, uint64_t b);
+
+// -----------------------------------------------------------------------
+// these "unsafe" functions are slightly faster, but do not save the divider state,
+// so are not generally safe to be called from interrupts
+// -----------------------------------------------------------------------
+
+/**
+ * \brief Unsafe integer divide of two signed 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient
+ *
+ * Do not use in interrupts
+ */
+int32_t div_s32s32_unsafe(int32_t a, int32_t b);
+
+/**
+ * \brief Unsafe integer divide of two signed 32-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ *
+ * Do not use in interrupts
+ */
+int32_t divmod_s32s32_rem_unsafe(int32_t a, int32_t b, int32_t *rem);
+
+/**
+ * \brief Unsafe integer divide of two unsigned 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in low word/r0, remainder in high word/r1
+ *
+ * Do not use in interrupts
+ */
+divmod_result_t divmod_s32s32_unsafe(int32_t a, int32_t b);
+
+/**
+ * \brief Unsafe integer divide of two unsigned 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return Quotient
+ *
+ * Do not use in interrupts
+ */
+uint32_t div_u32u32_unsafe(uint32_t a, uint32_t b);
+
+/**
+ * \brief Unsafe integer divide of two unsigned 32-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ *
+ * Do not use in interrupts
+ */
+uint32_t divmod_u32u32_rem_unsafe(uint32_t a, uint32_t b, uint32_t *rem);
+
+/**
+ * \brief Unsafe integer divide of two unsigned 32-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in low word/r0, remainder in high word/r1
+ *
+ * Do not use in interrupts
+ */
+divmod_result_t divmod_u32u32_unsafe(uint32_t a, uint32_t b);
+
+/**
+ * \brief Unsafe integer divide of two signed 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return Quotient
+ *
+ * Do not use in interrupts
+ */
+int64_t div_s64s64_unsafe(int64_t a, int64_t b);
+
+/**
+ * \brief Unsafe integer divide of two signed 64-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ *
+ * Do not use in interrupts
+ */
+int64_t divmod_s64s64_rem_unsafe(int64_t a, int64_t b, int64_t *rem);
+
+/**
+ * \brief Unsafe integer divide of two signed 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in result (r0,r1), remainder in regs (r2, r3)
+ *
+ * Do not use in interrupts
+ */
+int64_t divmod_s64s64_unsafe(int64_t a, int64_t b);
+
+/**
+ * \brief Unsafe integer divide of two unsigned 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return Quotient
+ *
+ * Do not use in interrupts
+ */
+uint64_t div_u64u64_unsafe(uint64_t a, uint64_t b);
+
+/**
+ * \brief Unsafe integer divide of two unsigned 64-bit values, with remainder
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \param [out] rem The remainder of dividend/divisor
+ * \return Quotient result of dividend/divisor
+ *
+ * Do not use in interrupts
+ */
+uint64_t divmod_u64u64_rem_unsafe(uint64_t a, uint64_t b, uint64_t *rem);
+
+/**
+ * \brief Unsafe integer divide of two signed 64-bit values
+ * \ingroup pico_divider
+ *
+ * \param a Dividend
+ * \param b Divisor
+ * \return quotient in result (r0,r1), remainder in regs (r2, r3)
+ *
+ * Do not use in interrupts
+ */
+uint64_t divmod_u64u64_unsafe(uint64_t a, uint64_t b);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/common/pico_stdlib/BUILD.bazel b/src/common/pico_stdlib/BUILD.bazel
deleted file mode 100644
index a332e1f..0000000
--- a/src/common/pico_stdlib/BUILD.bazel
+++ /dev/null
@@ -1,51 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-# This exists to break a header dependency cycle from rp2_common/pico_stdlib.
-# Do not directly depend on this.
-cc_library(
- name = "pico_stdlib_interface",
- hdrs = ["include/pico/stdlib.h"],
- includes = ["include"],
- visibility = [
- "//src/host/pico_stdio:__pkg__",
- "//src/host/pico_stdlib:__pkg__",
- "//src/rp2_common/pico_stdlib:__pkg__",
- "//src/rp2_common/tinyusb:__pkg__",
- ],
- deps = [
- "//src/common/pico_base",
- "//src/common/pico_time",
- ] + select({
- "//bazel/constraint:host": [
- "//src/host/hardware_gpio",
- "//src/host/hardware_uart",
- ],
- "//conditions:default": [
- "//src/rp2_common/hardware_gpio",
- "//src/rp2_common/hardware_uart",
- ],
- }),
-)
-
-cc_library(
- name = "pico_stdlib",
- hdrs = ["include/pico/stdlib.h"],
- includes = ["include"],
- deps = [
- "//src/common/pico_base",
- "//src/common/pico_time",
- ] + select({
- "//bazel/constraint:host": [
- "//src/host/hardware_gpio",
- "//src/host/hardware_uart",
- "//src/host/pico_stdio",
- "//src/host/pico_stdlib",
- ],
- "//conditions:default": [
- "//src/rp2_common/hardware_gpio",
- "//src/rp2_common/hardware_uart",
- "//src/rp2_common/pico_stdio",
- "//src/rp2_common/pico_stdlib",
- ],
- }),
-)
diff --git a/src/common/pico_stdlib/CMakeLists.txt b/src/common/pico_stdlib/CMakeLists.txt
deleted file mode 100644
index 7523d08..0000000
--- a/src/common/pico_stdlib/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-if (NOT TARGET pico_stdlib_headers)
- add_library(pico_stdlib_headers INTERFACE)
- target_include_directories(pico_stdlib_headers INTERFACE include)
- # dependencies handled in implementation CMakeLists.txt
-endif()
\ No newline at end of file
diff --git a/src/common/pico_stdlib/include/pico/stdlib.h b/src/common/pico_stdlib/include/pico/stdlib.h
deleted file mode 100644
index 1de172a..0000000
--- a/src/common/pico_stdlib/include/pico/stdlib.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_STDLIB_H
-#define _PICO_STDLIB_H
-
-#include "pico.h"
-#include "pico/stdio.h"
-#include "pico/time.h"
-#include "hardware/gpio.h"
-#include "hardware/uart.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** \file stdlib.h
- * \defgroup pico_stdlib pico_stdlib
- *
- * \brief Aggregation of a core subset of Raspberry Pi Pico SDK libraries used by most executables along with some additional
- * utility methods. Including pico_stdlib gives you everything you need to get a basic program running
- * which prints to stdout or flashes a LED
- *
- * This library aggregates:
- * - @ref hardware_uart
- * - @ref hardware_gpio
- * - @ref pico_binary_info
- * - @ref pico_runtime
- * - @ref pico_platform
- * - @ref pico_printf
- * - @ref pico_stdio
- * - @ref pico_standard_link
- * - @ref pico_util
- *
- * There are some basic default values used by these functions that will default to
- * usable values, however, they can be customised in a board definition header via
- * config.h or similar
- */
-
-// Note PICO_STDIO_UART, PICO_STDIO_USB, PICO_STDIO_SEMIHOSTING are set by the
-// respective INTERFACE libraries, so these defines are set if the library
-// is included for the target executable
-
-#if LIB_PICO_STDIO_UART
-#include "pico/stdio_uart.h"
-#endif
-
-#if LIB_PICO_STDIO_USB
-#include "pico/stdio_usb.h"
-#endif
-
-#if LIB_PICO_STDIO_SEMIHOSTING
-#include "pico/stdio_semihosting.h"
-#endif
-
-// PICO_CONFIG: PICO_DEFAULT_LED_PIN, Optionally define a pin that drives a regular LED on the board, group=pico_stdlib
-
-// PICO_CONFIG: PICO_DEFAULT_LED_PIN_INVERTED, 1 if LED is inverted or 0 if not, type=int, default=0, group=pico_stdlib
-#ifndef PICO_DEFAULT_LED_PIN_INVERTED
-#define PICO_DEFAULT_LED_PIN_INVERTED 0
-#endif
-
-// PICO_CONFIG: PICO_DEFAULT_WS2812_PIN, Optionally define a pin that controls data to a WS2812 compatible LED on the board, group=pico_stdlib
-// PICO_CONFIG: PICO_DEFAULT_WS2812_POWER_PIN, Optionally define a pin that controls power to a WS2812 compatible LED on the board, group=pico_stdlib
-
-/*! \brief Set up the default UART and assign it to the default GPIOs
- * \ingroup pico_stdlib
- *
- * By default this will use UART 0, with TX to pin GPIO 0,
- * RX to pin GPIO 1, and the baudrate to 115200
- *
- * Calling this method also initializes stdin/stdout over UART if the
- * @ref pico_stdio_uart library is linked.
- *
- * Defaults can be changed using configuration defines,
- * PICO_DEFAULT_UART_INSTANCE,
- * PICO_DEFAULT_UART_BAUD_RATE
- * PICO_DEFAULT_UART_TX_PIN
- * PICO_DEFAULT_UART_RX_PIN
- */
-void setup_default_uart(void);
-
-/*! \brief Initialise the system clock to 48MHz
- * \ingroup pico_stdlib
- *
- * Set the system clock to 48MHz, and set the peripheral clock to match.
- */
-void set_sys_clock_48mhz(void);
-
-/*! \brief Initialise the system clock
- * \ingroup pico_stdlib
- *
- * \param vco_freq The voltage controller oscillator frequency to be used by the SYS PLL
- * \param post_div1 The first post divider for the SYS PLL
- * \param post_div2 The second post divider for the SYS PLL.
- *
- * See the PLL documentation in the datasheet for details of driving the PLLs.
- */
-void set_sys_clock_pll(uint32_t vco_freq, uint post_div1, uint post_div2);
-
-/*! \brief Check if a given system clock frequency is valid/attainable
- * \ingroup pico_stdlib
- *
- * \param freq_khz Requested frequency
- * \param vco_freq_out On success, the voltage controlled oscillator frequency to be used by the SYS PLL
- * \param post_div1_out On success, The first post divider for the SYS PLL
- * \param post_div2_out On success, The second post divider for the SYS PLL.
- * @return true if the frequency is possible and the output parameters have been written.
- */
-bool check_sys_clock_khz(uint32_t freq_khz, uint *vco_freq_out, uint *post_div1_out, uint *post_div2_out);
-
-/*! \brief Attempt to set a system clock frequency in khz
- * \ingroup pico_stdlib
- *
- * Note that not all clock frequencies are possible; it is preferred that you
- * use src/rp2_common/hardware_clocks/scripts/vcocalc.py to calculate the parameters
- * for use with set_sys_clock_pll
- *
- * \param freq_khz Requested frequency
- * \param required if true then this function will assert if the frequency is not attainable.
- * \return true if the clock was configured
- */
-static inline bool set_sys_clock_khz(uint32_t freq_khz, bool required) {
- uint vco, postdiv1, postdiv2;
- if (check_sys_clock_khz(freq_khz, &vco, &postdiv1, &postdiv2)) {
- set_sys_clock_pll(vco, postdiv1, postdiv2);
- return true;
- } else if (required) {
- panic("System clock of %u kHz cannot be exactly achieved", freq_khz);
- }
- return false;
-}
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/common/pico_stdlib_headers/BUILD.bazel b/src/common/pico_stdlib_headers/BUILD.bazel
new file mode 100644
index 0000000..e20a656
--- /dev/null
+++ b/src/common/pico_stdlib_headers/BUILD.bazel
@@ -0,0 +1,16 @@
+package(default_visibility = ["//visibility:public"])
+
+# Use //host/pico_stdlib or //rp2_common/pico_stdlib to get the
+# implementation of this header, along with other critical defines headers.
+cc_library(
+ name = "pico_stdlib_headers",
+ hdrs = ["include/pico/stdlib.h"],
+ includes = ["include"],
+ visibility = [
+ "//src/host/pico_stdio:__pkg__",
+ "//src/host/pico_stdlib:__pkg__",
+ "//src/rp2_common/pico_stdio:__pkg__",
+ "//src/rp2_common/pico_stdlib:__pkg__",
+ "//src/rp2_common/tinyusb:__pkg__",
+ ],
+)
diff --git a/src/common/pico_stdlib_headers/CMakeLists.txt b/src/common/pico_stdlib_headers/CMakeLists.txt
new file mode 100644
index 0000000..a93257c
--- /dev/null
+++ b/src/common/pico_stdlib_headers/CMakeLists.txt
@@ -0,0 +1,5 @@
+if (NOT TARGET pico_stdlib_headers)
+ add_library(pico_stdlib_headers INTERFACE)
+ target_include_directories(pico_stdlib_headers SYSTEM INTERFACE include)
+ # dependencies handled in implementation CMakeLists.txt
+endif()
diff --git a/src/common/pico_stdlib_headers/include/pico/stdlib.h b/src/common/pico_stdlib_headers/include/pico/stdlib.h
new file mode 100644
index 0000000..811f565
--- /dev/null
+++ b/src/common/pico_stdlib_headers/include/pico/stdlib.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_STDLIB_H
+#define _PICO_STDLIB_H
+
+#include "pico.h"
+#include "pico/stdio.h"
+#include "pico/time.h"
+#include "hardware/gpio.h"
+#include "hardware/uart.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** \file stdlib.h
+ * \defgroup pico_stdlib pico_stdlib
+ *
+ * \brief Aggregation of a core subset of Raspberry Pi Pico SDK libraries used by most executables along with some additional
+ * utility methods
+ *
+ * Including pico_stdlib gives you everything you need to get a basic program running
+ * which prints to stdout or flashes a LED
+ *
+ * This library aggregates:
+ * - @ref hardware_divider
+ * - @ref hardware_gpio
+ * - @ref hardware_uart
+ * - @ref pico_runtime
+ * - @ref pico_platform
+ * - @ref pico_stdio
+ * - @ref pico_time
+ * - @ref pico_util
+ *
+ * There are some basic default values used by these functions that will default to
+ * usable values, however, they can be customised in a board definition header via
+ * config.h or similar
+ */
+
+// Note PICO_STDIO_UART, PICO_STDIO_USB, PICO_STDIO_SEMIHOSTING are set by the
+// respective INTERFACE libraries, so these defines are set if the library
+// is included for the target executable
+
+#if LIB_PICO_STDIO_UART
+#include "pico/stdio_uart.h"
+#endif
+
+#if LIB_PICO_STDIO_USB
+#include "pico/stdio_usb.h"
+#endif
+
+#if LIB_PICO_STDIO_SEMIHOSTING
+#include "pico/stdio_semihosting.h"
+#endif
+
+// PICO_CONFIG: PICO_DEFAULT_LED_PIN, Optionally define a pin that drives a regular LED on the board, default=Usually provided via board header, group=pico_stdlib
+
+// PICO_CONFIG: PICO_DEFAULT_LED_PIN_INVERTED, 1 if LED is inverted or 0 if not, type=int, default=0, group=pico_stdlib
+#ifndef PICO_DEFAULT_LED_PIN_INVERTED
+#define PICO_DEFAULT_LED_PIN_INVERTED 0
+#endif
+
+// PICO_CONFIG: PICO_DEFAULT_WS2812_PIN, Optionally define a pin that controls data to a WS2812 compatible LED on the board, group=pico_stdlib
+// PICO_CONFIG: PICO_DEFAULT_WS2812_POWER_PIN, Optionally define a pin that controls power to a WS2812 compatible LED on the board, group=pico_stdlib
+
+/*! \brief Set up the default UART and assign it to the default GPIOs
+ * \ingroup pico_stdlib
+ *
+ * By default this will use UART 0, with TX to pin GPIO 0,
+ * RX to pin GPIO 1, and the baudrate to 115200
+ *
+ * Calling this method also initializes stdin/stdout over UART if the
+ * @ref pico_stdio_uart library is linked.
+ *
+ * Defaults can be changed using configuration defines,
+ * PICO_DEFAULT_UART_INSTANCE,
+ * PICO_DEFAULT_UART_BAUD_RATE
+ * PICO_DEFAULT_UART_TX_PIN
+ * PICO_DEFAULT_UART_RX_PIN
+ */
+void setup_default_uart(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/common/pico_sync/BUILD.bazel b/src/common/pico_sync/BUILD.bazel
index 53c56b4..4b65e89 100644
--- a/src/common/pico_sync/BUILD.bazel
+++ b/src/common/pico_sync/BUILD.bazel
@@ -1,6 +1,24 @@
+load("@pico-sdk//bazel:defs.bzl", "incompatible_with_config")
+
package(default_visibility = ["//visibility:public"])
cc_library(
+ name = "pico_sync_headers",
+ hdrs = [
+ "include/pico/critical_section.h",
+ "include/pico/lock_core.h",
+ "include/pico/mutex.h",
+ "include/pico/sem.h",
+ "include/pico/sync.h",
+ ],
+ includes = ["include"],
+ visibility = [
+ "//src/rp2_common/hardware_sync:__pkg__",
+ "//src/rp2_common/hardware_sync_spin_lock:__pkg__",
+ ],
+)
+
+cc_library(
name = "pico_sync",
srcs = [
"critical_section.c",
@@ -8,23 +26,21 @@
"mutex.c",
"sem.c",
],
- hdrs = [
- "include/pico/critical_section.h",
- "include/pico/lock_core.h",
- "include/pico/mutex.h",
- "include/pico/sem.h",
- "include/pico/sync.h",
- ],
- includes = ["include"],
+ # valid_params_if() uses Statement Expressions, which aren't supported in MSVC.
+ target_compatible_with = incompatible_with_config("@rules_cc//cc/compiler:msvc-cl"),
deps = [
- "//src/common/pico_base:pico_base_interface",
+ ":pico_sync_headers",
+ "//src/common/pico_base_headers",
"//src/common/pico_time:pico_time_headers",
] + select({
"//bazel/constraint:host": [
"//src/host/hardware_sync",
+ "//src/host/pico_runtime",
],
"//conditions:default": [
"//src/rp2_common/hardware_sync",
+ "//src/rp2_common/hardware_sync_spin_lock",
+ "//src/rp2_common/pico_runtime_init",
],
}),
)
diff --git a/src/common/pico_sync/CMakeLists.txt b/src/common/pico_sync/CMakeLists.txt
index 05b969c..07e9291 100644
--- a/src/common/pico_sync/CMakeLists.txt
+++ b/src/common/pico_sync/CMakeLists.txt
@@ -7,7 +7,7 @@
if (NOT TARGET pico_sync)
pico_add_impl_library(pico_sync)
- target_include_directories(pico_sync_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ target_include_directories(pico_sync_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
pico_mirrored_target_link_libraries(pico_sync INTERFACE pico_sync_sem pico_sync_mutex pico_sync_critical_section pico_time hardware_sync)
endif()
diff --git a/src/common/pico_sync/critical_section.c b/src/common/pico_sync/critical_section.c
index 7cbb622..d51bf76 100644
--- a/src/common/pico_sync/critical_section.c
+++ b/src/common/pico_sync/critical_section.c
@@ -6,7 +6,7 @@
#include "pico/critical_section.h"
-#if !PICO_NO_HARDWARE
+#if PICO_32BIT
static_assert(sizeof(critical_section_t) == 8, "");
#endif
diff --git a/src/common/pico_sync/include/pico/lock_core.h b/src/common/pico_sync/include/pico/lock_core.h
index fbfa7cb..babd285 100644
--- a/src/common/pico_sync/include/pico/lock_core.h
+++ b/src/common/pico_sync/include/pico/lock_core.h
@@ -14,7 +14,7 @@
/** \file lock_core.h
* \defgroup lock_core lock_core
* \ingroup pico_sync
- * \brief base synchronization/lock primitive support
+ * \brief base synchronization/lock primitive support.
*
* Most of the pico_sync locking primitives contain a lock_core_t structure member. This currently just holds a spin
* lock which is used only to protect the contents of the rest of the structure as part of implementing the synchronization
@@ -34,7 +34,7 @@
* and those that notify, to wake a blocked task which isn't on processor. At least the wait macro implementation needs to be atomic with the protecting
* spin_lock unlock from the callers point of view; i.e. the task should unlock the spin lock when it starts its wait. Such implementation is
* up to the RTOS integration, however the macros are defined such that such operations are always combined into a single call
- * (so they can be perfomed atomically) even though the default implementation does not need this, as a WFE which starts
+ * (so they can be performed atomically) even though the default implementation does not need this, as a WFE which starts
* following the corresponding SEV is not missed.
*/
diff --git a/src/common/pico_sync/include/pico/mutex.h b/src/common/pico_sync/include/pico/mutex.h
index 75fa1ef..32eb7a0 100644
--- a/src/common/pico_sync/include/pico/mutex.h
+++ b/src/common/pico_sync/include/pico/mutex.h
@@ -44,7 +44,7 @@
/*! \brief recursive mutex instance
* \ingroup mutex
*/
-typedef struct __packed_aligned {
+typedef struct {
lock_core_t core;
lock_owner_id_t owner; //! owner id LOCK_INVALID_OWNER_ID for unowned
uint8_t enter_count; //! ownership count
@@ -57,7 +57,7 @@
* \ingroup mutex
*/
#if !PICO_MUTEX_ENABLE_SDK120_COMPATIBILITY
-typedef struct __packed_aligned mutex {
+typedef struct mutex {
lock_core_t core;
lock_owner_id_t owner; //! owner id LOCK_INVALID_OWNER_ID for unowned
} mutex_t;
@@ -305,6 +305,8 @@
*/
#define auto_init_recursive_mutex(name) static __attribute__((section(".mutex_array"))) recursive_mutex_t name = { .core = { .spin_lock = (spin_lock_t *)1 /* marker for runtime_init */ }, .owner = 0, .enter_count = 0 }
+void runtime_init_mutex(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/common/pico_sync/include/pico/sem.h b/src/common/pico_sync/include/pico/sem.h
index 9bb5731..832f149 100644
--- a/src/common/pico_sync/include/pico/sem.h
+++ b/src/common/pico_sync/include/pico/sem.h
@@ -28,7 +28,7 @@
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct __packed_aligned semaphore {
+typedef struct semaphore {
struct lock_core core;
int16_t permits;
int16_t max_permits;
diff --git a/src/common/pico_sync/mutex.c b/src/common/pico_sync/mutex.c
index 828be68..66e9476 100644
--- a/src/common/pico_sync/mutex.c
+++ b/src/common/pico_sync/mutex.c
@@ -6,6 +6,39 @@
#include "pico/mutex.h"
#include "pico/time.h"
+#include "pico/runtime_init.h"
+
+#if !PICO_RUNTIME_NO_INIT_MUTEX
+void __weak runtime_init_mutex(void) {
+ // this is an array of either mutex_t or recursive_mutex_t (i.e. not necessarily the same size)
+ // however each starts with a lock_core_t, and the spin_lock is initialized to address 1 for a recursive
+ // spinlock and 0 for a regular one.
+
+ static_assert(!(sizeof(mutex_t)&3), "");
+ static_assert(!(sizeof(recursive_mutex_t)&3), "");
+ static_assert(!offsetof(mutex_t, core), "");
+ static_assert(!offsetof(recursive_mutex_t, core), "");
+ extern lock_core_t __mutex_array_start;
+ extern lock_core_t __mutex_array_end;
+
+ for (lock_core_t *l = &__mutex_array_start; l < &__mutex_array_end; ) {
+ if (l->spin_lock) {
+ assert(1 == (uintptr_t)l->spin_lock); // indicator for a recursive mutex
+ recursive_mutex_t *rm = (recursive_mutex_t *)l;
+ recursive_mutex_init(rm);
+ l = &rm[1].core; // next
+ } else {
+ mutex_t *m = (mutex_t *)l;
+ mutex_init(m);
+ l = &m[1].core; // next
+ }
+ }
+}
+#endif
+
+#if defined(PICO_RUNTIME_INIT_MUTEX) && !PICO_RUNTIME_SKIP_INIT_MUTEX
+PICO_RUNTIME_INIT_FUNC_RUNTIME(runtime_init_mutex, PICO_RUNTIME_INIT_MUTEX);
+#endif
void mutex_init(mutex_t *mtx) {
lock_init(&mtx->core, next_striped_spin_lock_num());
diff --git a/src/common/pico_time/BUILD.bazel b/src/common/pico_time/BUILD.bazel
index b429dc5..acf8774 100644
--- a/src/common/pico_time/BUILD.bazel
+++ b/src/common/pico_time/BUILD.bazel
@@ -1,3 +1,5 @@
+load("@pico-sdk//bazel:defs.bzl", "incompatible_with_config")
+
package(default_visibility = ["//visibility:public"])
# This exists to break a dependency cycle between
@@ -10,8 +12,11 @@
"include/pico/timeout_helper.h",
],
includes = ["include"],
+ # invalid_params_if() uses Statement Expressions, which aren't supported in MSVC.
+ target_compatible_with = incompatible_with_config("@rules_cc//cc/compiler:msvc-cl"),
visibility = [
"//src/common/pico_sync:__pkg__",
+ "//src/host/pico_time_adapter:__pkg__",
"//src/rp2_common/tinyusb:__pkg__",
],
deps = select({
@@ -34,17 +39,29 @@
"include/pico/time.h",
"include/pico/timeout_helper.h",
],
+ # macOS defines __weak as part of Xcode, and the semantics are unfortunately
+ # different.
+ copts = select({
+ "@platforms//os:macos": ["-Wno-ignored-attributes"],
+ "//conditions:default": [],
+ }),
includes = ["include"],
deps = [
- "//src/common/pico_base:pico_base_interface",
+ "//src/common/pico_base_headers",
"//src/common/pico_sync",
"//src/common/pico_util",
] + select({
"//bazel/constraint:host": [
+ "//src/host/hardware_gpio",
"//src/host/hardware_timer",
+ "//src/host/pico_runtime",
+ "//src/host/pico_time_adapter",
],
"//conditions:default": [
+ "//src/rp2_common/hardware_gpio",
"//src/rp2_common/hardware_timer",
+ "//src/rp2_common/pico_runtime_init",
+ "//src/rp2_common/pico_time_adapter",
],
}),
)
diff --git a/src/common/pico_time/CMakeLists.txt b/src/common/pico_time/CMakeLists.txt
index 658b6b4..9cbe5dc 100644
--- a/src/common/pico_time/CMakeLists.txt
+++ b/src/common/pico_time/CMakeLists.txt
@@ -1,6 +1,6 @@
if (NOT TARGET pico_time_headers)
add_library(pico_time_headers INTERFACE)
- target_include_directories(pico_time_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ target_include_directories(pico_time_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(pico_time_headers INTERFACE hardware_timer_headers pico_sync_headers pico_util_headers)
endif()
diff --git a/src/common/pico_time/include/pico/time.h b/src/common/pico_time/include/pico/time.h
index 050cdcc..699523e 100644
--- a/src/common/pico_time/include/pico/time.h
+++ b/src/common/pico_time/include/pico/time.h
@@ -29,19 +29,24 @@
* \sa \ref hardware_timer
*/
-// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_TIME, Enable/disable assertions in the time module, type=bool, default=0, group=pico_time
-#ifndef PARAM_ASSERTIONS_ENABLED_TIME
-#define PARAM_ASSERTIONS_ENABLED_TIME 0
+// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_PICO_TIME, Enable/disable assertions in the pico_time module, type=bool, default=0, group=pico_time
+#ifndef PARAM_ASSERTIONS_ENABLED_PICO_TIME
+#ifdef PARAM_ASSERTIONS_ENABLED_PICO_TIME // backwards compatibility with SDK < 2.0.0
+#define PARAM_ASSERTIONS_ENABLED_PICO_TIME PARAM_ASSERTIONS_ENABLED_TIME
+#else
+#define PARAM_ASSERTIONS_ENABLED_PICO_TIME 0
+#endif
#endif
// PICO_CONFIG: PICO_TIME_SLEEP_OVERHEAD_ADJUST_US, How many microseconds to wake up early (and then busy_wait) to account for timer overhead when sleeping in low power mode, type=int, default=6, group=pico_time
#ifndef PICO_TIME_SLEEP_OVERHEAD_ADJUST_US
#define PICO_TIME_SLEEP_OVERHEAD_ADJUST_US 6
#endif
+
/*!
* \defgroup timestamp timestamp
* \ingroup pico_time
- * \brief Timestamp functions relating to points in time (including the current time)
+ * \brief Timestamp functions relating to points in time (including the current time).
*
* These are functions for dealing with timestamps (i.e. instants in time) represented by the type absolute_time_t. This opaque
* type is provided to help prevent accidental mixing of timestamps and relative time values.
@@ -291,9 +296,9 @@
* \brief Alarm functions for scheduling future execution
*
* Alarms are added to alarm pools, which may hold a certain fixed number of active alarms. Each alarm pool
- * utilizes one of four underlying hardware alarms, thus you may have up to four alarm pools. An alarm pool
+ * utilizes one of four underlying timer_alarms, thus you may have up to four alarm pools. An alarm pool
* calls (except when the callback would happen before or during being set) the callback on the core from which
- * the alarm pool was created. Callbacks are called from the hardware alarm IRQ handler, so care must
+ * the alarm pool was created. Callbacks are called from the timer_alarm IRQ handler, so care must
* be taken in their implementation.
*
* A default pool is created the core specified by PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM
@@ -306,7 +311,7 @@
// PICO_CONFIG: PICO_TIME_DEFAULT_ALARM_POOL_DISABLED, Disable the default alarm pool, type=bool, default=0, advanced=true, group=pico_time
#ifndef PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
/*!
- * \brief If 1 then the default alarm pool is disabled (so no hardware alarm is claimed for the pool)
+ * \brief If 1 then the default alarm pool is disabled (so no timer_alarm is claimed for the pool)
*
* \note Setting to 1 may cause some code not to compile as default timer pool related methods are removed
*
@@ -323,7 +328,7 @@
// PICO_CONFIG: PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM, Select which HW alarm is used for the default alarm pool, min=0, max=3, default=3, advanced=true, group=pico_time
#ifndef PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM
/*!
- * \brief Selects which hardware alarm is used for the default alarm pool
+ * \brief Selects which timer_alarm is used for the default alarm pool
* \ingroup alarm
* \sa alarm_pool_get_default()
*/
@@ -346,7 +351,7 @@
/**
* \brief The identifier for an alarm
*
- * \note this identifier is signed because -1 is used as an error condition when creating alarms
+ * \note this identifier is signed because <0 is used as an error condition when creating alarms
*
* \note alarm ids may be reused, however for convenience the implementation makes an attempt to defer
* reusing as long as possible. You should certainly expect it to be hundreds of ids before one is
@@ -354,9 +359,10 @@
* alarms or other functionality based on alarms when the alarm may have expired, as eventually
* the alarm id may be reused for another alarm.
*
+ * \see pico_error_codes
* \ingroup alarm
*/
-typedef int32_t alarm_id_t; // note this is signed because we use -1 as a meaningful error value
+typedef int32_t alarm_id_t; // note this is signed because we use <0 as a meaningful error value
/**
* \brief User alarm callback
@@ -370,12 +376,14 @@
typedef int64_t (*alarm_callback_t)(alarm_id_t id, void *user_data);
typedef struct alarm_pool alarm_pool_t;
+typedef void alarm_pool_timer_t;
/**
* \brief Create the default alarm pool (if not already created or disabled)
* \ingroup alarm
*/
void alarm_pool_init_default(void);
+void runtime_init_default_alarm_pool(void);
#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
/*!
@@ -388,6 +396,12 @@
alarm_pool_t *alarm_pool_get_default(void);
#endif
+alarm_pool_t *alarm_pool_create_on_timer(alarm_pool_timer_t *timer, uint timer_alarm_num, uint max_timers);
+
+alarm_pool_timer_t *alarm_pool_timer_for_timer_num(uint timer_num);
+
+alarm_pool_timer_t *alarm_pool_get_default_timer(void);
+
/**
* \brief Create an alarm pool
*
@@ -397,19 +411,23 @@
* might want to create another if you want alarm callbacks on core 1 or require alarm pools of
* different priority (IRQ priority based preemption of callbacks)
*
- * \note This method will hard assert if the hardware alarm is already claimed.
+ * \note This method will hard assert if the timer_alarm is already claimed.
*
* \ingroup alarm
- * \param hardware_alarm_num the hardware alarm to use to back this pool
+ * \param timer_alarm_num the timer_alarm to use to back this pool
* \param max_timers the maximum number of timers
* \note For implementation reasons this is limited to PICO_PHEAP_MAX_ENTRIES which defaults to 255
* \sa alarm_pool_get_default()
* \sa hardware_claiming
*/
-alarm_pool_t *alarm_pool_create(uint hardware_alarm_num, uint max_timers);
+static inline alarm_pool_t *alarm_pool_create(uint timer_alarm_num, uint max_timers) {
+ return alarm_pool_create_on_timer(alarm_pool_get_default_timer(), timer_alarm_num, max_timers);
+}
+
+alarm_pool_t *alarm_pool_create_on_timer_with_unused_hardware_alarm(alarm_pool_timer_t *timer, uint max_timers);
/**
- * \brief Create an alarm pool, claiming an used hardware alarm to back it.
+ * \brief Create an alarm pool, claiming an used timer_alarm to back it.
*
* The alarm pool will call callbacks from an alarm IRQ Handler on the core of this function is called from.
*
@@ -425,16 +443,21 @@
* \sa alarm_pool_get_default()
* \sa hardware_claiming
*/
-alarm_pool_t *alarm_pool_create_with_unused_hardware_alarm(uint max_timers);
+static inline alarm_pool_t *alarm_pool_create_with_unused_hardware_alarm(uint max_timers) {
+ return alarm_pool_create_on_timer_with_unused_hardware_alarm(alarm_pool_get_default_timer(), max_timers);
+}
/**
- * \brief Return the hardware alarm used by an alarm pool
+ * \brief Return the timer alarm used by an alarm pool
* \ingroup alarm
* \param pool the pool
- * \return the hardware alarm used by the pool
+ * \return the timer_alarm used by the pool
*/
-uint alarm_pool_hardware_alarm_num(alarm_pool_t *pool);
-
+uint alarm_pool_timer_alarm_num(alarm_pool_t *pool);
+// backwards compatibility
+static inline uint alarm_pool_hardware_alarm_num(alarm_pool_t *pool) {
+ return alarm_pool_timer_alarm_num(pool);
+}
/**
* \brief Return the core number the alarm pool was initialized on (and hence callbacks are called on)
* \ingroup alarm
@@ -444,7 +467,7 @@
uint alarm_pool_core_num(alarm_pool_t *pool);
/**
- * \brief Destroy the alarm pool, cancelling all alarms and freeing up the underlying hardware alarm
+ * \brief Destroy the alarm pool, cancelling all alarms and freeing up the underlying timer_alarm
* \ingroup alarm
* \param pool the pool
*/
@@ -461,17 +484,15 @@
*
* \note It is safe to call this method from an IRQ handler (including alarm callbacks), and from either core.
*
- * @param pool the alarm pool to use for scheduling the callback (this determines which hardware alarm is used, and which core calls the callback)
+ * @param pool the alarm pool to use for scheduling the callback (this determines which timer_alarm is used, and which core calls the callback)
* @param time the timestamp when (after which) the callback should fire
* @param callback the callback function
* @param user_data user data to pass to the callback function
* @param fire_if_past if true, and the alarm time falls before or during this call before the alarm can be set,
* then the callback should be called during (by) this function instead
* @return >0 the alarm id for an active (at the time of return) alarm
- * @return 0 if the alarm time passed before or during the call AND there is no active alarm to return the id of.
- * The latter can either happen because fire_if_past was false (i.e. no timer was ever created),
- * or if the callback <i>was</i> called during this method but the callback cancelled itself by returning 0
- * @return -1 if there were no alarm slots available
+ * @return 0 if the alarm time passed before or during the call and fire_if_past was false
+ * @return <0 if there were no alarm slots available, or other error occurred
*/
alarm_id_t alarm_pool_add_alarm_at(alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback, void *user_data, bool fire_if_past);
@@ -485,12 +506,12 @@
*
* \note It is safe to call this method from an IRQ handler (including alarm callbacks), and from either core.
*
- * @param pool the alarm pool to use for scheduling the callback (this determines which hardware alarm is used, and which core calls the callback)
+ * @param pool the alarm pool to use for scheduling the callback (this determines which timer_alarm is used, and which core calls the callback)
* @param time the timestamp when (after which) the callback should fire
* @param callback the callback function
* @param user_data user data to pass to the callback function
* @return >0 the alarm id for an active (at the time of return) alarm
- * @return -1 if there were no alarm slots available
+ * @return <0 if there were no alarm slots available, or other error occurred
*/
alarm_id_t alarm_pool_add_alarm_at_force_in_context(alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback,
void *user_data);
@@ -505,17 +526,15 @@
*
* \note It is safe to call this method from an IRQ handler (including alarm callbacks), and from either core.
*
- * @param pool the alarm pool to use for scheduling the callback (this determines which hardware alarm is used, and which core calls the callback)
+ * @param pool the alarm pool to use for scheduling the callback (this determines which timer_alarm is used, and which core calls the callback)
* @param us the delay (from now) in microseconds when (after which) the callback should fire
* @param callback the callback function
* @param user_data user data to pass to the callback function
* @param fire_if_past if true, and the alarm time falls during this call before the alarm can be set,
* then the callback should be called during (by) this function instead
* @return >0 the alarm id
- * @return 0 if the alarm time passed before or during the call AND there is no active alarm to return the id of.
- * The latter can either happen because fire_if_past was false (i.e. no timer was ever created),
- * or if the callback <i>was</i> called during this method but the callback cancelled itself by returning 0
- * @return -1 if there were no alarm slots available
+ * @return 0 if the alarm time passed before or during the call and fire_if_past was false
+ * @return <0 if there were no alarm slots available, or other error occurred
*/
static inline alarm_id_t alarm_pool_add_alarm_in_us(alarm_pool_t *pool, uint64_t us, alarm_callback_t callback, void *user_data, bool fire_if_past) {
return alarm_pool_add_alarm_at(pool, delayed_by_us(get_absolute_time(), us), callback, user_data, fire_if_past);
@@ -532,23 +551,45 @@
*
* \note It is safe to call this method from an IRQ handler (including alarm callbacks), and from either core.
*
- * @param pool the alarm pool to use for scheduling the callback (this determines which hardware alarm is used, and which core calls the callback)
+ * @param pool the alarm pool to use for scheduling the callback (this determines which timer_alarm is used, and which core calls the callback)
* @param ms the delay (from now) in milliseconds when (after which) the callback should fire
* @param callback the callback function
* @param user_data user data to pass to the callback function
* @param fire_if_past if true, and the alarm time falls before or during this call before the alarm can be set,
* then the callback should be called during (by) this function instead
* @return >0 the alarm id
- * @return 0 if the alarm time passed before or during the call AND there is no active alarm to return the id of.
- * The latter can either happen because fire_if_past was false (i.e. no timer was ever created),
- * or if the callback <i>was</i> called during this method but the callback cancelled itself by returning 0
- * @return -1 if there were no alarm slots available
+ * @return 0 if the alarm time passed before or during the call and fire_if_past was false
+ * @return <0 if there were no alarm slots available, or other error occurred
*/
static inline alarm_id_t alarm_pool_add_alarm_in_ms(alarm_pool_t *pool, uint32_t ms, alarm_callback_t callback, void *user_data, bool fire_if_past) {
return alarm_pool_add_alarm_at(pool, delayed_by_ms(get_absolute_time(), ms), callback, user_data, fire_if_past);
}
/*!
+ * \brief Return the time remaining before the next trigger of an alarm
+ * \ingroup alarm
+ *
+ * @param pool the alarm_pool containing the alarm
+ * @param alarm_id the alarm
+ *
+ * @return >=0 the number of microseconds before the next trigger
+ * @return <0 if either the given alarm is not in progress or it has passed
+ */
+int64_t alarm_pool_remaining_alarm_time_us(alarm_pool_t *pool, alarm_id_t alarm_id);
+
+/*!
+ * \brief Return the time remaining before the next trigger of an alarm
+ * \ingroup alarm
+ *
+ * @param pool the alarm_pool containing the alarm
+ * @param alarm_id the alarm
+ *
+ * @return >=0 the number of microseconds before the next trigger (INT32_MAX if the number of ms is higher than can be represented0
+ * @return <0 if either the given alarm is not in progress or it has passed
+ */
+int32_t alarm_pool_remaining_alarm_time_ms(alarm_pool_t *pool, alarm_id_t alarm_id);
+
+/*!
* \brief Cancel an alarm
* \ingroup alarm
* \param pool the alarm_pool containing the alarm
@@ -576,10 +617,8 @@
* @param fire_if_past if true, and the alarm time falls before or during this call before the alarm can be set,
* then the callback should be called during (by) this function instead
* @return >0 the alarm id
- * @return 0 if the alarm time passed before or during the call AND there is no active alarm to return the id of.
- * The latter can either happen because fire_if_past was false (i.e. no timer was ever created),
- * or if the callback <i>was</i> called during this method but the callback cancelled itself by returning 0
- * @return -1 if there were no alarm slots available
+ * @return 0 if the alarm time passed before or during the call and fire_if_past was false
+ * @return <0 if there were no alarm slots available, or other error occurred
*/
static inline alarm_id_t add_alarm_at(absolute_time_t time, alarm_callback_t callback, void *user_data, bool fire_if_past) {
return alarm_pool_add_alarm_at(alarm_pool_get_default(), time, callback, user_data, fire_if_past);
@@ -602,10 +641,8 @@
* @param fire_if_past if true, and the alarm time falls during this call before the alarm can be set,
* then the callback should be called during (by) this function instead
* @return >0 the alarm id
- * @return 0 if the alarm time passed before or during the call AND there is no active alarm to return the id of.
- * The latter can either happen because fire_if_past was false (i.e. no timer was ever created),
- * or if the callback <i>was</i> called during this method but the callback cancelled itself by returning 0
- * @return -1 if there were no alarm slots available
+ * @return 0 if the alarm time passed before or during the call and fire_if_past was false
+ * @return <0 if there were no alarm slots available, or other error occurred
*/
static inline alarm_id_t add_alarm_in_us(uint64_t us, alarm_callback_t callback, void *user_data, bool fire_if_past) {
return alarm_pool_add_alarm_in_us(alarm_pool_get_default(), us, callback, user_data, fire_if_past);
@@ -628,10 +665,8 @@
* @param fire_if_past if true, and the alarm time falls during this call before the alarm can be set,
* then the callback should be called during (by) this function instead
* @return >0 the alarm id
- * @return 0 if the alarm time passed before or during the call AND there is no active alarm to return the id of.
- * The latter can either happen because fire_if_past was false (i.e. no timer was ever created),
- * or if the callback <i>was</i> called during this method but the callback cancelled itself by returning 0
- * @return -1 if there were no alarm slots available
+ * @return 0 if the alarm time passed before or during the call and fire_if_past was false
+ * @return <0 if there were no alarm slots available, or other error occurred
*/
static inline alarm_id_t add_alarm_in_ms(uint32_t ms, alarm_callback_t callback, void *user_data, bool fire_if_past) {
return alarm_pool_add_alarm_in_ms(alarm_pool_get_default(), ms, callback, user_data, fire_if_past);
@@ -647,6 +682,29 @@
return alarm_pool_cancel_alarm(alarm_pool_get_default(), alarm_id);
}
+/*!
+ * \brief Return the time remaining before the next trigger of an alarm
+ * \ingroup alarm
+ *
+ * @param pool the alarm_pool containing the alarm
+ * @param alarm_id the alarm
+ *
+ * @return >=0 the number of microseconds before the next trigger
+ * @return <0 if either the given alarm is not in progress or it has passed
+ */
+int64_t remaining_alarm_time_us(alarm_id_t alarm_id);
+
+/*!
+ * \brief Return the time remaining before the next trigger of an alarm
+ * \ingroup alarm
+ *
+ * @param alarm_id the alarm
+ *
+ * @return >=0 the number of microseconds before the next trigger (INT32_MAX if the number of ms is higher than can be represented0
+ * @return <0 if either the given alarm is not in progress or it has passed
+ */
+int32_t remaining_alarm_time_ms(alarm_id_t alarm_id);
+
#endif
/*!
@@ -693,7 +751,7 @@
*
* \note It is safe to call this method from an IRQ handler (including alarm callbacks), and from either core.
*
- * @param pool the alarm pool to use for scheduling the repeating timer (this determines which hardware alarm is used, and which core calls the callback)
+ * @param pool the alarm pool to use for scheduling the repeating timer (this determines which timer_alarm is used, and which core calls the callback)
* @param delay_us the repeat delay in microseconds; if >0 then this is the delay between one callback ending and the next starting; if <0 then this is the negative of the time between the starts of the callbacks. The value of 0 is treated as 1
* @param callback the repeating timer callback function
* @param user_data user data to pass to store in the repeating_timer structure for use by the callback.
@@ -713,7 +771,7 @@
*
* \note It is safe to call this method from an IRQ handler (including alarm callbacks), and from either core.
*
- * @param pool the alarm pool to use for scheduling the repeating timer (this determines which hardware alarm is used, and which core calls the callback)
+ * @param pool the alarm pool to use for scheduling the repeating timer (this determines which timer_alarm is used, and which core calls the callback)
* @param delay_ms the repeat delay in milliseconds; if >0 then this is the delay between one callback ending and the next starting; if <0 then this is the negative of the time between the starts of the callbacks. The value of 0 is treated as 1 microsecond
* @param callback the repeating timer callback function
* @param user_data user data to pass to store in the repeating_timer structure for use by the callback.
diff --git a/src/common/pico_time/include/pico/timeout_helper.h b/src/common/pico_time/include/pico/timeout_helper.h
index e757f73..88de8d8 100644
--- a/src/common/pico_time/include/pico/timeout_helper.h
+++ b/src/common/pico_time/include/pico/timeout_helper.h
@@ -18,7 +18,7 @@
uint64_t param;
} timeout_state_t;
-typedef bool (*check_timeout_fn)(timeout_state_t *ts);
+typedef bool (*check_timeout_fn)(timeout_state_t *ts, bool reset);
check_timeout_fn init_single_timeout_until(timeout_state_t *ts, absolute_time_t target);
check_timeout_fn init_per_iteration_timeout_us(timeout_state_t *ts, uint64_t per_iteration_timeout_us);
diff --git a/src/common/pico_time/time.c b/src/common/pico_time/time.c
index d4511f4..118547d 100644
--- a/src/common/pico_time/time.c
+++ b/src/common/pico_time/time.c
@@ -4,205 +4,287 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <limits.h>
-#include <inttypes.h>
-#include <stdio.h>
#include <stdlib.h>
#include "pico.h"
#include "pico/time.h"
-#include "pico/util/pheap.h"
#include "pico/sync.h"
+#include "pico/runtime_init.h"
const absolute_time_t ABSOLUTE_TIME_INITIALIZED_VAR(nil_time, 0);
const absolute_time_t ABSOLUTE_TIME_INITIALIZED_VAR(at_the_end_of_time, INT64_MAX);
typedef struct alarm_pool_entry {
- absolute_time_t target;
+ // next entry link or -1
+ int16_t next;
+ // low 15 bits are a sequence number used in the low word of the alarm_id so that
+ // the alarm_id for this entry only repeats every 32767 adds (note this value is never zero)
+ // the top bit is a cancellation flag.
+ volatile uint16_t sequence;
+ int64_t target;
alarm_callback_t callback;
void *user_data;
} alarm_pool_entry_t;
struct alarm_pool {
- pheap_t *heap;
+ uint8_t timer_alarm_num;
+ uint8_t core_num;
+ // this is protected by the lock (threads allocate from it, and the IRQ handler adds back to it)
+ int16_t free_head;
+ // this is protected by the lock (threads add to it, the IRQ handler removes from it)
+ volatile int16_t new_head;
+ volatile bool has_pending_cancellations;
+
+ // this is owned by the IRQ handler so doesn't need additional locking
+ int16_t ordered_head;
+ uint16_t num_entries;
+ alarm_pool_timer_t *timer;
spin_lock_t *lock;
alarm_pool_entry_t *entries;
- // one byte per entry, used to provide more longevity to public IDs than heap node ids do
- // (this is increment every time the heap node id is re-used)
- uint8_t *entry_ids_high;
- alarm_id_t alarm_in_progress; // this is set during a callback from the IRQ handler... it can be cleared by alarm_cancel to prevent repeats
- uint8_t hardware_alarm_num;
- uint8_t core_num;
};
#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
// To avoid bringing in calloc, we statically allocate the arrays and the heap
-PHEAP_DEFINE_STATIC(default_alarm_pool_heap, PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS);
static alarm_pool_entry_t default_alarm_pool_entries[PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS];
-static uint8_t default_alarm_pool_entry_ids_high[PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS];
-static lock_core_t sleep_notifier;
static alarm_pool_t default_alarm_pool = {
- .heap = &default_alarm_pool_heap,
.entries = default_alarm_pool_entries,
- .entry_ids_high = default_alarm_pool_entry_ids_high,
};
static inline bool default_alarm_pool_initialized(void) {
return default_alarm_pool.lock != NULL;
}
+
+static lock_core_t sleep_notifier;
#endif
-static alarm_pool_t *pools[NUM_TIMERS];
-static void alarm_pool_post_alloc_init(alarm_pool_t *pool, uint hardware_alarm_num);
+#include "pico/time_adapter.h"
+static alarm_pool_t *pools[TA_NUM_TIMERS][TA_NUM_TIMER_ALARMS];
-static inline alarm_pool_entry_t *get_entry(alarm_pool_t *pool, pheap_node_id_t id) {
- assert(id && id <= pool->heap->max_nodes);
- return pool->entries + id - 1;
+static void alarm_pool_post_alloc_init(alarm_pool_t *pool, alarm_pool_timer_t *timer, uint hardware_alarm_num, uint max_timers);
+
+static inline int16_t alarm_index(alarm_id_t id) {
+ return (int16_t)(id >> 16);
}
-static inline uint8_t *get_entry_id_high(alarm_pool_t *pool, pheap_node_id_t id) {
- assert(id && id <= pool->heap->max_nodes);
- return pool->entry_ids_high + id - 1;
+static inline uint16_t alarm_sequence(alarm_id_t id) {
+ return (uint16_t)id;
}
-bool timer_pool_entry_comparator(void *user_data, pheap_node_id_t a, pheap_node_id_t b) {
- alarm_pool_t *pool = (alarm_pool_t *)user_data;
- return to_us_since_boot(get_entry(pool, a)->target) < to_us_since_boot(get_entry(pool, b)->target);
+static alarm_id_t make_alarm_id(int index, uint16_t counter) {
+ return index << 16 | counter;
}
-static inline alarm_id_t make_public_id(uint8_t id_high, pheap_node_id_t id) {
- return (alarm_id_t)(((uint)id_high << 8u * sizeof(id)) | id);
-}
-
-void alarm_pool_init_default() {
+#if !PICO_RUNTIME_NO_INIT_DEFAULT_ALARM_POOL
+void __weak runtime_init_default_alarm_pool(void) {
#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
// allow multiple calls for ease of use from host tests
if (!default_alarm_pool_initialized()) {
- ph_post_alloc_init(default_alarm_pool.heap, PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS,
- timer_pool_entry_comparator, &default_alarm_pool);
- hardware_alarm_claim(PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM);
+ alarm_pool_timer_t *timer = alarm_pool_get_default_timer();
+ ta_hardware_alarm_claim(timer, PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM);
alarm_pool_post_alloc_init(&default_alarm_pool,
- PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM);
+ timer,
+ PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM,
+ PICO_TIME_DEFAULT_ALARM_POOL_MAX_TIMERS);
}
lock_init(&sleep_notifier, PICO_SPINLOCK_ID_TIMER);
#endif
}
+#endif
+
+void alarm_pool_init_default(void) {
+ runtime_init_default_alarm_pool();
+}
#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
-alarm_pool_t *alarm_pool_get_default() {
+alarm_pool_t *alarm_pool_get_default(void) {
assert(default_alarm_pool_initialized());
return &default_alarm_pool;
}
+
+#if defined(PICO_RUNTIME_INIT_DEFAULT_ALARM_POOL) && !PICO_RUNTIME_SKIP_INIT_DEFAULT_ALARM_POOL
+PICO_RUNTIME_INIT_FUNC_RUNTIME(runtime_init_default_alarm_pool, PICO_RUNTIME_INIT_DEFAULT_ALARM_POOL);
+#endif
#endif
-static pheap_node_id_t add_alarm_under_lock(alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback,
- void *user_data, pheap_node_id_t reuse_id, bool create_if_past, bool *missed) {
- pheap_node_id_t id;
- if (reuse_id) {
- assert(!ph_contains_node(pool->heap, reuse_id));
- id = reuse_id;
- } else {
- id = ph_new_node(pool->heap);
+// note the timer is created with IRQs on this core
+alarm_pool_t *alarm_pool_create_on_timer(alarm_pool_timer_t *timer, uint hardware_alarm_num, uint max_timers) {
+ alarm_pool_t *pool = (alarm_pool_t *) malloc(sizeof(alarm_pool_t));
+ if (pool) {
+ pool->entries = (alarm_pool_entry_t *) calloc(max_timers, sizeof(alarm_pool_entry_t));
+ ta_hardware_alarm_claim(timer, hardware_alarm_num);
+ alarm_pool_post_alloc_init(pool, timer, hardware_alarm_num, max_timers);
}
- if (id) {
- alarm_pool_entry_t *entry = get_entry(pool, id);
- entry->target = time;
- entry->callback = callback;
- entry->user_data = user_data;
- if (id == ph_insert_node(pool->heap, id)) {
- bool is_missed = hardware_alarm_set_target(pool->hardware_alarm_num, time);
- if (is_missed && !create_if_past) {
- ph_remove_and_free_node(pool->heap, id);
- }
- if (missed) *missed = is_missed;
- }
- }
- return id;
+ return pool;
}
-static void alarm_pool_alarm_callback(uint alarm_num) {
- // note this is called from timer IRQ handler
- alarm_pool_t *pool = pools[alarm_num];
- bool again;
+alarm_pool_t *alarm_pool_create_on_timer_with_unused_hardware_alarm(alarm_pool_timer_t *timer, uint max_timers) {
+ alarm_pool_t *pool = (alarm_pool_t *) malloc(sizeof(alarm_pool_t));
+ if (pool) {
+ pool->entries = (alarm_pool_entry_t *) calloc(max_timers, sizeof(alarm_pool_entry_t));
+ alarm_pool_post_alloc_init(pool, timer, (uint) ta_hardware_alarm_claim_unused(timer, true), max_timers);
+ }
+ return pool;
+}
+
+static void alarm_pool_irq_handler(void);
+
+// marker which we can use in place of handler function to indicate we are a repeating timer
+
+#define repeating_timer_marker ((alarm_callback_t)alarm_pool_irq_handler)
+#include "hardware/gpio.h"
+static void alarm_pool_irq_handler(void) {
+ // This IRQ handler does the main work, as it always (assuming the IRQ hasn't been enabled on both cores
+ // which is unsupported) run on the alarm pool's core, and can't be preempted by itself, meaning
+ // that it doesn't need locks except to protect against linked list access
+ uint timer_alarm_num;
+ alarm_pool_timer_t *timer = ta_from_current_irq(&timer_alarm_num);
+ uint timer_num = ta_timer_num(timer);
+ alarm_pool_t *pool = pools[timer_num][timer_alarm_num];
+ assert(pool->timer_alarm_num == timer_alarm_num);
+ int64_t now = (int64_t) ta_time_us_64(timer);
+ int64_t earliest_target;
+ // 1. clear force bits if we were forced (do this outside the loop, as forcing is hopefully rare)
+ ta_clear_force_irq(timer, timer_alarm_num);
do {
- absolute_time_t now = get_absolute_time();
- alarm_callback_t callback = NULL;
- absolute_time_t target = nil_time;
- void *user_data = NULL;
- uint8_t id_high;
- again = false;
- uint32_t save = spin_lock_blocking(pool->lock);
- pheap_node_id_t next_id = ph_peek_head(pool->heap);
- if (next_id) {
- alarm_pool_entry_t *entry = get_entry(pool, next_id);
- if (absolute_time_diff_us(now, entry->target) <= 0) {
- // we don't free the id in case we need to re-add the timer
- pheap_node_id_t __unused removed_id = ph_remove_head(pool->heap, false);
- assert(removed_id == next_id); // will be true under lock
- target = entry->target;
- callback = entry->callback;
- user_data = entry->user_data;
- assert(callback);
- id_high = *get_entry_id_high(pool, next_id);
- pool->alarm_in_progress = make_public_id(id_high, removed_id);
- } else {
- if (hardware_alarm_set_target(alarm_num, entry->target)) {
- again = true;
+ // 2. clear the IRQ if it was fired
+ ta_clear_irq(timer, timer_alarm_num);
+ // 3. we look at the earliest existing alarm first; the reasoning here is that we
+ // don't want to delay an existing callback because a later one is added, and
+ // if both are due now, then we have a race anyway (but we prefer to fire existing
+ // timers before new ones anyway.
+ int16_t earliest_index = pool->ordered_head;
+ // by default, we loop if there was any event pending (we will mark it false
+ // later if there is no work to do)
+ if (earliest_index >= 0) {
+ alarm_pool_entry_t *earliest_entry = &pool->entries[earliest_index];
+ earliest_target = earliest_entry->target;
+ if ((now - earliest_target) >= 0) {
+ // time to call the callback now (or in the past)
+ // note that an entry->target of < 0 means the entry has been canceled (not this is set
+ // by this function, in response to the entry having been queued by the cancel_alarm API
+ // meaning that we don't need to worry about tearing of the 64 bit value)
+ int64_t delta;
+ if (earliest_target >= 0) {
+ // special case repeating timer without making another function call which adds overhead
+ if (earliest_entry->callback == repeating_timer_marker) {
+ repeating_timer_t *rpt = (repeating_timer_t *)earliest_entry->user_data;
+ delta = rpt->callback(rpt) ? rpt->delay_us : 0;
+ } else {
+ alarm_id_t id = make_alarm_id(pool->ordered_head, earliest_entry->sequence);
+ delta = earliest_entry->callback(id, earliest_entry->user_data);
+ }
+ } else {
+ // negative target means cancel alarm
+ delta = 0;
+ }
+ if (delta) {
+ int64_t next_time;
+ if (delta < 0) {
+ // delta is (positive) delta from last fire time
+ next_time = earliest_target - delta;
+ } else {
+ // delta is relative to now
+ next_time = (int64_t) ta_time_us_64(timer) + delta;
+ }
+ earliest_entry->target = next_time;
+ // need to re-add, unless we are the only entry or already at the front
+ if (earliest_entry->next >= 0 && next_time - pool->entries[earliest_entry->next].target >= 0) {
+ // unlink this item
+ pool->ordered_head = earliest_entry->next;
+ int16_t *prev = &pool->ordered_head;
+ // find insertion point; note >= as if we add a new item for the same time as another, then it follows
+ while (*prev >= 0 && (next_time - pool->entries[*prev].target) >= 0) {
+ prev = &pool->entries[*prev].next;
+ }
+ earliest_entry->next = *prev;
+ *prev = earliest_index;
+ }
+ } else {
+ // need to remove the item
+ pool->ordered_head = earliest_entry->next;
+ // and add it back to the free list (under lock)
+ uint32_t save = spin_lock_blocking(pool->lock);
+ earliest_entry->next = pool->free_head;
+ pool->free_head = earliest_index;
+ spin_unlock(pool->lock, save);
}
}
}
- spin_unlock(pool->lock, save);
- if (callback) {
- int64_t repeat = callback(make_public_id(id_high, next_id), user_data);
- save = spin_lock_blocking(pool->lock);
- // todo think more about whether we want to keep calling
- if (repeat < 0 && pool->alarm_in_progress) {
- assert(pool->alarm_in_progress == make_public_id(id_high, next_id));
- add_alarm_under_lock(pool, delayed_by_us(target, (uint64_t)-repeat), callback, user_data, next_id, true, NULL);
- } else if (repeat > 0 && pool->alarm_in_progress) {
- assert(pool->alarm_in_progress == make_public_id(id_high, next_id));
- add_alarm_under_lock(pool, delayed_by_us(get_absolute_time(), (uint64_t)repeat), callback, user_data, next_id,
- true, NULL);
- } else {
- // need to return the id to the heap
- ph_free_node(pool->heap, next_id);
- (*get_entry_id_high(pool, next_id))++; // we bump it for next use of id
- }
- pool->alarm_in_progress = 0;
+ // if we have any new alarms, add them to the ordered list
+ if (pool->new_head >= 0) {
+ uint32_t save = spin_lock_blocking(pool->lock);
+ // must re-read new head under lock
+ int16_t new_index = pool->new_head;
+ // clear the list
+ pool->new_head = -1;
spin_unlock(pool->lock, save);
- again = true;
+ // insert each of the new items
+ while (new_index >= 0) {
+ alarm_pool_entry_t *new_entry = &pool->entries[new_index];
+ int64_t new_entry_time = new_entry->target;
+ int16_t *prev = &pool->ordered_head;
+ // find insertion point; note >= as if we add a new item for the same time as another, then it follows
+ while (*prev >= 0 && (new_entry_time - pool->entries[*prev].target) >= 0) {
+ prev = &pool->entries[*prev].next;
+ }
+ int16_t next = *prev;
+ *prev = new_index;
+ new_index = new_entry->next;
+ new_entry->next = next;
+ }
}
- } while (again);
+ // if we have any canceled alarms, then mark them for removal by setting their due time to -1 (which will
+ // cause them to be handled the next time round and removed)
+ if (pool->has_pending_cancellations) {
+ pool->has_pending_cancellations = false;
+ __compiler_memory_barrier();
+ int16_t *prev = &pool->ordered_head;
+ // set target for canceled items to -1, and move to front of the list
+ for(int16_t index = pool->ordered_head; index != -1; ) {
+ alarm_pool_entry_t *entry = &pool->entries[index];
+ int16_t next = entry->next;
+ if ((int16_t)entry->sequence < 0) {
+ // mark for deletion
+ entry->target = -1;
+ if (index != pool->ordered_head) {
+ // move to start of queue
+ *prev = entry->next;
+ entry->next = pool->ordered_head;
+ pool->ordered_head = index;
+ }
+ } else {
+ prev = &entry->next;
+ }
+ index = next;
+ }
+ }
+ now = (int64_t) ta_time_us_64(timer);
+ earliest_index = pool->ordered_head;
+ if (earliest_index < 0) break;
+ // need to wait
+ alarm_pool_entry_t *earliest_entry = &pool->entries[earliest_index];
+ earliest_target = earliest_entry->target;
+ ta_set_timeout(timer, timer_alarm_num, earliest_target);
+ // check we haven't now past the target time; if not we don't want to loop again
+ } while ((earliest_target - now) <= 0);
}
-// note the timer is create with IRQs on this core
-alarm_pool_t *alarm_pool_create(uint hardware_alarm_num, uint max_timers) {
- alarm_pool_t *pool = (alarm_pool_t *) malloc(sizeof(alarm_pool_t));
- pool->heap = ph_create(max_timers, timer_pool_entry_comparator, pool);
- pool->entries = (alarm_pool_entry_t *)calloc(max_timers, sizeof(alarm_pool_entry_t));
- pool->entry_ids_high = (uint8_t *)calloc(max_timers, sizeof(uint8_t));
- hardware_alarm_claim(hardware_alarm_num);
- alarm_pool_post_alloc_init(pool, hardware_alarm_num);
- return pool;
-}
-
-alarm_pool_t *alarm_pool_create_with_unused_hardware_alarm(uint max_timers) {
- alarm_pool_t *pool = (alarm_pool_t *) malloc(sizeof(alarm_pool_t));
- pool->heap = ph_create(max_timers, timer_pool_entry_comparator, pool);
- pool->entries = (alarm_pool_entry_t *)calloc(max_timers, sizeof(alarm_pool_entry_t));
- pool->entry_ids_high = (uint8_t *)calloc(max_timers, sizeof(uint8_t));
- alarm_pool_post_alloc_init(pool, (uint)hardware_alarm_claim_unused(true));
- return pool;
-}
-
-void alarm_pool_post_alloc_init(alarm_pool_t *pool, uint hardware_alarm_num) {
- hardware_alarm_cancel(hardware_alarm_num);
- hardware_alarm_set_callback(hardware_alarm_num, alarm_pool_alarm_callback);
+void alarm_pool_post_alloc_init(alarm_pool_t *pool, alarm_pool_timer_t *timer, uint hardware_alarm_num, uint max_timers) {
+ pool->timer = timer;
pool->lock = spin_lock_instance(next_striped_spin_lock_num());
- pool->hardware_alarm_num = (uint8_t) hardware_alarm_num;
+ pool->timer_alarm_num = (uint8_t) hardware_alarm_num;
+ invalid_params_if(PICO_TIME, max_timers > 65536);
+ pool->num_entries = (uint16_t)max_timers;
pool->core_num = (uint8_t) get_core_num();
- pools[hardware_alarm_num] = pool;
+ pool->new_head = pool->ordered_head = -1;
+ pool->free_head = (int16_t)(max_timers - 1);
+ for(uint i=0;i<max_timers;i++) {
+ pool->entries[i].next = (int16_t)(i-1);
+ }
+ pools[ta_timer_num(timer)][hardware_alarm_num] = pool;
+
+ ta_enable_irq_handler(timer, hardware_alarm_num, alarm_pool_irq_handler);
}
void alarm_pool_destroy(alarm_pool_t *pool) {
@@ -212,164 +294,85 @@
return;
}
#endif
- assert(pools[pool->hardware_alarm_num] == pool);
- pools[pool->hardware_alarm_num] = NULL;
- // todo clear out timers
- ph_destroy(pool->heap);
- hardware_alarm_set_callback(pool->hardware_alarm_num, NULL);
- hardware_alarm_unclaim(pool->hardware_alarm_num);
- free(pool->entry_ids_high);
+ ta_disable_irq_handler(pool->timer, pool->timer_alarm_num, alarm_pool_irq_handler);
+ assert(pools[ta_timer_num(pool->timer)][pool->timer_alarm_num] == pool);
+ pools[ta_timer_num(pool->timer)][pool->timer_alarm_num] = NULL;
free(pool->entries);
free(pool);
}
alarm_id_t alarm_pool_add_alarm_at(alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback,
void *user_data, bool fire_if_past) {
- bool missed = false;
-
- alarm_id_t public_id;
- do {
- uint8_t id_high = 0;
- uint32_t save = spin_lock_blocking(pool->lock);
-
- pheap_node_id_t id = add_alarm_under_lock(pool, time, callback, user_data, 0, false, &missed);
- if (id) id_high = *get_entry_id_high(pool, id);
-
- spin_unlock(pool->lock, save);
-
- if (!id) {
- // no space in pheap to allocate an alarm
- return -1;
- }
-
- // note that if missed was true, then the id was never added to the pheap (because we
- // passed false for create_if_past arg above)
- public_id = missed ? 0 : make_public_id(id_high, id);
- if (missed && fire_if_past) {
- // ... so if fire_if_past == true we call the callback
- int64_t repeat = callback(public_id, user_data);
- // if not repeated we have no id to return so set public_id to 0,
- // otherwise we need to repeat, but will assign a new id next time
- // todo arguably this does mean that the id passed to the first callback may differ from subsequent calls
- if (!repeat) {
- public_id = 0;
- break;
- } else if (repeat < 0) {
- time = delayed_by_us(time, (uint64_t)-repeat);
- } else {
- time = delayed_by_us(get_absolute_time(), (uint64_t)repeat);
- }
- } else {
- // either:
- // a) missed == false && public_id is > 0
- // b) missed == true && fire_if_past == false && public_id = 0
- // but we are done in either case
- break;
- }
- } while (true);
- return public_id;
+ if (!fire_if_past) {
+ absolute_time_t t = get_absolute_time();
+ if (absolute_time_diff_us(t, time) < 0) return 0;
+ }
+ return alarm_pool_add_alarm_at_force_in_context(pool, time, callback, user_data);
}
alarm_id_t alarm_pool_add_alarm_at_force_in_context(alarm_pool_t *pool, absolute_time_t time, alarm_callback_t callback,
void *user_data) {
- bool missed = false;
-
- uint8_t id_high = 0;
+ // ---- take a free pool entry
uint32_t save = spin_lock_blocking(pool->lock);
-
- pheap_node_id_t id = add_alarm_under_lock(pool, time, callback, user_data, 0, true, &missed);
- if (id) id_high = *get_entry_id_high(pool, id);
- spin_unlock(pool->lock, save);
- if (!id) return -1;
- if (missed) {
- // we want to fire the timer forcibly because it is in the past. Note that we do
- // not care about racing with other timers, as it is harmless to have the IRQ
- // wake up one time too many, we just need to make sure it does wake up
- hardware_alarm_force_irq(pool->hardware_alarm_num);
+ int16_t index = pool->free_head;
+ alarm_pool_entry_t *entry = &pool->entries[index];
+ if (index >= 0) {
+ // remove from free list
+ pool->free_head = entry->next;
}
- return make_public_id(id_high, id);
+ spin_unlock(pool->lock, save);
+ if (index < 0) return PICO_ERROR_GENERIC; // PICO_ERROR_INSUFFICIENT_RESOURCES - not using to preserve previous -1 return code
+
+ // ---- initialize the pool entry
+ entry->callback = callback;
+ entry->user_data = user_data;
+ entry->target = (int64_t)to_us_since_boot(time);
+ uint16_t next_sequence = (entry->sequence + 1) & 0x7fff;
+ if (!next_sequence) next_sequence = 1; // zero is not allowed
+ entry->sequence = next_sequence;
+ alarm_id_t id = make_alarm_id(index, next_sequence);
+
+ // ---- and add it to the new list
+ save = spin_lock_blocking(pool->lock);
+ entry->next = pool->new_head;
+ pool->new_head = index;
+ spin_unlock(pool->lock, save);
+
+ // force the IRQ
+ ta_force_irq(pool->timer, pool->timer_alarm_num);
+ return id;
}
bool alarm_pool_cancel_alarm(alarm_pool_t *pool, alarm_id_t alarm_id) {
- if (!alarm_id) return false;
- bool rc = false;
+ int16_t index = alarm_index(alarm_id);
+ if (index >= pool->num_entries) return false;
+ uint16_t sequence = alarm_sequence(alarm_id);
+ bool canceled = false;
+ alarm_pool_entry_t *entry = &pool->entries[index];
uint32_t save = spin_lock_blocking(pool->lock);
- pheap_node_id_t id = (pheap_node_id_t) alarm_id;
- if (ph_contains_node(pool->heap, id)) {
- assert(alarm_id != pool->alarm_in_progress); // it shouldn't be in the heap if it is in progress
- // check we have the right high value
- uint8_t id_high = (uint8_t)((uint)alarm_id >> 8u * sizeof(pheap_node_id_t));
- if (id_high == *get_entry_id_high(pool, id)) {
- rc = ph_remove_and_free_node(pool->heap, id);
- // note we don't bother to remove the actual hardware alarm timeout...
- // it will either do callbacks or not depending on other alarms, and reset the next timeout itself
- assert(rc);
- }
- } else {
- if (alarm_id == pool->alarm_in_progress) {
- // make sure the alarm doesn't repeat
- pool->alarm_in_progress = 0;
- }
+ // note this will not be true if the entry is already canceled (as the entry->sequence
+ // will have the top bit set)
+ uint current_sequence = entry->sequence;
+ if (sequence == current_sequence) {
+ entry->sequence = (uint16_t)(current_sequence | 0x8000);
+ __compiler_memory_barrier();
+ pool->has_pending_cancellations = true;
+ canceled = true;
}
spin_unlock(pool->lock, save);
- return rc;
+ // force the IRQ if we need to clean up an alarm id
+ if (canceled) ta_force_irq(pool->timer, pool->timer_alarm_num);
+ return canceled;
}
-uint alarm_pool_hardware_alarm_num(alarm_pool_t *pool) {
- return pool->hardware_alarm_num;
+uint alarm_pool_timer_alarm_num(alarm_pool_t *pool) {
+ return pool->timer_alarm_num;
}
uint alarm_pool_core_num(alarm_pool_t *pool) {
return pool->core_num;
}
-static void alarm_pool_dump_key(pheap_node_id_t id, void *user_data) {
- alarm_pool_t *pool = (alarm_pool_t *)user_data;
-#if PICO_ON_DEVICE
- printf("%lld (hi %02x)", to_us_since_boot(get_entry(pool, id)->target), *get_entry_id_high(pool, id));
-#else
- printf("%"PRIu64, to_us_since_boot(get_entry(pool, id)->target));
-#endif
-}
-
-static int64_t repeating_timer_callback(__unused alarm_id_t id, void *user_data) {
- repeating_timer_t *rt = (repeating_timer_t *)user_data;
- if (rt->callback(rt)) {
- return rt->delay_us;
- } else {
- rt->alarm_id = 0;
- return 0;
- }
-}
-
-bool alarm_pool_add_repeating_timer_us(alarm_pool_t *pool, int64_t delay_us, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out) {
- if (!delay_us) delay_us = 1;
- out->pool = pool;
- out->callback = callback;
- out->delay_us = delay_us;
- out->user_data = user_data;
- out->alarm_id = alarm_pool_add_alarm_at(pool, make_timeout_time_us((uint64_t)(delay_us >= 0 ? delay_us : -delay_us)),
- repeating_timer_callback, out, true);
- // note that if out->alarm_id is 0, then the callback was called during the above call (fire_if_past == true)
- // and then the callback removed itself.
- return out->alarm_id >= 0;
-}
-
-bool cancel_repeating_timer(repeating_timer_t *timer) {
- bool rc = false;
- if (timer->alarm_id) {
- rc = alarm_pool_cancel_alarm(timer->pool, timer->alarm_id);
- timer->alarm_id = 0;
- }
- return rc;
-}
-
-void alarm_pool_dump(alarm_pool_t *pool) {
- uint32_t save = spin_lock_blocking(pool->lock);
- ph_dump(pool->heap, alarm_pool_dump_key, pool);
- spin_unlock(pool->lock, save);
-}
-
#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
static int64_t sleep_until_callback(__unused alarm_id_t id, __unused void *user_data) {
uint32_t save = spin_lock_blocking(sleep_notifier.spin_lock);
@@ -419,7 +422,7 @@
absolute_time_t t = make_timeout_time_us(us - PICO_TIME_SLEEP_OVERHEAD_ADJUST_US);
sync_internal_yield_until_before(t);
- // then wait the rest of thw way
+ // then wait the rest of the way
busy_wait_until(t);
}
#endif
@@ -441,7 +444,18 @@
tight_loop_contents();
return time_reached(timeout_timestamp);
} else {
+ // the above alarm add now may force an IRQ which will wake us up,
+ // so we want to consume one __wfe.. we do an explicit __sev
+ // just to make sure there is one
+ __sev(); // make sure there is an event sow ee don't block
__wfe();
+ if (!time_reached(timeout_timestamp))
+ {
+ // ^ at the point above the timer hadn't fired, so it is safe
+ // to wait; the event will happen due to IRQ at some point between
+ // then and the correct wakeup time
+ __wfe();
+ }
// we need to clean up if it wasn't us that caused the wfe; if it was this will be a noop.
cancel_alarm(id);
return time_reached(timeout_timestamp);
@@ -452,3 +466,75 @@
return time_reached(timeout_timestamp);
#endif
}
+
+bool alarm_pool_add_repeating_timer_us(alarm_pool_t *pool, int64_t delay_us, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out) {
+ if (!delay_us) delay_us = 1;
+ out->pool = pool;
+ out->callback = callback;
+ out->delay_us = delay_us;
+ out->user_data = user_data;
+ out->alarm_id = alarm_pool_add_alarm_at(pool, make_timeout_time_us((uint64_t)(delay_us >= 0 ? delay_us : -delay_us)),
+ repeating_timer_marker, out, true);
+ return out->alarm_id > 0;
+}
+
+bool cancel_repeating_timer(repeating_timer_t *timer) {
+ bool rc = false;
+ if (timer->alarm_id) {
+ rc = alarm_pool_cancel_alarm(timer->pool, timer->alarm_id);
+ timer->alarm_id = 0;
+ }
+ return rc;
+}
+
+alarm_pool_timer_t *alarm_pool_timer_for_timer_num(uint timer_num) {
+ return ta_timer_instance(timer_num);
+}
+
+alarm_pool_timer_t *alarm_pool_get_default_timer(void) {
+ return ta_default_timer_instance();
+}
+
+int64_t alarm_pool_remaining_alarm_time_us(alarm_pool_t *pool, alarm_id_t alarm_id) {
+ // note there is no point distinguishing between invalid alarm_id and timer passed,
+ // since an alarm_id that has fired without being re-enabled becomes logically invalid after
+ // that point anyway
+ int64_t rc = -1;
+ int16_t index = alarm_index(alarm_id);
+ if ((uint16_t)index < pool->num_entries) {
+ uint16_t sequence = alarm_sequence(alarm_id);
+ alarm_pool_entry_t *entry = &pool->entries[index];
+ if (entry->sequence == sequence) {
+ uint32_t save = spin_lock_blocking(pool->lock);
+ int16_t search_index = pool->ordered_head;
+ while (search_index >= 0) {
+ entry = &pool->entries[search_index];
+ if (index == search_index) {
+ if (entry->sequence == sequence) {
+ rc = entry->target - (int64_t) ta_time_us_64(pool->timer);
+ }
+ break;
+ }
+ search_index = entry->next;
+ }
+ spin_unlock(pool->lock, save);
+ }
+ }
+ return rc;
+}
+
+int32_t alarm_pool_remaining_alarm_time_ms(alarm_pool_t *pool, alarm_id_t alarm_id) {
+ int64_t rc = alarm_pool_remaining_alarm_time_us(pool, alarm_id);
+ if (rc >= 0) rc /= 1000;
+ return rc >= INT32_MAX ? INT32_MAX : (int32_t) rc;
+}
+
+#if !PICO_TIME_DEFAULT_ALARM_POOL_DISABLED
+int64_t remaining_alarm_time_us(alarm_id_t alarm_id) {
+ return alarm_pool_remaining_alarm_time_us(alarm_pool_get_default(), alarm_id);
+}
+
+int32_t remaining_alarm_time_ms(alarm_id_t alarm_id) {
+ return alarm_pool_remaining_alarm_time_ms(alarm_pool_get_default(), alarm_id);
+}
+#endif
\ No newline at end of file
diff --git a/src/common/pico_time/timeout_helper.c b/src/common/pico_time/timeout_helper.c
index d9abe5a..3f22457 100644
--- a/src/common/pico_time/timeout_helper.c
+++ b/src/common/pico_time/timeout_helper.c
@@ -6,7 +6,7 @@
#include "pico/timeout_helper.h"
-static bool check_single_timeout_us(timeout_state_t *ts) {
+static bool check_single_timeout_us(timeout_state_t *ts, __unused bool reset) {
return time_reached(ts->next_timeout);
}
@@ -15,11 +15,13 @@
return check_single_timeout_us;
}
-static bool check_per_iteration_timeout_us(timeout_state_t *ts) {
+static bool check_per_iteration_timeout_us(timeout_state_t *ts, bool reset) {
+ if (reset) {
+ ts->next_timeout = make_timeout_time_us(ts->param);
+ }
if (time_reached(ts->next_timeout)) {
return true;
}
- ts->next_timeout = make_timeout_time_us(ts->param);
return false;
}
@@ -27,4 +29,4 @@
ts->next_timeout = make_timeout_time_us(per_iteration_timeout_us);
ts->param = per_iteration_timeout_us;
return check_per_iteration_timeout_us;
-}
+}
\ No newline at end of file
diff --git a/src/common/pico_usb_reset_interface/BUILD.bazel b/src/common/pico_usb_reset_interface/BUILD.bazel
deleted file mode 100644
index 14f4a34..0000000
--- a/src/common/pico_usb_reset_interface/BUILD.bazel
+++ /dev/null
@@ -1,7 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-cc_library(
- name = "pico_usb_reset_interface",
- hdrs = ["include/pico/usb_reset_interface.h"],
- includes = ["include"],
-)
diff --git a/src/common/pico_usb_reset_interface/CMakeLists.txt b/src/common/pico_usb_reset_interface/CMakeLists.txt
deleted file mode 100644
index 7d2b4e7..0000000
--- a/src/common/pico_usb_reset_interface/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# don't use pico_add_library here as picotool includes it directly
-add_library(pico_usb_reset_interface_headers INTERFACE)
-add_library(pico_usb_reset_interface INTERFACE)
-target_link_libraries(pico_usb_reset_interface INTERFACE pico_usb_reset_interface_headers)
-
-target_include_directories(pico_usb_reset_interface_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/src/common/pico_usb_reset_interface/include/pico/usb_reset_interface.h b/src/common/pico_usb_reset_interface/include/pico/usb_reset_interface.h
deleted file mode 100644
index 908ec0c..0000000
--- a/src/common/pico_usb_reset_interface/include/pico/usb_reset_interface.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef _PICO_USB_RESET_INTERFACE_H
-#define _PICO_USB_RESET_INTERFACE_H
-
-/** \file usb_reset_interface.h
- * \defgroup pico_usb_reset_interface pico_usb_reset_interface
- *
- * \brief Definition for the reset interface that may be exposed by the pico_stdio_usb library
- */
-
-// VENDOR sub-class for the reset interface
-#define RESET_INTERFACE_SUBCLASS 0x00
-// VENDOR protocol for the reset interface
-#define RESET_INTERFACE_PROTOCOL 0x01
-
-// CONTROL requests:
-
-// reset to BOOTSEL
-#define RESET_REQUEST_BOOTSEL 0x01
-// regular flash boot
-#define RESET_REQUEST_FLASH 0x02
-
-#endif
\ No newline at end of file
diff --git a/src/common/pico_usb_reset_interface_headers/BUILD.bazel b/src/common/pico_usb_reset_interface_headers/BUILD.bazel
new file mode 100644
index 0000000..880792d
--- /dev/null
+++ b/src/common/pico_usb_reset_interface_headers/BUILD.bazel
@@ -0,0 +1,7 @@
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "pico_usb_reset_interface_headers",
+ hdrs = ["include/pico/usb_reset_interface.h"],
+ includes = ["include"],
+)
diff --git a/src/common/pico_usb_reset_interface_headers/CMakeLists.txt b/src/common/pico_usb_reset_interface_headers/CMakeLists.txt
new file mode 100644
index 0000000..6be755e
--- /dev/null
+++ b/src/common/pico_usb_reset_interface_headers/CMakeLists.txt
@@ -0,0 +1,6 @@
+# don't use pico_add_library here as picotool includes it directly
+add_library(pico_usb_reset_interface_headers INTERFACE)
+add_library(pico_usb_reset_interface INTERFACE)
+target_link_libraries(pico_usb_reset_interface INTERFACE pico_usb_reset_interface_headers)
+
+target_include_directories(pico_usb_reset_interface_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
diff --git a/src/common/pico_usb_reset_interface_headers/include/pico/usb_reset_interface.h b/src/common/pico_usb_reset_interface_headers/include/pico/usb_reset_interface.h
new file mode 100644
index 0000000..d5269ec
--- /dev/null
+++ b/src/common/pico_usb_reset_interface_headers/include/pico/usb_reset_interface.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2021 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _PICO_USB_RESET_INTERFACE_H
+#define _PICO_USB_RESET_INTERFACE_H
+
+/** \file usb_reset_interface.h
+ * \defgroup pico_usb_reset_interface_headers pico_usb_reset_interface_headers
+ *
+ * \brief Definition for the reset interface that may be exposed by the pico_stdio_usb library
+ */
+
+// VENDOR sub-class for the reset interface
+#define RESET_INTERFACE_SUBCLASS 0x00
+// VENDOR protocol for the reset interface
+#define RESET_INTERFACE_PROTOCOL 0x01
+
+// CONTROL requests:
+
+// reset to BOOTSEL
+#define RESET_REQUEST_BOOTSEL 0x01
+// regular flash boot
+#define RESET_REQUEST_FLASH 0x02
+
+#endif
\ No newline at end of file
diff --git a/src/common/pico_util/BUILD.bazel b/src/common/pico_util/BUILD.bazel
index 7eed87a..6ee64a3 100644
--- a/src/common/pico_util/BUILD.bazel
+++ b/src/common/pico_util/BUILD.bazel
@@ -1,3 +1,5 @@
+load("@pico-sdk//bazel:defs.bzl", "incompatible_with_config")
+
package(default_visibility = ["//visibility:public"])
cc_library(
@@ -13,8 +15,10 @@
"include/pico/util/queue.h",
],
includes = ["include"],
+ # invalid_params_if() uses Statement Expressions, which aren't supported in MSVC.
+ target_compatible_with = incompatible_with_config("@rules_cc//cc/compiler:msvc-cl"),
deps = [
- "//src/common/pico_base:pico_base_interface",
+ "//src/common/pico_base_headers",
"//src/common/pico_sync",
] + select({
"//bazel/constraint:host": [
diff --git a/src/common/pico_util/CMakeLists.txt b/src/common/pico_util/CMakeLists.txt
index 3a4d7cd..86921dd 100644
--- a/src/common/pico_util/CMakeLists.txt
+++ b/src/common/pico_util/CMakeLists.txt
@@ -1,6 +1,6 @@
if (NOT TARGET pico_util_headers)
add_library(pico_util_headers INTERFACE)
- target_include_directories(pico_util_headers INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+ target_include_directories(pico_util_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(pico_util_headers INTERFACE pico_base_headers hardware_sync_headers)
endif()
diff --git a/src/common/pico_util/datetime.c b/src/common/pico_util/datetime.c
index e035515..c113ce4 100644
--- a/src/common/pico_util/datetime.c
+++ b/src/common/pico_util/datetime.c
@@ -2,6 +2,7 @@
#include <stdio.h>
+#if PICO_INCLUDE_RTC_DATETIME
static const char *DATETIME_MONTHS[12] = {
"January",
"February",
@@ -38,4 +39,57 @@
t->min,
t->sec,
t->year);
-};
\ No newline at end of file
+};
+
+
+bool time_to_datetime(time_t time, datetime_t *dt) {
+ struct tm local;
+ if (localtime_r(&time, &local)) {
+ dt->year = (int16_t) (local.tm_year + 1900); // 0..4095
+ dt->month = (int8_t) (local.tm_mon + 1); // 1..12, 1 is January
+ dt->day = (int8_t) local.tm_mday; // 1..28,29,30,31 depending on month
+ dt->dotw = (int8_t) local.tm_wday; // 0..6, 0 is Sunday
+ dt->hour = (int8_t) local.tm_hour; // 0..23
+ dt->min = (int8_t) local.tm_min; // 0..59
+ dt->sec = (int8_t) local.tm_sec; // 0..59
+ return true;
+ }
+ return false;
+}
+
+bool datetime_to_time(const datetime_t *dt, time_t *time) {
+ struct tm local;
+ local.tm_year = dt->year - 1900;
+ local.tm_mon = dt->month - 1;
+ local.tm_mday = dt->day;
+ local.tm_hour = dt->hour;
+ local.tm_min = dt->min;
+ local.tm_sec = dt->sec;
+ *time = mktime(&local);
+ return *time >= 0;
+}
+
+#endif
+
+uint64_t timespec_to_ms(const struct timespec *ts) {
+ int64_t rc = ts->tv_sec * 1000;
+ rc += ts->tv_nsec / 1000000;
+ return (uint64_t) rc;
+}
+
+void ms_to_timespec(uint64_t ms, struct timespec *ts) {
+ ts->tv_sec = (time_t)((int64_t)ms / 1000);
+ ts->tv_nsec = ((long)((int64_t)ms % 1000)) * 1000000;
+}
+
+uint64_t timespec_to_us(const struct timespec *ts) {
+ int64_t rc = ts->tv_sec * 1000000;
+ rc += ts->tv_nsec / 1000;
+ return (uint64_t) rc;
+}
+
+void us_to_timespec(uint64_t ms, struct timespec *ts) {
+ ts->tv_sec = (time_t)((int64_t)ms / 1000000);
+ ts->tv_nsec = ((long)((int64_t)ms % 1000000)) * 1000;
+}
+
diff --git a/src/common/pico_util/include/pico/util/datetime.h b/src/common/pico_util/include/pico/util/datetime.h
index a897f6e..92e6d64 100644
--- a/src/common/pico_util/include/pico/util/datetime.h
+++ b/src/common/pico_util/include/pico/util/datetime.h
@@ -19,6 +19,9 @@
* \ingroup pico_util
*/
+#if PICO_INCLUDE_RTC_DATETIME
+#include <time.h>
+
/*! \brief Convert a datetime_t structure to a string
* \ingroup util_datetime
*
@@ -28,6 +31,16 @@
*/
void datetime_to_str(char *buf, uint buf_size, const datetime_t *t);
+bool time_to_datetime(time_t time, datetime_t *dt);
+bool datetime_to_time(const datetime_t *dt, time_t *time);
+#endif
+
+#include <sys/time.h>
+uint64_t timespec_to_ms(const struct timespec *ts);
+uint64_t timespec_to_us(const struct timespec *ts);
+void ms_to_timespec(uint64_t ms, struct timespec *ts);
+void us_to_timespec(uint64_t ms, struct timespec *ts);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/common/pico_util/include/pico/util/queue.h b/src/common/pico_util/include/pico/util/queue.h
index 2822985..998b434 100644
--- a/src/common/pico_util/include/pico/util/queue.h
+++ b/src/common/pico_util/include/pico/util/queue.h
@@ -17,7 +17,7 @@
/** \file queue.h
* \defgroup queue queue
- * \brief Multi-core and IRQ safe queue implementation.
+ * \brief Multi-core and IRQ safe queue implementation
*
* Note that this queue stores values of a specified size, and pushed values are copied into the queue
* \ingroup pico_util
@@ -169,7 +169,7 @@
* \ingroup queue
*
* \param q Pointer to a queue_t structure, used as a handle
- * \param data Pointer to the location to receive the removed value
+ * \param data Pointer to the location to receive the removed value, or NULL if the data isn't required
* \return true if a value was removed
*
* If the queue is not empty function will copy the removed value into the location provided and return
@@ -181,7 +181,7 @@
* \ingroup queue
*
* \param q Pointer to a queue_t structure, used as a handle
- * \param data Pointer to the location to receive the peeked value
+ * \param data Pointer to the location to receive the peeked value, or NULL if the data isn't required
* \return true if there was a value to peek
*
* If the queue is not empty this function will return immediately with true with the peeked entry
@@ -205,7 +205,7 @@
* \ingroup queue
*
* \param q Pointer to a queue_t structure, used as a handle
- * \param data Pointer to the location to receive the removed value
+ * \param data Pointer to the location to receive the removed value, or NULL if the data isn't required
*
* If the queue is empty this function will block until a value is added.
*/
@@ -215,7 +215,7 @@
* \ingroup queue
*
* \param q Pointer to a queue_t structure, used as a handle
- * \param data Pointer to the location to receive the peeked value
+ * \param data Pointer to the location to receive the peeked value, or NULL if the data isn't required
*
* If the queue is empty function will block until a value is added
*/
diff --git a/src/common/pico_util/queue.c b/src/common/pico_util/queue.c
index a5c8e18..9209407 100644
--- a/src/common/pico_util/queue.c
+++ b/src/common/pico_util/queue.c
@@ -63,7 +63,9 @@
do {
uint32_t save = spin_lock_blocking(q->core.spin_lock);
if (queue_get_level_unsafe(q) != 0) {
- memcpy(data, element_ptr(q, q->rptr), q->element_size);
+ if (data) {
+ memcpy(data, element_ptr(q, q->rptr), q->element_size);
+ }
q->rptr = inc_index(q, q->rptr);
lock_internal_spin_unlock_with_notify(&q->core, save);
return true;
@@ -81,7 +83,9 @@
do {
uint32_t save = spin_lock_blocking(q->core.spin_lock);
if (queue_get_level_unsafe(q) != 0) {
- memcpy(data, element_ptr(q, q->rptr), q->element_size);
+ if (data) {
+ memcpy(data, element_ptr(q, q->rptr), q->element_size);
+ }
lock_internal_spin_unlock_with_notify(&q->core, save);
return true;
}
diff --git a/src/host.cmake b/src/host.cmake
index 5a3f358..3399866 100644
--- a/src/host.cmake
+++ b/src/host.cmake
@@ -1,10 +1,40 @@
-# For targeting the host for testing purposes
+set(CMAKE_DIR cmake)
+set(COMMON_DIR common)
+set(HOST_DIR host)
-function(pico_add_extra_outputs TARGET)
-endfunction()
+include (${CMAKE_DIR}/no_hardware.cmake)
-set(PICO_NO_HARDWARE "1" CACHE INTERNAL "")
-set(PICO_ON_DEVICE "0" CACHE INTERNAL "")
-add_subdirectory(common)
-add_subdirectory(host)
\ No newline at end of file
+# common
+ pico_add_subdirectory(${COMMON_DIR}/boot_picobin_headers)
+ pico_add_subdirectory(${COMMON_DIR}/boot_picoboot_headers)
+ pico_add_subdirectory(${COMMON_DIR}/boot_uf2_headers)
+ pico_add_subdirectory(${COMMON_DIR}/pico_base_headers)
+ pico_add_subdirectory(${COMMON_DIR}/pico_usb_reset_interface_headers)
+ pico_add_subdirectory(${COMMON_DIR}/pico_bit_ops_headers)
+ pico_add_subdirectory(${COMMON_DIR}/pico_binary_info)
+ pico_add_subdirectory(${COMMON_DIR}/pico_divider_headers)
+ pico_add_subdirectory(${COMMON_DIR}/pico_sync)
+ pico_add_subdirectory(${COMMON_DIR}/pico_time)
+ pico_add_subdirectory(${COMMON_DIR}/pico_util)
+ pico_add_subdirectory(${COMMON_DIR}/pico_stdlib_headers)
+
+# host-specific
+ pico_add_subdirectory(${HOST_DIR}/hardware_divider)
+ pico_add_subdirectory(${HOST_DIR}/hardware_gpio)
+ pico_add_subdirectory(${HOST_DIR}/hardware_sync)
+ pico_add_subdirectory(${HOST_DIR}/hardware_timer)
+ pico_add_subdirectory(${HOST_DIR}/hardware_uart)
+ pico_add_subdirectory(${HOST_DIR}/pico_bit_ops)
+ pico_add_subdirectory(${HOST_DIR}/pico_divider)
+ pico_add_subdirectory(${HOST_DIR}/pico_multicore)
+ pico_add_subdirectory(${HOST_DIR}/pico_platform)
+ pico_add_subdirectory(${HOST_DIR}/pico_runtime)
+ pico_add_subdirectory(${HOST_DIR}/pico_printf)
+ pico_add_subdirectory(${HOST_DIR}/pico_stdio)
+ pico_add_subdirectory(${HOST_DIR}/pico_stdlib)
+ pico_add_subdirectory(${HOST_DIR}/pico_time_adapter)
+
+unset(CMAKE_DIR)
+unset(COMMON_DIR)
+unset(HOST_DIR)
\ No newline at end of file
diff --git a/src/host/BUILD.bazel b/src/host/BUILD.bazel
new file mode 100644
index 0000000..6dbf955
--- /dev/null
+++ b/src/host/BUILD.bazel
@@ -0,0 +1,8 @@
+package(default_visibility = ["//visibility:public"])
+
+# This is currently unused in Bazel.
+cc_binary(
+ name = "boot_stage2",
+ srcs = ["boot_stage2.c"],
+ target_compatible_with = ["//bazel/constraint:host"],
+)
diff --git a/src/host/CMakeLists.txt b/src/host/CMakeLists.txt
deleted file mode 100644
index 9edcd7b..0000000
--- a/src/host/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-pico_add_subdirectory(hardware_divider)
-pico_add_subdirectory(hardware_gpio)
-pico_add_subdirectory(hardware_sync)
-pico_add_subdirectory(hardware_timer)
-pico_add_subdirectory(hardware_uart)
-pico_add_subdirectory(pico_bit_ops)
-pico_add_subdirectory(pico_divider)
-pico_add_subdirectory(pico_multicore)
-pico_add_subdirectory(pico_platform)
-pico_add_subdirectory(pico_printf)
-pico_add_subdirectory(pico_stdio)
-pico_add_subdirectory(pico_stdlib)
-
-pico_add_doxygen(${CMAKE_CURRENT_LIST_DIR})
-
-macro(pico_set_float_implementation TARGET IMPL)
- # ignore
-endmacro()
-
-macro(pico_set_double_implementation TARGET IMPL)
- # ignore
-endmacro()
-
-macro(pico_set_binary_type TARGET IMPL)
- # ignore
-endmacro()
-
-macro(pico_set_boot_stage2 TARGET IMPL)
- # ignore
-endmacro()
-
-set(PICO_HOST_DIR "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "")
-function(pico_define_boot_stage2 NAME)
- add_executable(${NAME} ${PICO_HOST_DIR}/boot_stage2.c)
-endfunction()
-
-pico_promote_common_scope_vars()
\ No newline at end of file
diff --git a/src/host/README.md b/src/host/README.md
index c6d8962..cc2c1f9 100644
--- a/src/host/README.md
+++ b/src/host/README.md
@@ -3,7 +3,7 @@
It is selected by `PICO_PLATFORM=host` in your CMake build
This can be extremely useful for testing and debugging higher level application code, or porting code which is not yet small enough
-to run on the RP2040 device itself.
+to run on the RP2040 or RP2350 device itself.
This base level host library provides a minimal environment to compile programs, but is likely sufficient for programs
that don't access hardware directly.
diff --git a/src/host/boot_stage2.c b/src/host/boot_stage2.c
index 52794b1..704dacc 100644
--- a/src/host/boot_stage2.c
+++ b/src/host/boot_stage2.c
@@ -1,3 +1,3 @@
-void main() {
+int main() {
}
\ No newline at end of file
diff --git a/src/host/hardware_divider/BUILD.bazel b/src/host/hardware_divider/BUILD.bazel
index 3548f1b..023340b 100644
--- a/src/host/hardware_divider/BUILD.bazel
+++ b/src/host/hardware_divider/BUILD.bazel
@@ -6,5 +6,5 @@
hdrs = ["include/hardware/divider.h"],
includes = ["include"],
target_compatible_with = ["//bazel/constraint:host"],
- deps = ["//src/common/pico_base"],
+ deps = ["//src/host/pico_platform"],
)
diff --git a/src/host/hardware_divider/include/hardware/divider.h b/src/host/hardware_divider/include/hardware/divider.h
index 0a6eccc..6e546ea 100644
--- a/src/host/hardware_divider/include/hardware/divider.h
+++ b/src/host/hardware_divider/include/hardware/divider.h
@@ -22,11 +22,11 @@
/*! \brief Do an unsigned HW divide and wait for result
* \ingroup hardware_divider
*
- * Divide \p a by \p b, wait for calculation to complete, return result as a pair of 32-bit quotient/remainder values.
+ * Divide \p a by \p b, wait for calculation to complete, return result as a fixed point 32p32 value.
*
* \param a The dividend
* \param b The divisor
- * \return Results of divide as a pair of 32-bit quotient/remainder values.
+ * \return Results of divide as a 32p32 fixed point value.
*/
static inline divmod_result_t hw_divider_divmod_u32(uint32_t a, uint32_t b) {
if (!b) return (((uint64_t)a)<<32u) | (uint32_t)(-1); // todo check this
@@ -36,11 +36,11 @@
/*! \brief Do a signed HW divide and wait for result
* \ingroup hardware_divider
*
- * Divide \p a by \p b, wait for calculation to complete, return result as a pair of 32-bit quotient/remainder values.
+ * Divide \p a by \p b, wait for calculation to complete, return result as a fixed point 32p32 value.
*
* \param a The dividend
* \param b The divisor
- * \return Results of divide as a pair of 32-bit quotient/remainder values.
+ * \return Results of divide as a 32p32 fixed point value.
*/
static inline divmod_result_t hw_divider_divmod_s32(int32_t a, int32_t b) {
if (!b) return (((uint64_t)a)<<32u) | (uint32_t)(-__sign_of(a));
@@ -108,7 +108,7 @@
/*! \brief Efficient extraction of unsigned quotient from 32p32 fixed point
* \ingroup hardware_divider
*
- * \param r A pair of 32-bit quotient/remainder values.
+ * \param r 32p32 fixed point value.
* \return Unsigned quotient
*/
inline static uint32_t to_quotient_u32(divmod_result_t r) {
@@ -118,7 +118,7 @@
/*! \brief Efficient extraction of signed quotient from 32p32 fixed point
* \ingroup hardware_divider
*
- * \param r A pair of 32-bit quotient/remainder values.
+ * \param r 32p32 fixed point value.
* \return Unsigned quotient
*/
inline static int32_t to_quotient_s32(divmod_result_t r) {
@@ -128,7 +128,7 @@
/*! \brief Efficient extraction of unsigned remainder from 32p32 fixed point
* \ingroup hardware_divider
*
- * \param r A pair of 32-bit quotient/remainder values.
+ * \param r 32p32 fixed point value.
* \return Unsigned remainder
*
* \note On Arm this is just a 32 bit register move or a nop
@@ -140,7 +140,7 @@
/*! \brief Efficient extraction of signed remainder from 32p32 fixed point
* \ingroup hardware_divider
*
- * \param r A pair of 32-bit quotient/remainder values.
+ * \param r 32p32 fixed point value.
* \return Signed remainder
*
* \note On arm this is just a 32 bit register move or a nop
diff --git a/src/host/hardware_gpio/BUILD.bazel b/src/host/hardware_gpio/BUILD.bazel
index 816ebb4..29c13aa 100644
--- a/src/host/hardware_gpio/BUILD.bazel
+++ b/src/host/hardware_gpio/BUILD.bazel
@@ -6,5 +6,8 @@
hdrs = ["include/hardware/gpio.h"],
includes = ["include"],
target_compatible_with = ["//bazel/constraint:host"],
- deps = ["//src/common/pico_base"],
+ deps = [
+ "//src/common/pico_binary_info:LIB_PICO_BINARY_INFO",
+ "//src/host/pico_platform",
+ ],
)
diff --git a/src/host/hardware_gpio/include/hardware/gpio.h b/src/host/hardware_gpio/include/hardware/gpio.h
index ee2f7f6..592a562 100644
--- a/src/host/hardware_gpio/include/hardware/gpio.h
+++ b/src/host/hardware_gpio/include/hardware/gpio.h
@@ -42,8 +42,6 @@
#define GPIO_OUT 1
#define GPIO_IN 0
-#define NUM_BANK0_GPIOS 30
-
// ----------------------------------------------------------------------------
// Pad Controls + IO Muxing
// ----------------------------------------------------------------------------
diff --git a/src/host/hardware_irq/BUILD.bazel b/src/host/hardware_irq/BUILD.bazel
new file mode 100644
index 0000000..af055a4
--- /dev/null
+++ b/src/host/hardware_irq/BUILD.bazel
@@ -0,0 +1,14 @@
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+ name = "hardware_irq",
+ srcs = ["irq.c"],
+ hdrs = ["include/hardware/irq.h"],
+ includes = ["include"],
+ tags = ["manual"], # TODO: No hardware/regs/intctrl.h for host yet.
+ target_compatible_with = ["//bazel/constraint:host"],
+ deps = [
+ "//src/host/hardware_claim",
+ "//src/host/pico_platform",
+ ],
+)
diff --git a/src/host/hardware_irq/CMakeLists.txt b/src/host/hardware_irq/CMakeLists.txt
new file mode 100644
index 0000000..7b23468
--- /dev/null
+++ b/src/host/hardware_irq/CMakeLists.txt
@@ -0,0 +1 @@
+pico_simple_hardware_target(irq)
\ No newline at end of file
diff --git a/src/host/hardware_irq/include/hardware/irq.h b/src/host/hardware_irq/include/hardware/irq.h
new file mode 100644
index 0000000..83c3a84
--- /dev/null
+++ b/src/host/hardware_irq/include/hardware/irq.h
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _HARDWARE_IRQ_H
+#define _HARDWARE_IRQ_H
+
+// These two config items are also used by assembler, so keeping separate
+// PICO_CONFIG: PICO_MAX_SHARED_IRQ_HANDLERS, Maximum number of shared IRQ handlers, default=4, advanced=true, group=hardware_irq
+#ifndef PICO_MAX_SHARED_IRQ_HANDLERS
+#define PICO_MAX_SHARED_IRQ_HANDLERS 4
+#endif
+
+// PICO_CONFIG: PICO_DISABLE_SHARED_IRQ_HANDLERS, Disable shared IRQ handlers, type=bool, default=0, group=hardware_irq
+#ifndef PICO_DISABLE_SHARED_IRQ_HANDLERS
+#define PICO_DISABLE_SHARED_IRQ_HANDLERS 0
+#endif
+
+// PICO_CONFIG: PICO_VTABLE_PER_CORE, user is using separate vector tables per core, type=bool, default=0, group=hardware_irq
+#ifndef PICO_VTABLE_PER_CORE
+#define PICO_VTABLE_PER_CORE 0
+#endif
+
+#include "pico.h"
+#include "hardware/regs/intctrl.h"
+
+/** \file irq.h
+ * \defgroup hardware_irq hardware_irq
+ *
+ * \brief Hardware interrupt handling
+ *
+ * The RP2040 uses the standard ARM nested vectored interrupt controller (NVIC).
+ *
+ * Interrupts are identified by a number from 0 to 31.
+ *
+ * On the RP2040, only the lower 26 IRQ signals are connected on the NVIC; IRQs 26 to 31 are tied to zero (never firing).
+ *
+ * There is one NVIC per core, and each core's NVIC has the same hardware interrupt lines routed to it, with the exception of the IO interrupts
+ * where there is one IO interrupt per bank, per core. These are completely independent, so, for example, processor 0 can be
+ * interrupted by GPIO 0 in bank 0, and processor 1 by GPIO 1 in the same bank.
+ *
+ * \note That all IRQ APIs affect the executing core only (i.e. the core calling the function).
+ *
+ * \note You should not enable the same (shared) IRQ number on both cores, as this will lead to race conditions
+ * or starvation of one of the cores. Additionally, don't forget that disabling interrupts on one core does not disable interrupts
+ * on the other core.
+ *
+ * There are three different ways to set handlers for an IRQ:
+ * - Calling irq_add_shared_handler() at runtime to add a handler for a multiplexed interrupt (e.g. GPIO bank) on the current core. Each handler, should check and clear the relevant hardware interrupt source
+ * - Calling irq_set_exclusive_handler() at runtime to install a single handler for the interrupt on the current core
+ * - Defining the interrupt handler explicitly in your application (e.g. by defining void `isr_dma_0` will make that function the handler for the DMA_IRQ_0 on core 0, and
+ * you will not be able to change it using the above APIs at runtime). Using this method can cause link conflicts at runtime, and offers no runtime performance benefit (i.e, it should not generally be used).
+ *
+ * \note If an IRQ is enabled and fires with no handler installed, a breakpoint will be hit and the IRQ number will
+ * be in register r0.
+ *
+ * \section interrupt_nums Interrupt Numbers
+ *
+ * Interrupts are numbered as follows, a set of defines is available (intctrl.h) with these names to avoid using the numbers directly.
+ *
+ * IRQ | Interrupt Source
+ * ----|-----------------
+ * 0 | TIMER_IRQ_0
+ * 1 | TIMER_IRQ_1
+ * 2 | TIMER_IRQ_2
+ * 3 | TIMER_IRQ_3
+ * 4 | PWM_IRQ_WRAP
+ * 5 | USBCTRL_IRQ
+ * 6 | XIP_IRQ
+ * 7 | PIO0_IRQ_0
+ * 8 | PIO0_IRQ_1
+ * 9 | PIO1_IRQ_0
+ * 10 | PIO1_IRQ_1
+ * 11 | DMA_IRQ_0
+ * 12 | DMA_IRQ_1
+ * 13 | IO_IRQ_BANK0
+ * 14 | IO_IRQ_QSPI
+ * 15 | SIO_IRQ_PROC0
+ * 16 | SIO_IRQ_PROC1
+ * 17 | CLOCKS_IRQ
+ * 18 | SPI0_IRQ
+ * 19 | SPI1_IRQ
+ * 20 | UART0_IRQ
+ * 21 | UART1_IRQ
+ * 22 | ADC0_IRQ_FIFO
+ * 23 | I2C0_IRQ
+ * 24 | I2C1_IRQ
+ * 25 | RTC_IRQ
+ *
+ */
+
+// PICO_CONFIG: PICO_DEFAULT_IRQ_PRIORITY, Define the default IRQ priority, default=0x80, group=hardware_irq
+#ifndef PICO_DEFAULT_IRQ_PRIORITY
+#define PICO_DEFAULT_IRQ_PRIORITY 0x80
+#endif
+
+#define PICO_LOWEST_IRQ_PRIORITY 0xff
+#define PICO_HIGHEST_IRQ_PRIORITY 0x00
+
+// PICO_CONFIG: PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY, Set default shared IRQ order priority, default=0x80, group=hardware_irq
+#ifndef PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY
+#define PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY 0x80
+#endif
+
+#define PICO_SHARED_IRQ_HANDLER_HIGHEST_ORDER_PRIORITY 0xff
+#define PICO_SHARED_IRQ_HANDLER_LOWEST_ORDER_PRIORITY 0x00
+
+// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_IRQ, Enable/disable assertions in the hardware_irq module, type=bool, default=0, group=hardware_irq
+#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_IRQ
+#ifdef PARAM_ASSERTIONS_ENABLED_IRQ // backwards compatibility with SDK < 2.0.0
+#define PARAM_ASSERTIONS_ENABLED_HARDWARE_IRQ PARAM_ASSERTIONS_ENABLED_IRQ
+#else
+#define PARAM_ASSERTIONS_ENABLED_HARDWARE_IRQ 0
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*! \brief Interrupt handler function type
+ * \ingroup hardware_irq
+ *
+ * All interrupts handlers should be of this type, and follow normal ARM EABI register saving conventions
+ */
+typedef void (*irq_handler_t)(void);
+
+static inline void check_irq_param(__unused uint num) {
+ invalid_params_if(HARDWARE_IRQ, num >= NUM_IRQS);
+}
+
+/*! \brief Set specified interrupt's priority
+ * \ingroup hardware_irq
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \param hardware_priority Priority to set.
+ * Numerically-lower values indicate a higher priority. Hardware priorities
+ * range from 0 (highest priority) to 255 (lowest priority) though only the
+ * top 2 bits are significant on ARM Cortex-M0+. To make it easier to specify
+ * higher or lower priorities than the default, all IRQ priorities are
+ * initialized to PICO_DEFAULT_IRQ_PRIORITY by the SDK runtime at startup.
+ * PICO_DEFAULT_IRQ_PRIORITY defaults to 0x80
+ */
+void irq_set_priority(uint num, uint8_t hardware_priority);
+
+/*! \brief Get specified interrupt's priority
+ * \ingroup hardware_irq
+ *
+ * Numerically-lower values indicate a higher priority. Hardware priorities
+ * range from 0 (highest priority) to 255 (lowest priority) though only the
+ * top 2 bits are significant on ARM Cortex-M0+. To make it easier to specify
+ * higher or lower priorities than the default, all IRQ priorities are
+ * initialized to PICO_DEFAULT_IRQ_PRIORITY by the SDK runtime at startup.
+ * PICO_DEFAULT_IRQ_PRIORITY defaults to 0x80
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \return the IRQ priority
+ */
+uint irq_get_priority(uint num);
+
+/*! \brief Enable or disable a specific interrupt on the executing core
+ * \ingroup hardware_irq
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \param enabled true to enable the interrupt, false to disable
+ */
+void irq_set_enabled(uint num, bool enabled);
+
+/*! \brief Determine if a specific interrupt is enabled on the executing core
+ * \ingroup hardware_irq
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \return true if the interrupt is enabled
+ */
+bool irq_is_enabled(uint num);
+
+/*! \brief Enable/disable multiple interrupts on the executing core
+ * \ingroup hardware_irq
+ *
+ * \param mask 32-bit mask with one bits set for the interrupts to enable/disable \ref interrupt_nums
+ * \param enabled true to enable the interrupts, false to disable them.
+ */
+void irq_set_mask_enabled(uint32_t mask, bool enabled);
+
+/*! \brief Enable/disable multiple interrupts on the executing core
+ * \ingroup hardware_irq
+ *
+ * \param n the index of the mask to update. n == 0 means 0->31, n == 1 mean 32->63 etc.
+ * \param mask 32-bit mask with one bits set for the interrupts to enable/disable \ref interrupt_nums
+ * \param enabled true to enable the interrupts, false to disable them.
+ */
+void irq_set_mask_n_enabled(uint n, uint32_t mask, bool enabled);
+
+/*! \brief Set an exclusive interrupt handler for an interrupt on the executing core.
+ * \ingroup hardware_irq
+ *
+ * Use this method to set a handler for single IRQ source interrupts, or when
+ * your code, use case or performance requirements dictate that there should
+ * no other handlers for the interrupt.
+ *
+ * This method will assert if there is already any sort of interrupt handler installed
+ * for the specified irq number.
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \param handler The handler to set. See \ref irq_handler_t
+ * \see irq_add_shared_handler()
+ */
+void irq_set_exclusive_handler(uint num, irq_handler_t handler);
+
+/*! \brief Get the exclusive interrupt handler for an interrupt on the executing core.
+ * \ingroup hardware_irq
+ *
+ * This method will return an exclusive IRQ handler set on this core
+ * by irq_set_exclusive_handler if there is one.
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \see irq_set_exclusive_handler()
+ * \return handler The handler if an exclusive handler is set for the IRQ,
+ * NULL if no handler is set or shared/shareable handlers are installed
+ */
+irq_handler_t irq_get_exclusive_handler(uint num);
+
+/*! \brief Add a shared interrupt handler for an interrupt on the executing core
+ * \ingroup hardware_irq
+ *
+ * Use this method to add a handler on an irq number shared between multiple distinct hardware sources (e.g. GPIO, DMA or PIO IRQs).
+ * Handlers added by this method will all be called in sequence from highest order_priority to lowest. The
+ * irq_set_exclusive_handler() method should be used instead if you know there will or should only ever be one handler for the interrupt.
+ *
+ * This method will assert if there is an exclusive interrupt handler set for this irq number on this core, or if
+ * the (total across all IRQs on both cores) maximum (configurable via PICO_MAX_SHARED_IRQ_HANDLERS) number of shared handlers
+ * would be exceeded.
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \param handler The handler to set. See \ref irq_handler_t
+ * \param order_priority The order priority controls the order that handlers for the same IRQ number on the core are called.
+ * The shared irq handlers for an interrupt are all called when an IRQ fires, however the order of the calls is based
+ * on the order_priority (higher priorities are called first, identical priorities are called in undefined order). A good
+ * rule of thumb is to use PICO_SHARED_IRQ_HANDLER_DEFAULT_ORDER_PRIORITY if you don't much care, as it is in the middle of
+ * the priority range by default.
+ *
+ * \note The order_priority uses \em higher values for higher priorities which is the \em opposite of the CPU interrupt priorities passed
+ * to irq_set_priority() which use lower values for higher priorities.
+ *
+ * \see irq_set_exclusive_handler()
+ */
+void irq_add_shared_handler(uint num, irq_handler_t handler, uint8_t order_priority);
+
+/*! \brief Remove a specific interrupt handler for the given irq number on the executing core
+ * \ingroup hardware_irq
+ *
+ * This method may be used to remove an irq set via either irq_set_exclusive_handler() or
+ * irq_add_shared_handler(), and will assert if the handler is not currently installed for the given
+ * IRQ number
+ *
+ * \note This method may *only* be called from user (non IRQ code) or from within the handler
+ * itself (i.e. an IRQ handler may remove itself as part of handling the IRQ). Attempts to call
+ * from another IRQ will cause an assertion.
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \param handler The handler to removed.
+ * \see irq_set_exclusive_handler()
+ * \see irq_add_shared_handler()
+ */
+void irq_remove_handler(uint num, irq_handler_t handler);
+
+/*! \brief Determine if the current handler for the given number is shared
+ * \ingroup hardware_irq
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \return true if the specified IRQ has a shared handler
+ */
+bool irq_has_shared_handler(uint num);
+
+/*! \brief Get the current IRQ handler for the specified IRQ from the currently installed hardware vector table (VTOR)
+ * of the execution core
+ * \ingroup hardware_irq
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ * \return the address stored in the VTABLE for the given irq number
+ */
+irq_handler_t irq_get_vtable_handler(uint num);
+
+/*! \brief Clear a specific interrupt on the executing core
+ * \ingroup hardware_irq
+ *
+ * This method is only useful for "software" IRQs that are not connected to hardware (i.e. IRQs 26-31)
+ * as the the NVIC always reflects the current state of the IRQ state of the hardware for hardware IRQs, and clearing
+ * of the IRQ state of the hardware is performed via the hardware's registers instead.
+ *
+ * \param int_num Interrupt number \ref interrupt_nums
+ */
+void irq_clear(uint int_num);
+
+/*! \brief Force an interrupt to be pending on the executing core
+ * \ingroup hardware_irq
+ *
+ * This should generally not be used for IRQs connected to hardware.
+ *
+ * \param num Interrupt number \ref interrupt_nums
+ */
+void irq_set_pending(uint num);
+
+
+/*! \brief Perform IRQ priority initialization for the current core
+ *
+ * \note This is an internal method and user should generally not call it.
+ */
+void irq_init_priorities(void);
+
+/*! \brief Claim ownership of a user IRQ on the calling core
+ * \ingroup hardware_irq
+ *
+ * User IRQs are numbered 26-31 and are not connected to any hardware, but can be triggered by \ref irq_set_pending.
+ *
+ * \note User IRQs are a core local feature; they cannot be used to communicate between cores. Therefore all functions
+ * dealing with Uer IRQs affect only the calling core
+ *
+ * This method explicitly claims ownership of a user IRQ, so other code can know it is being used.
+ *
+ * \param irq_num the user IRQ to claim
+ */
+void user_irq_claim(uint irq_num);
+
+/*! \brief Mark a user IRQ as no longer used on the calling core
+ * \ingroup hardware_irq
+ *
+ * User IRQs are numbered 26-31 and are not connected to any hardware, but can be triggered by \ref irq_set_pending.
+ *
+ * \note User IRQs are a core local feature; they cannot be used to communicate between cores. Therefore all functions
+ * dealing with Uer IRQs affect only the calling core
+ *
+ * This method explicitly releases ownership of a user IRQ, so other code can know it is free to use.
+ *
+ * \note it is customary to have disabled the irq and removed the handler prior to calling this method.
+ *
+ * \param irq_num the irq irq_num to unclaim
+ */
+void user_irq_unclaim(uint irq_num);
+
+/*! \brief Claim ownership of a free user IRQ on the calling core
+ * \ingroup hardware_irq
+ *
+ * User IRQs are numbered 26-31 and are not connected to any hardware, but can be triggered by \ref irq_set_pending.
+ *
+ * \note User IRQs are a core local feature; they cannot be used to communicate between cores. Therefore all functions
+ * dealing with Uer IRQs affect only the calling core
+ *
+ * This method explicitly claims ownership of an unused user IRQ if there is one, so other code can know it is being used.
+ *
+ * \param required if true the function will panic if none are available
+ * \return the user IRQ number or -1 if required was false, and none were free
+ */
+int user_irq_claim_unused(bool required);
+
+/*
+*! \brief Check if a user IRQ is in use on the calling core
+ * \ingroup hardware_irq
+ *
+ * User IRQs are numbered 26-31 and are not connected to any hardware, but can be triggered by \ref irq_set_pending.
+ *
+ * \note User IRQs are a core local feature; they cannot be used to communicate between cores. Therefore all functions
+ * dealing with Uer IRQs affect only the calling core
+ *
+ * \param irq_num the irq irq_num
+ * \return true if the irq_num is claimed, false otherwise
+ * \sa user_irq_c