Skip to content

Commit aa7e2b1

Browse files
michallencnvlsianpu
authored andcommitted
nuttx: switch to flash_area_get_sector
Function flash_area_sector_from_off is replaced with newly used flash_area_get_sector to cope with calls in bootutil_misc.c file. This is required for CONFIG_MCUBOOT_SWAP_USING_MOVE to work correctly. Signed-off-by: Michal Lenc <[email protected]>
1 parent 61898da commit aa7e2b1

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

boot/nuttx/include/flash_map_backend/flash_map_backend.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ static inline uint8_t flash_area_get_device_id(const struct flash_area *fa)
107107
}
108108

109109
/****************************************************************************
110-
* Name: flash_area_sector_from_off
110+
* Name: flash_area_get_sector
111111
*
112112
* Description:
113113
* Retrieve the flash sector a given offset belongs to.
114114
*
115115
* Input Parameters:
116+
* fap - flash area structure
116117
* off - address offset.
117118
* sector - flash sector
118119
*
@@ -121,7 +122,8 @@ static inline uint8_t flash_area_get_device_id(const struct flash_area *fa)
121122
*
122123
****************************************************************************/
123124

124-
int flash_area_sector_from_off(off_t off, struct flash_sector *fs);
125+
int flash_area_get_sector(const struct flash_area *fap, off_t off,
126+
struct flash_sector *fs);
125127

126128
/****************************************************************************
127129
* Name: flash_area_get_off

boot/nuttx/src/flash_map_backend/flash_map_backend.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,13 @@ int flash_area_id_from_image_offset(uint32_t offset)
812812
}
813813

814814
/****************************************************************************
815-
* Name: flash_area_sector_from_off
815+
* Name: flash_area_get_sector
816816
*
817817
* Description:
818818
* Retrieve the flash sector a given offset belongs to.
819819
*
820820
* Input Parameters:
821+
* fap - flash area structure
821822
* off - address offset.
822823
* sector - flash sector
823824
*
@@ -826,15 +827,17 @@ int flash_area_id_from_image_offset(uint32_t offset)
826827
*
827828
****************************************************************************/
828829

829-
int flash_area_sector_from_off(off_t off, struct flash_sector *fs)
830+
int flash_area_get_sector(const struct flash_area *fap, off_t off,
831+
struct flash_sector *fs)
830832
{
831-
struct flash_device_s *dev = lookup_flash_device_by_offset(off);
833+
off_t offset = fap->fa_off + off;
834+
struct flash_device_s *dev = lookup_flash_device_by_offset(offset);
832835
if (dev == NULL)
833-
{
834-
return -errno;
835-
}
836+
{
837+
return -errno;
838+
}
836839

837-
fs->fs_off = (off / dev->mtdgeo.erasesize) * dev->mtdgeo.erasesize;
840+
fs->fs_off = (offset / dev->mtdgeo.erasesize) * dev->mtdgeo.erasesize;
838841
fs->fs_size = dev->mtdgeo.erasesize;
839842

840843
return 0;

0 commit comments

Comments
 (0)