commit | 8ee7ad55868e415a0837ec3baf7630be8609d9f2 | [log] [tgz] |
---|---|---|
author | Nick Ward <nick.ward@setec.com.au> | Sun Sep 27 04:28:17 2020 +1000 |
committer | Fabio Utzig <utzig@utzig.org> | Tue Sep 29 16:49:50 2020 -0300 |
tree | bb84d2a2022b882259ec438ace947d24f6b2f823 | |
parent | 8d087a7e0e5485394419d10051606c92d68d2111 [diff] |
Fix image erase command for partial slot-1 erase This is a fix for devices in the field using mcuboot versions v1.6.0 or less. If a firmware update is attempted with a corrupt image and a power outage or reset occurs while the bootloader* is erasing the corrupt image then the secondary (slot-1) can be left in a state where the bootloader has not properly released slot-1 and a DFU transfer can no longer happen. Attempts to execute the image erase command will fail with 6 (MGMT_ERR_EBADSTATE). This commit fixes this issue by adding an additional requirement to determine if a slot is 'in use': the image must also be valid. If this additional requirement is not also met then the slot is considered not in use. * The issue was originally discovered with Zephyr v1.14 LTS and mcuboot release v3.1 and a fix for mcuboot has been applied here: https://github.com/JuulLabs-OSS/mcuboot/pull/765 mcuboot commit: 42335be22bc8fb576845f41e6174f1921fcff5d9 A fix for mcumgr library in Zephyr v1.14 LTS is in progress here: https://github.com/zephyrproject-rtos/zephyr/pull/26738 Note that previously this issue also affected the image upload command but that has not been fixed in the code restructure in commit 8914f8755983bf5e08ce30a56e0c0660341978e5 Signed-off-by: Nick Ward <nick.ward@setec.com.au>
This is mcumgr, version 0.1.0
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 management.
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.
For tips on using mcumgr with your particular OS, see the appropriate file from the list below:
To use mcumgr's image management support, your device must be running version 1.1.0 or later of the MCUboot boot loader. The other mcumgr features do not require MCUboot.
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. 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.
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:
Each transport is configured with a single transfer encoding.
As an example, the sample application smp_svr
uses the following components:
img_mgmt
)fs_mgmt
)log_mgmt
)os_mgmt
)yielding the following stack diagram:
+----------+----------+----------+----------+ | img_mgmt | fs_mgmt | log_mgmt | os_mgmt | +----------+----------+----------+----------+ | mgmt | +---------------------+---------------------+ | SMP | SMP | +---------------------+---------------------+ | Bluetooth | Shell | +---------------------+---------------------+
An mcumgr request or response consists of the following two components:
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.
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
.
The mcumgr project defines two transports:
Implementations, being hardware- and OS-specific, are not included.
Information and documentation for mcumgr is stored within the source.
For more information in the source, here are some pointers:
mgmt
layer of mcumgr.Developers welcome!