diff --git a/drivers/bch/bchlib_write.c b/drivers/bch/bchlib_write.c index 59209972a4..13ba4698c6 100644 --- a/drivers/bch/bchlib_write.c +++ b/drivers/bch/bchlib_write.c @@ -141,6 +141,15 @@ ssize_t bchlib_write(FAR void *handle, FAR const char *buffer, size_t offset, nsectors = bch->nsectors - sector; } + /* Flush the dirty sector to keep the sector sequence */ + + ret = bchlib_flushsector(bch); + if (ret < 0) + { + ferr("ERROR: Flush failed: %d\n", ret); + return ret; + } + /* Write the contiguous sectors */ ret = bch->inode->u.i_bops->write(bch->inode, (FAR uint8_t *)buffer,