View contents of SD Card

  • I have a Lopy and expansion board. I'm using FileZilla to view/edit contents of the flash and want to know if I can also view/edit contents of the expansion board's SD card with FileZilla.

  • This post is deleted!

  • Hello Robert, I used the example SD code where I see it call the mount statement.

    from machine import SD
    import os

    sd = SD()
    os.mount(sd, '/sd')
    f = open('/sd/test.txt', 'w')
    f.write('Testing SD card write operations')
    f = open('/sd/test.txt', 'r')

  • @JimT The SD card has to be mounted before you can access internally and externally. If you could write to it, that only means that somewhere in the code it was mounted. That does not have to be in But since is always executed on boot, this is a good place to perform the mounting.
    If you ask about documentation: for and, look at the (very good) documentation, chapter 1.5 or 2.5. The SD card set-up is documented in chapter SD
    I wonder how you managed to write to the SD card w/o mounting it?

  • Thank you for your response. I will add these statements to the file. Where is the documentation which discusses this? I was able to write to the sd card without these statements but it will be great to see the results using fileZilla.

  • @JimT Once you have mounted the SD card from within the LoPy, you can see it's content by ftp under the name you used for mounting. You can add the statements for mounting to your script, like:

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

    In that case, the SD cards content would appear under /sd.

Log in to reply

Pycom on Twitter