diff --git a/source/fs/mufs/tree.c b/source/fs/mufs/tree.c index 2022d09..aeead8e 100644 --- a/source/fs/mufs/tree.c +++ b/source/fs/mufs/tree.c @@ -190,7 +190,8 @@ int mufs_shrink_tree(struct mufs_tree *tree, uint32_t max_size) dev->log2_block_size); if (index <= 1) { - if (flash_read(dev, base, &tree->root, sizeof tree->root) == 0) + if (flash_read(dev, (base << dev->log2_block_size), &tree->root, + sizeof tree->root) == 0) return -1; --tree->depth; @@ -200,8 +201,9 @@ int mufs_shrink_tree(struct mufs_tree *tree, uint32_t max_size) continue; } - if (flash_write0(dev, base + index * sizeof(uint32_t), (UINT32_C(1) << - dev->log2_block_size) - index * sizeof(uint32_t)) == 0) + if (flash_write0(dev, (base << dev->log2_block_size) + + index * sizeof(uint32_t), (UINT32_C(1) << dev->log2_block_size) - + index * sizeof(uint32_t)) == 0) return -1; if (flash_sync(dev) < 0)