MicroSD, FAT and USB storage

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

MicroSD, FAT and USB storage

Post by mcauser » Mon Jun 25, 2018 12:21 am

I came across some problems using various old/new microSD(HC) memory cards with my PyBoard 1.0 (and Mac OSX Sierra).

I formatted a new 8GB microSDHC with exFAT, plugged it into my PyBoard and it when connected, mounted the PyBoard flash instead of the SD card. Tried again with FAT32 + MBR and it mounted the SD card via the PyBoard over USB. So, FAT32 works, exFAT does not.

Tried a very old 32MB TransFlash card from a decade ago. Formatted with FAT32, FAT16 and exFAT, each didn't work.
Wikipedia revealed microSD added SDIO mode. Perhaps SDIO is a requirement?
TransFlash and microSD are the same size, but microSD has support for SDIO mode.
https://simple.wikipedia.org/wiki/MicroSD
TransFlash and microSD cards are functionally identical allowing either to operate in devices made for the other.
https://en.wikipedia.org/wiki/Secure_Di ... icro-cards

Tried a 1GB microSD with FAT32 and FAT16, both worked. Tried exFAT, didn't work.

In Mac OSX's Disk Utility app, you can format a drive with "MS-DOS (FAT)" or "ExFAT". Doesn't say which specific FAT version. I believe it creates FAT16 or FAT32 depending on the card size.

If you want more fine grain control, use the command line app diskutil. eg.

Code: Select all

diskutil list
sudo diskutil unmountDisk /dev/disk5
sudo diskutil eraseDisk FAT32 NAME MBRFormat /dev/disk5
diskutil listFilesystems
sudo diskutil eraseDisk "MS-DOS FAT12" NAME MBRFormat /dev/disk5
sudo diskutil eraseDisk "MS-DOS FAT16" NAME MBRFormat /dev/disk5
sudo diskutil eraseDisk "MS-DOS FAT32" NAME MBRFormat /dev/disk5
Disk name must be uppercase, replace disk5 with your disk.
I went with a high number so a failed copy-paste won't accidentally erase your disk.

In Disk Utility, I noticed the PyBoard flash is FAT16. I'm guessing they chose FAT16 over FAT32 as there is so little flash space.

Hoping to put together a list of what works and what does not with MicroPython.
I don't think we need a list of specific vendor microSD cards which are known to work, instead, strike off some incompatibilities to help people pick the right type of card and format it correctly.

Card types:
* TransFlash up to 32MB
* microSD (SDSC) up to 2GB
* microSDHC up to 32GB
* microSDXC up to 2TB

Partitions:
* Master Boot Record (MBR)
* GUID Partition Map (GPT)

File systems:
* FAT12
* FAT16
* FAT32
* exFAT

Post Reply