Mount SD card later in my program using os.mount
Posted: Tue Oct 17, 2017 8:24 am
I'm trying to build a datalogger with PYBv1.1 and MicroPython V1.9.1 and I want to mount the SD card from within my main.py program. I don't want to be told to play with various USB modes during boot. I just want to do exactly what the documentation says is possible.
"If needed, you can prevent the use of the SD card by creating an empty file called /flash/SKIPSD. If this file exists when the pyboard boots up then the SD card will be skipped and the pyboard will always boot from the internal filesystem (in this case the SD card won’t be mounted but you can still mount and use it later in your program using os.mount)."
I put the SKIPSD empty file on /flash and it works as described, which is excellent. So, what I now need is the correct syntax for mounting the SD card using os.mount.
I've spent hours searching for an example that works, or attempting to work it out via trial and error. But every attempt caused error messages about missing modules, bad syntax, or objects not being callable. I'm feeling pretty stupid and frustrated.
I think I need to do 3 things:
1. Import some module(s) such as os, pyb, or SD depending on which example I've looked at
2. Create an sd object including a definition of the correct pins connected to the pyboard's micro-sd connector
3. Do the actual "mount" command
Is anybody able to help by providing a working example of approximately 3 or 4 lines of code?
Thanks.
"If needed, you can prevent the use of the SD card by creating an empty file called /flash/SKIPSD. If this file exists when the pyboard boots up then the SD card will be skipped and the pyboard will always boot from the internal filesystem (in this case the SD card won’t be mounted but you can still mount and use it later in your program using os.mount)."
I put the SKIPSD empty file on /flash and it works as described, which is excellent. So, what I now need is the correct syntax for mounting the SD card using os.mount.
I've spent hours searching for an example that works, or attempting to work it out via trial and error. But every attempt caused error messages about missing modules, bad syntax, or objects not being callable. I'm feeling pretty stupid and frustrated.
I think I need to do 3 things:
1. Import some module(s) such as os, pyb, or SD depending on which example I've looked at
2. Create an sd object including a definition of the correct pins connected to the pyboard's micro-sd connector
3. Do the actual "mount" command
Is anybody able to help by providing a working example of approximately 3 or 4 lines of code?
Thanks.