'module' object has no attribute 'mkfs'
-
Running into a series of gotchas with Micropython and Pymakr. One more to share. Either I or documentation need to be corrected. Here's the link: https://docs.pycom.io/gettingstarted/programming/first-project/
>>> Running d:\repo\Pycom\main.py >>> >>> Traceback (most recent call last): File "<stdin>", line 17, in <module> AttributeError: 'module' object has no attribute 'mkfs' > Pycom MicroPython 1.20.0.rc13 [v1.9.4-94bb382] on 2019-08-22; GPy with ESP32 Type "help()" for more information.
This is the failing code:
import os os.mkfs('/flash')
-
@kjm I don't believe so. It will just reformat the user space filesystem mounted at
/flash
. This is completely different from more lower level operations likeerase_all
.
-
@andreas does os.fsformat('/flash') do a full flash erase equivalent to pycom-fwtool-cli.exe -p COMxx erase_all ?
-
Nowadays, we also have
os.fsformat('/flash')
, see also https://forum.pycom.io/topic/5375/using-pycom-fwtool-cli/6.
-
@nathanh said in 'module' object has no attribute 'mkfs':
I am bumping this as I just ran into this exact problem with the incorrect documentation, this post just saved me so would be useful to have the documentation updated.
I like way MicroPython handles it, so you can see the matching documentation for your firmware version. Or like Microsoft, show in which versions the methods exists.
-
I am bumping this as I just ran into this exact problem with the incorrect documentation, this post just saved me so would be useful to have the documentation updated.
-
I think I found the solution buried in a post, https://forum.pycom.io/topic/4099/new-firmware-release-candidate-v1-20-0/81, about a firmware upgrade. Please upgrade the official documentation as I'm sure this is stopping others as well. I'm not sure why this hasn't been reported before!
Note: The function os.mkfs() has been replaced with os.fsformat() To format the internal file system, use os.fsformat('/flash') and os.fsformat('/sd') to format SD cards (card needs to be mounted as '/sd') To mount the SD card, use this code: sd = SD() fs = os.mkfat(sd) os.mount(fs, '/sd')
-
Ran into another similar instance of this issue in another section for firmware upgrading of the LTE modem: https://docs.pycom.io/tutorials/lte/firmware/.
>>> from machine import SD >>> >>> sd = SD() >>> os.mkfs(sd) # format SD card Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'mkfs' >>> os.mount(sd, '/sd') # mount it Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 1] EPERM >>> os.listdir('/sd') # list its content Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 19] ENODEV