Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SD Cards producing OSError 19 #245

Closed
tannewt opened this issue Sep 6, 2017 · 27 comments · Fixed by adafruit/Adafruit_CircuitPython_SD#1
Assignees
Milestone

Comments

@tannewt
Copy link
Collaborator

@tannewt tannewt commented Sep 6, 2017

Adafruit CircuitPython 2.0.0-rc.1 on 2017-09-01; Adafruit Feather M0 Adalogger with samd21g18
>>> import os
>>> import adafruit_sdcard
>>> import busio
>>> import digitalio
>>> import board
>>> import storage
>>> os.listdir()
['boot_out.txt', 'adafruit_sdcard.mpy', 'adafruit_bus_device', 'spi_device.mpy', 'i2c_device.mpy']
>>> spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
>>> cs = digitalio.DigitalInOut(board.SD_CS)
>>> sdcard = adafruit_sdcard.SDCard(spi, cs)
>>> vfs = storage.VfsFat(sdcard)
>>> storage.mount(vfs, "/sd")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: 19
>>> with open("/sd/test.txt", "w") as f:
... f.write("Hello world\n")
... 
... 
... 
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: 30
>>>

https://forums.adafruit.com/viewtopic.php?f=60&t=114744

@tannewt tannewt added this to the 2.0 milestone Sep 6, 2017
@hukuzatuna

This comment has been minimized.

Copy link

@hukuzatuna hukuzatuna commented Sep 7, 2017

NOT replicated on Feather M0 Adalogger! The above code works without error (Class 10 Sandisk card).

@hukuzatuna hukuzatuna closed this Sep 7, 2017
@hukuzatuna hukuzatuna reopened this Sep 7, 2017
@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 7, 2017

This error can occur if the card isn't formatted. fabitencourt, does it work when connecting to a computer or in Arduino?

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 8, 2017

The black Verbatim 16 G one wasn't formatted. I've formatted fat32 with gparted and still the same errors on the same places. After many trials finally the black lexar 16G worked one shot. I'm happy...

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 8, 2017

Press any key to enter the REPL. Use CTRL-D to reload.

Adafruit CircuitPython 2.0.0-rc.1 on 2017-09-01; Adafruit Feather M0 Adalogger with samd21g18

import os
os.listdir()
['boot_out.txt', 'adafruit_sdcard.mpy', 'adafruit_bus_device', '.Trash-1000']
import adafruit_sdcard
import busio
import digitalio
import board
import storage
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
sdcard = adafruit_sdcard.SDCard(spi, cs)
Traceback (most recent call last):
File "", line 1, in
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 84, in init
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 117, in _init_card
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 172, in _init_card_v2
OSError: timeout waiting for v2 card
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
with open("/sd/test.txt", "w") as f:
... f.write("Hello world\n")
...
...
...
12
os.listdir()
['boot_out.txt', 'adafruit_sdcard.mpy', 'adafruit_bus_device', '.Trash-1000']
os.listdir('/sd')
['test.txt']

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 8, 2017

Adafruit CircuitPython 2.0.0-rc.1 on 2017-09-01; Adafruit Feather M0 Adalogger with samd21g18

import os
os.listdir()
['boot_out.txt', 'adafruit_sdcard.mpy', 'adafruit_bus_device', '.Trash-1000']
import adafruit_sdcard
import busio
import digitalio
import board
import storage
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.SD_CS)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
with open("/sd/test2.txt", "w") as f:
... f.write("Salut tout le monde\n")
...
...
...
20
os.listdir('/sd')
['test.txt', 'test2.txt']

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 8, 2017

Just saw the blue 16G on gparted and it had a 4 M not allowed. I've formatted on fat 32. I'll try with that too. No way. The only one is that Verbatin 16G black card you see on the photo. Lexar doesn't seems to work at all. Even if they work on arduino sketches.

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 8, 2017

No way. Neither of Lexar cards are working. The black 4G and the blue 16 G too. Both Lexar cards don't seems to work for now.

@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 8, 2017

Did you get it working with a different card? I ended up with a Kodak card instead of Lexar but I'll give it a try today.

@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 8, 2017

I believe I'm seeing the same thing with a Samsung EVO Select card. It works with my Mac via card reader but produces an OSError 19 in CircuitPython. Looking at it now.

@tannewt tannewt self-assigned this Sep 8, 2017
@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 8, 2017

I've downloaded the new version, candidate 2. I'll try it as soon as I can. I've noticed the DS3231 library is already there. Perfect. I'll give a try.

tannewt added a commit to chickadee-tech/Adafruit_CircuitPython_SD that referenced this issue Sep 8, 2017
response code and response data. Samsung EVO cards do not work
otherwise.

May fix adafruit/circuitpython#245
@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 8, 2017

@fabitencourt can you please try this mpy (after unzipping)? Its for CircuitPython 2.x. What I found was that the Samsung cards I have don't like the chip select deinit and extra clocks between the read command response and the actual data.

The fix is in this pull request.

adafruit_sdcard.mpy.zip

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 8, 2017

OK Scott, I just tried that version and it's not working better for me, even my verbatim 16 G that worked well before got stuck on:
sdcard = adafruit_sdcard.SDCard(spi, cs)
Traceback (most recent call last):
File "", line 1, in
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 84, in init
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 117, in _init_card
File "libraries/drivers/sdcard/adafruit_sdcard.py", line 172, in _init_card_v2
OSError: timeout waiting for v2 card

I've tried the last bundle candidate 2 and even if my Lexar doesn't work any better my verbatim 16G works like a charm. So I prefer the adafruit_sdcard.mpy from candidate 2 bundle.

@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 8, 2017

No rush! Thanks for the quick reply.

@jerryneedell

This comment has been minimized.

Copy link
Collaborator

@jerryneedell jerryneedell commented Sep 9, 2017

@tannewt FYI - I am able to access a SanDisk 8GByte Class 10 card from my M0-Express via an Adalogger Featherwing. Using latest 2.0.0 and library bundle

@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 10, 2017

Ok! Thanks for the report @fabitencourt. I will buy some more cards off of Amazon. I expected the newer library to work better. Perhaps they are even pickier about the chip select line. The arduino library is also much faster in talking with the chips.

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 10, 2017

@tannewt tannewt modified the milestones: Long term, 2.0 Sep 11, 2017
@cehiles

This comment has been minimized.

Copy link

@cehiles cehiles commented Sep 13, 2017

I am experiencing similar behaviour with the following:
-Adafruit CircuitPython 2.0.0 on 2017-09-12; Adafruit Feather M0 Express with samd21g18
-Adafruit Adalogger FeatherWing
-adafruit-circuitpython-bundle-2.0.0-20170912
-SanDisk Ultra 64GB microSDXC UHS-I Card (Class 10)

import os
import adafruit_sdcard
import busio
import digitalio
import board
import storage
os.listdir()
['boot_out.txt', '.Trash-1000', 'code.py', 'lib']
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D10)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
Traceback (most recent call last):
File "", line 1, in
OSError: 19

Is anyone able to send the exact product description for an SD card that they have working with CircuitPython? Preferably 32GB or bigger. I'd like to order a card that is known to work. Thanks!

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 13, 2017

In my opinion you're missing some files on circuitpy's directory. Personally mine is like this and is working with a 16 G Verbatim card...
https://forums.adafruit.com/viewtopic.php?f=60&t=114744 (for the photo of my card)

os.listdir()
['boot_out.txt', 'adafruit_sdcard.mpy', 'adafruit_bus_device', '.Trash-1000']

Have you formatted your card fat32 ?

@cehiles

This comment has been minimized.

Copy link

@cehiles cehiles commented Sep 13, 2017

The necessary libraries are in the /lib folder. However, I reformatted Fat32 using gparted and that got things working. Thank you!

@fabitencourt

This comment has been minimized.

Copy link

@fabitencourt fabitencourt commented Sep 13, 2017

My pleasure. Really glad to know it. That's exactly what happened in my case. Error 19 seems to mean: "card not formatted" and I've used gparted too.

@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 14, 2017

@cehiles glad that worked!

@meichr

This comment has been minimized.

Copy link

@meichr meichr commented Sep 19, 2017

Adafruit CircuitPython 2.0.0 on 2017-09-12; Adafruit Feather M0 Express with samd21g18

import os
import adafruit_sdcard
import busio
import digitalio
import board
import storage
os.listdir()
['boot_out.txt', '.fseventsd', 'lib', '._lib', 'code.py', '._code.py', '.Trashes']
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D10)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")

After the last line the terminal freezes, no reaction for at least 10 minutes.
Test of SD card in "Adalogger FeatherWing - RTC + SD Add-on".
Tested SD cards with this reaction:
Transcend 4GB class 10, Transcend 4GB class 4.

@meichr

This comment has been minimized.

Copy link

@meichr meichr commented Sep 19, 2017

Adafruit CircuitPython 2.0.0 on 2017-09-12; Adafruit Feather M0 Express with samd21g18

import os
import adafruit_sdcard
import busio
import digitalio
import board
import storage
os.listdir()
['boot_out.txt', '.fseventsd', 'lib', '._lib', 'code.py', '._code.py', '.Trashes']
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
cs = digitalio.DigitalInOut(board.D10)
sdcard = adafruit_sdcard.SDCard(spi, cs)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/sd")
Traceback (most recent call last):
File "", line 1, in
OSError: 19
with open("/sd/test.txt", "w") as f:
... f.write("Hello world\n")
...
...
...
Traceback (most recent call last):
File "", line 1, in
OSError: 30

Test of SD card in "Adalogger FeatherWing - RTC + SD Add-on".
Tested SD card with this reaction:
Samsung EVO 32GB UHS-I, cass 10 (up to 48 MB/s).
SD Card had been quick formatted with SDFormatter Version 4.0 (macOS Sierra).

@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 19, 2017

Ok, I've ordered Transcend, Verbatim and Lexar cards to test with. @meichr could you post a picture of the cards? I think I've tested a similar Samsung card and it worked ok.

My test cards so far:

img_2292

@meichr

This comment has been minimized.

Copy link

@meichr meichr commented Sep 19, 2017

@tannewt I've done the above tests with the library-2.0.0 bundle from Sep. 15th and thought that it already contained the above update from Sep 9th. My error!
The pictured SanDisk sd card works with the Sep. 15th version and the above Sep. 9th version. The Transcend sd cards and the Samsung sd card work with the above Sep. 9th version, but not with the bundled Sep. 15th version.

20170919_sdcards_working_with_circuitpython

These cards work with the above Sep. 9th library update.

@tannewt

This comment has been minimized.

Copy link
Collaborator Author

@tannewt tannewt commented Sep 19, 2017

Wups, looks like I forgot to request a review from @dhalbert on it! The fix is here: adafruit/Adafruit_CircuitPython_SD#1

@meichr

This comment has been minimized.

Copy link

@meichr meichr commented Sep 19, 2017

But I forgot to thank you for the fixes :-) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.