sdutil Initialize CHS too (some BIOSes dont like it), libfat Add update callback function
All checks were successful
Build documentation / build-and-deploy (push) Successful in 4m33s

This commit is contained in:
2026-03-21 15:16:03 +01:00
parent 3a48856ee4
commit cc291568f5
4 changed files with 70 additions and 9 deletions

View File

@@ -41,6 +41,9 @@ static int fat_diskio_read (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* buf
NULL)) < 0)
return 0;
if (ctx->update_cb != NULL)
ctx->update_cb (phys_sector, phys_sector_count);
return 1;
}
@@ -65,18 +68,20 @@ static int fat_diskio_write (struct fatfs_ctx* ctx, uint32_t sector, uint8_t* bu
NULL)) < 0)
return 0;
if (ctx->update_cb != NULL)
ctx->update_cb (phys_sector, phys_sector_count);
return 1;
}
int fat_format_drive (struct fatfs_ctx* ctx, const char* device_key, int fs_type) {
memset (ctx, 0, sizeof (*ctx));
memcpy (ctx->device_name, device_key, min (sizeof (ctx->device_name) - 1, strlen (device_key)));
memcpy (ctx->device_name, device_key, strlen (device_key));
int r = -1;
size_t total_size = 0;
device_do (device_key, XDRV_GET_SIZE, &total_size, NULL, NULL, NULL);
if (total_size == 0)
return -ST_NOT_FOUND;
if ((r = device_do (device_key, XDRV_GET_SIZE, &total_size, NULL, NULL, NULL)) < 0)
return r;
size_t sectors = ((total_size + FAT_SECTOR_SIZE) / FAT_SECTOR_SIZE);
@@ -84,7 +89,7 @@ int fat_format_drive (struct fatfs_ctx* ctx, const char* device_key, int fs_type
ctx->_fs.disk_io.read_media = &fat_diskio_read;
ctx->_fs.disk_io.write_media = &fat_diskio_write;
int r = -1;
r = -1;
switch (fs_type) {
case FS_FAT16: