Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writing code.py causes: OSError: [Errno 5] Input/output error #229

Open
dhalbert opened this issue Aug 8, 2024 · 12 comments
Open

writing code.py causes: OSError: [Errno 5] Input/output error #229

dhalbert opened this issue Aug 8, 2024 · 12 comments
Labels
beta Issue is available in beta bug Something isn't working

Comments

@dhalbert
Copy link
Contributor

dhalbert commented Aug 8, 2024

CircuitPython Version

8.2.0
9.0.0
9.1.1
all of above tested on two RP2040 boards

also reproduced the problem on 9.1.1 on an ESP32-S3

did not reproduce on a Trinket M0

Workflow(s)

USB in code-beta.circuitpython.org on 2024-08-07, 2019 ET

Browser(s)

Version 127.0.6533.99 (Official Build) (64-bit) on Ubuntu 24.04

Console Log

Load different workflow
index.js:91 Requesting any serial device...
index.js:91 > Requested  SerialPort {onconnect: null, ondisconnect: null, readable: null, writable: null}
index.js:91 switch to SerialPort {onconnect: null, ondisconnect: null, readable: null, writable: null}
index.js:93 Read Loop Init
index.js:93 Read Loop Started
index.js:91 Getting Device UID...
index.js:93 Device UID: F6254209F45633
index.js:91 Successfully loaded directory: CIRCUITPY
index.js:91 New folder name: CIRCUITPY
index.js:91 SerialPort {onconnect: null, ondisconnect: null, readable: ReadableStream, writable: WritableStream}
index.js:89 Connected!
index.js:89 Path: /code.py
index.js:93 Current File Changed to: /code.py

[no output when writing code.py]

Steps

  1. Shift reload https://code-beta.circuitpython.org
  2. select USB and choose serial and CIRCUITPY for an RP2040 board (I've tried two). The board has previously had storage.erase_filesystem() done, so CIRCUITPY is in good shape.
  3. open Serial window
  4. edit code.py and another another print() statement. Note that saving code.py does NOT cause an auto-reload
  5. Type ctrl-D in serial window. I get:
>>> 
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.

Press any key to enter the REPL. Use CTRL-D to reload.

The OSError is new. It did not show up if I did ctrl-D before editing the file.

Description

No response

Additional information

This does not seem to reflect a corrupted CIRCUITPY. Instead, it is some other I/O error, maybe due to something being done via serial. If I disconnect from web-editor and just connect via a terminal program, without resetting, and do a ctrl-D, I do not see the OSError.

@dhalbert dhalbert added the bug Something isn't working label Aug 8, 2024
@makermelissa
Copy link
Collaborator

Thanks, I'll look into this today.

@makermelissa
Copy link
Collaborator

I wasn't able to exactly fix the issue, but did find a similar issue in the process and have slowly been working it out of the system. After that, I'll try the exact reproduction steps.

@makermelissa
Copy link
Collaborator

Oh, I just realized it didn't happen on all boards. Will try on a RP2040 after I get the issue I notice worked out.

@makermelissa
Copy link
Collaborator

Just tested on the Feather RP2040 running CP 9.1.1 on my system locally and did not experience the error, so perhaps it's fixed now. After I finish #230, I'll submit a PR.

@makermelissa
Copy link
Collaborator

This should now be fixed via #231.

@makermelissa makermelissa added the beta Issue is available in beta label Aug 10, 2024
@makermelissa makermelissa reopened this Aug 12, 2024
@FoamyGuy
Copy link

I'm able to re-create this issue reliably as well.

Browser: Version 127.0.6533.99 (Official Build) (64-bit)
OS: Ubunty 24.04

I've seen the same issue with a MEMENTO 9.1.1 and a Feather RP2040 9.0.4 and 9.1.1, it doesn't appear to be tied to a specific device or version that I can tell.

Here is a screen recording of one of occurrences on the MEMENTO
Screencast from 2024-08-12 17-37-05.webm

I found that when the device is in the state where it's always getting the Input/Output error I can press the disconnect button at the top, and then re-connect and upon re-connecting open the serial and use ctrl-c / ctrl-d to run code.py and it does execute without the error as long as I do not change the code again before running. I have noticed what I think is an unrelated issue where disconnect / re-connecting to a device without reloading the page causes serial input and outputs to be duplicated, i'll create a seperate issue for that.

Since it works after disconnect / reconnecting it seems to me that this issue is tied specifically to when it saves the code.py content and then tries to run it afterward. The actual content of the file seems to get saved correctly because it works without any further changes after the disconnect / reconnect.

@makermelissa
Copy link
Collaborator

makermelissa commented Aug 13, 2024

I wonder if the issue is only appearing on linux. I'm trying with Mac OS and still unable to produce issue, but have a linux computer (running Linux Mint) I can try it on. I believe Dan was probably also trying on Linux.

@dhalbert
Copy link
Contributor Author

Yes, I only tested on Linux.

@makermelissa
Copy link
Collaborator

First of all, it worked fine for me on linux. However, I may have an idea about what is happening. For the RP2040, there should be a CIRCUITPY drive that you need to grant permission to. If it is trying to go through the REPL (because maybe it detects the file system isn't read only), then I think that's why it is encountering the error.

Getting down a bit deeper, I remembered that in order to make it Micropython compatible, I have it attempting to check if the file system is read only and if there are any errors it assumes that it isn't read-only. I think I need to make it more specific to an import error.

@makermelissa
Copy link
Collaborator

Ok, am trying the memento and noticing weirdness (code timeouts, slowness, not connecting with File System API, etc). Hopefully getting it working will iron out the issue. I think the weirdness is causing it to think it should do file ops through the REPL and then it can't write to a read-only file system.

@makermelissa
Copy link
Collaborator

Ok, good news is same board works much better after trying on my local system (which only assumes not read-only on import error instead of all errors). I think I can improve the connection speed/weirdness though and can call this good.

@makermelissa
Copy link
Collaborator

I just noticed in Dan's log:

index.js:91 New folder name: CIRCUITPY

This means that it is connecting through the File System API, which is correct. So, I don't think my hypothesis is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Issue is available in beta bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants