Unable to mound SD Card



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



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



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


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



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



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



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



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



Pycom on Twitter