Command-line tutorial for the advanced Device Management Client example with an Mbed OS device
This is an advanced Device Management Client example (mbed-cloud-client-example) for Mbed OS device with the following features:
- Support for latest Mbed OS and Device Management Client releases.
- Support for multiple operating systems.
- Support for developer and production mode provisioning.
- Support for firmware update.
- Support for delta firmware update.
- Support for advanced network stack and Pelion features.
- Configuring Device Management Client.
- Compiling and flashing Device Management Client.
- Connecting and performing a firmware update on your device.
Versions
The Device Management Client version used for the tutorial is 3.0.0 or later.
Here is how the different Device Management Client example application and Mbed OS versions work together:
Device Management Client | 3.0.0 | 3.1.0 | 3.2.0 | 3.3.0 | 3.4.0 | 4.0.0 | 4.1.0 |
---|---|---|---|---|---|---|---|
Mbed OS 5.12 | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box |
Mbed OS 5.13 | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box |
Mbed OS 5.14 | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box | Works out-of-box |
The highlighted combinations have been tested as part of the release. Other combinations should mostly work as listed, although some minor issues may appear. The PSA configuration is not available for Mbed OS releases older than version 5.14.
Note: If you are using Device Management Client 3.2.0, we recommend you upgrade to 3.3.0 (or later) as soon as possible. In 3.2.0, if an SSL session is stored when the device rebootstraps, a bootstrap loop may render the device unusable. Client 3.3.0 release fixes this issue by clearing the SSL session.
We recommend that you review the release notes for the Client example application and Device Management Client library.
Supported boards
You can use this tutorial with the following boards. The default stack configuration is in the mbed_app.json
file.
Board/MCU | Default stack | Other stacks | DAPLink or STLink | Notes |
---|---|---|---|---|
K64F |
Ethernet | Wi-Fi, 6LoWPAN | DAPLink | (1) , (2b) , (3) , (5) |
K66F |
Ethernet | DAPLink | (3) , (4b) |
|
NUCLEO_F429ZI |
Ethernet | Wi-SUN | STLink | (2a) , (3) |
NUCLEO_F411RE |
Wi-Fi | STLink | (1) , (4a) , (5) |
|
UBLOX_EVK_ODIN_W2 |
Wi-Fi | Ethernet | STLink | (1) , (3) , (5) |
LPC55S69_NS |
Wi-Fi | DAPlink | (4a) , (5) |
|
DISCO-L475VG-IOT01A |
Wi-Fi | Wi-Fi | STLink | (1) , (5) |
(1)
Wi-Fi configurations are available inconfigs/wifi.json
.- RAM-optimized configuration for K64F is available in
configs/wifi_esp8266_minimal.json
.
- RAM-optimized configuration for K64F is available in
(2)
Mesh configurations are available in theconfigs/
folder.(2a)
Wi-SUN configuration is available inconfigs/mesh_wisun.json
.(2b)
6LoWPAN configuration is available inconfigs/mesh_6lowpan.json
.
(3)
Ethernet configurations forIPv4
andIPv6
are available inconfigs/eth_v4.json
andconfigs/eth_v6.json
.(4)
The Platform Security Architecture (PSA) target configuration is available in theconfigs-psa/
folder.(4a)
PSA Wi-Fi configuration is available inconfigs-psa/wifi.json
.(4b)
PSA ethernet configuration is available inconfigs-psa/eth_v4.json
.
(5)
For Wi-Fi stacks, you need to add your SSID and password information to the configuration file.
Note: The --app-config
option does not support relative paths used for linking the bootloader binary files, thus all configuration files must be copied to the application root-level. Alternatively, you can also copy the configuration file over the default mbed_app.json
.
For Mesh, we recommend that you use a router compiled with same version of Mbed OS as the application. For Wi-SUN stack, also the Wi-SUN certificates (configs/wisun_certificates.h
) need to match between the application and the router. See the Github repository for the Nanostack Border router.
Prerequisites
To work with the Device Management Client example application, you need:
- A supported board with a network connection and an SD card attached.
- Serial connection to your device with open terminal connection (baud rate 115200, 8N1).
- Arm Mbed CLI installed. See installation instructions.
- Make sure that all the Python components are in par with the
pip
package requirements.txt list from Mbed OS.
- Make sure that all the Python components are in par with the
- An API key (with
Administrators
group privilages) for your Device Management account. - Updated DAPLink software (version 250 or later), if your board uses DAPLink.
Configuring Device Management Client
-
Clone the embedded application's GitHub repository to your local computer and navigate to the new folder:
mbed import https://github.com/ARMmbed/mbed-cloud-client-example cd mbed-cloud-client-example
-
Configure Mbed CLI to use your Device Management account and board:
mbed config -G CLOUD_SDK_API_KEY <API_KEY> mbed target <MCU> mbed toolchain GCC_ARM
-
Use Mbed CLI to download a developer certificate and to create an update-related configuration for your device:
mbed device-management init -d arm.com --model-name example-app --force -q
Compiling and flashing Device Management Client
To compile the example application:
mbed compile
Read more detailed instructions on the parameters related to Mbed CLI and device-management
command.
Flashing the binary to the device
To flash the binary to the device:
- Connect the device to your computer over USB. It's listed as a mass storage device.
- Drag and drop
mbed-cloud-client-example.bin
to the device. This flashes the binary to the device. You should see the LED blink rapidly; wait for it to stop.
Connecting and performing a firmware update on your device
Checking the device connection and obtaining the Device ID
- Press the Reset button to restart the device.
- Obtain your device's Device ID either from device console logs or from Device Management Portal.
When the client has successfully connected, the terminal shows:
Client registered
Endpoint Name: <Endpoint name>
Device ID: <Device ID>
To verify the connection with Device Management Portal:
- Log in to Device Management Portal.
- Select Device directory from the menu on the left.
- When your device is listed on the Devices page, it is connected and available.
Your device is now connected and ready for the firmware update. For development devices, the Endpoint name and Device ID are identical.
Updating the firmware
To update the firmware on your device:
mbed device-management update device -D <Device ID>
When the update starts, the client tracing log shows:
Firmware download requested
Authorization granted
Downloading: [++++++++++++++++++++++++++++++++++++++++++++++++++] 100 %
Download completed
Firmware install requested
Authorization granted
After this, the device reboots automatically and registers to Device Management.