Skip to content

Commit dfff6f2

Browse files
committed
Add more helpful error messages to boot.py SD card initialization
1 parent 09aa23c commit dfff6f2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

examples/boot.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@
4949
uos.mount(vfs, "/sd")
5050
except ImportError:
5151
print("boot.py - sdcard module not found, skipping SD card initialization.")
52-
except OSError:
53-
print("boot.py - Failed to mount SD card, skipping SD card initialization.")
52+
except OSError as e:
53+
eStr = str(e)
54+
if "no SD card" in eStr:
55+
print("boot.py - no SD card found, skipping SD card initialization.")
56+
elif "Errno 1" in eStr:
57+
print("boot.py - SD card already mounted, skipping SD card initialization.")
58+
else:
59+
print("boot.py - Failed to mount SD card, skipping SD card initialization.")
5460

5561
# Set the SPI bus baudrate (note - the sdcard module overrides the baudrate upon
5662
# initialization, so the baudrate should be set after that). It is recommended

0 commit comments

Comments
 (0)