Successfully reported this slideshow.
Your SlideShare is downloading. ×

Open Hours: Mbed Simulator

Open Hours: Mbed Simulator

Download to read offline

Recording: https://www.youtube.com/watch?v=DxTetwYsXvo&index=1&list=PLiVCejcvpsevQ_I9oDIK6eIgau45fWje2

The Mbed Simulator allows you to cross-compile Mbed OS 5 applications and run them on your computer.

Recording: https://www.youtube.com/watch?v=DxTetwYsXvo&index=1&list=PLiVCejcvpsevQ_I9oDIK6eIgau45fWje2

The Mbed Simulator allows you to cross-compile Mbed OS 5 applications and run them on your computer.

More Related Content

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Open Hours: Mbed Simulator

  1. 1. Copyright © 2019 Arm Open Hours
 Mbed Simulator Jan Jongboom Principal Developer Evangelist Arm
  2. 2. Jan Jongboom Principal Developer Evangelist jan.jongboom@arm.com
  3. 3. Developer Evangelism at Arm Jan Jongboom Europe Neil Tan APAC Austin Blackstone US & Japan Daniel Lee South Korea
  4. 4. Web development 💚
  5. 5. MCU development 😩
  6. 6. Hardware Debugger Module (MCU+Radio) Development Board
  7. 7. Copyright © 2019 Arm 7 Embedded development is stuck in the 90s Everything ASM / C / C++ Development tools only run on Windows Paid debugger with limited number of breakpoints Very slow feedback loop https://www.flickr.com/photos/65290859@N05/5995262928
  8. 8. BBC micro:bit Given to 1 mio kids in UK True microcontroller (16K of RAM, runs Mbed) Unique developer experience https://pxhere.com/en/photo/1396499
  9. 9. Copyright © 2019 Arm 9 BBC micro:bit - online editor Pseudo-language (block based) Can output JS or C++ or anything
  10. 10. Copyright © 2019 Arm 10 I want this... But in normal C++ #include "mbed.h" #include "compass.h" Compass compass(I2C_SDA, I2C_SCL); Display display; int main() { while (1) { display.printf("%d", compass.read()); } }
  11. 11. Copyright © 2019 Arm 11 Emscripten LLVM to asm.js / WebAssembly Runs C/C++ in the browser Supported by Mozilla
  12. 12. Copyright © 2019 Arm 12 Mbed OS Blinky - User API #include "mbed.h" DigitalOut led(LED1); int main() { while (1) { led = !led; wait_ms(500); } }
  13. 13. Copyright © 2019 Arm 13 Mbed OS Blinky - under the covers Cortex-M boot sequence explanation: https://www.youtube.com/watch?v=3brOzLJmeek // Mbed C++ HAL DigitalOut::write(int value) { gpio_write(&gpio, value); } // Mbed C HAL (implemented by vendor) void gpio_write(gpio_t *gpio, int value) { if (value == 1) { 0x40200000 = 1U << gpio->pin; } else { 0x40200004 = 1U << gpio->pin; } }
  14. 14. Copyright © 2019 Arm 14 Places for simulation Application Mbed C++ HAL (generic) Mbed C HAL (vendor specific) Peripherals When write to 0x40200000 comes in call JavaScript When DigitalOut::write is called call JavaScript When gpio_write() is called call JavaScript 🎉
  15. 15. Copyright © 2019 Arm 15 Mbed Simulator in Mbed OS Full Mbed C++ HAL Target implements Mbed C HAL Calls JavaScript functions from C HAL
  16. 16. Copyright © 2019 Arm 16 Challenges Microcontroller is always busy Interrupt handling Single-threaded Networking
  17. 17. Copyright © 2019 Arm 17 IP Networking Application HTTP Library Mbed Networking Stack Networking primitives TCP Sockets, UDP Sockets Networking hardware DNS handling, socket management, buffering, generic socket APIs Node.js daemon that provides TCPSocket and UDPSocket (over synchronous AJAX calls) 🔐
  18. 18. Copyright © 2019 Arm 18 Runs Pelion Device Management (DTLS, CoAP, LwM2M, X509 client certificates)
  19. 19. Copyright © 2019 Arm 19 LPWAN networking Application Mbed HAL SX1276 radio driver LoRaWAN stack Peripherals Device LoRa
 PHY Packet Forwarder IP
  20. 20. Copyright © 2019 Arm 20 LPWAN networking Device Wrap in packet forwarder protocol Application Mbed HAL Fake radio driver LoRaWAN stack Simulated Peripherals
  21. 21. Copyright © 2019 Arm 21 Bringing in new components Take C++ library Add in a few EM_ASM calls in strategic places
 (#ifdef TARGET_SIMULATOR) F.e. when flushing frame buffer over SPI for a display Implement JS HAL and JS UI 
 (e.g. draw canvas and handle frame buffer updates)
  22. 22. Copyright © 2019 Arm 22 Two ways of using the simulator Online: https://labs.mbed.com/simulator Great for teaching Online compiler Share code by copy pasting the URL Offline (requires Emscripten SDK): $ npm install mbed-simulator -g $ mbed-simulator .
  23. 23. Copyright © 2019 Arm 23 Simulator CLI Install via: npm install mbed-simulator -g Exclude or replace libraries via simconfig.json Reads mbed_app.json Detect where you run via: #ifdef TARGET_SIMULATOR
  24. 24. Copyright © 2019 Arm 24 simconfig.json example { "compiler-args": [ "-std=c++11", "--preload-file", "sdcard@/fs", "--preload-file", "constants@/fs/constants" ], "emterpretify": true, "ignore": [ "./BSP_DISCO_F413ZH", "./F413ZH_SD_BlockDevice", "./utensor/sd-driver/" ], "peripherals": [ { "component": "ST7789H2", "args": {} } ] }
  25. 25. Copyright © 2019 Arm 25 Debugging Source maps can be generated by Emscripten Debugging through normal browser JS debugger
  26. 26. Recap Embedded development is a PITA The web has brought so many cool tools, let's use them Cross-compile your embedded app => ??? => PROFIT Open source @ https://github.com/janjongboom/mbed-simulator Live demo @ https://labs.mbed.com https://www.pexels.com/photo/arduino-breadboard-circuit-diodes-370518/
  27. 27. Copyright © 2019 Arm Trademark and copyright statement The trademarks featured in this presentation are registered and/or unregistered trademarks of Arm (or its subsidiaries) in the EU and/or elsewhere. All rights reserved. All other marks featured may be trademarks of their respective owners. Copyright © 2019 Thank You! 27

×