8000 docs: Use vfs module instead of os. · ukicomputers/micropython@4c56b39 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c56b39

Browse files
committed
docs: Use vfs module instead of os.
Signed-off-by: Damien George <damien@micropython.org>
1 parent 7d28789 commit 4c56b39

File tree

12 files changed

+65
-65
lines changed

12 files changed

+65
-65
lines changed

docs/esp32/quickref.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,15 +650,15 @@ SD card
650650

651651
See :ref:`machine.SDCard <machine.SDCard>`. ::
652652

653-
import machine, os
653+
import machine, os, vfs
654654

655655
# Slot 2 uses pins sck=18, cs=5, miso=19, mosi=23
656656
sd = machine.SDCard(slot=2)
657-
os.mount(sd, '/sd') # mount
657+
vfs.mount(sd, '/sd') # mount
658658

659659
os.listdir('/sd') # list directory contents
660660

661-
os.umount('/sd') # eject
661+
vfs.umount('/sd') # eject
662662

663663
RMT
664664
---

docs/library/machine.SD.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ more info regarding the pins which can be remapped to be used with a SD card.
2020
Example usage::
2121

2222
from machine import SD
23-
import os
23+
import vfs
2424
# clk cmd and dat0 pins must be passed along with
2525
# their respective alternate functions
2626
sd = machine.SD(pins=('GP10', 'GP11', 'GP15'))
27-
os.mount(sd, '/sd')
27+
vfs.mount(sd, '/sd')
2828
# do normal file operations
2929

3030
Constructors

docs/library/machine.SDCard.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ vary from platform to platform.
3030
The class implements the block protocol defined by :class:`vfs.AbstractBlockDev`.
3131
This allows the mounting of an SD card to be as simple as::
3232

33-
os.mount(machine.SDCard(), "/sd")
33+
vfs.mount(machine.SDCard(), "/sd")
3434

3535
The constructor takes the following parameters:
3636

docs/library/pyb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Miscellaneous functions
213213
.. function:: mount(device, mountpoint, *, readonly=False, mkfs=False)
214214

215215
.. note:: This function is deprecated. Mounting and unmounting devices should
216-
be performed by :meth:`os.mount` and :meth:`os.umount` instead.
216+
be performed by :meth:`vfs.mount` and :meth:`vfs.umount` instead.
217217

218218
Mount a block device and make it available as part of the filesystem.
219219
``device`` must be an object that provides the block protocol. (The

docs/mimxrt/quickref.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,27 +443,27 @@ SD card
443443

444444
See :ref:`machine.SDCard <machine.SDCard>`::
445445

446-
import machine, os
446+
import machine, os, vfs
447447

448448
sd = machine.SDCard()
449-
fs = os.VfsFat(sd)
450-
os.mount(fs, "/sd") # mount
449+
fs = vfs.VfsFat(sd)
450+
vfs.mount(fs, "/sd") # mount
451451
os.listdir('/sd') # list directory contents
452-
os.umount('/sd') # eject
452+
vfs.umount('/sd') # eject
453453

454454
Note: The i.mx-rt 1011 and 1015 based boards do not support the ``machine.SDCard``
455455
class. For these, the SPI based driver ``sdcard.py`` from the MicroPython drivers
456456
can be used. When using it, you have to overdrive the CS pin of the SPI hardware
457457
module. Example::
458458

459-
import os, sdcard, machine
459+
import vfs, sdcard, machine
460460

461461
cs_pin = "D10"
462462
spi = machine.SPI(0) # SPI0 with cs at Pin "D10" used for SDCARD
463463
cs = machine.Pin(cs_pin, machine.Pin.OUT, value=1)
464464
sd = sdcard.SDCard(spi, cs)
465-
vfs = os.VfsFat(sd)
466-
os.mount(vfs, "/sdcard")
465+
fs = vfs.VfsFat(sd)
466+
vfs.mount(fs, "/sdcard")
467467

468468
OneWire driver
469469
--------------

docs/pyboard/general.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If needed, you can prevent the use of the SD card by creating an empty file
2121
called ``/flash/SKIPSD``. If this file exists when the pyboard boots
2222
up then the SD card will be skipped and the pyboard will always boot from the
2323
internal filesystem (in this case the SD card won't be mounted but you can still
24-
mount and use it later in your program using ``os.mount``).
24+
mount and use it later in your program using ``vfs.mount``).
2525

2626
(Note that on older versions of the board, ``/flash`` is called ``0:/`` and ``/sd``
2727
is called ``1:/``).

docs/reference/filesystem.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ RAM using a ``bytearray``::
108108

109109
It can be used as follows::
110110

111-
import os
111+
import vfs
112112

113113
bdev = RAMBlockDev(512, 50)
114-
os.VfsFat.mkfs(bdev)
115-
os.mount(bdev, '/ramdisk')
114+
vfs.VfsFat.mkfs(bdev)
115+
vfs.mount(bdev, '/ramdisk')
116116

117117
An example of a block device that supports both the simple and extended
118118
interface (i.e. both signatures and behaviours of the
@@ -150,11 +150,11 @@ interface (i.e. both signatures and behaviours of the
150150
As it supports the extended interface, it can be used with :class:`littlefs
151151
<vfs.VfsLfs2>`::
152152

153-
import os
153+
import vfs
154154

155155
bdev = RAMBlockDev(512, 50)
156-
os.VfsLfs2.mkfs(bdev)
157-
os.mount(bdev, '/ramdisk')
156+
vfs.VfsLfs2.mkfs(bdev)
157+
vfs.mount(bdev, '/ramdisk')
158158

159159
Once mounted, the filesystem (regardless of its type) can be used as it
160160
normally would be used from Python code, for example::
@@ -197,16 +197,16 @@ recommended to use littlefs instead.
197197
To format the entire flash using FAT::
198198

199199
# ESP8266 and ESP32
200-
import os
201-
os.umount('/')
202-
os.VfsFat.mkfs(bdev)
203-
os.mount(bdev, '/')
200+
import vfs
201+
vfs.umount('/')
202+
vfs.VfsFat.mkfs(bdev)
203+
vfs.mount(bdev, '/')
204204

205205
# STM32
206-
import os, pyb
207-
os.umount('/flash')
208-
os.VfsFat.mkfs(pyb.Flash(start=0))
209-
os.mount(pyb.Flash(start=0), '/flash')
206+
import os, vfs, pyb
207+
vfs.umount('/flash')
208+
vfs.VfsFat.mkfs(pyb.Flash(start=0))
209+
vfs.mount(pyb.Flash(start=0), '/flash')
210210
os.chdir('/flash')
211211

212212
Littlefs
@@ -222,16 +222,16 @@ resistant to filesystem corruption.
222222
To format the entire flash using littlefs v2::
223223

224224
# ESP8266 and ESP32
225-
import os
226-
os.umount('/')
227-
os.VfsLfs2.mkfs(bdev)
228-
os.mount(bdev, '/')
225+
import vfs
226+
vfs.umount('/')
227+
vfs.VfsLfs2.mkfs(bdev)
228+
vfs.mount(bdev, '/')
229229

230230
# STM32
231-
import os, pyb
232-
os.umount('/flash')
233-
os.VfsLfs2.mkfs(pyb.Flash(start=0))
234-
os.mount(pyb.Flash(start=0), '/flash')
231+
import os, vfs, pyb
232+
vfs.umount('/flash')
233+
vfs.VfsLfs2.mkfs(pyb.Flash(start=0))
234+
vfs.mount(pyb.Flash(start=0), '/flash')
235235
os.chdir('/flash')
236236

237237
A littlefs filesystem can be still be accessed on a PC over USB MSC using the
@@ -264,14 +264,14 @@ block devices spanning a subset of the flash device.
264264
For example, to configure the first 256kiB as FAT (and available over USB MSC),
265265
and the remainder as littlefs::
266266

267-
import os, pyb
268-
os.umount('/flash')
267+
import os, vfs, pyb
268+
vfs.umount('/flash')
269269
p1 = pyb.Flash(start=0, len=256*1024)
270270
p2 = pyb.Flash(start=256*1024)
271-
os.VfsFat.mkfs(p1)
272-
os.VfsLfs2.mkfs(p2)
273-
os.mount(p1, '/flash')
274-
os.mount(p2, '/data')
271+
vfs.VfsFat.mkfs(p1)
272+
vfs.VfsLfs2.mkfs(p2)
273+
vfs.mount(p1, '/flash')
274+
vfs.mount(p2, '/data')
275275
os.chdir('/flash')
276276

277277
This might be useful to make your Python files, configuration and other
@@ -282,9 +282,9 @@ failure, etc.
282282
The partition at offset ``0`` will be mounted automatically (and the filesystem
283283
type automatically detected), but you can add::
284284

285-
import os, pyb
285+
import vfs, pyb
286286
p2 = pyb.Flash(start=256*1024)
287-
os.mount(p2, '/data')
287+
vfs.mount(p2, '/data')
288288

289289
to ``boot.py`` to mount the data partition.
290290

@@ -297,7 +297,7 @@ define an arbitrary partition layout.
297297
At boot, the partition named "vfs" will be mounted at ``/`` by default, but any
298298
additional partitions can be mounted in your ``boot.py`` using::
299299

300-
import esp32, os
300+
import esp32, vfs
301301
p = esp32.Partition.find(esp32.Partition.TYPE_DATA, label='foo')
302-
os.mount(p, '/foo')
302+
vfs.mount(p, '/foo')
303303

docs/renesas-ra/quickref.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,15 @@ SDCard
387387
The frozen sdcard driver (drivers/sdcard/sdcard.py) is available by connecting microSD card device to hardware SPI0 pins.::
388388

389389
from machine import Pin, SPI
390-
import os, sdcard
390+
import os, vfs, sdcard
391391

392392
spi = SPI(0, baudrate=500000)
393393
cs = Pin.cpu.P103
394394
sd = sdcard.SDCard(spi, cs)
395-
os.mount(sd, '/sd')
395+
vfs.mount(sd, '/sd')
396396
os.listdir('/')
397397
os.chdir('/sd')
398-
os.umount('/sd')
398+
vfs.umount('/sd')
399399

400400
OneWire driver
401401
--------------

docs/wipy/general.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ functions are defined in ``os`` module:
373373
Mounts a block device (like an ``SD`` object) in the specified mount
374374
point. Example::
375375

376-
os.mount(sd, '/sd')
376+
vfs.mount(sd, '/sd')
377377

378378
.. function:: unmount(path)
379379

docs/wipy/quickref.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ SD card
171171
See :ref:`machine.SD <machine.SD>`. ::
172172

173173
from machine import SD
174-
import os
174+
import vfs
175175

176176
# clock pin, cmd pin, data0 pin
177177
sd = SD(pins=('GP10', 'GP11', 'GP15'))
178178
# or use default ones for the expansion board
179179
sd = SD()
180-
os.mount(sd, '/sd')
180+
vfs.mount(sd, '/sd')
181181

182182
WLAN (WiFi)
183183
-----------

0 commit comments

Comments
 (0)
0