Skip to content

Commit 9779c99

Browse files
committed
stmhal: Add ability to skip booting from SD card via /flash/SKIPSD file.
1 parent de48a27 commit 9779c99

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

docs/pyboard/general.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ is inserted into the slot, it is available as ``/sd``.
1111
When the pyboard boots up, it needs to choose a filesystem to boot from. If
1212
there is no SD card, then it uses the internal filesystem ``/flash`` as the boot
1313
filesystem, otherwise, it uses the SD card ``/sd``.
14+
If needed, you can prevent the use of the SD card by creating an empty file
15+
called ``/flash/SKIPSD``. If this file exists when the pyboard boots
16+
up then the SD card will be skipped and the pyboard will always boot from the
17+
internal filesystem (in this case the SD card won't be mounted but you can still
18+
mount and use it later in your program using ``os.mount``).
1419

1520
(Note that on older versions of the board, ``/flash`` is called ``0:/`` and ``/sd``
1621
is called ``1:/``).

stmhal/main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,10 @@ int main(void) {
568568
#if MICROPY_HW_HAS_SDCARD
569569
// if an SD card is present then mount it on /sd/
570570
if (sdcard_is_present()) {
571-
mounted_sdcard = init_sdcard_fs(first_soft_reset);
571+
// if there is a file in the flash called "SKIPSD", then we don't mount the SD card
572+
if (!mounted_flash || f_stat(&fs_user_mount_flash.fatfs, "/SKIPSD", NULL) != FR_OK) {
573+
mounted_sdcard = init_sdcard_fs(first_soft_reset);
574+
}
572575
}
573576
#endif
574577

0 commit comments

Comments
 (0)