So I want to format the SD card by os.VfsFat.mkfs(sd) but I got error.
My code for mounting SD card:
Code: Select all
=== from machine import Pin,SPI
=== import json, sdcard, os,time
=== def SD_BEGIN():
=== spi = SPI(sck=Pin(13), mosi=Pin(23), miso=Pin(22))
=== spi.init() # Ensure right baudrate
=== sd = sdcard.SDCard(spi, Pin(21)) # Compatible with PCB
=== vfs = os.VfsFat(sd)
=== os.mount(vfs, '/sd')
=== print('Filesystem check')
=== print(os.listdir())
=== print(os.listdir('/sd'))
=== SD_BEGIN()
Filesystem check
['sd', 'boot.py', 'sdcard.py', 'LOG']
['System Volume Information', '010001.txt']
>>>
Code: Select all
=== from machine import Pin,SPI
=== import json, sdcard, os,time
=== spi = SPI(sck=Pin(13), mosi=Pin(23), miso=Pin(22))
=== spi.init() # Ensure right baudrate
=== sd = sdcard.SDCard(spi, Pin(21)) # Compatible with PCB
=== os.VfsFat.mkfs(sd)
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
OSError: [Errno 5] EIO
>>>
Thank you in advance.