From 8c1878b7c066e6519cd3e5ba24eeed009c09779a Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Mon, 20 Oct 2025 09:18:05 -0700 Subject: [PATCH 1/6] Add initial Mbed CE support --- boards/rpipico.json | 3 ++- builder/frameworks/mbed-ce.py | 26 ++++++++++++++++++++++++++ platform.json | 23 +++++++++++++++++++++++ platform.py | 7 +++++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 builder/frameworks/mbed-ce.py diff --git a/boards/rpipico.json b/boards/rpipico.json index fd43e88..16e9234 100644 --- a/boards/rpipico.json +++ b/boards/rpipico.json @@ -31,7 +31,8 @@ }, "frameworks": [ "arduino", - "picosdk" + "picosdk", + "mbed" ], "name": "Pico", "upload": { diff --git a/builder/frameworks/mbed-ce.py b/builder/frameworks/mbed-ce.py new file mode 100644 index 0000000..9cfc181 --- /dev/null +++ b/builder/frameworks/mbed-ce.py @@ -0,0 +1,26 @@ +# Copyright 2014-present PlatformIO +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Mbed OS Community Edition +https://mbed-ce.dev/ +""" + +from os.path import join + +from SCons.Script import Import, SConscript + +Import("env") + +SConscript( + join(env.PioPlatform().get_package_dir("framework-mbed-ce"), "tools", "python", "mbed_platformio", "build_mbed_ce.py")) \ No newline at end of file diff --git a/platform.json b/platform.json index 343511c..70918eb 100644 --- a/platform.json +++ b/platform.json @@ -27,6 +27,13 @@ "picosdk": { "package": "framework-picosdk", "script": "builder/frameworks/picosdk.py" + }, + "mbed-ce": { + "package": "framework-mbed-ce", + "script": "builder/frameworks/mbed-ce.py", + "description": "Community edition of Mbed OS, an open-source operating system designed for the Internet of Things.", + "homepage": "https://mbed-ce.dev", + "title": "Mbed CE" } }, "packages": { @@ -65,6 +72,12 @@ "owner": "platformio", "version": "https://github.com/maxgerhardt/pico-sdk.git#4315984000afe20ac82c78c597a3c4a591f524b0" }, + "framework-mbed-ce": { + "type": "framework", + "optional": true, + "owner": "mbed-ce-project", + "version": ">=6.99" + }, "tool-picotool-rp2040-earlephilhower": { "type": "uploader", "optional": false, @@ -94,6 +107,16 @@ "optional": true, "owner": "earlephilhower", "version": "~5.100300.0" + }, + "tool-ninja": { + "optional": true, + "owner": "platformio", + "version": ">=1.7.0" + }, + "tool-cmake": { + "optional": true, + "owner": "platformio", + "version": ">=3.21.0" } } } diff --git a/platform.py b/platform.py index d21fe97..933fb04 100644 --- a/platform.py +++ b/platform.py @@ -166,6 +166,13 @@ def configure_default_packages(self, variables, targets): sys.stderr.write( "Error! Unknown build.core value '%s'. Don't know which Arduino core package to use." % build_core) sys.exit(-1) + elif "mbed-ce" in frameworks: + # Mbed CE only supports ARM cores and needs CMake and Ninja + self.packages.pop("toolchain-gccarmnoneeabi", None) + self.packages["toolchain-rp2040-earlephilhower"]["optional"] = False + self.packages["toolchain-rp2040-earlephilhower"]["version"] = RaspberrypiPlatform.earle_toolchain_arm[sys_type] + self.packages["tool-cmake"]["optional"] = False + self.packages["tool-ninja"]["optional"] = False else: # this is a pico-sdk or baremetal project. if it's for a rp2350-riscv, we need the RISC-V toolchain. if chip == "rp2350-riscv": From 9baff39567d1fedbbf06d4afdf081f814d360a8c Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Mon, 12 Jan 2026 22:31:46 -0800 Subject: [PATCH 2/6] Pin >=6.99.2 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 70918eb..ceaeff1 100644 --- a/platform.json +++ b/platform.json @@ -76,7 +76,7 @@ "type": "framework", "optional": true, "owner": "mbed-ce-project", - "version": ">=6.99" + "version": ">=6.99.2" }, "tool-picotool-rp2040-earlephilhower": { "type": "uploader", From 53353f4d65b610d7c8fd297babc5509a8178d487 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Mon, 12 Jan 2026 22:48:45 -0800 Subject: [PATCH 3/6] Add Mbed CE example --- .github/workflows/examples.yml | 1 + examples/mbed-ce-hello-world/.gitignore | 1 + examples/mbed-ce-hello-world/mbed_app.json5 | 15 +++++++++++++++ examples/mbed-ce-hello-world/platformio.ini | 14 ++++++++++++++ examples/mbed-ce-hello-world/src/main.cpp | 14 ++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 examples/mbed-ce-hello-world/.gitignore create mode 100644 examples/mbed-ce-hello-world/mbed_app.json5 create mode 100644 examples/mbed-ce-hello-world/platformio.ini create mode 100644 examples/mbed-ce-hello-world/src/main.cpp diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 3e0c257..6168c44 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -20,6 +20,7 @@ jobs: - "examples/picosdk-blink" - "examples/picosdk-pioasm-blink" - "examples/picosdk-pioasm-blink-auto" + - "examples/mbed-ce-hello-world" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/examples/mbed-ce-hello-world/.gitignore b/examples/mbed-ce-hello-world/.gitignore new file mode 100644 index 0000000..03f4a3c --- /dev/null +++ b/examples/mbed-ce-hello-world/.gitignore @@ -0,0 +1 @@ +.pio diff --git a/examples/mbed-ce-hello-world/mbed_app.json5 b/examples/mbed-ce-hello-world/mbed_app.json5 new file mode 100644 index 0000000..3733bca --- /dev/null +++ b/examples/mbed-ce-hello-world/mbed_app.json5 @@ -0,0 +1,15 @@ + +{ + "target_overrides": { + "*": { + "platform.stdio-baud-rate": 9600, + "platform.stdio-buffered-serial": 1, + + // Uncomment to use mbed-baremetal instead of mbed-os + // "target.application-profile": "bare-metal" + } + }, + "link_libraries": [ + "mbed-storage-sd" + ] +} diff --git a/examples/mbed-ce-hello-world/platformio.ini b/examples/mbed-ce-hello-world/platformio.ini new file mode 100644 index 0000000..2601076 --- /dev/null +++ b/examples/mbed-ce-hello-world/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env] +platform = raspberrypi +board = rpipico +framework = mbed-ce \ No newline at end of file diff --git a/examples/mbed-ce-hello-world/src/main.cpp b/examples/mbed-ce-hello-world/src/main.cpp new file mode 100644 index 0000000..c33f4da --- /dev/null +++ b/examples/mbed-ce-hello-world/src/main.cpp @@ -0,0 +1,14 @@ +#include "mbed.h" + +int main() +{ + while(true) + { + printf("Hello world from Mbed CE!\n"); + ThisThread::sleep_for(1s); + } + + // main() is expected to loop forever. + // If main() actually returns the processor will halt + return 0; +} \ No newline at end of file From 0d544ccfddafb55caeac2f88dac8ada519a08f01 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sat, 17 Jan 2026 09:17:10 -0800 Subject: [PATCH 4/6] Fix platformio.ini --- examples/mbed-ce-hello-world/platformio.ini | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/mbed-ce-hello-world/platformio.ini b/examples/mbed-ce-hello-world/platformio.ini index 2601076..13f9de6 100644 --- a/examples/mbed-ce-hello-world/platformio.ini +++ b/examples/mbed-ce-hello-world/platformio.ini @@ -10,5 +10,7 @@ [env] platform = raspberrypi -board = rpipico -framework = mbed-ce \ No newline at end of file +framework = mbed-ce + +[env:rpipico] +board = rpipico \ No newline at end of file From f7e7bca2b7ea887804f1e47573cf050b79baea53 Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sat, 17 Jan 2026 13:35:41 -0800 Subject: [PATCH 5/6] mbed-ce! --- boards/rpipico.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/rpipico.json b/boards/rpipico.json index 16e9234..59fd526 100644 --- a/boards/rpipico.json +++ b/boards/rpipico.json @@ -32,7 +32,7 @@ "frameworks": [ "arduino", "picosdk", - "mbed" + "mbed-ce" ], "name": "Pico", "upload": { From 871f2a33dffb4bbfd9c755860a6fa350e674124d Mon Sep 17 00:00:00 2001 From: Jamie Smith Date: Sat, 31 Jan 2026 19:33:17 -0800 Subject: [PATCH 6/6] Bump mbed-ce version, should be working now! --- platform.json | 2 +- platform.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/platform.json b/platform.json index ceaeff1..83e21d8 100644 --- a/platform.json +++ b/platform.json @@ -76,7 +76,7 @@ "type": "framework", "optional": true, "owner": "mbed-ce-project", - "version": ">=6.99.2" + "version": ">=6.99.4" }, "tool-picotool-rp2040-earlephilhower": { "type": "uploader", diff --git a/platform.py b/platform.py index 933fb04..9230af8 100644 --- a/platform.py +++ b/platform.py @@ -167,10 +167,11 @@ def configure_default_packages(self, variables, targets): "Error! Unknown build.core value '%s'. Don't know which Arduino core package to use." % build_core) sys.exit(-1) elif "mbed-ce" in frameworks: - # Mbed CE only supports ARM cores and needs CMake and Ninja - self.packages.pop("toolchain-gccarmnoneeabi", None) - self.packages["toolchain-rp2040-earlephilhower"]["optional"] = False - self.packages["toolchain-rp2040-earlephilhower"]["version"] = RaspberrypiPlatform.earle_toolchain_arm[sys_type] + # Mbed CE only supports ARM cores and needs CMake and Ninja. + # Note: Currently unable to link via the earlephilhower toolchain as that seems to have retargetable locking + # turned on in Newlib, which Mbed does not currently support. + self.packages["toolchain-rp2040-earlephilhower"]["optional"] = True + self.packages.pop("toolchain-rp2040-earlephilhower", None) self.packages["tool-cmake"]["optional"] = False self.packages["tool-ninja"]["optional"] = False else: