MacOS Sonoma (as of Oct 30, 2023) has a bug that causes delays to writes to certain CircuitPython boards. Writes to the virtual filesystem on the CircuitPython are delayed by approximately 5-30 seconds, which causes strange errors, particularly with autoreload enabled.

If your code doesn’t run immediately after saving and you sometimes see errors like this you may be affected.

Code stopped by auto-reload. Reloading soon.
soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
OSError: [Errno 5] Input/output error

Code done running.

Update (Dec 22, 2023)
Rather than manually running the code below it should be possible to have the CircuitPython volume mounted for synchronous writes only by editing the /etc/fstab.

Update (Dec 22, 2023)
Rather than manually running the code below it should be possible to have the CircuitPython volume mounted for synchronous writes only by editing the /etc/fstab.

One partial workaround is to force MacOS to flush the writes immediately by running the ‘sync’ command in a terminal window. It’s still possible there could be race conditions that cause data corruption. You should disable auto-save in your editor in order to minimize the number of writes.

You can copy and paste this code into the Terminal app to sync the filesystems every 5 seconds. This should be safe but could possibly have other side effects, so only run while necessary (editing CircuitPython code).

Code adapted from CircuitPython bug report:

while true; do echo “Syncing writes to disk”; sync; sleep 5; done

You may still see the OSError: [Errno 5] errors sometimes but your code should start running within 5 seconds of being saved.

Categories: CircuitPython