如何用mbed OS 5来开发物联网设备
粗略得阐释一些概念,下午我们有一个workshop,手把手教一个整的物联网的案例。
From Cambridge we have Liyou Zhou, from Amsterdam Jan Jongboom.
孙正义,软银的老板,刚刚付了320亿美元来买下了我们这个只有5000人的公司,他说:我永远是在巨大变化之初买入,物联网这个领域,马上要开始翻天覆地的变化。我希望他的这番话,能够增强你们对mbed这个生态系统的信心。
Let me start with a quote, by Masa Son, the guy that just paid 32 billion$ for ARM. I hope that justifies the investment you've made in mbed in the past, we are at a great point in computer science history.
如果你今天早上有听SAM GROVE的发言,你会发现mbed OS有很多新的更新。
Just heard the mbed 'state of the union', might realize that mbed has changed quite a lot.
曾经,mbed OS是一个在线的开发环境,mbed OS 是一个硬件适配层。HAL 让我们写一遍代码,就可以运行在数十种开发板上面。
这就是我们当年的商标,谢天谢地我们现在有专门的商标设计师了。
我们这个旧的mbed生态圈叫做'mbed 2.0'或者 'mbed Classic’。在座各位很有可能就是在这个原来的mbed的时候加入我们的生态圈的。
对我个人来说,我也是通过mbed第一次接触到这么现代的嵌入式编程模式。
mbed used to be the online compiler & a HAL
"yes, that was the real mbed SDK logo, thank God we have designers now!"
. Ecosystem now known as 'mbed 2.0' or 'mbed Classic'. Probably the thing that has dragged you into mbed.Jan: for me it was the first time I figured 'this is how micros should be programmed'
mbed成果的另外一个原因就是众多的公开程序库。
我们也无法预料到的是下这这两个数字,28900 个公开程序,每个月一百二十万在线编译。
Pretty great, allows to write code once and target many platforms. Reason mbed has grown so much. Thousands of libraries.
Then: 'Also, probably when writing this code we didn't expect this much. There's no comma between the thousands separators ;-)'
Click: also doing 1.2 million compiles per month in the online compiler
但是,嵌入式正在发生着潜移默化的变革。PADI IoT Stamp, 2$ Cortex-M3, 512K RAM, 1MB Flash, Realtek WiFi chip. 24mm by 16mm.
我们需要重新整合,兼顾电池续航和系统安全。
PADI IoT Stamp, 2$ Cortex-M3, 512K RAM, 1MB Flash, Realtek WiFi chip. 24mm by 16mm.
Need to balance everything, while maintaining battery life and keeping the system secure.
我们在做的东西,同时影响了专业的嵌入式工程师和业余电子爱好者。
我们要让专业人士认可我们可以做好网络程序库,也可以坚持低功耗。对于专业人士来说,更复杂的程序,意味着更大的攻击面。更大的机会产生错误。我们现在渐渐进入一个阶段,我们没办法一个人从头到位全包全览得把一个项目做完。现在的程序猿想专注于如何为产品添加价值,做高层的应用,而不是花很多时间做底层硬件的整合。
对于电子爱好者来说,他们想要的是程序容易上手,你的平台应该把90%的问题都帮他们解决了,他们专注做最后的10%。你的网络程序库应该开箱即用,功耗也不能太差。
For professionals, bigger application means a bigger attack surface. Bigger chance of bugs, getting to a state where you cannot fit the whole problem space in your head anymore. Want to add value to the product rather than do the plumbing on device side.
For hobbyist, want sane defaults. Your platform should help you get to 90% without too much effort. Networking stack should work pretty well out of the box, and power consumption should be decent too.
所以在mbed OS 5里面,我们统一了许多新特性,对我们两种不同的用户需求都考虑周到。
So, in mbed OS 5 we're standardizing more things, catering for both groups. Unify network APIs (both IP and non-IP). Adding security features. Isolating memory. Preparing the way for firmware updates.
Don't need all that? Fall back to just RTOS+HAL and continue developing as-is.
* Three development environments:
1. Online compiler - has been updated to also support mbed OS 5
2. Local IDE - refactored exporters for mbed OS 5 and should be more stable than ever. Can export to your favourite IDE. IDE not supported? Use projgen project to add an exporter.
3. mbed CLI - command line interface for mbed, contains library management (like online compiler) and compilation supported with GCC, ARMCC and IAR.
Due to mbed CLI we have a story for online -> offline -> online for the first time.
At the moment there's no IDEs with mbed OS 5 library management in there, can use CLI for that. Clone project locally with mbed CLI, export to toolchain, project files generated in same directory. Use IDE as normal, then use CLI to load new libaries, sync back to developer.mbed.org etc.
Not just exporting, but actually as middleware CMSIS-PACK. Establishing mbed OS 5 as Cortex-M middleware, outside mbed.org.
We can go two ways from here, either use RTOS directly or use the Events library. Events library is similar to minar in mbed OS 3 but can run in an RTOS thread, so you can mix and match.
We want to use this model in more places, for example BLE libraries. It makes radio isolation nicer. No need to dedicate your event loop to your radio driver.
Libraries for Ethernet, WiFi, Cellular, Thread, 6LoWPAN, BLE, LoRaWAN available. Plus more from community.
Libraries for Ethernet, WiFi, Cellular, Thread, 6LoWPAN, BLE, LoRaWAN available. Plus more from community.
x:53
Idea is that core things like Update service, keystore are separate blocks. Super well tested. Then your app code talks to it through a bus, like CAN bus in cars, to execute calls in those blocks.
Can run anything on top of this. For IoT devices we have mbed Client, which is cloud-middleware. Standard way of sending data to mbed Device Connector - cloud service for device management.