Introduction to the
Mbed Platform and
CMSIS
Syllabus
This module will cover the following
• Mbed Overview
• Mbed OS
• Mbed Software Development Kit (SDK)
• Mbed Hardware Development Kit (HDK)
• Cortex Microcontroller Software Interface Standard (CMSIS)
2 © 2020 Arm Limited
Introduction to Mbed
What is Mbed? The Mbed platform provides: The Mbed platform includes:
A platform used for the easy Open software libraries Mbed Operating System (Mbed OS)
prototyping and development of Open hardware designs – Libraries, RTOS core, HAL, API,
applications and systems based on and more
Open online tools for professional
Arm Cortex-M-based A microcontroller Hardware
rapid prototyping of products based
microcontrollers, typically used in Development Kit (HDK) and
on Arm-based microcontrollers
the world of IoT supported development boards
Integrated Development
Environment (IDE), including an
online compiler and online
developer collaboration tools
3 © 2020 Arm Limited
Mbed OS
Overview
Cortex-M
• Open-source operating system for platforms RTOS Kernel
using Arm microcontrollers (IoT)
Development Portable
• Offers a variety of features to enable the Tools Drivers
development of IoT connected systems
• Layer of abstraction interprets application code
Mbed
for hardware to understand OS
Management Integrated
• Developers can focus on programming portable Services Security
applications
• An Mbed OS application can be run on any Mbed-
compatible platform IoT
Connectivity
4 © 2020 Arm Limited
Mbed OS
Cortex-M RTOS kernel
• Mbed has an RTOS core
• Supports deterministic, multi-threaded, real-time software execution
Cortex-M
• RTOS primitives are available to allow drivers and applications to RTOS Kernel
rely on threads, semaphores, mutexes, and other RTOS features
5 © 2020 Arm Limited
Mbed OS
Security
• Two security-focused building blocks:
• Arm Mbed TLS
• Secure Partition Manager (SPM)
• Mbed TLS is a protocol for securing communication channels
between devices and servers or gateways Integrated
Security
• The SPM is responsible for:
• Isolating software within partitions
• Managing the execution of software within partitions
• Providing Inter-Process Communication (IPC) between partitions
6 © 2020 Arm Limited
Mbed OS
IoT Connectivity
• Mbed OS supports a number of connectivity protocols
• Paired with Pelion Device Management to provide full support for a range
of communication options
• Such technologies include:
• Bluetooth Low Energy (BLE) IoT
Connectivity
• Wi-Fi
• Narrowband-IoT (NB-IoT)
• 6LoWPAN
• Thread
• Ethernet
7 © 2020 Arm Limited
Mbed OS
Development tools
• Arm Mbed Online Compiler
• Circumvents need for dedicated desktop setup
• Allows writing code from scratch or import existing projects
• Arm Mbed CLI
• Python-based command line tool, specifically for Mbed OS 5
• Compiler versions supported: Arm compiler, GNU Arm Embedded, IAR Development
Tools
Embedded workbench
• Arm Mbed Studio
• Desktop IDE for quick development, debug and deployment cycle
• All can fetch the Mbed OS source code from GitHub/[Link],
along with dependencies, and compile code for a target board
8 © 2020 Arm Limited
Mbed Online Compiler
Lightweight online C/C++ IDE
• Enables quick program writing, compilation, and
execution on a microcontroller
• No prior-installation or set-up required to work
with Mbed
• Includes full code editor, version control, and
library management
9 © 2020 Arm Limited
Mbed CLI
Command-line tool packaged as “mbed-cli” and based on Python
• Solves dependency management and
code publishing
• Support for remotely hosted repositories
• Git and Mercurial-based version control
• Use of the Arm Mbed OS build system
10 © 2020 Arm Limited
Mbed Studio
Integrated development environment (IDE) for Mbed OS 5 applications
• Includes everything required to create,
compile, and debug Mbed programs
• Automatically detects connected Mbed-
enabled boards
• Quick development for specific targets
• Flashes code directly to connected platform
• Provides debug session for debugging and
profiling the target board
11 © 2020 Arm Limited
Mbed Software Development Kit (SDK)
C/C++ microcontroller software platform, licensed under Apache 2.0 license
Mbed SDK includes:
• Official C/C++ software libraries
• Start-up code, peripheral drivers, networking, RTOS, and runtime environment
• Community-developed libraries and code
• Cookbook of hundreds of reusable peripheral and module libraries built on top of the SDK
• Software tools, such as build tools, test, and debug scripts
Enables rapid prototyping of embedded applications
12 © 2020 Arm Limited
Mbed Hardware Development Kit (HDK)
Collection of designs to help develop custom hardware
• Working with boards based on the Mbed HDK Example
allows using Mbed ecosystem and associated
technologies, including Mbed OS and DAPLink • Microcontroller sub-system used to build an
evaluation board
• The HDK offers:
• Eagle schematics and board files
• PDF schematics and board copies
• CAM Job GERBERS for manufacture (including
pick/place and drill)
• Bill of Materials (BOM)
• A repository of content and projects
• Easy-to-use USB and debugging support
13 © 2020 Arm Limited
DAPLink
Open-source project implementing embedded firmware required for a Cortex debug probe
Human Interface Device (HID) USB drag and drop programming USB serial port
Provides a channel over which The DAPLink debug probes appear DAPLink probe also provides a USB
CMSIS-DAP protocols can run as USB disks on host computers serial port
• Enables tools such as Keil MDK, Binary and hex files can be copied • Port will appear on a Windows PC
IAR Workbench, and pyOCD to the USB disk that are then as a COM port or in Linux as a
programmed into the memory of /dev/tty interface
the target system
14 © 2020 Arm Limited
Testing with Mbed
The Mbed platform offers several tools that support testing of Mbed code
Greentea
• Automated testing tool for Arm Mbed OS development
• Pair with “UNITY” and “utest” frameworks
• [Link]
Icetea
• Automated testing tool for Arm Mbed OS development
• Typically used for local development and automation in a continuous integration environment
• [Link]
15 © 2020 Arm Limited
Mbed enabled platforms
• The Arm® Mbed Enabled™ program outlines a set of functionality and requirements that must be met in order to
become “Mbed Enabled.” This can cover development boards, modules, components, and interfaces
• This benefits developers, as they are assured that the platforms they choose to work with can perform certain
functions/provide certain performance.
• It is also beneficial to vendors, as it gives their products more exposure when certified that can increase their
popularity with developers in the Mbed ecosystem.
• Some example boards include:
NUCLEO-F401RE NXP FRDM-K64F DISCO-F413ZH Nordic nRF52-DK
16 © 2020 Arm Limited
High-level vs. low-level programming
High-level Low-level
• Advantages: • Advantages:
• Higher productivity (less development time) • More optimized code and higher memory
• Portability across devices efficiency
• Code is easier to read and maintain • Less translation time from source to
• Allows code reuse machine code
• Rapid prototyping of applications • Direct interaction with hardware
• Disadvantages: • Disadvantages:
• Less optimized code • Less portability from one device to another
• Additional translation time from source to • Code is more difficult to read, reuse, and
machine code maintain
• Another level of abstraction to deal with • Low productivity
17 © 2020 Arm Limited
High-level vs. low-level programming
Low-level example: Blinking LED by manipulating MCU registers
• A GPIO peripheral can be directly accessed by
writing/reading specific memory addresses:
• Assign a pointer to the address of each register
• Registers can be read/written using the pointer
18 © 2020 Arm Limited
High-level vs. low-level programming
High-level example: Blinking LED using Mbed API
• Mbed provides a user-friendly object-oriented
API (C++ based)
• More friendly functions
• Defines basic operators to provide intuitive
casting to primitive types and assignments
• A digital I/O class is defined, as shown in the
code snippet on the right that we can use to
implement the LED blinking example.
19 © 2020 Arm Limited
High-level vs. low-level programming
High-level example: Blinking LED using Mbed API
• With the support of the Mbed API, the same example can be programmed in a much simpler and more intuitive way:
... using Mbed API
code...
• Deep knowledge of C++ is not necessary to use the Mbed API. However, there are many C++ tutorials and books that
can prove helpful.
20 © 2020 Arm Limited
Cortex Microcontroller Software Interface Standard (CMSIS)
• Vendor-independent hardware abstraction layer for the Cortex-M processor series
• Provides a standardized software interface (library functions) that helps control the processor more
easily, e.g., configuring the Nested Vectored Interrupt Controller (NVIC)
• Improves software portability across different Cortex-M processors and Cortex-M based microcontrollers
Low-level programming Higher-level CMSIS programming
Configure Cortex-M by directly accessing Configure Cortex-M processors
registers in internal memory space, e.g., by using CMSIS libraries, e.g.,
*(unsigned int*) NVIC_INT_ENABLE = 0x01; NVIC_EnableIRQ(Timer_IRQn);
API
Arm CMSIS-Core
Cortex-M0
Cortex-M
Arm Cortex-M
Cortex-M3
Processor
Cortex-M4
21 © 2020 Arm Limited
What is standardized by CMSIS?
Functions to access, e.g., NVIC, • Enables an interrupt or exception: NVIC_EnableIRQ (IRQn_Type IRQn)
System Control Block (SCB), and • Sets pending status of interrupt: void NVIC_SetPendingIRQ (IRQn_Type IRQn)
System Tick timer
• Read PRIMASK register: uint32_t __get_PRIMASK (void)
Access to special registers, e.g., • Set CONTROL register: void __set_CONTROL (uint32_t value)
Functions to access special • REV: uint32_t __REV(uint32_t int value)
instructions, e.g., • NOP: void __NOP(void)
Names of system initialization • System initialization: void SystemInit (void)
functions, e.g.,
22 © 2020 Arm Limited
Benefits of CMSIS
Easier to port application code from
Easier to reuse the same code between
one Cortex-M based microcontroller to
different Cortex-M based
another Cortex-M based
microcontrollers
microcontroller
Better compatibility when integrating
third-party software components, since
Better code density and smaller
all third-party components, such as
memory footprint, since the code in
applications, embedded OS,
CMSIS has been optimized and tested
middleware, etc., can share the same
standard CMSIS interface
23 © 2020 Arm Limited
CMSIS components
The CMSIS consists of the following components:
• CMSIS-CORE – implements basic run-time system
for a Cortex-M device
• CMSIS-RTOS – API that enables consistent
software layers with middleware and library
components
• CMSIS-DSP library – rich collection of DSP
optimized for various Cortex-M processor cores
• CMSIS-SVD files – enable detailed views of device
peripherals with current register state
• CMSIS-DAP – standardized interface to the
CoreSight Debug Access Port (DAP)
• CMSIS-NN – collection of neural network kernels
24 © 2020 Arm Limited
CMSIS-DAP
Interface firmware for the debug unit that connects the debug port to USB
• Debugger can
connect via USB to
debug unit & device
• Debug unit
connected to target
via JTAG/SW
• CoreSight Debug and
Trace Unit on CPU
• Multi-core debugging
25 © 2020 Arm Limited
Coming next
Module Contents
IoT Connectivity, Part I • Introduction to Bluetooth
• Bluetooth Low Energy
• ZigBee
IoT Connectivity, Part II • WLAN and LPWAN
• IEEE 802.11
• LoRaWAN
• NB-IoT
The Cloud • Virtual Machines and Containers
• Protocols
• Big Data Processing
• The Arm Pelion Platform
26 © 2020 Arm Limited