Can microSD card be accessed in UIFlow or with MicroPython?



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



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

    Micropython.org



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

    etc...



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



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



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



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



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


  • 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
    
    >>>
    
    




  • 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
    
    


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