diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 7e1d2421d3..58349f69a6 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -292,6 +292,9 @@ int ata_write_sectors(unsigned long start, last_disk_activity = current_tick; + if (start == 0) + panicf("Writing on sector 0\n"); + mutex_lock(&ata_mtx); if ( sleeping ) { diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 38223edc6a..37b0648c2e 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1128,8 +1128,11 @@ static bool transfer( int start, int count, char* buf, bool write ) int err; LDEBUGF("transfer(s=%x, c=%x, %s)\n",start, count, write?"write":"read"); - if (write) + if (write) { + if (start < fat_bpb.firstdatasector) + panicf("Writing before data\n"); err = ata_write_sectors(start, count, buf); + } else err = ata_read_sectors(start, count, buf); if (err) {