Skip to content
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

zephyr: Missing header and definitions in boot_serial extensions #1551

Conversation

de-nordic
Copy link
Collaborator

Moved group definitions to extension source code.

Signed-off-by: Dominik Ermel dominik.ermel@nordicsemi.no

Moved group definitions to extension source code.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
@@ -21,6 +20,9 @@

BOOT_LOG_MODULE_DECLARE(mcuboot);

#define ZEPHYR_MGMT_GRP_BASIC (MGMT_GROUP_ID_PERUSER - 1)
#define ZEPHYR_MGMT_GRP_BASIC_CMD_ERASE_STORAGE 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be including <zephyr/mgmt/mcumgr/grp/zephyr/zephyr_basic.h> not redefining these

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unfortuately this requires addition of mgmt.h which then requires addition of smp.h which then ... generally half of MCUmgr and Zephyr needs to be brought here. The MCUboot provides own definitions for groups it serves, so I do not find this as a problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is duplicating data and making it redundant/prone to errors if one is changed. @gmarull thoughts on this?

For the command, zephyr_basic.h can at least be included as it has no include requirements

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

MCUboot is independent from Zephyr and may redefine identifiers as it wishes, and actually does so.

Copy link
Collaborator

Choose a reason for hiding this comment

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

boot/zephyr/boot_serial_extensions.c this is a zephyr file. Neither MCUmgr groups nor commands should not re-registered, or like any duplicate code you have the possibility of a mismatch in the future - this is not a MCUmgr-specific issue

de-nordic added a commit to de-nordic/sdk-mcuboot that referenced this pull request Dec 19, 2022
... extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
@kmeinhar
Copy link

kmeinhar commented Jan 3, 2023

I am curious what is the status on this PR? Is this the intended fix or is there another way to use boot_serial extensions?

@de-nordic
Copy link
Collaborator Author

I am curious what is the status on this PR?

Disagreement limbo.

Is this the intended fix

Yes.
This specific source file defines Zephyr specific extension to MCUboot serial recovery. It is Zephyr specific in a way that it has originally been defined for Zephyr to provide command of storage erase; it has been given group 1 below first user group in Zephyr.
MCUboot is free to redefine any identifiers for the SMP protocol group as it wishes, which the PR tries to do.
This is a little bit gray area because the code implements Zephyr specific codes so the best way to do that would be to bring identifier definitions from some Zephyr header, but this causes major problem: Zephyr headers, often, do not separate identifiers/enums and API definitions which means that when you try to include header for some identifier you end up including half of the system headers, and this gets problematic when some of the headers are not visible, for some reason, to MCUboot.
So it makes the Zephyr extensions for boot_serial not possible to compile.

That is why the redefinition here.

or is there another way to use boot_serial extensions?

I do not understand the question.

@tejlmand
Copy link
Contributor

tejlmand commented Jan 3, 2023

Zephyr headers, often, do not separate identifiers/enums and API definitions which means that when you try to include header for some identifier you end up including half of the system headers, and this gets problematic when some of the headers are not visible, for some reason, to MCUboot.

Have you tried opening a PR in Zephyr that improves this for this use-case ?

That would allow you to just include what you need and avoid duplication of define, as well as it avoids including half of Zephyr system headers.

@de-nordic
Copy link
Collaborator Author

Zephyr headers, often, do not separate identifiers/enums and API definitions which means that when you try to include header for some identifier you end up including half of the system headers, and this gets problematic when some of the headers are not visible, for some reason, to MCUboot.

Have you tried opening a PR in Zephyr that improves this for this use-case ?

No. I was considering that, but I will (or @nordicjm ) doing the work for MCUmgr anyway and it takes time to review stuff in Zephyr. And I needed quick workaround for customer visible issue, that is why I have decided to duplicate the definition rather than wait for the solution to get accepted in Zephyr. Afterwards I can remove workaround without customer noticing.

The question is whether this should be considered Zephyr-wide issue to fix or are we fixing the MCUmgr headers for the use-case.

That would allow you to just include what you need and avoid duplication of define, as well as it avoids including half of Zephyr system headers.

I don't mind duplicate defines in separate project, as the project is allowed to define stuff as it wants as long as it works with protocol specification, but as I have mentioned before: in this case it would be better if Zephyr headers could be used.

cvinayak pushed a commit to de-nordic/sdk-mcuboot that referenced this pull request Jan 11, 2023
... extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
de-nordic added a commit to nrfconnect/sdk-mcuboot that referenced this pull request Jan 11, 2023
... extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
@de-nordic de-nordic marked this pull request as draft February 15, 2023 15:55
mbolivar-nordic pushed a commit to mbolivar-nordic/sdk-mcuboot that referenced this pull request Feb 20, 2023
…extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit 9d2f9b5)
de-nordic added a commit to nrfconnect/sdk-mcuboot that referenced this pull request Mar 17, 2023
…extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit 9d2f9b5)
de-nordic added a commit to nrfconnect/sdk-mcuboot that referenced this pull request Mar 27, 2023
…extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit 9d2f9b5)
de-nordic added a commit to de-nordic/sdk-mcuboot that referenced this pull request Apr 12, 2023
…extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit 9d2f9b5)
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
de-nordic added a commit to de-nordic/sdk-mcuboot that referenced this pull request May 26, 2023
…extensions

Moved group definitions to extension source code.

Upstream PR: mcu-tools/mcuboot#1551

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
(cherry picked from commit 2fea451)
@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 15, 2023
@github-actions github-actions bot closed this Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants