SD card doesn't work on pysense
-
For some reason i can't get the SD card working in my pysense, i use a 16 GB microSDHC card.
Even the example code doesn't run:from machine import SD
import ossd = SD()
os.mount(sd, '/sd')os.listdir('/sd')
f = open('/sd/test.txt', 'w')
f.write('Testing SD card write operations')
f.close()It gives the following error;
Traceback (most recent call last):
File "<stdin>", line 6, in <module>
OSError: the requested operation is not possibledoes anybody know a solution? Thanks in advance!
-
I had the same issue with the Expansionboard v3.1. The issue got solved, after using another Expansionboard v3.1 I've bought recentely..... I never used the SD-Card slot on the first one before, so I don't know, why it seems to be broken. Well, at least it works flawless with the second Expansionboard.
-
@freddy said in SD card doesn't work on pysense:
os.mount(sd, '/sd')
I was getting the error on os.mount(sd, '/sd')
I found that cause the SD card was greater than 32GB that windows was only allowing it to be formatted to exFAT which doesn't work for the pycom. I had to delete all volumes of the SD card and create a new volume that was less than 32GB. Windows then could format to FAT32 and it worked from there
-
some SD cards are not compatible with pysense so you have to check which card is compatible and working fine on it.
-
@timh When we dig down the G15 pull up to enable SD card use 10K resistor,
G15 is also SD_DAT. I wonder if when USB power is connected the 10K isn't quite correct and write operations once i2c is in use, causes insufficient voltage for SD writes ? I assume a write requires more power.
Don't know enough about this level of operation.
-
I am doing all of this as we use Losant, and want to be able to change running config if sensors or other parameters are changed and want to update remotely over LTE.
Really waiting for PyBytes to officially support LTE.
-
@robert-hh yes, though I can see the sd card and list contents. It's only writes that fail.
Did a bit more poking around.Till now I have either tested just with USB or with external power on VIN and USB connected, and the writes failed always after I2C was initialised, and i2c deinit() didn't change the situation.
Using USB was the easiest to test seeing the full reboot. rather than reconnecting wifi.
What I have since discovered is removing USB connection and running off external power only, the SD card writes are now successful and reliable after I2C is initialized and being used.
I need to do more testing to really confirm this is the case.
Combine all of that with having to jumper G15 with 10K resistor etc for SD access makes the Expansion board 3.0 a bit of a pain compared with the 2.0 version. Also have had them go back into DFU mode a few times.
-
@timh The reason might be, that even if you deinit I2C on that Pin, it is not re-init'ed for SD card use. Without looking into the code, I assume that this is done when instantiating the SD object with
sd = machine.SD()
-
I have even tried disabling I2c before writing to SD, but this doesn't work.
Bit stumped.
-
@timh P23 is used for SD card clock. That is shown in the Pin-Out.
-
@timh I have narrowed down why I can't write to SD card.
If i2c is being used then writes fail. (reads don't).
By not enabling I2C writes are successful.
I am using PINS P22 and P23 for I2C. This worked on Expansion Board 2.0
I cannot find anything in the docs regarding a potential clash with this choice of PINS.Am now going to experiment with deinitialising the i2c devices before reading/writing SD.
;-(
-
Update:
I figured it out why it failed on one of our PySense boards ... after closer examination it looks like the pins on the board ... poked holes in the LiPo Battery pack we used ... and this must have shortened something inside the PySense ... ergo, it looks like it's the SD-Card controller that got fried or so ...
In other words, not really a software issue this time around :-)
-
Hi
Having the same experience with Expansion Board 3.0.
After power up I can write some of the time if performed early (sometimes).
Leave it 20min powered up and no chance of writing.
Exception message - operation is not possible or OSError: [Errno 5] EIOCan read most of the time.
Sometimes unable to call SD()
Only use Sanddisk and FAT32.
This most frustrating.
T
-
Well, I have the same issue as the original poster... tried all ... and still it fails.
The odd thing is ... all of the SDCards work with all of your PyTrack's .... really off that that they don't work with the PySense ...
-
@freddy I was having a problem reading the SD card on a Pytrack and a WiPy 3.0. I formatted the card in a USB adapter on a Windows 10 machine to FAT32. Initially, the WiPy could read it just fine so I wrote sd_boot.py to the SD card. Boot.py would run sd_boot.py if the SD card is present. After a couple minutes, I could no longer read the SD card but it was still mounted. If I rebooted the WiPy, it would still find and run sd_boot.py but I could no longer FTP to /sd/ nor see it in the REPL window (os.chdir('/sd') would give an error).
I reformatted the card while inserted into the PyTrack via the os.mkfs('/sd') command (as shown below) and now it works fine. Seems like it didn't like the way Windows 10 formatted the card.
-
@charlesdarwin I have FiPy with Expansion board 2.0 and SD mounting is fine, as long as there is a card present and it's got Fat32/Fat16 FS I only use Sandisk.
-
@henning I am getting the same error using a FiPy on a PyTrack board. This is really frustrating.
-
I tried a brand new 32GB SD card and get the same error.
Code
from machine import SD sd = SD()
Output
OSError: the requested operation failed
MicroPython v1.8.6-849-83e2f7f on 2018-03-19; FiPy with ESP32Version:
>>> os.uname()
(sysname='FiPy', nodename='FiPy', release='1.17.3.b1', version='v1.8.6-849-83e2f7f on 2018-03-19', machine='FiPy with ESP32', lorawan='1.0.2', sigfox='1.0.1')I'm using the SD slot of the pysense board.
Any ideas on what might cause it to crash at this early stage or how to debug the issue?
-
Thanks for your reply. The problem is that I get the error already on the sd=SD() line. Which fileystem does pycom expect or which is recommended? Currently the card is fat32 formatted.
I'll try to get a different card to test too.
@jmarcelino said in SD card doesn't work on pysense:@henning
Please follow the format procedure I posted below:https://forum.pycom.io/post/19664
If it still fails try another card.
Thanks
-
@henning
Please follow the format procedure I posted below:https://forum.pycom.io/post/19664
If it still fails try another card.
Thanks