Is it Flash or micro-SD?

I was unable to find a class/method to directly report whether the mounted filesystem is the built-in flash or a microSD card. I want to verify that a microSD is being used before attempting to save images. (The docs warn not to save images to the built-in flash.)

As a workaround, I am checking whether the tuple returned by uos.statvfs("/") matches the value returned for the onboard flash — (4096, 4096, 8183, 8178, 8178, 0, 0, 0, 0, 255) for the H7 Plus. If not, I’ll presume a microSD is mounted.

Is there a better or more appropriate way to check? My approach requires knowing which OpenMV device the code is running on and having this tuple to compare. Ideally, I’d prefer to call a function that returns True/False on all OpenMV devices.

Yeah, you can actually do card presence detection too just like you did the VBUS trick. So, one of the pins is attached to the card detect pin that you can read.

So, PG7 on the H7 plus.

Note, we don’t yet have a method for script deployment when you are done writing your code except for you to modify main.c and make a custom firmware image. So, once you are done making your MicroPython code you’ll need to do this in order to have your script run regardless of what drive is mounted. However, you seem to be actively helping out on the forums. Maybe we can collaborate to figure out how this should be done. It’s not that straightforward however to design a method that meets everyone’s needs.

Um, I can change the label to SD_CD so that it’s the same in all OpenMV Cam devices. Because this pin moves around on different versions.

Thank you; again, you’re very helpful. I hope you hear that a lot :slight_smile:

But I’m laughing at myself because you’re giving me far too much credit regarding “script deployment.” I wasn’t thinking of making a custom firmware with my code. Just a and library files… on the microSD card. So of course it’s not going to save pictures to internal flash because if the microSD is removed, so is the code!

I will still check that PG7 (future SD_CD?) pin anyway just to be safe… maybe when copying the code files a user would think they had the microSD inserted but didn’t really.

Hi, use:

import pyb

That sounds like a useful class! It is not listed among the pyb classes at pyb — functions related to the board — MicroPython 1.13 documentation. Would it be helpful for me to add an issue at Issues · openmv/openmv-doc · GitHub or am I misunderstanding where this would be documented?

Edit: I found class SDCard – secure digital memory card — MicroPython 1.15 documentation but that seems to only provide a blockdevice for mounting; there is not any mention of methods such as present() or info() so I don’t think it’s the same class?

It’s the same, but it’s port/implementation defined so it’s different on other ports, and not documented.