Skip to content

Add documentation about mbed dm #681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 4, 2018
4 changes: 4 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,10 @@
"type": "markdown",
"url": "https://github.com/ARMmbed/mbed-os-5-docs/blob/development/docs/tools/offline/cli-compile.md"
},
{
"type": "markdown",
"url": "https://github.com/ARMmbed/mbed-os-5-docs/blob/development/docs/tools/offline/cli-device-management.md"
},
{
"type": "markdown",
"url": "https://github.com/ARMmbed/mbed-os-5-docs/blob/development/docs/tools/offline/cli-collaborate.md"
Expand Down
76 changes: 76 additions & 0 deletions docs/tools/offline/cli-device-management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
### Updating Devices with Mbed CLI

Mbed CLI includes features that help prepare and ship updates for devices managed through Pelion. The Mbed CLI uses the subcommands starting with `mbed device-management`, `mbed dev-mgmt` or `mbed dm` to manage devices.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mbed CLI doesn't take "the"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd also clarify that these are all the same command, that they're just aliases. I'd suggest something along these lines (but feel free to tweak):

Mbed CLI provides the subcommand mbed device-management to manage devices (mbed dev-mgmt are mbed dm are also available as shorter aliases).


Start by configuring your Mbed Cloud SDK API Key, target and toolchain. Obtain the API Key from the Pelion portal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, it's the Device Management Portal. Yes, this is a mouthful. :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API key (not Key)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start what? It would help if you explained the process you're going to detail.


```
$ mbed config -G CLOUD_SDK_API_KEY ak_...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally use something like <API_KEY>, not ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'd drop the CLOUD_SDK_ part

$ mbed target K64F
$ mbed toolchain GCC_ARM
```

Next, initialize the device management feature of Mbed CLI with the following command:

```
$ mbed device-management init -d "<company domain name>" -m "<product model identifier>"
```

First, this command asks for information about your update certificate. When Mbed CLI has enough information, it creates several files:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need "first" here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total nit pick: The line "When Mbed CLI has enough information" tripped up my brain for a second (enough information from the command line args? Where is it coming from?). How do you feel about this as an alternative:

After completing the prompts, Mbed CLI creates several files:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

* A certificate in `.update-certificates/default.der`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this will render as a list without an empty line before the first bullet

* A matching private key in `.update-certificates/default.key.pem`.
* A set of default settings in `.manifest_tool.json`.
* Mbed Cloud settings in `.mbed_cloud_config.json`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device Management settings (though the filenames are still the same...)

* Mbed Cloud developer credentials in `mbed_cloud_dev_credentials.c`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is only for development? What about production flows?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in the Mbed OS docs, it should (as part of the intro way up there around line 1) link to the Pelion docs. As an Mbed OS user, I've no idea what all these concepts mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no production flow yet. That's not part of the requirement as far as I know.

* Mbed Cloud update credentials in `update_defalut_resources.c`

The default settings include:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the default settings in mbed_cloud_config.json? Would help to make them sub-bullets of that, rather than make the reader go back to figure out where default settings come in (this is only obvious to people who already know - most readers won't remember that they've just read about default settings two lines ago).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And needs an empty line to render the bullets

* A unique vendor identifier, based on the domain name supplied to `init`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When did I supply things to init?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You supplied them to mbed dm init above.

* A unique model identifier, based on the vendor identifier and the model name supplied to `init`.
* The path of the certificate and private key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which certificate? Developer? Update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update.


If you do not want to enter the subject information for your update certificate (country, state, city, organization and so on), add the `-q` flag to the command above.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How far above? Why not add this as a note right below the command?


As `device-management` is very long to type, the remainder of this document will use the `mbed dm` alias for all device management subcommands.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should have said that right after you listed the three possible forms and never used the full form again. It's so random here.


<span class="notes">**Note:** The certificate created in `mbed dm init` is not suitable for production. Use it for testing and development only. To create a certificate for production purposes, please use an air-gapped computer or a Hardware Security Module. When going to production, conduct a security review on your manifest signing infrastructure, as it is the core of the security guarantees for update client.</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like someone from Update to look at this note. @bremoran ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also it should come earlier (right around where I asked about a production flow)


#### Single-device update
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need empty line after headers, too

Once you have run `mbed device-management init`, you can perform updates on a single device by:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device Management isn't shortened here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also haven't been 'allowed' to shorten it on our side, but I'm not sure that requirements still stands for what things are named in code. Also not willing to risk making that decision myself 😑

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is its own thing; they need to sort it out between them

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like using "once you have x". Also, why is single-device hyphenated?

Copy link
Contributor Author

@theotherjimmy theotherjimmy Aug 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iriark01 I'll reword it. Single device is not hyphenated as that's not how I would write. I'll drop single.


```
$ mbed compile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But what am I compiling? Where should I be at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably immediately after mbed dm init, as the text above indicated.

$ mbed dm update device -D <device ID>
```

This will perform several actions:
1. Upload the payload, generated by `mbed compile`, to Mbed Cloud.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device Management

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That applies for all instances of Mbed Cloud in this list.

1. Hash the payload and create a manifest that links to its location in Mbed Cloud.
1. Create an update campaign for the supplied device ID, with the newly created manifest.
1. Start the campaign.
1. Wait for the campaign to complete.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's waiting? Even though devices could take ages to come on line and receive an update? What happens if it fails? Do I see that here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point of the command is to update a device. so, yes it waits for that to happen, and yes that can take a while.

1. Delete the payload, manifest and update campaign out of Mbed Cloud.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deletes the update campaign seems odd - don't we show all finished campaigns in the portal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intended for development, so I would expect a developer to do this flow 4-40 times/hour. That would flood the campaign list.


This allows development with a device for testing purposes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should come before you start giving me commands - I want to know why I'm bothering to compile and run things.


#### Multidevice update
If you need to update more than one device, you can use the Mbed Cloud portal to create device filters that can include many devices into an update campaign. First, you need a manifest. Once you have run `mbed device-management init`, you can create manifests by:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device Management Portal


```
$ mbed compile
$ mbed dm update prepare
```

Optionally, a name and description for the payload and corresponding manifest can be provided:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why passive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy paste.


```
$ mbed dm update prepare -n <PAYLOAD_NAME> -d <PAYLOAD_DESCRIPTION>\
--manifest-name <MANIFEST_NAME> --manifest-description <MANIFEST_DESCRIPTION>
```

Both methods of creating a manifest use the defaults created in `mbed dm init`. You can override each default using an input file or command-line arguments. See below for more details.

Once you execute `mbed dm update prepare`, Mbed CLI automatically uploads to Mbed Cloud and you can then create and start an update campaign using the Mbed Cloud portal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Device Management, Device Management Portal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to where we explain that (in the Pelion docs) would help massively. Also, it's not obvious that the commands you give me have nothing to do with the filter you sent me to create a second before.


### Advanced usage
Mbed CLI allows for significantly more flexibility than the model above shows in exactly the same way as Manifest Tool. You can override each of the defaults that `mbed dm init` sets by using the command-line or an input file. Mbed CLI supports a variety of commands. You can print a full list of commands by using `manifest-tool --help`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mbed CLI keeps its name as far as I'm aware.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also looks like in our manifest tool documentation, it's not capitalized, and instead referred to as "the manifest tool."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the tool's docs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing how this is the first mention of the manifest tool, I would provide a link to the tool's page.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/docs/working/updating-firmware/manifest-tool.html