In the “full main.cpp” I gave you, dumpSdPins() did this:
pinMode(SCK, INPUT_PULLUP);
pinMode(MISO, INPUT_PULLUP);
pinMode(MOSI, INPUT_PULLUP);
…and you were calling dumpSdPins("after-idle-clocks") inside tryMountWithBus(), after bus.begin() and the 0xFF idle clocks, but before SD.begin().
That means: right before SD.begin(), you were accidentally turning the SPI pins back into inputs. The card then can’t respond, so you get endless:
sdCommand(): Card Failed! cmd: 0x00
f_mount failed: (3) The physical drive cannot work
That matches your new log perfectly.
|
||
|---|---|---|
| .. | ||
| src | ||
| platformio.ini | ||
| README.md | ||
Exercise 05: SD Card Watcher
This exercise continuously watches SD card presence and prints state-change events.
Watcher behavior:
- Initializes PMU and enables SD power rail (AXP2101 BLDO1).
- Polls for card changes with debounced state transitions.
- Emits events only on change:
EVENT: card inserted/mountedEVENT: card removed/unavailableEVENT: no card detected
- On mount event, prints card info and runs SD write workflow.
- Every 15 seconds while mounted, runs a periodic write/permission check.
- Uses fast preferred probe (
HSPI @ 400k) and occasional full fallback scan.
Files used in this exercise:
/Exercise_05_test.txt/test/testsub1/testsubsub1/Exercise_05_test.txt
Build
source /home/jlpoole/rnsenv/bin/activate
pio run -e node_a
Upload
source /home/jlpoole/rnsenv/bin/activate
pio run -e node_a -t upload --upload-port /dev/ttyACM0
Monitor
screen /dev/ttyACM0 115200