Running boot script on flash then attaching SD card
Posted: Mon Aug 02, 2021 10:48 pm
I have built my own version of the Pyboard. It is mostly the same but one of the changes I made is to switch the power to the SD card via a GPIO. The reason for this is that I am building a datalogger that uses deepsleep to save power but if I leave the SD card powered on the whole time the sleep current is about ~3ma which is much to high for my battery operated purposes. If I remove the SD card it drops down to 5uA which is much better.
Now what I am trying to do is when the Pyboard wakes up from sleep it runs the boot script on the flash memory which is fine. I then turn on a GPIO in that script which provides power to the attached SD card. I then want to mount that SD card and run the main.py file on that SD card. Is that possible?
I have tried the below code but it returns OSError: [Errno 19] ENODEV[/code]
I am not entirely sure how the boot.py works but it seems that if the SD card is not present when that script first runs I can't mount the SD card afterwards? Is there a way around this issue? Thanks
Now what I am trying to do is when the Pyboard wakes up from sleep it runs the boot script on the flash memory which is fine. I then turn on a GPIO in that script which provides power to the attached SD card. I then want to mount that SD card and run the main.py file on that SD card. Is that possible?
I have tried the below code but it returns OSError: [Errno 19] ENODEV
Code: Select all
if pyb.SDCard().present():
os.mount(pyb.SDCard(), '/sd')
sys.path[1:1] = ['/sd', '/sd/lib'][code]
I am not entirely sure how the boot.py works but it seems that if the SD card is not present when that script first runs I can't mount the SD card afterwards? Is there a way around this issue? Thanks