SD Card write error: OSError: [Errno 5] EIO



  • I am getting this error when I am trying to log exception on my SD card.
    This is my code:
    In boot.py:

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

    in main.py:

    try:
        with open('/sd/debug.log', 'a') as f:
            f.write('starting loop')
        f.close()
        mainloop()
    
    except Exception as e:
       with open('/sd/error.log', 'w') as errorFile:
            errorFile.write('test')
        errorFile.close()
        sys.print_exception(e)
        machine.reset()
    

    My SD Card is a 32GB Fat32 formatted card, and I can successfully read the debug.log file on my mac.
    I don't understand why the second write in the error.log failed ... any help would be appreciated ...



  • @robert-hh In my main loop, I have simulated an Exception with

    raise Exception
    

    But it's working when I am writing to /flash/error.log, thanks for the tip. I just want to let my lopy running for a week and wanted some feedback if an exception have occured.



  • @geda For trial, I replaced the mainloop() by a 1/0 statement, just to cause an exception,, and all worked a expected. So maybe the error which happens in your test case has an impact on SD card I/O. What happens if you try writing to /flash/error.log instead?


Log in to reply
 

Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.