No fs format nor file recreation and boot reason changes
This resolves a couple of things. Firstly we now reattach USB Mass Storage Device after recreating the filesystem, this means that the drive now shows up on first boot after an initial firmware installation (tested with erased device). Previously the first boot would not show a drive, but subsequent boots would.
Secondly, in relation to brown-out situations, we now avoid erasing files unnecessarily, and if we last reset due to brownout we do not attempt to write any files like boot log nor erase the circuitpython files. There turns out to be little reason to write to the filesystem every boot. Mostly a load of .exists guards to avoid unnecessary erases, and checking the boot reason for some operations.
There's a minor tweak to the print_reset_reason method as it was being used incorrectly. It was being passed CPU core number instead of passing in the result of rtc_get_reset_reason(cpuCore). Finally the pico now has a boot reason adding in the latest Earle core, so included that too.
Add getResetReason for rp2040/2350 (needs latest earle core) See https://github.com/earlephilhower/arduino-pico/pull/2516/files
@brentru this is ready for review
Recreation Steps: Firstly if you want to keep the corruption you'll need to change the code to not call initialised filesystem the second time (with forceFormat true), also disabling the check inside the initFilesystem function on failure. The same for the file.open with bootlog+secrets. I think I totally disabled the macOS file writing + eraseCPFS.
Secondly pull this repository (and read the readme) https://github.com/tyeth/python_nordic_ppk2_wipper_secrets_brownout The hardware setup and test process is described there with a circuit diagram, but in short it powers the device and waits for wifi related serial messages (successful boot), or corruption serial messages (test stops), it totally ignores anything else and continues (timing out that test run at X seconds).
Note - I will have more bandwidth to reproduce and trace this error after November, we'll re-look into it then.
Future Tyeth, mention closes #621 and rejig a bit after #672