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

MCUboot directly references struct flash_area members in certain places #2227

Open
Cpt-Seablue opened this issue Mar 7, 2025 · 0 comments
Open

Comments

@Cpt-Seablue
Copy link

MCUBoot version: 2.1.0

We are trying to port MCUBoot to our C++ based SDK. As a part of the porting process, we planned to provide a forward declaration of struct flash_area and then define the struct in C++ code.

However, doing this causes a compilation error in file bootutil_misc.c, on line 176:

.../third-party/mcuboot/repo/boot/bootutil/src/bootutil_misc.c:176:12: error: invalid use of undefined type 'const struct flash_area'
  176 |     if (fap->fa_id == FLASH_AREA_IMAGE_SCRATCH) {

If the problematic line is rewritten as below, the issue is solved.

if(flash_area_get_id(fap) == FLASH_AREA_IMAGE_SCRATCH) {

This seems like an obvious oversight, because the PORTING document says that MCUBoot should never access flash_area directly, and instead accessor functions are used. Also in the same bootutil_misc.c file, accessor functions are used, including flash_area_get_id().

While researching the issue, I found a PR about this exact problem #1929. It was reviewed, accepted but then never merged. It is now auto-closed by the bot.

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

No branches or pull requests

1 participant