Hi everyone,
A lot of times resetting too early corrupts the filesystem.
I know the red LED indicates when the flash is being written to, but is there a way to check for this in software?
How to know when it's safe to restart after a write to flash
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to know when it's safe to restart after a write to flash
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How to know when it's safe to restart after a write to flash
Thanks for the response.
Could you elaborate what these precautions are?
Using rshell is not an option for me.
I'm sending filecontents from one pyboard to another.
Then the receiving pyboard writes the filecontents to flash.
At this point I'd like to know when the flash write was completed and the receiving pyboard is safe to reset.
Could you elaborate what these precautions are?
Using rshell is not an option for me.
I'm sending filecontents from one pyboard to another.
Then the receiving pyboard writes the filecontents to flash.
At this point I'd like to know when the flash write was completed and the receiving pyboard is safe to reset.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to know when it's safe to restart after a write to flash
The precaution is to disable MSC mode. Failing that, avoid mounting the filesystem on a PC. Sharing the filesystem between a PC and code which updates the contents will lead to corruption.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: How to know when it's safe to restart after a write to flash
The receiving pyboard is not connected to a PC.
The filesystem is only updated from code.
Maybe this could help to clarify.
I'd like to know if there's a function or method like flash.active()
The filesystem is only updated from code.
Maybe this could help to clarify.
Code: Select all
import machine
with open('main.py', 'w') as f:
f.write('print("hello world")')
while flash.active():
pass
machine.reset()
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: How to know when it's safe to restart after a write to flash
Unlike a PC a Pyboard is a bare-metal system. There is no underlying OS, no background tasks and no concurrency. So the file closure implied by completion of your context manager should mean that it is safe to reboot.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.