Skip to content

Commit cb97ae6

Browse files
committed
Be stricter about what filesystems it works with.
Add Metro RP2350 definitions
1 parent 2c0f9e9 commit cb97ae6

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

ports/raspberrypi/boards/adafruit_metro_rp2350/mpconfigboard.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@
3535
#define DEFAULT_DVI_BUS_GREEN_DP (&pin_GPIO16)
3636
#define DEFAULT_DVI_BUS_BLUE_DN (&pin_GPIO13)
3737
#define DEFAULT_DVI_BUS_BLUE_DP (&pin_GPIO12)
38+
39+
#define DEFAULT_SD_SCK (&pin_GPIO34)
40+
#define DEFAULT_SD_MOSI (&pin_GPIO35)
41+
#define DEFAULT_SD_MISO (&pin_GPIO36)
42+
#define DEFAULT_SD_CS (&pin_GPIO39)
43+
#define DEFAULT_SD_CARD_DETECT (&pin_GPIO40)
44+
#define DEFAULT_SD_CARD_INSERTED false

shared-module/sdcardio/__init__.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ static bool _mounted = false;
2626

2727
#ifdef DEFAULT_SD_MOSI
2828
static busio_spi_obj_t busio_spi_obj;
29+
#else
30+
#include "shared-bindings/board/__init__.h"
2931
#endif
3032
#endif
3133

@@ -82,7 +84,12 @@ void automount_sd_card(void) {
8284
mp_rom_error_text_t error = sdcardio_sdcard_construct(&sdcard, spi_obj, DEFAULT_SD_CS, 25000000);
8385
if (error != NULL) {
8486
// Failed to communicate with the card.
87+
_mounted = false;
8588
_init_error = true;
89+
#ifdef DEFAULT_SD_MOSI
90+
common_hal_busio_spi_deinit(spi_obj);
91+
#endif
92+
return;
8693
}
8794
common_hal_digitalio_digitalinout_never_reset(&sdcard.cs);
8895

supervisor/shared/usb/usb_msc_flash.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "extmod/vfs_fat.h"
1313
#include "lib/oofatfs/diskio.h"
1414
#include "lib/oofatfs/ff.h"
15+
#include "py/gc.h"
1516
#include "py/mpstate.h"
1617

1718
#include "shared-module/storage/__init__.h"
@@ -125,11 +126,13 @@ static fs_user_mount_t *get_vfs(int lun) {
125126
if (lun == 0) {
126127
return root;
127128
}
129+
// Other filesystems must be native because we don't guard against exceptions.
130+
// They must also be off the VM heap so they don't disappear on autoreload.
128131
#ifdef SAVES_LUN
129132
if (lun == SAVES_LUN) {
130133
const char *path_under_mount;
131134
fs_user_mount_t *saves = filesystem_for_path("/saves", &path_under_mount);
132-
if (saves != root) {
135+
if (saves != root && (saves->blockdev.flags & MP_BLOCKDEV_FLAG_NATIVE) != 0 && gc_nbytes(saves) == 0) {
133136
return saves;
134137
}
135138
}
@@ -138,7 +141,7 @@ static fs_user_mount_t *get_vfs(int lun) {
138141
if (lun == SDCARD_LUN) {
139142
const char *path_under_mount;
140143
fs_user_mount_t *sdcard = filesystem_for_path("/sd", &path_under_mount);
141-
if (sdcard != root) {
144+
if (sdcard != root && (sdcard->blockdev.flags & MP_BLOCKDEV_FLAG_NATIVE) != 0 && gc_nbytes(sdcard) == 0) {
142145
return sdcard;
143146
} else {
144147
// Clear any ejected state so that a re-insert causes it to reappear.

0 commit comments

Comments
 (0)