Skip to content

Move mcumgr functionality as internal Zephyr service #36092

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

Conversation

de-nordic
Copy link
Collaborator

@de-nordic de-nordic commented Jun 9, 2021

NOTE: Most of PRs can be squashed, are kept for easier re-editing of the PR contents.

The PR consists of commits:

  • affb8f9f66 mgmt/mcumgr: Add CONFIG_IMG_MGMT_FRUGAL_LIST
  • beba8296dc manifest: Remove mcumgr from manifest
  • fc2f666b29 mgmt/mcumgr/lib: Add Kconfig option MGMT_CBORATTR_FLOAT_SUPPORT
  • 2581113690 mgmt/mcumgr/lib: Replace license block
  • 053a701a84 mgmt/mcumgr/lib: Fix compliance
  • 801ce9d859 mgmt/mcumgr/lib: Documentation fixes
  • 35c4c220f2 mgmt/mcumgr/lib: Remove non-Zephyr code
  • 49098c1d28 mgmt/mcumgr/lib: Remove log management commands
  • 606d3aa mgmt/mcumgr/lib: Copy mcumgr library under mgmt subsystem

TODO:

  • Complete testing of MCUMGR.

Depends on: #39584

Resolves: #36017

@github-actions
Copy link

github-actions bot commented Jun 9, 2021

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff
mcumgr zephyrproject-rtos/mcumgr@c854c85 (master) N/A N/A

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@carlescufi
Copy link
Member

@de-nordic thank you for the PR.
I assume that this is a first step, to later then start modifying the source accordingly in order to get rid of the shim layers that are no longer required now that the code is in-tree. I would also suggest not having a lib/ folder in the end, but rather the code directly in subsys/mgmt/mcumgr/ with folders for transports and other logically independent parts.

@de-nordic
Copy link
Collaborator Author

@de-nordic thank you for the PR.
I assume that this is a first step, to later then start modifying the source accordingly in order to get rid of the shim layers that are no longer required now that the code is in-tree. I would also suggest not having a lib/ folder in the end, but rather the code directly in subsys/mgmt/mcumgr/ with folders for transports and other logically independent parts.

Yes. This is first step. I want to bring code as it is, of course with filled in missing licenses, compliance and style fixes here and there, so that it would past tests.

Then plan is to change structure of subsys/mgmg/mcumgr' into something like: commands, protocol, transports` and move files around; then specialize and reorganize the code to work efficiently with Zephry and so on.

I want to keep the thing moving and I have decided to make changes in steps; as I have more priority task to complete and some of them collide, regarding the mcumgr changes, I need to structure work in a way that lets me keep the changes going in gradually while working on other items.

@mniestroj mniestroj self-requested a review June 10, 2021 21:14
@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch 2 times, most recently from 838304c to ade2d28 Compare June 11, 2021 14:35
@nvlsianpu nvlsianpu self-requested a review June 15, 2021 06:05
@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch 2 times, most recently from b9cc16e to 53d44d5 Compare June 17, 2021 11:49
@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Aug 17, 2021
@de-nordic de-nordic removed the Stale label Aug 17, 2021
@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch 2 times, most recently from e808765 to 238e3af Compare August 20, 2021 11:22
@de-nordic de-nordic changed the title RFC: Move mcugmr functionality as internal Zephyr service RFC: Move mcumgr functionality as internal Zephyr service Oct 19, 2021
@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch 2 times, most recently from 142e791 to 0db5184 Compare October 20, 2021 16:19
@de-nordic de-nordic marked this pull request as ready for review October 20, 2021 16:26
@de-nordic de-nordic requested a review from carlescufi as a code owner October 20, 2021 16:26
@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch from ff197d3 to 8646913 Compare October 21, 2021 09:38
@de-nordic de-nordic changed the title RFC: Move mcumgr functionality as internal Zephyr service Move mcumgr functionality as internal Zephyr service Oct 21, 2021
@rerickson1
Copy link
Member

@ahedin25

@@ -11,5 +11,4 @@ are described below:
| `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 |
Copy link
Member

Choose a reason for hiding this comment

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

Need to squash this commit yet or change the commit description?
Leaving this commit may make the changes more readable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, you need to be more verbose because I did not get that.

Copy link
Member

Choose a reason for hiding this comment

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

The Commit description for the commit containing this change says it will be squashed. You should squash this commit or remove that message in the commit description.
I would be in favor of leaving this commit to have better tracking of the changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed information on squashing from commit messages.

| `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_OS_MGMT` | Enable mcumgr handlers for OS management | n |
Copy link
Collaborator

@nordicjm nordicjm Nov 9, 2021

Choose a reason for hiding this comment

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

Missing CONFIG_MCUMGR_GRP_ZEPHYR_BASIC and CONFIG_MCUMGR_CMD_STAT_MGMT

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

* Command handlers:
* Image management (`img_mgmt`)
* File system management (`fs_mgmt`)
* Log management (`log_mgmt`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't log management empty and unimplemented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


Developers welcome!

* Our Slack channel: https://mynewt.slack.com/messages/C7Y3K0C2J
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can replace with zephyr discord link https://discord.com/invite/Ck7jw53nU2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

struct cbor_out_attr_t {
const char *attribute; /** The attribute name (key). */
struct cbor_out_val_t val; /** The attribute value. */
bool omit; /** Attribute ignored if true. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment spacing here is a bit much

case CborAttrUnsignedIntegerType:
targetaddr = (char *)&cursor->addr.uinteger[offset];
break;
#if FLOAT_SUPPORT
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be good to use the zephyr float Kconfig name for this, or add a new Kconfig specifically for this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

lptr = &arr->arr.uintegers.store[off];
err |= cbor_value_get_uint64(&elem, lptr);
break;
#if FLOAT_SUPPORT
Copy link
Collaborator

Choose a reason for hiding this comment

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

As above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

TEST_CASE_DECL(test_cborattr_decode_string_array);
TEST_CASE_DECL(test_cborattr_decode_object_array);
TEST_CASE_DECL(test_cborattr_decode_unnamed_array);
TEST_CASE_DECL(test_cborattr_decode_substring_key);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be good addition for a future commit to add support for testing float and half float here also

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes we will have to do that.

Comment on lines +29 to +41
#define IMG_MGMT_STATE_F_ACTIVE 0x04
#define IMG_MGMT_STATE_F_PERMANENT 0x08

#define IMG_MGMT_VER_MAX_STR_LEN 25 /* 255.255.65535.4294967295\0 */

/*
* Swap Types for image management state machine
*/
#define IMG_MGMT_SWAP_TYPE_NONE 0
#define IMG_MGMT_SWAP_TYPE_TEST 1
#define IMG_MGMT_SWAP_TYPE_PERM 2
#define IMG_MGMT_SWAP_TYPE_REVERT 3

Copy link
Collaborator

Choose a reason for hiding this comment

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

Spacing seems different throughout file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

#endif

/* MTU for newtmgr responses */
#define MGMT_MAX_MTU 1024
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be good to have this as a Kconfig in future

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately right now this thing is not used anywhere.

Comment on lines +234 to +236
### Mcumgr/Newtmgr SMP Client Over Serial

`mcumgr` or `newtmgr` can be used over TTY serial with the following parameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does newtmgr still work with zephyr?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, mcumgr is just rename for newtmgr

The commit copies code of mcumgr, as a lib, under subsys/mgmt/mcumgr.
Only source files relevant for Zephyr have been copied, and changes
to source files have been limited only to path changes, where
required.
Samples have been left out as the only relevant sample, smp_svr,
is already within Zephyr source tree.

Signed-off-by: Dominik Ermel <[email protected]>
@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch from cf0240b to 8fb0f8f Compare November 9, 2021 14:59
@de-nordic
Copy link
Collaborator Author

@lairdjm Can you ping me on discord so we could have brief talk on further plans for the mcumgr?

@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch from 8fb0f8f to affb8f9 Compare November 9, 2021 15:37
@de-nordic de-nordic requested a review from rerickson1 November 9, 2021 15:41
Not implemented.

Signed-off-by: Dominik Ermel <[email protected]>
The commit removes MYNEWT sepcific code and code that has been
conditionally compiled with "ifndef _ZEPHYR_".

Signed-off-by: Dominik Ermel <[email protected]>
References to Mynewt have been removed and README for Zephyr has been
merged directly to the README.

Signed-off-by: Dominik Ermel <[email protected]>
Commit fixes compliance issues.

Signed-off-by: Dominik Ermel <[email protected]>
The commit changes licensing to SPDX tags.

Signed-off-by: Dominik Ermel <[email protected]>
The option enables float numbers processing within CBOR attributes.

Signed-off-by: Dominik Ermel <[email protected]>
The commit removes mcumgr library, as module, from west.yml
manifest, as the mcumgr library source is now kept within Zephyr
source code tree.

Signed-off-by: Dominik Ermel <[email protected]>
The commit adds Kconfig options that enables "frugal status list";
when enabled, the status list will be sent with zero, empty and false
values omitted, slightly reducing number of bytes sent as response
from device.

Signed-off-by: Dominik Ermel <[email protected]>
@de-nordic de-nordic force-pushed the move-mcumgr-to-zephyr-as-lib branch from affb8f9 to d8213cf Compare November 15, 2021 15:47
@carlescufi carlescufi merged commit 1d17a4b into zephyrproject-rtos:main Nov 16, 2021
@de-nordic de-nordic deleted the move-mcumgr-to-zephyr-as-lib branch November 30, 2021 14:03
rexut added a commit to tiacsys/bridle that referenced this pull request Jun 12, 2023
Remove mcumgr library, as module, from manifest, as the mcumgr
library source is now kept within Zephyr since v3.0, see:

zephyrproject-rtos/zephyr#36092

issues: #105
Signed-off-by: Stephan Linz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Move mcumgr functionality as internal Zephyr service
4 participants