Skip to content

Commit 74c79f0

Browse files
bwhitmanclaude
andcommitted
amyboard: fix SD card writes failing with EIO (#1065)
The VFS block protocol treats any writeblocks return value other than None (or 0) as an error. The vendored machine_sdcard.c returned True on success, so every SD write failed with OSError: [Errno 5] EIO even though the sectors were never sent to the card. readblocks got this exact fix in March 2025 (which is why reads/ls work); apply the same to writeblocks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent cf24d04 commit 74c79f0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tulip/amyboard/machine_sdcard.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ static mp_obj_t machine_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t block_num,
391391
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ);
392392
err = sdmmc_write_sectors(&(self->card), bufinfo.buf, mp_obj_get_int(block_num), bufinfo.len / _SECTOR_SIZE(self));
393393

394+
// The VFS block protocol treats any return other than None (or 0) as an
395+
// error, so returning True on success made every write fail with EIO.
396+
// Same fix as readblocks above (#1065).
397+
if (err == ESP_OK) {
398+
return mp_const_none;
399+
}
394400
return mp_obj_new_bool(err == ESP_OK);
395401
}
396402
static MP_DEFINE_CONST_FUN_OBJ_3(machine_sdcard_writeblocks_obj, machine_sdcard_writeblocks);

0 commit comments

Comments
 (0)