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: flash_area_get_device_id implementation broken for ARM devices #2188

Open
de-nordic opened this issue Jan 23, 2025 · 0 comments
Open
Labels
area: zephyr Affects the Zephyr port

Comments

@de-nordic
Copy link
Collaborator

de-nordic commented Jan 23, 2025

There is a bug where flash_area_get_device_id will return flash area partition id instead of device id when compiled on ARM arch.

This happens because code returns flash_area.fa_id, where it should fa_device_id. The fa_device_id member does not exist in Zephyr variant of Flash Area API defined flash_area type.

This device id is only used by flash_device_base function, which is provided by system backend, to return offset where device FLASH to RAM mapping begins.

Current implementation of flash_device_base:

int flash_device_base(uint8_t fd_id, uintptr_t *ret)
{
if (fd_id != FLASH_DEVICE_ID) {
BOOT_LOG_ERR("invalid flash ID %d; expected %d",
fd_id, FLASH_DEVICE_ID);
return -EINVAL;
}
*ret = FLASH_DEVICE_BASE;
return 0;
}

will fail to return for ID that is different than FLASH_DEVICE_ID, which will, for Zephyr, be hardcoded as 0 or 1, to identify internal and external memory respectively, and Flash Area device ID may be anything from 0 to 255.

Bug has been introduced with #1661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: zephyr Affects the Zephyr port
Projects
None yet
Development

No branches or pull requests

1 participant