Skip to content

Commit 4226ebb

Browse files
author
Amanda Butler
authored
Create device-management-test.md
Move content from device management document into separate file to better organize thoughts.
1 parent 6207f65 commit 4226ebb

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

docs/device-management-test.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<h2 id="device-management-test">Validation and testing</h2>
2+
3+
Mbed Device Management provides built-in tests to help you when define your device management configuration. Before running these tests, we recommend you refer to the [testing setup](#testing-setup) section below.
4+
5+
### Test suites
6+
7+
| **Test suite** | **Description** |
8+
| ------------- | ------------- |
9+
| `fs-single` | File system single-threaded tests with write buffer sizes - 1 byte, 4b, 16b, 64b, 256b, 1kb, 4kb, 16kb, 64kb. |
10+
| `fs-multi` | File system multithreaded test with write buffer sizes - 1 byte, 4b, 16b, 64b, 256b, 1kb, 4kb, 16kb, 64kb. |
11+
| `net-single` | Network single-threaded test with receive buffer sizes - 128 bytes, 256b, 1kb, 2kb, 4kb. |
12+
| `net-multi` | Network multithreaded test for 1, 2 and 3 download threads with 1kb receive buffer size. |
13+
| `stress-net-fs` | Network and file system single and multithreaded tests:<ul><li>1 thread (sequential) - 1 download (1kb buffer), 1 file thread (1kb buffer)</li><li>2 parallel threads - 1 download, 1 file thread (1kb buffer)</li><li>3 parallel threads - 1 download, 2 file (256 bytes, 1 kb buffer)</li><li>4 parallel threads - 1 download, 3 file (1 byte, 256 bytes, 1kb buffer)</li></ul> |
14+
15+
### Test cases - connect
16+
17+
| **Test case** | **Description** |
18+
| ------------- | ------------- |
19+
| `Connect to <Network type>` | Tests the connection to the network through the network interface. |
20+
| `Initialize <Blockdevice>+<Filesystem>` | Initializes the block device driver and file system on top. Usually, the test will be stuck at this point if there's a problem with the storage device. |
21+
| `Format <Filesystem>` | Tests that you can successfully format the block device for the file system type. |
22+
| `Initialize Simple PDMC ` | Verifies you can initialize Pelion Device Management with the given network, storage and file system configuration. This is where the FCU and KCM configuration is written to storage and the Root of Trust is written to SOTP.
23+
| `Pelion DM Bootstrap & Register` | Bootstraps the device and registers it for first time with Pelion Device Management. |
24+
| `Pelion DM Directory` | Verifies that a registered device appears in the Device Directory in Pelion Device Management. |
25+
| `Pelion DM Re-register` | Resets the device and reregisters with Pelion Device Management with previously bootstrapped credentials. |
26+
| `Post-reset Identity` | Verifies that the device identity is preserved over device reset, confirming that Root of Trust is stored in SOTP correctly. |
27+
| `ResourceLwM2M GET` | Verifies that the device can perform a GET request on an LwM2M resource. |
28+
| `ResourceLwM2M SET Test` | Sets or changes value from the device and verifies the Pelion Device Management API client can observe the value changing. |
29+
| `ResourceLwM2M PUT Test` | Verifies the device can perform a PUT request on an LwM2M resource by setting a new value. |
30+
| `Resource LwM2M POST Test` | Verifies the device can execute a POST on an LwM2M resource and the callback function on the device is called. |
31+
32+
### Test cases - update
33+
34+
| **Test case** | **Description** |
35+
| ------------- | ------------- |
36+
| `Connect to <Network type>` | Tests the connection to the network using the network interface. |
37+
| `Initialize <Blockdevice>+<Filesystem>` | Initializes block device driver and file system on top. Usually the test will be stuck at this point if there's problem with the storage device. |
38+
| `Format <Filesystem>` | Tests that you can successfully format the block device for the file system type. |
39+
| `Initialize Simple PDMC ` | Verifies you can initialize Pelion Device Management with the given network, storage and file system configuration. This is where the FCU and KCM configuration is written to storage and the Root of Trust is written to SOTP.
40+
| `Pelion DM Bootstrap & Register` | Bootstraps the device and registers it for first time with Pelion Device Management. |
41+
| `Pelion DM Directory` | Verifies a registered device appears in the Device Directory in Pelion Device Management. |
42+
| `Firmware Prepare` | Prepares the firmware on the host side and calls `mbed dm` to initiate the Pelion Device Management update campaign. |
43+
| `Firmware Download` | Downloads the firmware onto the device. |
44+
| `Firmware Update` | Resets the device, verifies that the firmware has correct checksum, applies it and reverifies the applied firmware checksum. |
45+
| `Pelion DM Re-register` | Reregisters the device with Pelion Device Management using the new firmware and previously bootstrapped credentials. |
46+
| `Post-update Identity` | Verifies that the device identity is preserved over firmware update and device reset, confirming that Root of Trust is stored in SOTP correctly. |
47+
48+
### Requirements
49+
50+
Mbed Device Management tests rely on the Python SDK to test the end-to-end solution. To install the Python SDK:
51+
52+
```
53+
$ pip install mbed-cloud-sdk
54+
```
55+
56+
<span class="notes">**Note:** The Python SDK requires Python 2.7.10+ or Python 3.4.3+, built with SSL support.</span>
57+
58+
### Testing setup
59+
60+
1. Import an example application for Pelion Device Management that contains the corresponding configuration for your target.
61+
62+
Please refer to the following [application example](https://github.com/ARMmbed/pelion-ready-example). It demonstrates how to connect to the Pelion IoT Platform service, register resources and get ready to receive a firmware update.
63+
64+
Also, there are board-specific applications that focus on providing more elaborate hardware features with Mbed OS and the Pelion IoT Platform. These are available in the Pelion [quick start](https://cloud.mbed.com/quick-start).
65+
66+
1. Set a global `mbed config` variable `CLOUD_SDK_API_KEY` on the host machine valid for the account your device will connect to. For example:
67+
68+
```
69+
$ mbed config -G CLOUD_SDK_API_KEY <API_KEY>
70+
```
71+
72+
For instructions on how to generate an API key, please [see the documentation](https://cloud.mbed.com/docs/current/integrate-web-app/api-keys.html#generating-an-api-key).
73+
74+
1. Initialize your Pelion DM credentials (once per project):
75+
76+
```
77+
$ mbed dm init -d "<your company name.com>" --model-name "<product model identifier>"
78+
```
79+
80+
This creates your private and public key pair and also initializes various `.c` files with these credentials, so you can use Connect and (firmware) Update device management features.
81+
82+
1. Remove the `main.cpp` application from the project, or ensure the content of the file is wrapped with `#ifndef MBED_TEST_MODE`.
83+
84+
1. Compile the tests with the `MBED_TEST_MODE` compilation flag.
85+
86+
```
87+
$ mbed test -t <toolchain> -m <platform> --app-config mbed_app.json -n simple-mbed-cloud-client-tests-* -DMBED_TEST_MODE --compile
88+
```
89+
90+
1. Run the tests from the application directory:
91+
92+
```
93+
$ mbed test -t <toolchain> -m <platform> --app-config mbed_app.json -n simple-mbed-cloud-client-tests-* --run -v
94+
```
95+
96+
### Troubleshooting
97+
98+
Below are common issues and fixes.
99+
100+
#### Autoformatting failed with error -5005
101+
102+
This is due to an issue with the storage block device. If using an SD card, ensure that the SD card is seated properly.
103+
104+
#### SYNC_FAILED during testing
105+
106+
Occasionally, if the test failed during a previous attempt, the SMCC Greentea tests fail to sync. If this is the case, please replug your device to the host PC. Additionally, you may need to update your DAPLink or ST-Link interface firmware.
107+
108+
#### Device identity is inconsistent
109+
110+
If your device ID in Pelion Device Management is inconsistent over a device reset, it could be because it is failing to open the credentials on the storage held in the Enhanced Secure File System. Typically, this is because the device cannot access the Root of Trust stored in SOTP.
111+
112+
One way to verify this is to see if the storage is reformatted after a device reset when `format-storage-layer-on-error` is set to `1` in `mbed_app.json`. It would appear on the serial terminal output from the device as:
113+
114+
```
115+
[SMCC] Initializing storage.
116+
[SMCC] Autoformatting the storage.
117+
[SMCC] Reset storage to an empty state.
118+
[SMCC] Starting developer flow
119+
```
120+
121+
When this occurs, look at the SOTP sectors defined in `mbed_app.json`:
122+
123+
```
124+
"sotp-section-1-address" : "0xFE000",
125+
"sotp-section-1-size" : "0x1000",
126+
"sotp-section-2-address" : "0xFF000",
127+
"sotp-section-2-size" : "0x1000",
128+
```
129+
130+
Ensure that the sectors are correct according to the flash layout of your device, and they are not being overwritten during the programming of the device. ST-Link devices overwrite these sectors when you use drag-and-drop of `.bin` files. Thus, moving the SOTP sectors to the end sectors of flash ensures they are not overwritten.
131+
132+
#### Stack overflow
133+
134+
If you receive a stack overflow error, increase the Mbed OS main stack size to at least 6000. You can do this by modifying the following parameter in `mbed_app.json`:
135+
136+
```
137+
"MBED_CONF_APP_MAIN_STACK_SIZE=6000",
138+
```
139+
140+
#### Device failed to register
141+
142+
Check the device allocation on your Pelion account to see if you are allowed additional devices to connect. You can delete development devices. After being deleted, they will not count toward your allocation.
143+
144+
### Known issues
145+
146+
Check open issues on [GitHub](https://github.com/ARMmbed/simple-mbed-cloud-client/issues).

0 commit comments

Comments
 (0)