Skip to content

Commit 794d150

Browse files
author
Offir Kochalsky
committed
fix unaligned address erase problem
1 parent 9d936e1 commit 794d150

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ int QSPIFBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size
374374
int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
375375
{
376376
int type = 0;
377+
uint32_t offset = 0;
377378
uint32_t chunk = 4096;
378379
unsigned int cur_erase_inst = _erase_instruction;
379380
int size = (int)in_size;
@@ -393,7 +394,8 @@ int QSPIFBlockDevice::erase(bd_addr_t addr, bd_size_t in_size)
393394
// find the matching instruction and erase size chunk for that type.
394395
type = _utils_iterate_next_largest_erase_type(bitfield, size, (int)addr, _region_high_boundary[region]);
395396
cur_erase_inst = _erase_type_inst_arr[type];
396-
chunk = _erase_type_size_arr[type];
397+
offset = addr % _erase_type_size_arr[type];
398+
chunk = ( (offset + size) < _erase_type_size_arr[type]) ? size : (_erase_type_size_arr[type] - offset);
397399

398400
tr_debug("DEBUG: erase - addr: %llu, size:%d, Inst: 0x%xh, chunk: %lu , ",
399401
addr, size, cur_erase_inst, chunk);

0 commit comments

Comments
 (0)