mcuboot icon indicating copy to clipboard operation
mcuboot copied to clipboard

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

Open adri326 opened this issue 1 year ago • 1 comments

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.

adri326 avatar Mar 28 '24 09:03 adri326

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

de-nordic avatar Apr 02 '24 08:04 de-nordic

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[bot] avatar Sep 30 '24 01:09 github-actions[bot]