Skip to content

Commit 1eac664

Browse files
committed
mimxrt/machine_sdcard: Fix buffer type in writeblocks.
The writeblocks function was requesting the buffer as MP_BUFFER_WRITE when it should be MP_BUFFER_READ, since we read FROM the buffer to write TO the card. This was preventing VFS operations like mkfs and mount from working, as FatFS passes const buffers for write operations. Signed-off-by: Andrew Leech <[email protected]>
1 parent 04bbc16 commit 1eac664

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ports/mimxrt/machine_sdcard.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(machine_sdcard_info_obj, machine_sdcard_info);
142142
static mp_obj_t machine_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t block_num, mp_obj_t buf) {
143143
mp_buffer_info_t bufinfo;
144144
mimxrt_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
145-
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_WRITE);
145+
mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ);
146146

147147
if (sdcard_write(self, bufinfo.buf, mp_obj_get_int(block_num), bufinfo.len / SDCARD_DEFAULT_BLOCK_SIZE)) {
148148
return MP_OBJ_NEW_SMALL_INT(0);

0 commit comments

Comments
 (0)