8000 stm32/main: Add board config option to enable/disable mounting SD card. · msuszko/micropython@ce0c581 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce0c581

Browse files
pi-anldpgeorge
authored andcommitted
stm32/main: Add board config option to enable/disable mounting SD card.
The new option MICROPY_HW_SDCARD_MOUNT_AT_BOOT can now be defined to 0 in mpconfigboard.h to allow SD hardware to be enabled but not auto-mounted at boot. This feature is enabled by default to retain previous behaviour. Previously, if an SD card is enabled in hardware it is also used to boot from. While this can be disabled with a SKIPSD file on internal flash, this wont be available at first boot or if the internal flash gets corrupted.
1 parent 5ed578e commit ce0c581

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ports/stm32/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ MP_NOINLINE STATIC bool init_flash_fs(uint reset_mode) {
268268
}
269269
#endif
270270

271-
#if MICROPY_HW_HAS_SDCARD
271+
#if MICROPY_HW_SDCARD_MOUNT_AT_BOOT
272272
STATIC bool init_sdcard_fs(void) {
273273
bool first_part = true;
274274
for (int part_num = 1; part_num <= 4; ++part_num) {
@@ -620,7 +620,7 @@ void stm32_main(uint32_t reset_mode) {
620620
#endif
621621

622622
bool mounted_sdcard = false;
623-
#if MICROPY_HW_HAS_SDCARD
623+
#if MICROPY_HW_SDCARD_MOUNT_AT_BOOT
624624
// if an SD card is present then mount it on /sd/
625625
if (sdcard_is_present()) {
626626
// if there is a file in the flash called "SKIPSD", then we don't mount the SD card

ports/stm32/mpconfigboard_common.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
#define MICROPY_HW_HAS_SDCARD (0)
9898
#endif
9999

100+
// Whether to automatically mount (and boot from) the SD card if it's present
101+
#ifndef MICROPY_HW_SDCARD_MOUNT_AT_BOOT
102+
#define MICROPY_HW_SDCARD_MOUNT_AT_BOOT (MICROPY_HW_HAS_SDCARD)
103+
#endif
104+
100105
// Whether to enable the MMA7660 driver, exposed as pyb.Accel
101106
#ifndef MICROPY_HW_HAS_MMA7660
102107
#define MICROPY_HW_HAS_MMA7660 (0)

0 commit comments

Comments
 (0)
0