Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

microSD-Card-Problem under CircuitPython - ok under Arduino
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

microSD-Card-Problem under CircuitPython - ok under Arduino

by meichr on Sat Sep 16, 2017 8:24 pm

Feather M0 Express + Featherwing RTC+SD. The SD-Card type is "Transcend microSDHC 4GB, Class 4", problem can be reproduced with two freshly FAT-32 formatted SDs of this type. Another SD-Card of type "SanDisk 4GB Class2" works properly under CircuitPython 2.0.0.

I've tried both Transcend SDs on the same Featherstack using all Arduino IDE SD examples properly. But using CircuitPython 2 with the latest library bundle, it stalls at "storage.mount(vfs, '/sd')".

Code: Select all | TOGGLE FULL SIZE
# Feather M0 Express + Featherwing RTC+SD
import gc
gc.collect()
print("After gc: "+str(gc.mem_free()))
import adafruit_sdcard
gc.collect()
print("After adafruit_sdcard: "+str(gc.mem_free()))
import busio
gc.collect()
print("After busio: "+str(gc.mem_free()))
import digitalio
gc.collect()
print("After digitalio: "+str(gc.mem_free()))
from board import *
gc.collect()
print("After board: "+str(gc.mem_free()))
import storage
gc.collect()
print("After storage: "+str(gc.mem_free()))
import math
gc.collect()
print("After math: "+str(gc.mem_free()))

# Connect to the card and mount the filesystem.
spi = busio.SPI(SCK, MOSI, MISO)
print("Test1: "+str(gc.mem_free()))
cs = digitalio.DigitalInOut(D10)
print("Test2: "+str(gc.mem_free()))
sdcard = adafruit_sdcard.SDCard(spi, cs)
print("Test3: "+str(gc.mem_free()))
vfs = storage.VfsFat(sdcard)
print("Test4: "+str(gc.mem_free()))
storage.mount(vfs, "/sd")
print("Test5: "+str(gc.mem_free()))


The REPL stalls at this point:

Code: Select all | TOGGLE FULL SIZE
code.py output:
After gc: 18080
After adafruit_sdcard: 12736
After busio: 12736
After digitalio: 12720
After board: 12512
After storage: 12528
After math: 12464
Test1: 12352
Test2: 12272
Test3: 11152
Test4: 10448



Could there be a timing problem in the CP SD library with this SD card type?

meichr
 
Posts: 10
Joined: Wed Aug 02, 2017 3:11 pm

Re: microSD-Card-Problem under CircuitPython - ok under Ardu

by meichr on Mon Sep 18, 2017 3:12 pm

Another test with a "Transcend microSDHC 4GB, Class 10" sd card seems to suggest, that it is not the speed of the card, but the make of the sd card. It looks like that Transcend microsd cards are not supported by CircuitPython 2.0.0. Also this card works with the Arduino IDE SD examples.

meichr
 
Posts: 10
Joined: Wed Aug 02, 2017 3:11 pm

Re: microSD-Card-Problem under CircuitPython - ok under Ardu

by danhalbert on Mon Sep 18, 2017 3:54 pm

Hi - we're investigating some issues with SD cards and CircuitPython in this GitHub issue: https://github.com/adafruit/circuitpython/issues/245. Could you try the test program there and see what happens. The more data we have the better. Thanks!

danhalbert
 
Posts: 2139
Joined: Tue Aug 08, 2017 12:37 pm

Re: microSD-Card-Problem under CircuitPython - ok under Ardu

by tannewt on Mon Sep 18, 2017 9:45 pm

I fixed a previous issue by modifying the toggling of the chip select line. Some cards are more picky about it than others. As Dan suggested lets use that issue to track cards that currently don't work. I'll make an order and see what I can do!

tannewt
 
Posts: 1845
Joined: Thu Oct 06, 2016 8:48 pm

Please be positive and constructive with your questions and comments.