summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-02-07 12:35:39 +1100
committerDamien George <damien.p.george@gmail.com>2017-02-07 12:35:39 +1100
commit9779c99317f229435c07f11fd18223956de77b41 (patch)
treedb4be3014ee250ce8cae18b05ca255a5407bfd06
parentde48a27d607f0e7acbcbd841a8a4c685574114dc (diff)
downloadmicropython-9779c99317f229435c07f11fd18223956de77b41.tar.gz
micropython-9779c99317f229435c07f11fd18223956de77b41.zip
stmhal: Add ability to skip booting from SD card via /flash/SKIPSD file.
-rw-r--r--docs/pyboard/general.rst5
-rw-r--r--stmhal/main.c5
2 files changed, 9 insertions, 1 deletions
diff --git a/docs/pyboard/general.rst b/docs/pyboard/general.rst
index 107bae69a7..48e0146442 100644
--- a/docs/pyboard/general.rst
+++ b/docs/pyboard/general.rst
@@ -11,6 +11,11 @@ is inserted into the slot, it is available as ``/sd``.
When the pyboard boots up, it needs to choose a filesystem to boot from. If
there is no SD card, then it uses the internal filesystem ``/flash`` as the boot
filesystem, otherwise, it uses the SD card ``/sd``.
+If needed, you can prevent the use of the SD card by creating an empty file
+called ``/flash/SKIPSD``. If this file exists when the pyboard boots
+up then the SD card will be skipped and the pyboard will always boot from the
+internal filesystem (in this case the SD card won't be mounted but you can still
+mount and use it later in your program using ``os.mount``).
(Note that on older versions of the board, ``/flash`` is called ``0:/`` and ``/sd``
is called ``1:/``).
diff --git a/stmhal/main.c b/stmhal/main.c
index 7bf6f6a3af..7bfdc52c3e 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -568,7 +568,10 @@ soft_reset:
#if MICROPY_HW_HAS_SDCARD
// if an SD card is present then mount it on /sd/
if (sdcard_is_present()) {
- mounted_sdcard = init_sdcard_fs(first_soft_reset);
+ // if there is a file in the flash called "SKIPSD", then we don't mount the SD card
+ if (!mounted_flash || f_stat(&fs_user_mount_flash.fatfs, "/SKIPSD", NULL) != FR_OK) {
+ mounted_sdcard = init_sdcard_fs(first_soft_reset);
+ }
}
#endif