Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 29

Thread: SD works fine on Teensy 4.0 but not SdFat

  1. #1
    Member
    Join Date
    Jan 2016
    Location
    USA
    Posts
    62

    SD works fine on Teensy 4.0 but not SdFat

    I have a Teensy 4.0 with the SD card holder sold here. SD seems to have no problem reading, writing, printing cardinfo etc on 32 gig sandisk microSd cards formatted FAT32.
    Of course the SdFat I already had installed didn't work, so installed Mr. Grieman's beta-master. Nada. I cannot make any of his examples work. I'm dumbfounded. Is it possible that there is a speed toggle in there somewhere which is skeptical of my card's efficacy?
    most of the errors I get running examples indicate inability to initialize or read card. 0X18 or 0x17 errors.

    What should I look at?

    I do need functions which SdFat has but SD doesn't.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    There is confirmation is can work in recent thread added code noted it was on a T_4 - went to SDFat Beta at the end : Teensy-3-6-SD-Card-missing-time-in-milliseconds

    I just transferred the code here to a T_4.0 on a breakout with SD card it it is working the same.

    In this case the SDFat Beta is using/expecting exFAT formatted card and fails without that.

    Check the file system type expected for SDFat codeand make sure the card is formatted properly. More notes on above thread and working sketch.

  3. #3
    Member
    Join Date
    Oct 2019
    Location
    Calgary
    Posts
    60
    You could try
    Code:
    SD.begin(PIN_SPI_SS, SD_SCK_MHZ(25));
    and seeing what that does. When I started off using the abundant el cheapo uSD adapters found on eBay and Amazon, that's the fastest that I could get a T4 + SdFat to run them at. I found that a bare bones breakout board - DigiKey part #CN0023-ND - and the uSD socket on an LCD display both worked flawlessly at full speed.

  4. #4
    Junior Member
    Join Date
    Feb 2017
    Location
    Chicago, IL
    Posts
    16
    Just a quick reply - I have the Teensy 4.0 working fine with the SdFat beta, as have others it seems. It's been a while since I got it going, but I remember having to format the card as exFAT, and I'm using SdExFat in code. Works with a SanDisk Ultra 16Gb card and a Samsung 128Gb EVO card, via a quick and dirty hard-wire to a uSD card adapter and, later, via a uSD card reader on a custom PCB.

  5. #5
    Member
    Join Date
    Jan 2016
    Location
    USA
    Posts
    62
    Thanks guys,
    I'll try formatting an exFAT card and see how that works. If it does work, then I'll go back and see if i can make it work with FAT32. This is a sort of requirement because the Teensy 3.2 system that writes the card-data does FAT32, but then maybe I can chage that to use ExFAT as well. or alternatively, drop the 4.0 for a 3.6 and make another board. I mount these things on home-brew pcb's which have the peripheral encoder, oled, sd reader, momentary push -switch, etc soldered on.

    This is a problem I hand't expected.

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    Again a great full example in post #10 on thread linked in p#2 above.

    Hopefully just formatting will fix

  7. #7
    Member
    Join Date
    Oct 2019
    Location
    Calgary
    Posts
    60
    Just as a data point, I've been using a FAT32 formatted card with SdFat-beta for a while now with absolutely no problems (Teensy 4.0, SPI connection).

  8. #8
    Junior Member
    Join Date
    Nov 2016
    Posts
    12
    Hello,

    Where did you find "Teensy 4.0 with the SD card holder"? I can find the one you have to add a card holder to it, but not one that comes with it. Do you have a link to purchase? Did you add it? or is there a part number that you can share?

    Thanks!

  9. #9
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    There was a sample somewhere with #ifdef for multiple file system formats. It can do multiple - but uses diff interfaces.

    From the doc :: .../libraries/SdFat/extras/html/index.html
    Introduction
    The Arduino SdFat library supports FAT16, FAT32, and exFAT file systems on Standard SD, SDHC, and SDXC cards.

  10. #10
    Member
    Join Date
    Jan 2016
    Location
    USA
    Posts
    62
    Quote Originally Posted by coinop View Post
    Hello,

    Where did you find "Teensy 4.0 with the SD card holder"? I can find the one you have to add a card holder to it, but not one that comes with it. Do you have a link to purchase? Did you add it? or is there a part number that you can share?

    Thanks!
    I bought the little separate SD board from these guys.

  11. #11
    Member
    Join Date
    Jan 2016
    Location
    USA
    Posts
    62
    Quote Originally Posted by Silverlock View Post
    Just as a data point, I've been using a FAT32 formatted card with SdFat-beta for a while now with absolutely no problems (Teensy 4.0, SPI connection).
    Well I'm clearly missing something. Were you able to run his examples? Did you modify SdFatConfig.h and if so how? or maybe easier, if you edited it, could you upload a copy? I just cannot understand how SD could have no problem with my SPI hardware setup and yet I cannot get this to work.

  12. #12
    Member
    Join Date
    Oct 2019
    Location
    Calgary
    Posts
    60
    I haven't touched SdFatConfig.h, so that's not it. Haven't run any other examples; it already works with my setup (and has for about 7 months now). And this is something that I'm actively using, day in day out, many hours a day.

    Something that just occurred to me: I didn't get SdFat-beta through the Library Manager (honestly don't know if it's even available through that). I cloned the repository. Could that be the difference? I don't see why it should make any difference (you ought to get the same code thru the Manager, as far as I know), but I thought I'd throw it out there for consideration.

    The only other thing that comes to mind is the card adaptor. I'm using a simple breakout board, no level converters, nothing but the socket and a header on a little PCB. I do use a separate 3.3V regulator just for the uSD card. Sure, the 3.3V regulator on the T4 has the capacity to handle the uSD card, but a separate. well filtered regulator for an SD card has always served me well. It's cheap insurance.

  13. #13
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    Post #2 linked to a good example on post #10 that thread - tried on T_4 and 4.1 with exFat formatted card. No mods were made to the zip extracted SDFat lib.

  14. #14
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    71
    I am using Adafruit's Teensy Adapter with T4 and their Adalogger with RTC and SdFat 1.1.2. The SD Card works flawlessly event with multiple files open in parallel. Unsure about the format, i think i just formatted it in mac os as exFat.

  15. #15
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    Is this adapter using the bottom pins for SDIO - 4 bit data transfer - or wired as a standard SPI device? The T_4.0 tested here solders to the bottom SDIO pins - and that is the default for SDFat Beta as I used it. That is the equivalent of 'chipSelect = BUILTIN_SDCARD;' in the SD.h examples.

  16. #16
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    71
    I think it uses SPI.

  17. #17
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    Quote Originally Posted by mstiller View Post
    I think it uses SPI.
    If not soldered using the pin array on the T_4 bottom , it will be normal SPI. That may take a settings adjustment in that case. p#9 has an idea where the HTML doc will be in your Teensy install that may provide that if not clear in an example.

    SD logging is active just now on 3 threads - on that linked thread another user posted that easy to read and use code that I took and modified to run on Beta T_4.1 and the performance is impressive - using an added RAM chip for 2 buffers near 1 MB- should be the same as a T_4.0 when wired to the bottom pads. I have PJRC Beta board that connects to bottom pins and two other breakouts that do the same.

  18. #18
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    71
    Besides soldering the headers on the boards, there is no soldering.

    It looks like this:

    Click image for larger version. 

Name:	IMG_4784.JPG 
Views:	15 
Size:	152.4 KB 
ID:	20019

  19. #19
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    Looks cool, but that would be normal SPI - normal pins if that worked with the SD. For T_4 with SDFat then the proper begin with info/pins specified may be needed - or change to config? - as by default it seems to assume SDIO with BUILTIN_SDCARD.

  20. #20
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    71
    Actually i don't really care if it's SPI or SDIO, i don't need max speed as long as it works. This is basically a PDP11/40 emulation, which means the cpu emulation is slowing everything down anyway.

    Besides that, you mentioned an added RAM chip, where can i get more information about that? Very interesting for my project.

  21. #21
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,769
    Added RAM is a T_4.1 add on - Not yet released - there is a Beta thread. 8MB and QSPI is usably fast.

    Only mentioned SPI .vs. SDIO because the software will need to know.

    If/when you get a T_4.1 - it has onboard SDIO driven SD card like the T_3.6/3.5. Also a place to solder a 16MB Flash chip and the onboard Program flash is 8MB - also easy to connect USBHost pins - and prepped for Ethernet … see that thread,

    Teensy-4-1-Beta-Test

  22. #22
    Member
    Join Date
    Apr 2020
    Location
    Germany, NRW
    Posts
    71
    Already read that thread, will definitely buy one, but it uses the larger board right?

  23. #23
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,665
    Quote Originally Posted by mstiller View Post
    Actually i don't really care if it's SPI or SDIO, i don't need max speed as long as it works.
    That is why you MUST open, understand and if necessary edit the config file.

    I only (mostly) use Bill Greiman's SDFat (beta) with Teensy, including T4.0. So it works.

  24. #24
    Member
    Join Date
    Jan 2016
    Location
    USA
    Posts
    62
    This is what I did physically. earlier effort was same except I used a nano (because I have a box full). It worked fine except that I ran out of room after coming to understand what I was actually trying to do which was to read microSDs, from a Teensy 3.2 powered flight data recorder, array each record, and send some combination of the fields out the USB port to a computer running X-Plane. I got as far as the array and couldn't make it fit, so fool that I was I thought a Teensy 4.0 would do the trick and here it is.

    Circuit designed in Eagle, G-code for router generated from Eagle in pcb-gcode, traces isolated on Chinese 6040 Router, copper tinned, and components soldered in place. Box is PETG 3D printed on MakerGear M2.

    Click image for larger version. 

Name:	flt-sender.jpg 
Views:	6 
Size:	84.1 KB 
ID:	20025 Click image for larger version. 

Name:	flight-sender-back.jpg 
Views:	2 
Size:	176.7 KB 
ID:	20026 Click image for larger version. 

Name:	box.jpg 
Views:	4 
Size:	113.6 KB 
ID:	20027

    I'm using SPI; standard wiring 10,11,12,13 with 5 volts coming from the teensy to the Sd-holder. I have it set up with a voltage regulator to run on a 9 volt battery, but haven't used it yet and may not. it now gets power via the usb port. The oled is an I2C device. SD Card holder is only spi device.

    it would still be very helpful if someone could upload a snippet of code known to work without modification to the config, and if at all possible the rev number of the working sdfat library.

    as an example, if i use Bill's backward compatibility sketch and set it to use SD, it works fine, but if I set it to use SdFat, I get an initialization failure.

    to wit:

    "Using SdFat.h. Set USE_SD_H nonzero to use SD.h.

    Type any character to begin.
    Initializing SD card...initialization failed!"


    Since some of you guys were able to make this work out of the box, I think I'll do a clean install of arduino ide, and libraries and see if that will work.
    Last edited by jferguson; 05-08-2020 at 02:36 PM. Reason: better grammar on the installment plan

  25. #25
    Member
    Join Date
    Jan 2016
    Location
    USA
    Posts
    62
    Also Compiling with Arduino IDE 1.8.9 FWTW.
    just checked on a T3.2 and my code and the examples run fine. I can't make it work on the T4.0 ???
    Last edited by jferguson; 05-08-2020 at 05:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •