adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
MIT License
3.95k stars 1.16k forks source link

(SAME54) Volume "Circuitpy" not updated after board reset #6470

Open antrapoint opened 2 years ago

antrapoint commented 2 years ago

CircuitPython version

CircuitPython version 7.0.0 work fine, volume is up to date after board reset

Installing CircuitPython higher then 7.0.0 all changes on the filesystem are readable but after board reset lost. All new cerated files are also lost.

Code/REPL

Not applicable

Behavior

Not applicable

Description

No response

Additional information

After installing CircuitPython 7.3.0 the file boot_out.txt is: _Adafruit CircuitPython 7.0.0 on 2021-09-20; SAM E54 Xplained Pro with same54p20 Board ID:same54xplained

After reboot RERL shows: Adafruit CircuitPython 7.3.0 on 2022-05-23; SAM E54 Xplained Pro with same54p20

jepler commented 2 years ago

I tried to reproduce this on an Adafruit PyGamer. First, I copied the "7.0.0" uf2 file to CPLAYBOOT, and checked the content of boot.out. It said:

Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit PyGamer with samd51j19
Board ID:pygamer

Then, I copied the "7.3.0" uf2 file to CPLAYBOOT and checked the content of boot.out again. It said:

Adafruit CircuitPython 7.3.0 on 2022-05-23; Adafruit PyGamer with samd51j19
Board ID:pygamer

So, on this similar board (albeit with a samd51 microcontroller) all is well.

If I understand right, you mention that other changes to CIRCUITPY are being lost. This could indicate that the actual problem is with the flash write code. Can you confirm this is what you mean, and that 7.0.0 operates correctly? The other troubleshooting step I can suggest is a drastic one: back up the full content of your CIRCUITPY drive and then use storage.erase_filesystem() to completely erase and re-format the CIRCUITPY drive: https://learn.adafruit.com/welcome-to-circuitpython/troubleshooting#to-erase-circuitpy-storage-dot-erase-filesystem-2987288-34

Last question: is your board a SAM E54 Xplained Pro or is it something else with an E54 MCU on it, that you're trying to make work?

antrapoint commented 2 years ago

Hi thanks for answer, the board is an SAM E54 Xplained Pro Yes all changes on the filesystem goes lost and get reset to the last stand of the 7.0.0 version. I tried _storage.erase_filesystem()_ but it doesn't solve the issue

jepler commented 2 years ago

Thanks for the response. Did you test with 7.1.x or 7.2.x—and if not, could you? knowing more about when this problem started will narrow down the possible changes that could have introduced the problem.

I have one of these boards but I won't be able to access it for a few weeks to do any testing of my own. Feel free to bump this bug after July 1 if you're waiting on us by then, so I don't forget it.

antrapoint commented 2 years ago

Hi, I tried also with 7.10 and 7.20. the interpreter works so far as expected and shows also the right version. But by none of this versions the edit or stored files survive an reboot of the board. Also the file _bootout.txt doesn't change.

dhalbert commented 2 years ago

Are you successfully writing .py files that run on the board? Assuming so, what is probably happening is that the filesystem appears to be corrupted when CircuitPython starts, so it does the equivalent of storage.erase_filesystem(). boot_out.txt is rewritten fresh when that happens, so it would appear not to change.

There might be a timing problem: perhaps it takes a little longer for the flash chip to be ready than >7.0.0 are waiting.

antrapoint commented 2 years ago

Yes, I can write, store and run py files. But after a reset on the volume are only these files, which get stored with version 7.0. As long as I do no reset, I can olso open the files with notepad++ and the content looks good. For me it looks like all what going to the volume is cached and not realy stored on the volume.

tannewt commented 2 years ago

What is the serial output from CircuitPython when you write a test code.py? If it writes successfully then CP should restart and you should see test prints. Please also post a picture of the flash chip on the board. It is possible that the external flash chip is different.

dhalbert commented 2 years ago

For me it looks like all what going to the volume is cached and not realy stored on the volume.

CircuitPython could not see the files if they were only in the host's cache. So the files are on the flash, but it sounds like they are getting erased on a hard reset because CIRCUITPY is being re-created.

antrapoint commented 2 years ago

Python script: _print("Hello World!")

f = open("demofile2.txt", "a") f.write("Hello world too") f.close()_

Output: _Adafruit CircuitPython 7.3.0 on 2022-05-23; SAM E54 Xplained Pro with same54p20

%Run -c $EDITORCONTENT Hello World! Zurückverfolgung (jüngste Aufforderung zuletzt): Datei "", Zeile 4, in OSError: [Errno 30] Schreibgeschützte Dateisystem

I looks like the filesystem ist write protected, but how can I remove the protection?

Picture of the fash chip: 20220608_172018

jepler commented 2 years ago

Making the storage writable by CircuitPython is covered in a guide: https://learn.adafruit.com/circuitpython-essentials/circuitpython-storage

however, if you have no ability to make a change to boot.py "stick" then this won't work out for you.

antrapoint commented 2 years ago

Ok, I can make CP writable. I put this in the boot.py: import board import digitalio import storage switch = digitalio.DigitalInOut(board.SW0) switch.direction = digitalio.Direction.INPUT switch.pull = digitalio.Pull.UP storage.remount("/", switch.value)

If I hold the SW0 button pressed after reboot the volume is for CP writable, also the created file is still there after reboot.

But the issue exists further, after a reboot all changes who comes from the Windows side are lost on the file system.

antrapoint commented 2 years ago

Additional info: If I create a file on the CP device from Windows side under V7.0.0 then the file is with: import os os.listdir() in REPL visible (also on the Win side)

If I do this under versions > 7.0.0 then the file is visible under Win but not shown with os.listdir() on the CP device.