Skip to content

Commit bbd99ac

Browse files
committed
lfsshim_write fixed
1 parent f10713d commit bbd99ac

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

stm32h7/littlefs_shim.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ int lfsshim_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, v
1515
uint32_t num_blocks = size / c->block_size;
1616
w_assert((size % c->block_size) == 0);
1717
w_assert(off == 0);
18+
1819
HAL_StatusTypeDef hal =
1920
HAL_SD_ReadBlocks(lfsshim_hsd, (uint8_t *)buffer, block_addr, num_blocks, timeout_ms);
2021
if (hal != HAL_OK) {
@@ -37,13 +38,9 @@ int lfsshim_write(const struct lfs_config *c, lfs_block_t block, lfs_off_t off,
3738
uint32_t timeout_ms = SD_RW_TIMEOUT_MS;
3839
uint32_t block_addr = block + lfsshim_first_block_offset;
3940
//uint32_t num_blocks = (size + c->block_size - 1) / c->block_size;
40-
uint32_t num_blocks = 1;
41-
if(size != 512){
42-
for(;;){}
43-
}
44-
if(off != 0){
45-
for(;;){}
46-
}
41+
uint32_t num_blocks = size / c->block_size;
42+
w_assert((size % c->block_size) == 0);
43+
w_assert(off == 0);
4744

4845
HAL_StatusTypeDef hal =
4946
HAL_SD_WriteBlocks(lfsshim_hsd, (uint8_t *)buffer, block_addr, num_blocks, timeout_ms);

0 commit comments

Comments
 (0)