M5Paper SDCard access

  • Is there a way to access M5Paper SD card with MicroPython?

    There is no uos module, but os has mount function.
    I tried:

    import os
    os.mount(machine.SDCard(), '/sd')

    which result in:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OSError: 16

  • Did you ever figure this out? Struggling with the same issue

  • @mrk I figured it out...

    turns out you dont need to mount at all just do

    import json
    with open('/sd/config.json', 'r') as fs:
    c = json.loads(fs.read())
    label0 = M5TextBox(140, 106, c['ssid'], lcd.FONT_Default, 0xFFFFFF, rotate=0)

    I may have run some code prior to that .. dont remember .. try that if the first thing didnt work .. ( this is from boot.py) ... maybe it gets added automatically

    import machine, os
        sd = machine.SDCard(slot=3, miso=19, mosi=23, sck=18, cs=4)
        os.mount(sd, '/sd')
        print("SD card mounted at \"/sd\"")


    import uos
    uos.sdconfig(uos.SDMODE_SPI,clk=18,mosi=23,miso=19,cs =4)

  • @medy which UIFlow version do you use? v1.9.0? I have the M5Paper (Version 1) with v1.9.0

    I've still got some issues but I'm glad that this topic still has some progress.

    The code you posted from boot.py is present on mine as well, but commented out. If I add the code (in boot.py or main.py) my device freezes. This happens on sd.info() and os.mount(sd, '/sd').

    Did you use your third code from the post? or is this just a regular micropython module?

    Any help is highly appreciated :)

  • Same problem. Any updates? There must be a reason why the code in boot.py is there and why it was commented out

  • Hello guys

    the uncommented code in boot.py uses the incorrect SPI GPIOs for M5Paper. But even with the correct GPIOs it doesn't seem to work. I suspect that the SDCard driver built into the M5Paper UiFlow firmware is faulty.

    That said, I found a replacement SDCard driver here mentioned here that seems to work.

    With the sdcard.py file downloaded onto my M5Paper (alongside boot.py, main.py) I was able to list the files on the inserted SD card and write and read a file.

    import os
    from machine import Pin, SPI
    from sdcard import SDCard
    spisd = SPI(-1, miso=Pin(13), mosi=Pin(12), sck=Pin(14))
    sd = SDCard(spisd, Pin(4))
    os.mount(sd, '/sd')
    ### Write file
    #f = open('/sd/___AAA.txt', 'w')
    #f.write('Some text')
    ### Read a file
    #f = open('/sd/___AAA.txt', 'r')

    Note: I was using Thonny to download and test.


  • @felmue said in M5Paper SDCard access:

    isd = SPI(-1, miso=Pin(13), mosi=Pin(12), sck=Pin(14))
    sd = SDCard(spisd, Pin(4))
    os.mount(sd, '/sd')

    Doesnt work for me ( it works for printing in thonny ... but the device freezes)