Skip to content

Commit ccc0f82

Browse files
committed
espressif: Add implementation of flash_area_get_sectors_fa
Variant of flash_area_get_sectors that takes flash_area object pointer instead of flash area identifier. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 5bf18f4 commit ccc0f82

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

boot/espressif/include/flash_map_backend/flash_map_backend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ uint8_t flash_area_erased_val(const struct flash_area *area);
7676
//! Given flash area ID, return info about sectors within the area
7777
int flash_area_get_sectors(int fa_id, uint32_t *count,
7878
struct flash_sector *sectors);
79+
int flash_area_get_sectors_fa(const struct flash_area *fa, uint32_t *count,
80+
struct flash_sector *sectors);
7981

8082
//! Retrieve the flash sector a given offset belongs to.
8183
int flash_area_sector_from_off(uint32_t off, struct flash_sector *sector);

boot/espressif/port/esp_mcuboot.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,9 @@ uint8_t flash_area_erased_val(const struct flash_area *area)
342342
{
343343
return 0xff;
344344
}
345-
346-
int flash_area_get_sectors(int fa_id, uint32_t *count,
347-
struct flash_sector *sectors)
345+
int flash_area_get_sectors_fa(const struct flash_area *fa, uint32_t *count,
346+
struct flash_sector *sectors)
348347
{
349-
const struct flash_area *fa = prv_lookup_flash_area(fa_id);
350-
if (fa->fa_device_id != FLASH_DEVICE_INTERNAL_FLASH) {
351-
return -1;
352-
}
353-
354348
const size_t sector_size = FLASH_SECTOR_SIZE;
355349
uint32_t total_count = 0;
356350
for (size_t off = 0; off < fa->fa_size; off += sector_size) {
@@ -364,6 +358,17 @@ int flash_area_get_sectors(int fa_id, uint32_t *count,
364358
return 0;
365359
}
366360

361+
int flash_area_get_sectors(int fa_id, uint32_t *count,
362+
struct flash_sector *sectors)
363+
{
364+
const struct flash_area *fa = prv_lookup_flash_area(fa_id);
365+
if (fa->fa_device_id != FLASH_DEVICE_INTERNAL_FLASH) {
366+
return -1;
367+
}
368+
369+
return flash_area_get_sectors_fa(fa, count, sectors);
370+
}
371+
367372
int flash_area_sector_from_off(uint32_t off, struct flash_sector *sector)
368373
{
369374
sector->fs_off = (off / FLASH_SECTOR_SIZE) * FLASH_SECTOR_SIZE;

0 commit comments

Comments
 (0)