mbed Connect Asia 2016 Developing IoT devices with mbed OS 5

Post on 12-Jan-2017

33 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

Transcript

Developing IoT deviceswith mbed OS 5

Jan JongboomLiyou Zhoumbed Connect 2016 - Shenzhen

© ARM 20162

Your hosts

Liyou ZhouSoftware Engineer

Jan JongboomDeveloper Evangelist

© ARM 2016

“I buy at the beginning of paradigm shifts. We are at that moment now

with Internet-of-things.”

3

Masayoshi Son

© ARM 20164

mbed has changed

mbed State of the Union

© ARM 20165

Before mbed OS 5

Online compiler Hardware Abstraction Layer

+

© ARM 20166

HAL fueled growth, compiler brought people in

© ARM 20167

But... embedded development is changingMCUs get more powerful, communication cheaperWe want more from our devices

Run full IP stacksFirmware upgradesDevice management

Challenges galore!

© ARM 20168

Affects both professionals and hobbyists

Professionals HobbyistsBigger attack surfaceLarger chance of bugsAdd value, not plumbing

Require sane defaultsGet to 90% without much

effortNeed proper networking

Good battery life out of the box

© ARM 20169

Standardizing the ecosystemProfessionals Hobbyists

Bigger attack surfaceMemory isolation

Larger chance of bugsWell tested isolated middleware

Add value, not plumbingCloud features, RTOS, unified network stacks

Require sane defaultsGet to 90% without much

effortWell tested cloud middleware

Need proper networkingUnified networking stacks

Good battery life out of the boxOptional schedular

© ARM 201610

mbed OS 5 is more...More than the online compilerMore than the library ecosystemWell-tested middleware for IoT

Not needed?Still runs in 8K of RAM...

© ARM 201611

Developing for mbed OS 5Or... how to get away from the online

compiler

© ARM 201612

Not just the online compiler

© ARM 201613

Three development environments

Online compiler mbed CLI Offline IDE

© ARM 201614

Proper online / offline story

Sync

mbed.orgGitHub

Private DVCS

© ARM 201615

Full integration coming to uVision 5

mbed Library manager

mbed OS 5 as CMSIS-PACK

Reference for other IDEs

© ARM 201616

Getting started - online compiler

Choose 'mbed OS Blinky'

© ARM 201617

Getting started - mbed CLIInstall mbed CLI - https://github.com/ARMmbed/mbed-cli

$ mbed new my-awesome-project

© ARM 201618

Full RTOS or event schedulerFull RTOS based on Keil RTXOptional event scheduler - mbed-events

Same concepts as minar in mbed OS 3Runs in an RTOS threadhttps://github.com/ARMmbed/mbed-os/blob/master/docs/

events.md

© ARM 2016

1 #include "mbed_events.h" 2 3 // Create an event queue 4 Queue queue(32 * EVENTS_EVENT_SIZE); 5 // Create a thread that'll run the event queue's dispatch function 6 Thread t; 7 8 int main () { 9 // Start the event queue's dispatch thread 10 t.start(callback(&queue, &EventQueue::dispatch_forever)); 11 12 // Use normal constructs (like tickers, interrupts) 13 // but wrap them in queue.event to go from ISR->event loop 14 Ticker t2; 15 t2.attach(queue.event(&doSomething), 1.0f); 16 }

19

mbed Events

© ARM 201620

Wait... There's an outside world?!Adding networking

© ARM 201621

Available networking libraries

WiFiEthernetCellularThread6LoWPANBluetooth Low EnergyLoRaWAN... many more by the community

© ARM 201622

Available networking libraries

WiFiEthernetCellularThread6LoWPANBluetooth Low EnergyLoRaWAN... many more by the community

}Unified networking APIWrite once, run anywherePorting is fast for socket-based librariesuBlox C027 ported in one day

mbed TLS included

© ARM 201623

Example - HTTP using ESP8266Add https://github.com/ARMmbed/esp8266-driver

1 #include "mbed.h" 2 #include "ESP8266Interface.h" 3 4 ESP8266Interface esp(D1 /* TX */, D0 /* RX */); 5 6 int main() { 7 NetworkInterface* network = esp.connect("SSID", "Password"); 8 9 if (network) { 10 const char *ip_addr = network_interface->get_ip_address(); 11 printf("IP address is %s\n", ip_addr); 12 }

© ARM 201624

Example - HTTP using ESP8266 (2)

1 socket.open(network); 2 socket.connect("developer.mbed.org", 80); 3 4 char sbuffer[] = "GET / HTTP/1.1\r\nHost: developer.mbed.org\r\n\r\n"; 5 int scount = socket.send(sbuffer, sizeof sbuffer); 6 7 char rbuffer[64]; 8 int rcount = socket.recv(rbuffer, sizeof rbuffer); 9 printf("recv %d [%.*s]\r\n", rcount);

© ARM 201625

Security is bigger than TLS

© ARM 201626

Reducing attack area on microcontrollersNo MMUFlat address spaceNeed component isolation

© ARM 201627

uVisorMemory isolationTrustzone on V8-M architecture (Cortex-M23, Cortex-M33)Secure boxesWill be integrated part of mbed OS 5.x

Critical parts will be provided as well-tested isolated blocks

Currently available on 3 targets

© ARM 201628

uVisor Blocks

Exposed Critical

Secure StorageCrypto Keys

Secure ID

Firmware Update

Crypto API

PRNGApplication

ProtocolTLS Library

Diagnose

WiFi StackBLE Stack

Device Manageme

nt

© ARM 201629

"Ceci n'est pas un nuage"

Adding mbed Client

© ARM 201630

mbed ClientRaw TCP / UDP sockets - easy data streams

Device management through mbed Device Connector

mbed Client is cloud middleware

© ARM 201631

Simple mbed Client

Library to easily bring variables into the cloudhttps://developer.mbed.org/teams/sandbox/code/simple-m

bed-client

Cloud variablesDefine a variableUse it as normal variable, magic!

Easy to re-use existing mbed libraries...(integrated in core mbed Client in next release)

One more thing...

© ARM 201633

http://mbed.com/js

Thank you!http://developer.mbed.orgThank you!

top related