Today, I added a couple of features to my code. If one of the pins is held low during boot, these new things happen:
1. boot.py does
Code: Select all
storage.remount("/", False)
2. code.py reads stuff from NVM and writes it to a text file on the board.
3. First time through, the code that writes the file must have had a bug in it, because it went through the "except" block. This may have been due to it writing an array where a string was expected. I wrapped it in "str()" and it avoided the "except" block after that.
Here's boot.py
Code: Select all
import time
import board
import digitalio
import storage
switch = digitalio.DigitalInOut(board.D7)
switch.direction = digitalio.Direction.INPUT
switch.pull = digitalio.Pull.UP
isUserWriteable = switch.value
if not isUserWriteable:
storage.remount("/", False)
switch = None
Code: Select all
def BackupWaveforms():
saved = False
try:
waveforms = str(nvm.GetWaveforms())
with open("/waveforms-backup.txt", "a") as fp:
fp.write(waveforms)
saved = True
except Exception as e:
saved = False
print(e)
I can't imagine why any of that would have interacted with NVM, but since I haven't thought of a better explanation yet, I thought I'd ask...
Could any of those things have corrupted NVM?