From caa31ecbdcb18bcb5b551518324737a210e37068 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Sun, 7 Jan 2024 16:46:58 +0100 Subject: [PATCH] drivers/mtd: fix mtd_write_sector Parameter `num` of `mtd_write_page_raw` is the number of bytes to be written, which is the number of sectors to be written`count` multiplied by the pages per sector `mtd->pages_per_sector` and the page size `mtd->page_size`. --- drivers/mtd/mtd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtd.c b/drivers/mtd/mtd.c index 5daf2e7cae..c9b08b4a87 100644 --- a/drivers/mtd/mtd.c +++ b/drivers/mtd/mtd.c @@ -395,7 +395,8 @@ int mtd_write_sector(mtd_dev_t *mtd, const void *data, uint32_t sector, } uint32_t page = sector * mtd->pages_per_sector; - return mtd_write_page_raw(mtd, data, page, 0, page * mtd->page_size); + return mtd_write_page_raw(mtd, data, page, 0, + count * mtd->pages_per_sector * mtd->page_size); } int mtd_power(mtd_dev_t *mtd, enum mtd_power_state power)