Skip to content

Commit 9f2755f

Browse files
committed
Debug
1 parent e9be571 commit 9f2755f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

stm32/littlefs_shim.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@ uint32_t first_sector_offset = 0;
66

77
int sd_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer,
88
lfs_size_t size) {
9+
910
uint32_t timeout_ms = 50U;
1011
uint32_t block_addr = block + first_sector_offset;
11-
uint32_t num_blocks = (size + c->block_size - 1) / c->block_size;
12+
//uint32_t num_blocks = (size + c->block_size - 1) / c->block_size;
13+
uint32_t num_blocks = 1;
14+
if((off+size)>512){
15+
for(;;){}
16+
}
17+
uint8_t blockbuf[512];
1218
HAL_StatusTypeDef hal =
13-
HAL_SD_ReadBlocks(lfs_shim_hsd, (uint8_t *)buffer, block_addr, num_blocks, timeout_ms);
19+
HAL_SD_ReadBlocks(lfs_shim_hsd, blockbuf, block_addr, num_blocks, timeout_ms);
20+
uint8_t* buf = (uint8_t*)buffer;
21+
for(size_t i = 0; i < size; i++) {
22+
buf[i] = blockbuf[i+off];
23+
}
1424
if (hal != HAL_OK) {
1525
return -1; // LFS_ERR_IO
1626
}

0 commit comments

Comments
 (0)