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

[RFC] Mcuboot XIP Support for Zephyr #29974

Closed
wants to merge 1 commit into from

Conversation

de-nordic
Copy link
Collaborator

@de-nordic de-nordic commented Nov 12, 2020

Provided script will automatically build alternative slot application.

Invocation:
python3 zephyr/scripts/direct_xip.py <original_build>

TODO:

  • add destination path selection instead of using harcoded one
  • error/exception handling

@de-nordic

This comment has been minimized.

@de-nordic de-nordic changed the title kconfig: Allow selecting of DTS partition for application code kconfig: Allow selecting DTS partition for application code Nov 12, 2020
Kconfig.zephyr Outdated Show resolved Hide resolved
Kconfig.zephyr Outdated Show resolved Hide resolved
Kconfig.zephyr Outdated Show resolved Hide resolved
Kconfig.zephyr Outdated Show resolved Hide resolved
@de-nordic de-nordic changed the title kconfig: Allow selecting DTS partition for application code [RFC] Mcuboot XIP Support for Zephyr Nov 16, 2020
@Laczen
Copy link
Collaborator

Laczen commented Nov 16, 2020

@de-nordic, I don't think it is required to do this change, correct usage of chosen partition allows to generate the correct image. The chosen partition info also has the required data to be passed to imgtool and to dfu-util/nrfjprog/...
To allow support for a bootloader (not only mcuboot) there are only two required pieces of info for a application image: where it will be placed in flash (partition offset) and where the image starts (unencrypted, uncompressed, ...): this is the partition offset + a image header size.

Easier support for "downloading" using dfu-util could be achieved by adding the location where the binary should be placed in flash to the header info, in that case the dfu "server" could read in the header and decide where to place it or to reject it. This is much more flexible that selecting alt-0 or alt-1 (BTW, selecting alt-0 to "upload" from flash should be disallowed). When using a "hex"-loader this is maybe less required, but still usefull for the bootloader to distinguish between execute or move.

@de-nordic
Copy link
Collaborator Author

Easier support for "downloading" using dfu-util could be achieved by adding the location where the binary should be placed in flash to the header info in that case the dfu "server" could read in the header and decide where to place it or to reject it.

Yes, but you are talking abut hi-end solution, I am still trying to build things for two slots. You may add that comment to the original issue reported here: #27673.

But yes, it would be nice to add header that would identify the slot of binary and allow dfu client to reject it citing the problem, or even pack two binaries together (one for each slot) and allow dft to negotiate which one will go in.

I will try with zephyr.dfu-code-partition that is supposed to be set to the slot the application will be uploaded to.
The combination of zephyr,code-partition and zephyr, dfu-code-partition, or lack of the former one, would decide whether application is built for dual slot bootable device, XIP dual boot device or single slot device.

@Laczen
Copy link
Collaborator

Laczen commented Nov 16, 2020

@de-nordic, maybe I am missing something, I was thinking you are trying to create a image to be executed from slot1. This could be done by setting the chosen partition to slot1 (or image1) nothing more. But then again, maybe you are trying to achieve something else.

@nandojve
Copy link
Member

nandojve commented Dec 1, 2020

Hi folks, I noted this improvement and have couple questions:

  1. How MCUboot will handle 3 or 4 images, or even more?

I mean, there are work on Zephyr to enable NS and SE images (non secure and secure images). These are two independent partitions + at least another one as temporary storage (scenario 1). So, how MCUboot + Zephyr will handle this ? I imagine XIP is essential for lots of platforms and there is a special case, i.MX-RT that only have external memory. Having two images on a single bin (scenario 2) is an alternative but can be impractical with LWPAN. My firsts tests with BLE IPSP (PC <-> nRF) needs around 30min to download and update 1 image with minimal resources to run the example without mesh and only 2 nodes.

  1. Since there will be needed work to change the current dual image to a new thing, would be interesting have a infrastructure that allows multi-image support, or something that address this current/future scenario?

Sorry if this is not the right place to add both questions but it seemed opportune to raise them.

CC: @otavio

@utzig
Copy link
Member

utzig commented Dec 1, 2020

  1. How MCUboot will handle 3 or 4 images, or even more?

The mcumgr CLI app already has a flag to choose the image pair where to upload, image upload -n <image-number>, which can be used to choose between S/NS, but this currently uploads in a fixed slot. I don't remember if the mcumgr library supports this, but MCUboot surely does. With the XIP support it will probably also get an extra flag for the slot number. Then a user will have control of what image pair and slot a particular image should be uploaded to.

Copy link
Collaborator

@nvlsianpu nvlsianpu left a comment

Choose a reason for hiding this comment

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

Did you consider to keep working usb dfu class when it is part of mcuboot in single application-slot-mode?

@@ -344,7 +353,7 @@ static void dfu_reset_counters(void)
{
dfu_data.bytes_sent = 0U;
dfu_data.block_nr = 0U;
if (flash_img_init(&dfu_data.ctx)) {
if (flash_img_init_id(&dfu_data.ctx, UPDATEABLE_FLASH_IMG_ID)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this is not applied in dfu_data declaration?

The script is intended to be run on already, successfully, compleated
build to generate build for alternative slot.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
@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
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 Jul 14, 2021
@de-nordic de-nordic removed the Stale label Jul 14, 2021
@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 Sep 13, 2021
@de-nordic de-nordic removed the Stale label Sep 13, 2021
@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 Nov 13, 2021
@de-nordic de-nordic removed the Stale label Nov 15, 2021
@tejlmand
Copy link
Collaborator

@de-nordic please take a look here: #40555 I believe the approach in that RFC will be very suitable for this kind of work you need to do here.

@de-nordic
Copy link
Collaborator Author

@de-nordic please take a look here: #40555 I believe the approach in that RFC will be very suitable for this kind of work you need to do here.

Thanks, I will take a look.

@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 Feb 12, 2022
@github-actions github-actions bot closed this Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Documentation area: Kconfig area: Modules area: native port Host native arch port (native_posix) area: Tests Issues related to a particular existing or missing test DNM This PR should not be merged (Do Not Merge) manifest manifest-mcuboot manifest-mcumgr Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants