summaryrefslogtreecommitdiffstatshomepage
path: root/docs/zephyr
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-02-02 13:51:18 +1100
committerDamien George <damien@micropython.org>2024-02-07 13:25:10 +1100
commit4c56b39051b4a992d8691aa504cd2e76b958bf26 (patch)
tree9bd5e19a08626bf26c222c3e093e65916ce147b0 /docs/zephyr
parent7d28789544e4e35d8c931b41765dd64a53c506f1 (diff)
downloadmicropython-4c56b39051b4a992d8691aa504cd2e76b958bf26.tar.gz
micropython-4c56b39051b4a992d8691aa504cd2e76b958bf26.zip
docs: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'docs/zephyr')
-rw-r--r--docs/zephyr/quickref.rst12
-rw-r--r--docs/zephyr/tutorial/storage.rst12
2 files changed, 12 insertions, 12 deletions
diff --git a/docs/zephyr/quickref.rst b/docs/zephyr/quickref.rst
index 57262ffb5c..d8b1f8768d 100644
--- a/docs/zephyr/quickref.rst
+++ b/docs/zephyr/quickref.rst
@@ -109,12 +109,12 @@ Disk Access
Use the :ref:`zephyr.DiskAccess <zephyr.DiskAccess>` class to support filesystem::
- import os
+ import vfs
from zephyr import DiskAccess
block_dev = DiskAccess('SDHC') # create a block device object for an SD card
- os.VfsFat.mkfs(block_dev) # create FAT filesystem object using the disk storage block
- os.mount(block_dev, '/sd') # mount the filesystem at the SD card subdirectory
+ vfs.VfsFat.mkfs(block_dev) # create FAT filesystem object using the disk storage block
+ vfs.mount(block_dev, '/sd') # mount the filesystem at the SD card subdirectory
# with the filesystem mounted, files can be manipulated as normal
with open('/sd/hello.txt','w') as f: # open a new file in the directory
@@ -126,12 +126,12 @@ Flash Area
Use the :ref:`zephyr.FlashArea <zephyr.FlashArea>` class to support filesystem::
- import os
+ import vfs
from zephyr import FlashArea
block_dev = FlashArea(4, 4096) # creates a block device object in the frdm-k64f flash scratch partition
- os.VfsLfs2.mkfs(block_dev) # create filesystem in lfs2 format using the flash block device
- os.mount(block_dev, '/flash') # mount the filesystem at the flash subdirectory
+ vfs.VfsLfs2.mkfs(block_dev) # create filesystem in lfs2 format using the flash block device
+ vfs.mount(block_dev, '/flash') # mount the filesystem at the flash subdirectory
# with the filesystem mounted, files can be manipulated as normal
with open('/flash/hello.txt','w') as f: # open a new file in the directory
diff --git a/docs/zephyr/tutorial/storage.rst b/docs/zephyr/tutorial/storage.rst
index e8dcbbd39a..7fd449226f 100644
--- a/docs/zephyr/tutorial/storage.rst
+++ b/docs/zephyr/tutorial/storage.rst
@@ -21,11 +21,11 @@ file system to access SD cards via disk access (see below).
Example usage of FatFS with an SD card on the mimxrt1050_evk board::
- import os
+ import vfs
from zephyr import DiskAccess
bdev = zephyr.DiskAccess('SDHC') # create block device object using DiskAccess
- os.VfsFat.mkfs(bdev) # create FAT filesystem object using the disk storage block
- os.mount(bdev, '/sd') # mount the filesystem at the SD card subdirectory
+ vfs.VfsFat.mkfs(bdev) # create FAT filesystem object using the disk storage block
+ vfs.mount(bdev, '/sd') # mount the filesystem at the SD card subdirectory
with open('/sd/hello.txt','w') as f: # open a new file in the directory
f.write('Hello world') # write to the file
print(open('/sd/hello.txt').read()) # print contents of the file
@@ -43,11 +43,11 @@ implements the `vfs.AbstractBlockDev` protocol.
Example usage with the internal flash on the reel_board or the rv32m1_vega_ri5cy board::
- import os
+ import vfs
from zephyr import FlashArea
bdev = FlashArea(FlashArea.STORAGE, 4096) # create block device object using FlashArea
- os.VfsLfs2.mkfs(bdev) # create Little filesystem object using the flash area block
- os.mount(bdev, '/flash') # mount the filesystem at the flash storage subdirectory
+ vfs.VfsLfs2.mkfs(bdev) # create Little filesystem object using the flash area block
+ vfs.mount(bdev, '/flash') # mount the filesystem at the flash storage subdirectory
with open('/flash/hello.txt','w') as f: # open a new file in the directory
f.write('Hello world') # write to the file
print(open('/flash/hello.txt').read()) # print contents of the file