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

    Unable to mound SD Card

    Scheduled Pinned Locked Moved LoPy
    lopysd cardexpansion board
    8 Posts 5 Posters 1.9k 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.
    • R Offline
      Robin
      last edited by

      Trying to write to a file on an SD card with LoPy4 connected to an expansion board.

      Used the following code:

      from machine import SD
      sd = SD()
      os.mount(sd, '/sd')

      and get the following error on the os.mount(sd,'/sd') command:

      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      OSError: the requested operation is not possible

      The SD card is FAT32 formatted, 8GB. Reads and writes perfectly on my mac.
      I previously managed to read and write files on the SD card, but since rebooting the device no joy at all.

      Now what? Has anyone been succesful in using an sd card in the expansion board?

      robert-hhR D E 3 Replies Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @Robin
        last edited by

        @robin Sure, I made that just now. The commands are:

        import os
        import machine
        
        sd = machine.SD()
        os.mount(sd, '/sd')
        

        So besides the import os, which you not showed, it#s the same. That works however only after a hard reset (pushing the reset button).

        R 1 Reply Last reply Reply Quote 0
        • R Offline
          Robin @robert-hh
          last edited by

          @robert-hh said in Unable to mound SD Card:

          import os
          import machine

          sd = machine.SD()
          os.mount(sd, '/sd')

          Yep you're right, i was performing os.mount twice which was caught in my exception handler and led me to think that was the problem..

          however that leads to OSError: [Errno 5] EIO
          while doing file.write. Here is the offending line.

          with open('/sd/%s' % 'log.txt', 'a+ ') as file:

          file.write('aha!')

          Traceback (most recent call last):
          File "<stdin>", line 2, in <module>
          OSError: [Errno 5] EIO

          Any clues what Errno 5 is or why its occuring?

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @Robin
            last edited by

            @robin error 5 is unspecific. Are you sure that you are using a FAT formatted card with exactly one partition?

            R 1 Reply Last reply Reply Quote 0
            • R Offline
              Robin @robert-hh
              last edited by

              @robert-hh yes. FAT 32 with one partition. Kingston 8GB SD card straight out of the box.
              I did manage to write some files to it at some point but i think continuous mounting and resetting the board may have corrupted the SD card. Right now i can't even do os.listdir('/sd').

              I'll reformat the SD card and see what happens.

              1 Reply Last reply Reply Quote 0
              • D Offline
                dabal221 @Robin
                last edited by

                @Robin Have you deal with this problem? I have got the same problem as you and I would like to know what is the reason and solution for this :)

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

                  @dabal221

                  There is no one reason for this.

                  • do not turn off/deepsleep immediately after write operations.
                  • You will get the same error If the SD card managed to rattle out. Using old school tape may be a fix for this ;)
                  1 Reply Last reply Reply Quote 0
                  • E Offline
                    Erick Falcon @Robin
                    last edited by

                    @Robin did you fix it?, I am trying to do the sema thing continuous mounting and resettind the SD Card. and sometimes I get the error: OSError: the requested operation is not possible, when i use "sd = SD()". and when I use "os.fsformat('/sd')" the program stop and I can only run again when I use the push button reset.

                    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