SD card filesystem type

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
cappy2112
Posts: 8
Joined: Fri Apr 22, 2016 9:58 pm

SD card filesystem type

Post by cappy2112 » Mon Oct 24, 2016 4:09 am

What kind of filesystem is needed on the SD card?
I haven't been able to find that information in the docs, maybe I'm looking in the wrong place.

https://docs.micropython.org/en/latest/ ... nd-sd-card

Damien if you're reading these, please add a few line about the filesystem for the SD card.

Thanks

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: SD card filesystem type

Post by shaoziyang » Mon Oct 24, 2016 6:54 am

cappy2112 wrote:What kind of filesystem is needed on the SD card?
I haven't been able to find that information in the docs, maybe I'm looking in the wrong place.

https://docs.micropython.org/en/latest/ ... nd-sd-card

Damien if you're reading these, please add a few line about the filesystem for the SD card.

Thanks
I test 8G, 16G and 32G sdcard, with FAT and FAT32 filesystem, some works fine, some can't support.

Lysenko
Posts: 62
Joined: Wed Aug 17, 2016 1:21 pm

Re: SD card filesystem type

Post by Lysenko » Mon Oct 24, 2016 10:23 am

shaoziyang wrote: I test 8G, 16G and 32G sdcard, with FAT and FAT32 filesystem, some works fine, some can't support.
You can't format a FAT (FAT16) partition >4Gb (2Gb for Windows).

shaoziyang
Posts: 363
Joined: Sun Apr 17, 2016 1:55 pm

Re: SD card filesystem type

Post by shaoziyang » Mon Oct 24, 2016 12:28 pm

Lysenko wrote:
shaoziyang wrote: I test 8G, 16G and 32G sdcard, with FAT and FAT32 filesystem, some works fine, some can't support.
You can't format a FAT (FAT16) partition >4Gb (2Gb for Windows).
Yes, I am sorry, I forgot it. I have a very old 2G SD card, it use FAT.

All my sdcard may work in USB reader, but in pyboard, some work fine, some can't work.

And in SPI mode, some sdcard worked in pyboard can't be recognize.

laoch
Posts: 1
Joined: Wed Nov 11, 2020 10:31 am

Re: SD card filesystem type

Post by laoch » Wed Nov 11, 2020 1:14 pm

Here is the process I used to partition, format and verify the microSD card for pyBoard.

Identify the microSD card.

Code: Select all

~$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb           8:16   1  7.4G  0 disk 
└─sdb1        8:17   1  6.5G  0 part /media/ob/32A1-4FC21
nvme0n1     259:0    0  1.9T  0 disk 
├─nvme0n1p1 259:1    0  512M  0 part /boot/efi
└─nvme0n1p2 259:2    0  1.9T  0 part /
Wipe microSD card

Code: Select all

~$ sudo wipefs --all --force /dev/sdb
/dev/sdb: 8 bytes were erased at offset 0x00000052 (vfat): 46 41 54 33 32 20 20 20
/dev/sdb: 1 byte was erased at offset 0x00000000 (vfat): eb
/dev/sdb: 2 bytes were erased at offset 0x000001fe (vfat): 55 aa
Run parted.

Code: Select all

~$ sudo parted /dev/sdb
GNU Parted 3.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
Create a new disk label msdos.

Code: Select all

(parted) mklabel msdos 
Determine the available space on the microSD card.

Code: Select all

(parted) print free                                                       
Model: Generic MassStorageClass (scsi)
Disk /dev/sdb: 7948MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End     Size    Type  File system  Flags
        1024B  7948MB  7948MB        Free Space
Make a primary partition including the full space.

Code: Select all

(parted) mkpart primary
File system type?  [ext2]? fat32                                          
Start? 1024                                                              
End? 7948    
Confirm partition creation.

Code: Select all

(parted) print
Model: Generic MassStorageClass (scsi)
Disk /dev/sdb: 7948MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1024MB  7948MB  6924MB  primary  fat32        lba
Format the partition as vfat.

Code: Select all

~$ sudo mkfs -t vfat /dev/sdb1
mkfs.fat 4.1 (2017-01-24)
Install the microSD card in the pyBoard and enter the Read, Evaluate, Print, Loop (REPL) shell.

Code: Select all

~$ sudo screen /dev/ttyACM0
List the directories and the microSD card should show as ∕sd.
Create a file and add some text. Verift the text is there.
Remove the microSD from the pyBoard and move it to the computer.
Confirm the file created on the pyBoard exists on ther microSD card.

Code: Select all

MicroPython v1.13 on 2020-09-02; PYBLITEv1.0 with STM32F411RE
Type "help()" for more information.
>>> 
>>> import os
>>> os.listdir('/')
['flash', 'sd']


>>> os.listdir('/')
['flash', 'sd']
>>> os.listdir('/sd')
[]


>>> file = '/sd/text.txt'
>>> fh = open(file, mode='w')
>>> fh.write('This is a test')
14
>>> fh.close()


>>> os.listdir('/sd')
['text.txt']

>>> fh = open(file, mode='r')
>>> print(fh.read())
This is a test

>>> fh.close()
Move the microSD to computer and confirm file is on the microSD card.

Code: Select all

~$ lsblk | grep sdb1
└─sdb1        8:17   1  6.5G  0 part /media/ob/32A1-4FC21

~$ ls /media/ob/32A1-4FC21
text.txt

~$ cat /media/ob/32A1-4FC21/text.txt
This is a test
There you go, it is verified as operational. Return the microSD card to the pyBoard.

Post Reply