Skip to content

Commit 47e35ae

Browse files
ludvigsjrlubos
authored andcommitted
[nrf fromtree] Bluetooth: Mesh: make blob_io_flash support smaller blocks
Only erase a page when starting the first block on that page. This fixes a bug where, if the block size is smaller than the page size, the entire page would be erased upon start of each block when writing, meaning only the final block on each page would be retained. This works because blocks are always received in order. Signed-off-by: Ludvig Jordet <[email protected]> (cherry picked from commit 99190cb)
1 parent 4024707 commit 47e35ae

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/bluetooth/mesh/blob_io_flash.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,13 @@ static inline int erase_device_block(const struct flash_area *fa, off_t start, s
8383
return err;
8484
}
8585

86+
if (start != page.start_offset) {
87+
/* Only need to erase when starting the first block on the page. */
88+
return 0;
89+
}
90+
8691
/* Align to page boundary. */
8792
size = page.size * DIV_ROUND_UP(size, page.size);
88-
start = page.start_offset;
8993

9094
return flash_area_erase(fa, start, size);
9195
}

0 commit comments

Comments
 (0)