'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 that's a bit esoteric for my current knowledge levels. I would have assumed that the "flash" is fragile regardless of language? Also, I'd be curious how you manage to stick to RTC RAM only.
TBH, my gripe is with the docs not being updating properly when Pycom/Micropython API changes are made. I could forgive it if they references the external Micropython docs for the latter. I'm not even annoyed that I have to recreate the filesystem so often, given the frequency that I make changes and re-upload a project.
Never too late to learn a new language, trouble is there always so many to choose from.
-
@goldfishalpha I sometimes wonder where I'd be know if I went down the Lua road beck in 2017. I've tried several flavours of upython on several different ESP32 devices these last 4 years & they all seem to have fragile flash. I tend to use RTC ram for variables I need to preserve between deepsleeps, anything to avoid writing to flash!
-
Jan 2022 and this still hasn't been updated in the documentation.
I find myself wasting so much time on these silly little 'updates' resulting in incomplete or incorrect API docs, that I think I would have been better off coding in C.
-
@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