🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Can microSD card be accessed in UIFlow or with MicroPython?

    Micropython
    4
    12
    29.0k
    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.
    • Z
      zhufu86
      last edited by zhufu86

      I can not find any instruction in the documentation regarding how to access the tf card with python.
      Can anyone help me?

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        Take a look at the micro python official forums, there is a discussion about it

        Micropython.org

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • lukasmaximusL
          lukasmaximus
          last edited by

          Not possible in uiflow yet. Micropython is easy
          import os
          os.mountsd()
          os.listdir('/sd')

          etc...

          Z 1 Reply Last reply Reply Quote 0
          • Z
            zhufu86 @lukasmaximus
            last edited by

            @lukasmaximus
            thank you for your reply.
            But when I tried to exec os.mountsd I got an error as below.

            os.mountsd()
            W (20141) sdspi_host: spi bus changed (1 -> 2)
            E (20141) sdspi_host: spi bus 2 not available
            E (20141) vfs_native: Failed to initialize SDcard (258).
            Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
            OSError: [Errno 5] EIO

            ajb2k3A 1 Reply Last reply Reply Quote 0
            • ajb2k3A
              ajb2k3 @zhufu86
              last edited by

              @zhufu86 said in Can TF card be accessed in UIFlow or with MicroPython?:

              @lukasmaximus
              thank you for your reply.
              But when I tried to exec os.mountsd I got an error as below.

              os.mountsd()
              W (20141) sdspi_host: spi bus changed (1 -> 2)
              E (20141) sdspi_host: spi bus 2 not available
              E (20141) vfs_native: Failed to initialize SDcard (258).
              Traceback (most recent call last):
              File "<stdin>", line 1, in <module>
              OSError: [Errno 5] EIO

              Can you post all you code please

              UIFlow, so easy an adult can learn it!
              If I don't know it, be patient!
              I've ether not learned it or am too drunk to remember it!
              Author of the WIP UIFlow Handbook!
              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

              Z 1 Reply Last reply Reply Quote 0
              • Z
                zhufu86 @ajb2k3
                last edited by

                @ajb2k3

                I just exec in REPL.

                import os
                os.mountsd()

                nothing else....

                I also tried os.SDMODE_4LINE, os.SDMODE_1LINE and os.SDMODE_SPI with os.sdconfig(...) before mountsd(), but none of them worked.

                Forgot to say, I'm using M5Stack Fire.

                ajb2k3A 1 Reply Last reply Reply Quote 0
                • ajb2k3A
                  ajb2k3 @zhufu86
                  last edited by

                  @zhufu86 said in Can TF card be accessed in UIFlow or with MicroPython?:

                  @ajb2k3

                  I just exec in REPL.

                  import os
                  os.mountsd()

                  nothing else....

                  I also tried os.SDMODE_4LINE, os.SDMODE_1LINE and os.SDMODE_SPI with os.sdconfig(...) before mountsd(), but none of them worked.

                  Forgot to say, I'm using M5Stack Fire.

                  You also need the machine, sdcard and dpi library imported. That’s why I recommend that you visit MicroPython.org

                  UIFlow, so easy an adult can learn it!
                  If I don't know it, be patient!
                  I've ether not learned it or am too drunk to remember it!
                  Author of the WIP UIFlow Handbook!
                  M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                  Z 1 Reply Last reply Reply Quote 0
                  • Z
                    zhufu86 @ajb2k3
                    last edited by

                    @ajb2k3

                    thank you.

                    I went to MicroPython.org but found nothing helpful.
                    Finally, I erased the firmware and burned the M5S with the UIFlow-v1.3.1-Beta firmware.

                    It worked, with the code below.

                    >>> import uos
                    >>> uos.sdconfig(uos.SDMODE_SPI,clk=18,mosi=23,miso=19,cs=4)
                    I (53596) gpio: GPIO[23]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pull             down: 0| Intr:0
                    I (53596) gpio: GPIO[19]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pull             down: 0| Intr:0
                    I (53604) gpio: GPIO[18]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pull             down: 0| Intr:0
                    >>> uos.mountsd()
                    W (65959) sdspi_host: spi bus changed (1 -> 2)
                    I (65959) gpio: GPIO[4]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulld             own: 0| Intr:0
                    ---------------------
                     Mode: SPI
                         Name: SU08G
                         Type: SDHC/SDXC
                        Speed: default speed (25 MHz)
                    SPI speed: 40 MHz
                         Size: 7580 MB
                          CSD: ver=1, sector_size=512, capacity=15523840 read_bl_len=9
                          SCR: sd_spec=2, bus_width=5
                    
                    >>> 
                    
                    1 Reply Last reply Reply Quote 0
                    • Z
                      zhufu86
                      last edited by

                      Funny...

                      I re-burned back to UIFlow-v1.2.3, and it also worked.

                      >>> import uos
                      >>> uos.sdconfig(uos.SDMODE_SPI,clk=18,mosi=23,miso=19,cs=4)
                      >>> uos.mountsd()
                      W (104277) sdspi_host: spi bus changed (1 -> 2)
                      ---------------------
                       Mode: SPI
                           Name: SU08G
                           Type: SDHC/SDXC
                          Speed: default speed (25 MHz)
                      SPI speed: 20 MHz
                           Size: 7580 MB
                            CSD: ver=1, sector_size=512, capacity=15523840 read_bl_len=9
                            SCR: sd_spec=2, bus_width=5
                      
                      >>>
                      
                      
                      1 Reply Last reply Reply Quote 0
                      • Z
                        zhufu86
                        last edited by zhufu86

                        Here I attach the webpages which helps me mostly.
                        Hope it can help other people.

                        https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki/filesystems
                        https://forum.micropython.org/viewtopic.php?t=4551
                        https://loboris.eu/forum/showthread.php?tid=85

                        Z 1 Reply Last reply Reply Quote 1
                        • Z
                          zhufu86 @zhufu86
                          last edited by

                          ok......

                          now even one simple uos.mountsd() also works...
                          good...

                          >>> import uos
                          >>> uos.mountsd()
                          W (497494) sdspi_host: spi bus changed (1 -> 2)
                          ---------------------
                           Mode: SPI
                               Name: SU08G
                               Type: SDHC/SDXC
                              Speed: default speed (25 MHz)
                          SPI speed: 20 MHz
                               Size: 7580 MB
                                CSD: ver=1, sector_size=512, capacity=15523840 read_bl_len=9
                                SCR: sd_spec=2, bus_width=5
                          
                          
                          1 Reply Last reply Reply Quote 0
                          • H
                            hema41
                            last edited by

                            Yes, microSD cards can be accessed in UIFlow or with MicroPython. They allow you to read and write data from/to the microSD card, enabling storage and retrieval of information on compatible devices.

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post