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

boot/bootutil: Remove direct accesses to flash_area::fa_xyz #1929

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adri326
Copy link

@adri326 adri326 commented Mar 28, 2024

I plan on working towards building a Rust API for bootutil, and I would like to pass an opaque struct flash_area to bootutil, so that this struct can be fully managed from the rust side, with only a few extern "C" functions that will need to be defined on the rust side before linking.

This PR removes the few direct accesses to flash_area::fa_id, flash_area::fa_off and flash_area::fa_size that are present in bootutil, and replaces them with the corresponding flash_area_get_XYZ functions.

Currently, however, one can only use an opaque struct flash_area if they enable the new flash sector API (MCUBOOT_USE_FLASH_AREA_GET_SECTORS), since otherwise loader.c will attempt to create an array of struct flash_area. I thus do not know how we could ensure that no additional mentions of flash_area::fa_XYZ will sneak back into the code.

One option would be to create a bootutil_shared.h file, which would contain the minimal expected subset of flash_map_backend.h, and progressively have files include it, until the flash_map_backend.h only needs to provide the struct flash_area for when MCUBOOT_USE_FLASH_AREA_GET_SECTORS isn't toggled on.

@nordicjm nordicjm requested a review from de-nordic April 2, 2024 08:27
Copy link
Collaborator

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

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

Thanks.

@de-nordic
Copy link
Collaborator

@adri326 Do not get used to flash_area in MCUboot: https://github.com/orgs/mcu-tools/projects/1?pane=issue&itemId=40095438

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants