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

    SD card doesn't work on pysense

    Scheduled Pinned Locked Moved Discussion
    pysensecodemicropython
    26 Posts 11 Posters 4.8k Views 12 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.
    • F Offline
      freddy
      last edited by

      For some reason i can't get the SD card working in my pysense, i use a 16 GB microSDHC card.
      Even the example code doesn't run:

      from machine import SD
      import os

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

      os.listdir('/sd')

      f = open('/sd/test.txt', 'w')
      f.write('Testing SD card write operations')
      f.close()

      It gives the following error;

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

      does anybody know a solution? Thanks in advance!

      J J 2 Replies Last reply Reply Quote 0
      • J Offline
        jmarcelino @freddy
        last edited by

        @freddy
        Can you try to format the SD card on the Pysense?

        import os
        from machine import SD
        sd=SD()
        os.mount(sd,'/sd')
        os.mkfs(‘/sd')
        
        F 1 Reply Last reply Reply Quote 0
        • F Offline
          freddy @jmarcelino
          last edited by

          @jmarcelino tried it, i get exactly the same error

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jmarcelino @freddy
            last edited by

            @freddy
            Can you try another card please?

            F 1 Reply Last reply Reply Quote 0
            • F Offline
              freddy @jmarcelino
              last edited by

              @jmarcelino made a little bit of progress, was abble to read out the content of the card, however suddenly out of nowhere a new issue popped up, i get the following error:

              Traceback (most recent call last):
              File "<stdin>", line 13, in <module>
              NameError: name 'SD' is not defined

              Do you maybe know a fix to that?

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jmarcelino @freddy
                last edited by

                @freddy
                That seems to mean the SD module hasn't been imported, did you do from machine import SD first?

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Henning
                  last edited by

                  I have the same or a similar issue. Upon sd = machine.SD() I get "OSError: the requested operation failed
                  MicroPython v1.8.6-849-83e2f7f on 2018-03-19; FiPy with ESP32"

                  import os
                  import machine
                  
                  ### SD Card
                  sd = machine.SD()
                  os.mount(sd, '/sd')
                  # check the content
                  os.listdir('/sd')
                  # try some standard file operations
                  f = open('/sd/test.txt', 'w')
                  f.write('Testing SD card write operations')
                  f.close()
                  
                  
                  J S 2 Replies Last reply Reply Quote 0
                  • J Offline
                    jmarcelino @Henning
                    last edited by

                    @henning
                    Please follow the format procedure I posted below:

                    https://forum.pycom.io/post/19664

                    If it still fails try another card.

                    Thanks

                    H C 2 Replies Last reply Reply Quote 0
                    • H Offline
                      Henning @jmarcelino
                      last edited by

                      Thanks for your reply. The problem is that I get the error already on the sd=SD() line. Which fileystem does pycom expect or which is recommended? Currently the card is fat32 formatted.
                      I'll try to get a different card to test too.
                      @jmarcelino said in SD card doesn't work on pysense:

                      @henning
                      Please follow the format procedure I posted below:

                      https://forum.pycom.io/post/19664

                      If it still fails try another card.

                      Thanks

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Henning
                        last edited by Henning

                        I tried a brand new 32GB SD card and get the same error.

                        Code

                        from machine import SD
                        
                        sd = SD()
                        

                        Output
                        OSError: the requested operation failed
                        MicroPython v1.8.6-849-83e2f7f on 2018-03-19; FiPy with ESP32

                        Version:
                        >>> os.uname()
                        (sysname='FiPy', nodename='FiPy', release='1.17.3.b1', version='v1.8.6-849-83e2f7f on 2018-03-19', machine='FiPy with ESP32', lorawan='1.0.2', sigfox='1.0.1')

                        I'm using the SD slot of the pysense board.

                        Any ideas on what might cause it to crash at this early stage or how to debug the issue?

                        CharlesDarwinC 1 Reply Last reply Reply Quote 0
                        • CharlesDarwinC Offline
                          CharlesDarwin @Henning
                          last edited by

                          @henning I am getting the same error using a FiPy on a PyTrack board. This is really frustrating.

                          T 1 Reply Last reply Reply Quote 0
                          • T Offline
                            timh @CharlesDarwin
                            last edited by

                            @charlesdarwin I have FiPy with Expansion board 2.0 and SD mounting is fine, as long as there is a card present and it's got Fat32/Fat16 FS I only use Sandisk.

                            1 Reply Last reply Reply Quote 0
                            • J Offline
                              jmpratt @freddy
                              last edited by

                              @freddy I was having a problem reading the SD card on a Pytrack and a WiPy 3.0. I formatted the card in a USB adapter on a Windows 10 machine to FAT32. Initially, the WiPy could read it just fine so I wrote sd_boot.py to the SD card. Boot.py would run sd_boot.py if the SD card is present. After a couple minutes, I could no longer read the SD card but it was still mounted. If I rebooted the WiPy, it would still find and run sd_boot.py but I could no longer FTP to /sd/ nor see it in the REPL window (os.chdir('/sd') would give an error).

                              I reformatted the card while inserted into the PyTrack via the os.mkfs('/sd') command (as shown below) and now it works fine. Seems like it didn't like the way Windows 10 formatted the card.

                              1 Reply Last reply Reply Quote 0
                              • C Offline
                                combaindeft @jmarcelino
                                last edited by

                                @jmarcelino

                                Well, I have the same issue as the original poster... tried all ... and still it fails.

                                The odd thing is ... all of the SDCards work with all of your PyTrack's .... really off that that they don't work with the PySense ...

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  timh
                                  last edited by timh

                                  Hi

                                  Having the same experience with Expansion Board 3.0.

                                  After power up I can write some of the time if performed early (sometimes).

                                  Leave it 20min powered up and no chance of writing.
                                  Exception message - operation is not possible or OSError: [Errno 5] EIO

                                  Can read most of the time.

                                  Sometimes unable to call SD()

                                  Only use Sanddisk and FAT32.

                                  This most frustrating.

                                  T

                                  T 1 Reply Last reply Reply Quote 0
                                  • C Offline
                                    combaindeft
                                    last edited by

                                    Update:

                                    I figured it out why it failed on one of our PySense boards ... after closer examination it looks like the pins on the board ... poked holes in the LiPo Battery pack we used ... and this must have shortened something inside the PySense ... ergo, it looks like it's the SD-Card controller that got fried or so ...

                                    In other words, not really a software issue this time around :-)

                                    1 Reply Last reply Reply Quote 0
                                    • T Offline
                                      timh @timh
                                      last edited by

                                      @timh I have narrowed down why I can't write to SD card.

                                      If i2c is being used then writes fail. (reads don't).

                                      By not enabling I2C writes are successful.

                                      I am using PINS P22 and P23 for I2C. This worked on Expansion Board 2.0
                                      I cannot find anything in the docs regarding a potential clash with this choice of PINS.

                                      Am now going to experiment with deinitialising the i2c devices before reading/writing SD.

                                      ;-(

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

                                        @timh P23 is used for SD card clock. That is shown in the Pin-Out.

                                        T 1 Reply Last reply Reply Quote 0
                                        • T Offline
                                          timh @robert-hh
                                          last edited by

                                          @robert-hh

                                          I have even tried disabling I2c before writing to SD, but this doesn't work.

                                          Bit stumped.

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

                                            @timh The reason might be, that even if you deinit I2C on that Pin, it is not re-init'ed for SD card use. Without looking into the code, I assume that this is done when instantiating the SD object with
                                            sd = machine.SD()

                                            T 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
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post

                                            Pycom on Twitter

                                            Pycom