Skip to content

Commit 24f5f5b

Browse files
authored
Merge pull request #117 from multiplemonomials/dev/add-mbed-ce-support
Add support for Mbed OS CE
2 parents cc24cfe + 871f2a3 commit 24f5f5b

9 files changed

Lines changed: 106 additions & 1 deletion

File tree

.github/workflows/examples.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- "examples/picosdk-blink"
2121
- "examples/picosdk-pioasm-blink"
2222
- "examples/picosdk-pioasm-blink-auto"
23+
- "examples/mbed-ce-hello-world"
2324
runs-on: ${{ matrix.os }}
2425
steps:
2526
- uses: actions/checkout@v4

boards/rpipico.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"frameworks": [
3333
"arduino",
34-
"picosdk"
34+
"picosdk",
35+
"mbed-ce"
3536
],
3637
"name": "Pico",
3738
"upload": {

builder/frameworks/mbed-ce.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2014-present PlatformIO <contact@platformio.org>
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""
15+
Mbed OS Community Edition
16+
https://mbed-ce.dev/
17+
"""
18+
19+
from os.path import join
20+
21+
from SCons.Script import Import, SConscript
22+
23+
Import("env")
24+
25+
SConscript(
26+
join(env.PioPlatform().get_package_dir("framework-mbed-ce"), "tools", "python", "mbed_platformio", "build_mbed_ce.py"))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.pio
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
{
3+
"target_overrides": {
4+
"*": {
5+
"platform.stdio-baud-rate": 9600,
6+
"platform.stdio-buffered-serial": 1,
7+
8+
// Uncomment to use mbed-baremetal instead of mbed-os
9+
// "target.application-profile": "bare-metal"
10+
}
11+
},
12+
"link_libraries": [
13+
"mbed-storage-sd"
14+
]
15+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter
4+
; Upload options: custom upload port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
; Advanced options: extra scripting
7+
;
8+
; Please visit documentation for the other options and examples
9+
; https://docs.platformio.org/page/projectconf.html
10+
11+
[env]
12+
platform = raspberrypi
13+
framework = mbed-ce
14+
15+
[env:rpipico]
16+
board = rpipico
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "mbed.h"
2+
3+
int main()
4+
{
5+
while(true)
6+
{
7+
printf("Hello world from Mbed CE!\n");
8+
ThisThread::sleep_for(1s);
9+
}
10+
11+
// main() is expected to loop forever.
12+
// If main() actually returns the processor will halt
13+
return 0;
14+
}

platform.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
"picosdk": {
2828
"package": "framework-picosdk",
2929
"script": "builder/frameworks/picosdk.py"
30+
},
31+
"mbed-ce": {
32+
"package": "framework-mbed-ce",
33+
"script": "builder/frameworks/mbed-ce.py",
34+
"description": "Community edition of Mbed OS, an open-source operating system designed for the Internet of Things.",
35+
"homepage": "https://mbed-ce.dev",
36+
"title": "Mbed CE"
3037
}
3138
},
3239
"packages": {
@@ -65,6 +72,12 @@
6572
"owner": "platformio",
6673
"version": "https://github.com/maxgerhardt/pico-sdk.git#4315984000afe20ac82c78c597a3c4a591f524b0"
6774
},
75+
"framework-mbed-ce": {
76+
"type": "framework",
77+
"optional": true,
78+
"owner": "mbed-ce-project",
79+
"version": ">=6.99.4"
80+
},
6881
"tool-picotool-rp2040-earlephilhower": {
6982
"type": "uploader",
7083
"optional": false,
@@ -94,6 +107,16 @@
94107
"optional": true,
95108
"owner": "earlephilhower",
96109
"version": "~5.100300.0"
110+
},
111+
"tool-ninja": {
112+
"optional": true,
113+
"owner": "platformio",
114+
"version": ">=1.7.0"
115+
},
116+
"tool-cmake": {
117+
"optional": true,
118+
"owner": "platformio",
119+
"version": ">=3.21.0"
97120
}
98121
}
99122
}

platform.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ def configure_default_packages(self, variables, targets):
166166
sys.stderr.write(
167167
"Error! Unknown build.core value '%s'. Don't know which Arduino core package to use." % build_core)
168168
sys.exit(-1)
169+
elif "mbed-ce" in frameworks:
170+
# Mbed CE only supports ARM cores and needs CMake and Ninja.
171+
# Note: Currently unable to link via the earlephilhower toolchain as that seems to have retargetable locking
172+
# turned on in Newlib, which Mbed does not currently support.
173+
self.packages["toolchain-rp2040-earlephilhower"]["optional"] = True
174+
self.packages.pop("toolchain-rp2040-earlephilhower", None)
175+
self.packages["tool-cmake"]["optional"] = False
176+
self.packages["tool-ninja"]["optional"] = False
169177
else:
170178
# this is a pico-sdk or baremetal project. if it's for a rp2350-riscv, we need the RISC-V toolchain.
171179
if chip == "rp2350-riscv":

0 commit comments

Comments
 (0)