Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    'module' object has no attribute 'mkfs'

    Scheduled Pinned Locked Moved GPy
    11 Posts 6 Posters 1.2k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      Sn3akyP3t3
      last edited by

      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')
      
      1 Reply Last reply Reply Quote 0
      • S Offline
        Sn3akyP3t3
        last edited by

        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
        
        1 Reply Last reply Reply Quote 0
        • S Offline
          Sn3akyP3t3
          last edited by

          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')
          
          1 Reply Last reply Reply Quote 2
          • N Offline
            nathanh
            last edited by

            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.

            C 1 Reply Last reply Reply Quote 0
            • C Offline
              crumble @nathanh
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0
              • A Offline
                andreas
                last edited by

                Nowadays, we also have os.fsformat('/flash'), see also https://forum.pycom.io/topic/5375/using-pycom-fwtool-cli/6.

                K 1 Reply Last reply Reply Quote 0
                • K Offline
                  kjm @andreas
                  last edited by

                  @andreas does os.fsformat('/flash') do a full flash erase equivalent to pycom-fwtool-cli.exe -p COMxx erase_all ?

                  A 1 Reply Last reply Reply Quote 0
                  • A Offline
                    andreas @kjm
                    last edited by

                    @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 like erase_all.

                    1 Reply Last reply Reply Quote 1
                    • G Offline
                      goldfishalpha
                      last edited by

                      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.

                      K 1 Reply Last reply Reply Quote 0
                      • K Offline
                        kjm @goldfishalpha
                        last edited by

                        @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!

                        G 1 Reply Last reply Reply Quote 1
                        • G Offline
                          goldfishalpha @kjm
                          last edited by

                          @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.

                          1 Reply Last reply Reply Quote 0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          • 1 / 1
                          • First post
                            Last post

                          Pycom on Twitter

                          Pycom