[RTL8722DM_MINI] SDFS - Directory Navigation

Materials

  • AmebaD[AMB23] x 1

  • MicroSD Card x 1 (SD card must be < 32GB with format set to fatfs)

Steps

SD File System is supported on MicroPython RTL8722 port through importing the SDFS module from the machine module. This module is a simplified file system with the aim to highlight SD card manipulation, thus it does not support virtual file system as well as virtual file object.

Copy and paste the following code line by line into REPL to see its effect.

1from machine import SDFS
2s=SDFS()          # create an instance and mount on file system on SD card
3s.listdir()       # listing the files and folders under current path
4s.mkdir("test")   # create a folder named "test" under current path
5s.chdir("test")   # change directory to test folder
6s.pwd()           # print out present working directory(current path)
7s.chdir("/")      # change directory bach to root directory
8s.rm("test")      # delete the test folder

Note

No file open or close is needed, the API does that automatically for you.