Skip to content

zephyr: flash_area_get_device_id implementation broken for ARM devices #2188

Open
@de-nordic

Description

@de-nordic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions