forked from zephyrproject-rtos/mcumgr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ext: lib: mgmt: mcumgr management infrastructure.
The goal of mcumgr is to define a common management infrastructure with pluggable transport and encoding components. In addition, mcumgr provides definitions and handlers for some core commands: e.g., image management, file system management, and OS managment. Origin: mcumgr License: Apache 2.0 URL: https://github.com/apache/mynewt-mcumgr commit: 59210e3 Purpose: Introduction of mcumgr Maintained-by: External Signed-off-by: Christopher Collins <[email protected]>
- Loading branch information
0 parents
commit deadab4
Showing
66 changed files
with
6,433 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
zephyr_interface_library_named(MCUMGR) | ||
|
||
zephyr_library() | ||
add_subdirectory(cborattr) | ||
add_subdirectory(cmd) | ||
add_subdirectory(mgmt) | ||
add_subdirectory(smp) | ||
add_subdirectory(util) | ||
|
||
zephyr_library_link_libraries(MCUMGR) | ||
|
||
target_link_libraries(MCUMGR INTERFACE | ||
zephyr_interface | ||
TINYCBOR | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
menuconfig MCUMGR | ||
bool | ||
prompt "mcumgr Support" | ||
select TINYCBOR | ||
default n | ||
help | ||
This option enables the mcumgr management library. | ||
|
||
if MCUMGR | ||
source "ext/lib/mgmt/mcumgr/mgmt/port/zephyr/Kconfig" | ||
source "ext/lib/mgmt/mcumgr/cmd/Kconfig" | ||
|
||
config APP_LINK_WITH_MCUMGR | ||
bool "Link 'app' with MCUMGR" | ||
default y | ||
help | ||
Add MCUMGR header files to the 'app' include path. It may be | ||
disabled if the include paths for MCUMGR are causing aliasing | ||
issues for 'app'. | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## Building and using mcumgr with Apache Mynewt | ||
|
||
NOTE: The *mcumgr* library consists of functionality that is already present in | ||
the `apache-mynewt-core` repo. There is currently no need to use the external | ||
*mcumgr* library with Mynewt, as the functionality is already built in to the | ||
OS. To use this library with a Mynewt application, you will need to remove the | ||
duplicate functionality from your copy of the `apache-mynewt-core` repo. | ||
|
||
### Configuration | ||
|
||
To use *mcumgr*, your Mynewt app needs to be configured to use: | ||
1. An mcumgr transfer encoding | ||
2. An mcumgr transport | ||
3. (optional) Command handlers. | ||
|
||
This is done by adding the necessary dependencies to your app or target. The following list of dependencies adds support for the SMP transfer encoding, the Bluetooth and shell transports, and all the built-in command handlers: | ||
|
||
``` | ||
- '@apache-mynewt-core/mgmt/newtmgr/transport/ble' | ||
- '@apache-mynewt-core/mgmt/newtmgr/transport/nmgr_shell' | ||
- '@mynewt-mcumgr/cmd/fs_mgmt' | ||
- '@mynewt-mcumgr/cmd/img_mgmt' | ||
- '@mynewt-mcumgr/cmd/os_mgmt' | ||
- '@mynewt-mcumgr/smp' | ||
``` | ||
|
||
For an example of an app that uses mcumgr, see the `smp_svr` sample app in `samples/smp_svr/mynewt`. | ||
|
||
### Building | ||
|
||
With the necessary dependencies in place, your project can be built using the usual `newt build <target-name>` or `newt run <target-name>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## Using mcumgr with Zephyr | ||
|
||
### Configuration | ||
|
||
The `samples/smp_svr/zephyr/prj.conf` file provides a good starting point for | ||
configuring an application to use *mcumgr*. The major configuration settings | ||
are described below: | ||
|
||
| Setting | Description | Default | | ||
| ------------- | ------------- | ------- | | ||
| `CONFIG_MCUMGR` | Enable the mcumgr management library. | n | | ||
| `CONFIG_MCUMGR_CMD_FS_MGMT` | Enable mcumgr handlers for file management | n | | ||
| `CONFIG_MCUMGR_CMD_IMG_MGMT` | Enable mcumgr handlers for image management | n | | ||
| `CONFIG_MCUMGR_CMD_LOG_MGMT` | Enable mcumgr handlers for log management | n | | ||
| `CONFIG_MCUMGR_CMD_OS_MGMT` | Enable mcumgr handlers for OS management | n | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# mcumgr | ||
|
||
This is mcumgr, version 0.0.1 | ||
|
||
mcumgr is a management library for 32-bit MCUs. The goal of mcumgr is to | ||
define a common management infrastructure with pluggable transport and encoding | ||
components. In addition, mcumgr provides definitions and handlers for some | ||
core commands: image management, file system management, and OS managment. | ||
|
||
mcumgr is operating system and hardware independent. It relies on hardware | ||
porting layers from the operating system it runs on. Currently, mcumgr runs on | ||
both the Apache Mynewt and Zephyr operating systems. | ||
|
||
## Getting started | ||
|
||
For tips on using mcumgr with your particular OS, see the appropriate file from | ||
the list below: | ||
|
||
* README-mynewt.md | ||
* README-zephyr.md | ||
|
||
## Dependencies | ||
|
||
To use mcumgr's image management support, your device must be running version | ||
1.1.0 or later of the [MCUboot boot | ||
loader](https://github.com/runtimeco/mcuboot). The other mcumgr features do | ||
not require MCUboot. | ||
|
||
## Command line tool | ||
|
||
The `mcumgr` command line tool is available at: | ||
https://github.com/apache/mynewt-mcumgr-cli. The command line tool requires [Go | ||
1.7 or later](https://golang.org/dl/). Once Go is installed and set up on your | ||
system, you can install the mcumgr CLI tool by issuing the following `go get` | ||
command: | ||
|
||
``` | ||
$ go get github.com/apache/mynewt-mcumgr-cli/mcumgr | ||
``` | ||
|
||
The `mcumgr` tool allows you to manage devices running an mcumgr server. | ||
|
||
## Architecture | ||
|
||
The mcumgr stack has the following layout: | ||
|
||
``` | ||
+---------------------+---------------------+ | ||
| <command handlers> | | ||
+---------------------+---------------------+ | ||
| mgmt | | ||
+---------------------+---------------------+ | ||
| <transfer encoding(s)> | | ||
+---------------------+---------------------+ | ||
| <transport(s)> | | ||
+---------------------+---------------------+ | ||
``` | ||
|
||
Items enclosed in angled brackets represent generic components that can be plugged into mcumgr. The items in this stack diagram are defined below: | ||
* *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. | ||
* *mgmt*: The core of mcumgr; facilitates the passing of requests and responses between the generic command handlers and the concrete transports and transfer encodings. | ||
* *Transfer encoding*: Defines how mcumgr requests and responses are encoded on the wire. | ||
* *Transport*: Sends and receives mcumgr packets over a particular medium. | ||
|
||
Each transport is configured with a single transfer encoding. | ||
|
||
As an example, the sample application `smp_svr` uses the following components: | ||
|
||
* Command handlers: | ||
* Image management (`img_mgmt`) | ||
* File system management (`fs_mgmt`) | ||
* Log management (`log_mgmt`) | ||
* OS management (`os_mgmt`) | ||
* Transfer/Transports protocols: | ||
* SMP/Bluetooth | ||
* SMP/Shell | ||
|
||
yielding the following stack diagram: | ||
|
||
``` | ||
+----------+----------+----------+----------+ | ||
| img_mgmt | fs_mgmt | log_mgmt | os_mgmt | | ||
+----------+----------+----------+----------+ | ||
| mgmt | | ||
+---------------------+---------------------+ | ||
| SMP | SMP | | ||
+---------------------+---------------------+ | ||
| Bluetooth | Shell | | ||
+---------------------+---------------------+ | ||
``` | ||
|
||
## Command definition | ||
|
||
An mcumgr request or response consists of the following two components: | ||
* mcumgr header | ||
* CBOR key-value map | ||
|
||
How these two components are encoded and parsed depends on the transfer | ||
encoding used. | ||
|
||
The mcumgr header structure is defined in `mgmt/include/mgmt/mgmt.h` as | ||
`struct mgmt_hdr`. | ||
|
||
The contents of the CBOR key-value map are specified per command type. | ||
|
||
## Supported transfer encodings | ||
|
||
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`. | ||
|
||
## Supported transports | ||
|
||
The mcumgr project defines two transports: | ||
* SMP/Console | ||
* SMP/Bluetooth | ||
|
||
Particulars of these transports are specified in the following documents: | ||
* SMP/Console: `transports/smp-console.md` | ||
* SMP/Bluetooth: `transports/smp-bluetooth.md` | ||
|
||
Implementations, being hardware- and OS-specified, are not included. | ||
|
||
## Browsing | ||
|
||
Information and documentation for mcumgr is stored within the source. | ||
|
||
For more information in the source, here are some pointers: | ||
|
||
- [cborattr](https://github.com/apache/mynewt-mcumgr/tree/master/cborattr): Used for parsing incoming mcumgr requests. Destructures mcumgr packets and populates corresponding field variables. | ||
- [cmd](https://github.com/apache/mynewt-mcumgr/tree/master/cmd): Built-in command handlers for the core mcumgr commands. | ||
- [ext](https://github.com/apache/mynewt-mcumgr/tree/master/ext): Third-party libraries that mcumgr depends on. | ||
- [mgmt](https://github.com/apache/mynewt-mcumgr/tree/master/mgmt): Code implementing the `mgmt` layer of mcumgr. | ||
- [samples](https://github.com/apache/mynewt-mcumgr/tree/master/samples): Sample applications utilizing mcumgr. | ||
- [smp](https://github.com/apache/mynewt-mcumgr/tree/master/smp): The built-in transfer encoding: Simple management protocol. | ||
|
||
## Joining | ||
|
||
Developers welcome! | ||
|
||
* Our Slack channel: https://mynewt.slack.com/messages/C7Y3K0C2J |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
target_include_directories(MCUMGR INTERFACE | ||
include | ||
) | ||
|
||
zephyr_library_sources( | ||
cborattr/src/cborattr.c | ||
) |
Oops, something went wrong.