Skip to content

Commit

Permalink
drivers/mtd: fix mtd_write_sector
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
gschorcht committed Jan 7, 2024
1 parent 866f2a0 commit caa31ec
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mtd/mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit caa31ec

Please sign in to comment.