|
1 |
| -# mynewt-mcumgr |
| 1 | +# mcumgr |
| 2 | + |
| 3 | +This is mcumgr, version 0.0.1 |
| 4 | + |
| 5 | +mcumgr is a management library for 32-bit MCUs. The goal of mcumgr is to |
| 6 | +define a common management infrastructure with pluggable transport and encoding |
| 7 | +components. In addition, mcumgr provides definitions and handlers for some |
| 8 | +core commands: image management, file system management, and OS managment. |
| 9 | + |
| 10 | +mcumgr is operating system and hardware independent. It relies on hardware |
| 11 | +porting layers from the operating system it runs on. Currently, mcumgr runs on |
| 12 | +both the Apache Mynewt and Zephyr operating systems. |
| 13 | + |
| 14 | +## Command line tool |
| 15 | + |
| 16 | +The `mcumgr` command line tool is available at: |
| 17 | +https://github.com/apache/mynewt-mcumgr-cli. The tool is written in Go, and it |
| 18 | +is installed with the `go get` command: |
| 19 | + |
| 20 | +``` |
| 21 | +$ go get github.com/apache/mynewt-mcumgr-cli/mcumgr |
| 22 | +``` |
| 23 | + |
| 24 | +The `mcumgr` tool allows you to manage devices running an mcumgr server. |
| 25 | + |
| 26 | +## Architecture |
| 27 | + |
| 28 | +The mcumgr stack has the following layout: |
| 29 | + |
| 30 | +``` |
| 31 | ++---------------------+---------------------+ |
| 32 | +| <command handlers> | |
| 33 | ++---------------------+---------------------+ |
| 34 | +| mgmt | |
| 35 | ++---------------------+---------------------+ |
| 36 | +| <transfer encoding(s)> | |
| 37 | ++---------------------+---------------------+ |
| 38 | +| <transport(s)> | |
| 39 | ++---------------------+---------------------+ |
| 40 | +``` |
| 41 | + |
| 42 | +Items enclosed in angled brackets represent generic components that can be plugged into mcumgr. The items in this stack diagram are defined below: |
| 43 | +* *Command handler*: Processes incoming mcumgr requests and generates corresponding responses. A command handler is associated with a single command type, defined by a (group ID, command ID) pair. |
| 44 | +* *mgmt*: The core of mcumgr; facilitates the passing of requests and responses between the generic command handlers and the concrete transports and transfer encodings. |
| 45 | +* *Transfer encoding*: Defines how mcumgr requests and responses are encoded on the wire. |
| 46 | +* *Transport*: Sends and receives mcumgr packets over a particular medium. |
| 47 | + |
| 48 | +Each transport is configured with a single transfer encoding. |
| 49 | + |
| 50 | +As an example, the sample application `smp_svr` uses the following components: |
| 51 | + |
| 52 | +* Command handlers: |
| 53 | + * Image management (`img_mgmt`) |
| 54 | + * File system management (`fs_mgmt`) |
| 55 | + * OS management (`os_mgmt`) |
| 56 | +* Transfer/Transports protocols: |
| 57 | + * SMP/Bluetooth |
| 58 | + * SMP/Shell |
| 59 | + |
| 60 | +yielding the following stack diagram: |
| 61 | + |
| 62 | +``` |
| 63 | ++--------------+--------------+-------------+ |
| 64 | +| img_mgmt | fs_mgmt | os_mgmt | |
| 65 | ++--------------+--------------+-------------+ |
| 66 | +| mgmt | |
| 67 | ++---------------------+---------------------+ |
| 68 | +| SMP | SMP | |
| 69 | ++---------------------+---------------------+ |
| 70 | +| Bluetooth | Shell | |
| 71 | ++---------------------+---------------------+ |
| 72 | +``` |
| 73 | + |
| 74 | +## Command definition |
| 75 | + |
| 76 | +An mcumgr request or response consists of the following two components: |
| 77 | +* mcumgr header |
| 78 | +* CBOR key-value map |
| 79 | + |
| 80 | +How these two components are encoded and parsed depends on the transfer |
| 81 | +encoding used. |
| 82 | + |
| 83 | +The mcumgr header structure is defined in `mgmt/include/mgmt/mgmt.h` as |
| 84 | +`struct mgmt_hdr`. |
| 85 | + |
| 86 | +The contents of the CBOR key-value map are specified per command type. |
| 87 | + |
| 88 | +## Supported transfer encodings |
| 89 | + |
| 90 | +Mcumgr comes with one built-in transfer encoding: Simple Management Protocol (SMP). SMP requests and responses have a very basic structure. For details, see the comments at the top of `smp/include/smp/smp.h`. |
| 91 | + |
| 92 | +## Supported transports |
| 93 | + |
| 94 | +The mcumgr project defines two transports: |
| 95 | + * SMP/Console |
| 96 | + * SMP/Bluetooth |
| 97 | + |
| 98 | +Particulars of these transports are specified in the following documents: |
| 99 | + * SMP/Console: `transports/smp-console.md` |
| 100 | + * SMP/Bluetooth: `transports/smp-bluetooth.md` |
| 101 | + |
| 102 | +Implementations, being hardware- and OS-specified, are not included. |
| 103 | + |
| 104 | +## Browsing |
| 105 | + |
| 106 | +Information and documentation for mcumgr is stored within the source. |
| 107 | + |
| 108 | +For more information in the source, here are some pointers: |
| 109 | + |
| 110 | +- [cborattr](https://github.com/apache/mcumgr/tree/master/cborattr): Used for parsing incoming mcumgr requests. Destructures mcumgr packets and populates corresponding field variables. |
| 111 | +- [cmd](https://github.com/apache/mcumgr/tree/master/cmd): Built-in command handlers for the core mcumgr commands. |
| 112 | +- [ext](https://github.com/apache/mcumgr/tree/master/ext): Third-party libraries that mcumgr depends on. |
| 113 | +- [mgmt](https://github.com/apache/mcumgr/tree/master/mgmt): Code implementing the `mgmt` layer of mcumgr. |
| 114 | +- [samples](https://github.com/apache/mcumgr/tree/master/samples): Sample applications utilizing mcumgr. |
| 115 | +- [smp](https://github.com/apache/mcumgr/tree/master/smp): The built-in transfer encoding: Simple management protocol. |
| 116 | + |
| 117 | +## Known issues |
| 118 | + |
| 119 | +- (Zephyr) If the Bluetooth stack runs out of ACL transmit buffers while a large mcumgr response is being sent, the buffers never get freed. This appears to trigger a net_buf leak in the stack. |
| 120 | + |
| 121 | +## Joining |
| 122 | + |
| 123 | +Developers welcome! |
| 124 | + |
| 125 | +* Our Slack channel: https://mynewt.slack.com/messages/C7Y3K0C2J |
0 commit comments