Coder Social home page Coder Social logo

sdfat-beta's People

Contributors

greiman avatar paulstoffregen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdfat-beta's Issues

Possible rtc

Hi i made a project based on this lowlatencylogger and combined it with reading a mma8451 accelerometer sensor instead of mpu4050. Do you know if it is possible to add a timestamp to the data with an rtf. I don't know if they are fast enough. But I like to add real time to my data. My recording are at 50ms . Like to know what my options are. Maybe data time + micros every minute or so. So only polling the rtc every minute.

multiple SD cards

I need to write sequentially to multiple SD cards (terra-byte data logger).

Any suggestions/examples?

IOW, is calling sd.begin with different ChipSelect save?

SD_CARD_ERROR_CMD0 - Card reset failed

I am using ESP32 and I modified SPI clock to 10 Mhz but i have problem with sd.begin(SD_CONFIG)
begin() failed
Do not reformat the SD.
No card, wrong chip select pin, or wiring error?
SdError: 0X1,0X0

0X01,SD_CARD_ERROR_CMD0 - Card reset failed

SD.open() is valid after removing SD card

In a datalogger sketch I use the line
myFile = SD.open( fileSD, FILE_WRITE )
to test whether a write can be done. After a couple of successful (checked) writes, I removed the SDcard and to my surprise the test: < if (myxFile) > remains true.
If I re-insert the SDcard no more data will be added, although the test remains to be true.
I am using this SD Card module: goo.gl/q0AeM2
Even the test < if (SD.exists(fileSD)) > remains true if the card is removed after successful write cycles
Same result for the SD.h library

Card detect in Teensy 3.6

When starting using this library with Teensy 3.6 I noted that no Card detect feature was enabled, either through an external pin or through the PRSSTAT register. This is due to the DAT3 line of the SD card (pin PTE4) being pulled high. This is asserted in the enableGPIO function:

`static void enableGPIO(bool enable) {
const uint32_t PORT_CLK = PORT_PCR_MUX(4) | PORT_PCR_DSE;
const uint32_t PORT_CMD_DATA = PORT_CLK | PORT_PCR_PS | PORT_PCR_PE;

PORTE_PCR0 = enable ? PORT_CMD_DATA : 0; // SDHC_D1
PORTE_PCR1 = enable ? PORT_CMD_DATA : 0; // SDHC_D0
PORTE_PCR2 = enable ? PORT_CLK : 0; // SDHC_CLK
PORTE_PCR3 = enable ? PORT_CMD_DATA : 0; // SDHC_CMD
PORTE_PCR4 = enable ? PORT_CMD_DATA : 0; // SDHC_D3
PORTE_PCR5 = enable ? PORT_CMD_DATA : 0; // SDHC_D2
}`

Altering the SDHC_D3 line to PORTE_PCR4 = enable ? (PORT_CLK | PORT_PCR_PE) : 0; and asserting the D3CD bit of the PROCTL register with SDHC_PROCTL |= SDHC_PROCTL_D3CD; enables the card detect feature in the PRSSTAT register, leaving detection to a simple bit check.

Could this bring any unwanted behaviour to the rest of the code ?

Error compiling for board Arduino Nano 33 ble

i tried to use the library with the folowing hardware:

  • arduino Nano 33 BLE
  • adafruit addaloger feather
    if i use the standard SD library for to write or read to the sd card everything is working fine.
    now i nee longer file name then 8.3.
    but everytime i try to compile every sketch example out of the SdFat-beta i get the same error:

Please help me...

in these exemple i used the sketch "Sdinfo"

Error Message:

Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: "Arduino Nano 33 BLE"

In file included from d:\documents\arduinodata\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys_default_fcntl.h:200:0,

             from d:\documents\arduinodata\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\fcntl.h:4,

             from d:\documents\arduinodata\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\fcntl.h:1,

             from d:\documents\arduino\libraries\sdfat\src\common\fsapiconstants.h:30,

             from D:\Documents\Arduino\libraries\SdFat\src/ExFatLib/ExFatFile.h:36,

             from D:\Documents\Arduino\libraries\SdFat\src/ExFatLib/ExFatVolume.h:28,

             from D:\Documents\Arduino\libraries\SdFat\src/ExFatLib/ExFatLib.h:27,

             from D:\Documents\Arduino\libraries\SdFat\src/SdFat.h:33,

             from C:\Users\Sacha\AppData\Local\Temp\arduino_modified_sketch_98204\SdInfo.ino:4:

d:\documents\arduinodata\packages\arduino\tools\arm-none-eabi-gcc\7-2017q4\arm-none-eabi\include\sys\stat.h:27:8: error: redefinition of 'struct stat'

struct stat

    ^~~~

In file included from D:\Documents\ArduinoData\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/platform/mbed_error.h:21:0,

             from D:\Documents\ArduinoData\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/Queue.h:28,

             from D:\Documents\ArduinoData\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/Mail.h:28,

             from D:\Documents\ArduinoData\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/rtos/rtos.h:33,

             from D:\Documents\ArduinoData\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/mbed.h:23,

             from D:\Documents\ArduinoData\packages\arduino\hardware\mbed\1.1.4\cores\arduino/Arduino.h:32,

             from sketch\SdInfo.ino.cpp:1:

D:\Documents\ArduinoData\packages\arduino\hardware\mbed\1.1.4\cores\arduino/mbed/platform/mbed_retarget.h:500:8: note: previous definition of 'struct stat'

struct stat {

    ^~~~

exit status 1
Error compiling for board Arduino Nano 33 BLE.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

esp32 exFAT SD not initialising

I have an esp32 using hardware SPI with a tft display and the sd card sharing the SPI.

It is working fine with a FAT32 sd card - the SPI frequency is set to 16Mhz for the sd card and the display. It still works fine using the new library.

The problem arises when I use a new SanDisk Extreme Pro SD card (64Gb).
I have got as far as begin() working but when it tries to open a file it fails.

I have run bench.ino and it fails at the same point (opening the file) though it ran quite happily in the same hardware setup with a fat32 card. The card is freshly formatted using the proper formatter.

I have
SD_FAT_TYPE 3
My chip select is fine on pin 5 for other cards. SD_CS_PIN 5
I have SPI_CLOCK SD_SCK_MHZ(16)
I have forced the use of #define SD_CONFIG SdSpiConfig(SD_CS_PIN, SHARED_SPI, SPI_CLOCK)

The output of bench is:-
Type is exFAT
Card size: 63.86 GB (GB = 1E9 bytes)

Manufacturer ID: 0X3
OEM ID: SD
Product: SR64G
Version: 8.0
Serial number: 0X78524428
Manufacturing date: 1/2014

FILE_SIZE_MB = 5
BUF_SIZE = 512 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
error: preAllocate failed
SdError: 0XC,0X7F

Thanks for your efforts.
I am a bit new to mucking around with SD cards so forgive me if I am being foolish.
Glyn

p..s. perhaps I should mention that I get a compiler warning -
#warning FreeStack is not defined for this system.
but I got that with the old library and it did not seem to make any difference. I commented out the include to get rid of the warning back then. I don't know what it does and since things were working I have ignored it.

sharing SPI with another device

Sir,
I am using low latency data logger code of yours. But I want to share the SPI with another device (2.7V 12-Bit A/D Converter with SPI™ Serial Interface). My requirement is to read from this ADC and log it to SD cad. But when I tie my MISO pins to share SPI, my read from SD and reads from ADC doesn't work. voltage on this Miso pin goes to some steady 3.3v, its not pulsing according to data. so my adc reads are showing 4096 (all high) and My SD cad reads are failing.This happens only when I tie MISO ins together. Is it because of clock speed issues? I understand that SD cad writes are happening at much faster rate, but for ADC this speed has to be reduced. how to solve this issue? I am sing Arduino Mega and a Micro Sd Card Module to connect SD card.

openNext fails when used with O_RDWR

When I use O_RDWR as oflag value for openNext, it fails to open the next file.
O_WRITE and O_WRONLY also don't seem to work.

I'm running the code on a Teensy 3.6 with an ExFat formatted SD card.

I was able to reproduce the issue with the OpenNext example and the following changes:

diff --git a/SdFat-beta/examples/OpenNext/OpenNext.ino b/SdFat-beta/examples/OpenNext/OpenNext.ino
index a00dcdb..d4aa16e 100644
--- a/SdFat-beta/examples/OpenNext/OpenNext.ino
+++ b/SdFat-beta/examples/OpenNext/OpenNext.ino
@@ -5,7 +5,7 @@

 // SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
 // 1 for FAT16/FAT32, 2 for exFAT, 3 for FAT16/FAT32 and exFAT.
-#define SD_FAT_TYPE 0
# Note: The issue also occurs when using 2
+#define SD_FAT_TYPE 3
 /*
   Change the value of SD_CS_PIN if you are using SPI and
   your hardware does not use the default value, SS.
@@ -79,7 +79,7 @@ void setup() {
   // Open next file in root.
   // Warning, openNext starts at the current position of dir so a
   // rewind may be necessary in your application.
-  while (file.openNext(&dir, O_RDONLY)) {
+  while (file.openNext(&dir, O_RDWR)) {
     file.printFileSize(&Serial);
     Serial.write(' ');
     file.printModifyDateTime(&Serial);

Expected output:

Type any character to start
      131072 2019-01-08 16:06 System Volume Information/
          35 2019-08-28 14:25 RtcTest.txt
          14 2019-09-09 13:28 boot.txt
         385 2019-10-21 15:47 1571672835.txt
      153300 2019-10-21 16:17 1571672907.txt
        3264 2019-11-05 16:31 1572971445.txt
Done!

Actual output:

Type any character to start
Done!

SoftwareSPI Example - Numerous Errors with fastPinConfig

Trying to run the SoftwareSPI example sketch throws numerous errors with fastPinConfig. First, I as for configuration, I added a new board pin config file for something called flutter wireless it is a SAM3S1A board that is Arduino compatible. I have used softSPI from your DigitalIO library with not issues - worked fine with no errors with fastPinConfig. Anyway, listed below are the errors (Pretty much same error repeated for one). I am missing something?

Thanks
Mike

In file included from C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h:31:0,

                 from C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SdSpiDriver.h:192,

                 from C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/SdSpiCard.h:30,

                 from C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/BlockDriver.h:27,

                 from C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdFat.h:27,

                 from C:\Users\CYBERP~1\AppData\Local\Temp\arduino_modified_sketch_565098\SoftwareSpi.ino:7:

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:278:25: error: variable or field 'fastPinMode' declared void

 inline void fastPinMode(pin, mode) {

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:278:25: error: 'pin' was not declared in this scope

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:278:30: error: 'mode' was not declared in this scope

 inline void fastPinMode(pin, mode) {

                              ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h: In member function 'void DigitalPin<PinNumber>::config(uint8_t, bool)':

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: error: there are no arguments to 'fastPinMode' that depend on a template parameter, so a declaration of 'fastPinMode' must be available [-fpermissive]

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:328:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(PinNumber, mode, level);

     ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:328:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(PinNumber, mode, level);

     ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h: In member function 'void DigitalPin<PinNumber>::mode(uint8_t)':

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:352:32: error: there are no arguments to 'fastPinMode' that depend on a template parameter, so a declaration of 'fastPinMode' must be available [-fpermissive]

     fastPinMode(PinNumber, mode);

                                ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h: In member function 'void SoftSPI<MisoPin, MosiPin, SckPin, Mode>::begin()':

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: error: there are no arguments to 'fastPinMode' that depend on a template parameter, so a declaration of 'fastPinMode' must be available [-fpermissive]

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h:55:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(MisoPin, MISO_MODE, MISO_LEVEL);

     ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: error: there are no arguments to 'fastPinMode' that depend on a template parameter, so a declaration of 'fastPinMode' must be available [-fpermissive]

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h:56:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(MosiPin, MOSI_MODE, !MODE_CPHA(Mode));

     ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: error: there are no arguments to 'fastPinMode' that depend on a template parameter, so a declaration of 'fastPinMode' must be available [-fpermissive]

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h:57:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(SckPin, SCK_MODE, MODE_CPOL(Mode));

     ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h: In instantiation of 'void SoftSPI<MisoPin, MosiPin, SckPin, Mode>::begin() [with unsigned char MisoPin = 8u; unsigned char MosiPin = 9u; unsigned char SckPin = 10u; unsigned char Mode = 0u]':

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SdSpiDriver.h:215:5:   required from 'void SdSpiSoftDriver<MisoPin, MosiPin, SckPin>::begin(uint8_t) [with unsigned char MisoPin = 8u; unsigned char MosiPin = 9u; unsigned char SckPin = 10u; uint8_t = unsigned char]'

C:\Users\CYBERP~1\AppData\Local\Temp\arduino_modified_sketch_565098\SoftwareSpi.ino:55:14:   required from here

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: error: 'fastPinMode' was not declared in this scope

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h:55:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(MisoPin, MISO_MODE, MISO_LEVEL);

     ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: error: 'fastPinMode' was not declared in this scope

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h:56:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(MosiPin, MOSI_MODE, !MODE_CPHA(Mode));

     ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/DigitalPin.h:290:25: error: 'fastPinMode' was not declared in this scope

   {fastPinMode(pin, mode); fastDigitalWrite(pin, level);}

                         ^

C:\Users\CyberPalin\Documents\Arduino\libraries\SdFat\src/SdCard/../SpiDriver/SoftSPI.h:57:5: note: in expansion of macro 'fastPinConfig'

     fastPinConfig(SckPin, SCK_MODE, MODE_CPOL(Mode));

possibility of stream iterator implementation?

I am trying to use SDfat streams with a serializer (ThorsSerializer), which uses stream iterators to parse out strings during deserialization.

specifically here: https://github.com/Loki-Astari/ThorsSerializer/blob/master/src/Serialize/JsonManualLexer.cpp#L157

I suppose this would also be tied to a full implementation of stdlib functions, or using a full distribution of stdlib (newlib on ARM) instead of the minimal implementation in SdFat.

With Teensy 4 and more powerful MCUs it shouldn't be as much of a problem to use full stdlib, but that is a different issue.

benchmarks for Nano 33 BLE Sense

Running "bench" on a Nano 33 BLE Sense.
("Struct Stat" compile error error fixed using https://github.com/ARMmbed/mbed-os/pull/12607/files)

I am wondering if 46.84 KB/Sec write and 47.28 KB/Sec read is the best this board can do, due to the implementation on top of MBED. (See https://forum.arduino.cc/index.php?topic=642496.0)

I tried with Toshiba and a SandDisk 16GB SD Cards.

Benchmark output:

FreeStack: -5092
Type is FAT32
Card size: 15.55 GB (GB = 1E9 bytes)

Manufacturer ID: 0X2
OEM ID: TM
Product: SA16G
Version: 3.1
Serial number: 0X30279627
Manufacturing date: 10/2011

FILE_SIZE_MB = 1
BUF_SIZE = 512 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
46.84,11017,10864,10921
46.85,11016,10864,10920

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
47.28,10865,10742,10819
47.25,10865,10742,10828

Sync Required for SDIO writes?

Bill, is a sync() (or flush()) still required with this BETA version, when using the SDIO FIFO mode? Our current code base performs the occasional (every 100 writes), a sync in place of a write. There was a mention in a post (sorry, I can't refind that post), that suggested that the write command will automatically sync when the block size is reached? If a sync is required, would it be better to base it off of a total write size, rather than a write count, to better match the 32kb block size?

Thanks!

  • Steve

open by index and LFN

Hi,

I'm currently working on converting a project from SdFat to SdFat-beta so I can ultimately make the change from a teensy 3.6 to a teensy 4. My project uses open by index to navigate through large directories containing many files. Since switching to SdFat-beta I can no longer get an LFN using getName() when the file is opened by index.

Hardware: teensy 3.6
Arduino 1.8.10
Teensyduino 1.48

Using OpenNext as an example I made some changes for troubleshooting. First, I modified the code to use getName().

//file.printName(&Serial);  // COMMENT OUT
char str[255];              // ADD
file.getName(str, 255);     // ADD
Serial.print(str);          // ADD

Running the code like this produces the expected output:

Type any character to start
     0 2019-10-17 18:41 With.Two dots.txt
     0 2019-10-17 18:41 A long name can be 255 characters.txt
     0 2019-10-17 18:42 lower.txt
     0 2019-10-17 18:42 MIXCASE.txt
     0 2019-10-17 18:42 mixed.TXT
     0 2019-10-17 18:42 Not_8_3.txt
     0 2019-10-17 18:42 OK%83.TXT
     0 2019-10-17 18:43 STD_8_3.TXT
     0 2019-10-17 18:43 With Blank.txt
     0 2019-10-17 18:43 sub folder/
Done!

Now I modify the code to use open by index instead of openNext:

//while (file.openNext(&dir, O_RDONLY)) {    // COMMENT OUT
for(int i=0; i<25; i++) {                    // ADD - the 25 is a meaningless number for troubleshooting
  file.open(&dir, i, O_RDONLY);              // ADD

With this change getName never returns a LFN.

Type any character to start
     0 2019-10-17 18:41 
     0 2019-10-17 18:41 
     0 2019-10-17 18:41 
     0 2019-10-17 18:41 
     0 2019-10-17 18:41 WITHTW~1.TXT
     0 2019-10-17 18:41 
     0 2019-10-17 18:41 
     0 2019-10-17 18:41 
     0 2019-10-17 18:41 ALONGN~1.TXT
     0 2019-10-17 18:42 lower.txt
     0 2019-10-17 18:42 MIXCASE.txt
     0 2019-10-17 18:42 mixed.TXT
     0 2019-10-17 18:42 
     0 2019-10-17 18:42 NOT_8_3.TXT
     0 2019-10-17 18:42 OK%83.TXT
     0 2019-10-17 18:43 STD_8_3.TXT
     0 2019-10-17 18:43 
     0 2019-10-17 18:43 
     0 2019-10-17 18:43 WITHBL~1.TXT
     0 2019-10-17 18:43 
     0 2019-10-17 18:43 SUBFOL~1/
     0 2019-10-17 18:43 
     0 2019-10-17 18:43 
Done!

Any ideas?

On a side note, there may be some strange behavior with isHidden() as well but I have not looked that far into it.

Thanks in advance for your help and thank you so much for the quick teensy 4 support.

SdFatSdioEx no longer working.

The new SD beta has dropped support for "SdFatSdioEx" and as a result sdEx, breaking most of my older projects which I want to port to teensy 4.1

Writing volatile buffers to the SD card error

I have a volatile buffer of size 4096 defined as: DMAMEM static volatile uint16_t buffer[4096] (from example code in the <ADC.h> library)

To test, I wrote to each element of the buffer its index, and then tried to pass the pointer to the buffer to the SD card to write and then read back from the file to see what was written. I cannot get the original buffer to agree with what was read. What was written to the SD card was much different than the buffer that was passed.

Normal arrays (uint16_t normal_buffer[4096]) work fine, so I suspect it has something to do with the volatile nature of the buffer.

I'm using a Teensy 4.0.

Here is the program I was using:

#include "SdFat.h"

#ifndef SDCARD_SS_PIN
const uint8_t SD_CS_PIN = SS;
#else  // SDCARD_SS_PIN
// Assume built-in SD is used.
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif  // SDCARD_SS_PIN

SdFs sd;
FsFile file;

uint32_t buffer_size = 4096;
DMAMEM static volatile uint16_t __attribute__((aligned(16))) dma_adc_buff1[4096];

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    Serial.begin(9600);
    while (!Serial) {
        delay(100);
    }

    if (!sd.begin(SdioConfig(DMA_SDIO))) { 
        Serial.println("Could not start SD");
    } 

    uint16_t buffer_read[buffer_size] = {0};

    for (uint16_t i = 0; i < buffer_size; i++) {
    dma_adc_buff1[i] = i;
    }

    size_t written_size = 2*buffer_size;

    if (dma_adc_buff1[0] == 0 && dma_adc_buff1[10] == 10)
        Serial.println("Successful initalization of DMA Buffer 1");
    else
        Serial.println("Bad initailization of DMA Buffer 1");
    
    if (!file.open("test_sd_write_buffer.bin", O_RDWR | O_CREAT | O_TRUNC))
        Serial.println("Could not open file");

    //write the vectors on the SD card
    if (written_size != file.write((void *)dma_adc_buff1, written_size))
        Serial.println("Could not write first block");

    if (!file.close())
        Serial.println("Could not close file");

    if (!file.open("test_sd_write_buffer.bin", O_RDONLY))
        Serial.println("Could not reopen file");

    //read the vector back from the SD card
    if (written_size != file.read(buffer_read, written_size))
        Serial.println("Unsuccessful read of first block from SD card");
    
    if (buffer_read[1] == dma_adc_buff1[1]) {
        Serial.println("Looks like file was written to successfully");
    }
    else
        Serial.println("Error in writing and then reading from file");
        Serial.println("Intended: " + String((uint16_t)dma_adc_buff1[1]));
        Serial.println("Read: " + String((uint16_t)buffer_read[1]));
        Serial.println("1st : " + String((uint16_t)buffer_read[0]));
    
    file.close();
}

void loop() {
    delay(1000);
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}

Sd card not found on Mega2560

I am trying your great AVR logger example.
Runs on Uno but when I move to Mega (using pins 50 to 53 for SPI)
#define PIN_SPI_SS (53)
#define PIN_SPI_MOSI (51)
#define PIN_SPI_MISO (50)
#define PIN_SPI_SCK (52)
it fails to find the sd card
Any suggestions for debugging further?

Card doesnt Sleep after writing on it

My hardware is a atmega644PA and i use the SPI hardware module that it has.
I upload the code with Arduino IDE and ad-hoc third party board implemented by my self.

I only use a SD in the SPI. It doesnt have any hardware Pull-ups on spi lines.

I use this library in order to allow a micro SD to go to Sleep mode with low consumption.

If I SD.begin() the SD, it consumes 250 uA, so i assume it goes to sleep mode correctly.

The issue is that when I write something on a file, (open file, write on it, close file) the card consumes around 14 mA permanently. Even after a while. So probably the SD blocks on same state and doent allow it to sleep. I can write again whitout problems.

I solve it calling SD.begin function after "close file".
But this is just a temporal patch. Probably the problem is in some of the code that SdSpiCard::begin function does and the file write code doesnt. I dont know sd specs to go deeply to solve it.

experience with SdFat-beta in Sloeber - ArduinoIDE Plug-in

Hello Sir,
I'm having problems trying to run the examples programs from this library in Sloeber. I don´t know if someone else had this already.

I also noticed that for FreeStack is for Sloeber not defined. Which are the consequences if it's not defined? I´m wondering if that's the reason why it doesn't work...
image

New Teensy

Hi Bill
Trying to get new Teensy T$ working on a SPI. Is there a way to specify what pins to use for SPI1, ie., MISO, MOSI, SCK? See this thread for the Teensy: https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test. Works right out of the box for SPI.

I set it up so:
#define SD1_CONFIG SdSpiConfig(36, DEDICATED_SPI, SD_SCK_MHZ(18), &SPI1)
SdFs sd1;

but if it print out the pins I get:
Assuming the SD chip select pin is: 36
Edit SD_CS_PIN to change the SD chip select pin.

SPI pins:
MISO: 12
MOSI: 11
SCK: 13

EDIT: Guess one of the I am asking is how to setup builtin_SDCARD pins for different MCU and what settings do I need in the Config file

writing block-wise in sd from an array type struct

Hardware:

Board: NodeMCU-32S
IDE name: Sloeber
Flash Frequency: 40Mhz
Upload Speed: 115200
Computer OS: Windows 10

Description:

Hi Mr. Greiman,
I'm using the Beta Version to save data from a sensor into an sd card. I defined an array type "sample", which is a structure with 32 Byte size. Since my µC only has 600µs to write in between I decided to write in 1024 Byte-Blocks, perhaps my array´s size 4096 Bytes is. After running the program and checking the sd, I saw completely different values than I expected so I'm doing something wrong and I suppose it´s my approach with the buffer pointer.
I thought about casting my values as a string but this takes to long.
Which is the popper way to approach in my case?
Thank you very much.
Sebastian

errors with SdFatSdio in teensy 3.6

I'm getting intermittent errors with erase and writeBlock. To get the SdFormatter example to work, I did the following:

  1. changed the define in line 16 to
    #define USE_SDIO 1
  2. changed line 42 to
    SdioCard card;
    (used to have SdioCardEX but I have not been able to make that work)

With these changes things go well, but almost always I get errors with the erase and writeBlock. To prevent this, I also changed:
3) around line 171 I changed the "if" to a "while"
while (!card.writeBlock(bgn + i, cache.data)) {
cout << 'e';
//sdError("Clear FAT/DIR writeBlock failed");
}
4) around 423 I also changed the "if" to a "while"
while (!card.erase(firstBlock, lastBlock)) {
cout << 'E';
//sdError("erase failed");
}

The code eventually succeeds (after repeating the erases and write blocks a few time) but I cannot read the card. I'm also having trouble with other sketches with errors in erase and writeBlock.

LGT8Fx support

I'm checking out the ATmega 328 clones by Logic Green (LGT8Fx). There is some support as these chips are not well known (https://github.com/dbuezas/lgt8fx). I have the 328P-SSOP20 (pro mini clone) and 328P-LQFP32 (nano clone)
Beforehand I tested the SD card and the library with Arduino Nano clone (328P-MU QFN32 with CH340G) and everything works. Also tested the standard SD card library that comes with Arduino IDE, and it works on Nano and on the LGT8Fx clones. I'd like to help to make this library support the LGT8Fx chips but I don't know too much about this low level stuff that it implies, but can do some tests and relay the results.
Here is SdInfo output from 328P-MU Nano at 16 MHz, the card was formated via the SdFormatter sketch.


Assuming the SD is the only SPI device.
Edit DISABLE_CS_PIN to disable an SPI device.

Assuming the SD chip select pin is: 9
Edit SD_CS_PIN to change the SD chip select pin.

type any character to start
init time: 21 ms

Card type: SD2

Manufacturer ID: 0X2
OEM ID: TM
Product: SA01G
Version: 0.1
Serial number: 0X6FBD009C
Manufacturing date: 5/2008

cardSize: 1019.22 MB (MB = 1,000,000 bytes)
flashEraseSize: 128 blocks
eraseSingleBlock: true

OCR: 0X80FF8000

SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X1,0X1,0X0,0X6,0XFE,0XFF,0XFF,249,1990407
2,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0

Scanning FAT, please wait.

Volume is FAT16
sectorsPerCluster: 32
clusterCount:      62184
freeClusterCount:  62184
fatStartSector:    250
dataStartSector:   768

At 32 MHz from SdInfo sketch:

init time: 166 ms
readInfo failed
SD errorCode: SD_CARD_ERROR_READ_TOKEN = 0x18
SD errorData = 0x1

And at 16 MHz (same for 8 MHz):

init time: 4 ms

Card type: SD2

Manufacturer ID: 0XFE
OEM ID: T
Product: S�0MG
Version: 4.1
Serial number: 0X1BD319C
Manufacturing date: 0/2000

m_csd version error

OCR: 0X80FF8000

SD Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
1,0X0,0X1,0X0,0X0,0X0,0XFE,0X1,0XFF,16711686,24569
2,0X7,0X0,0X1E,0X0,0X0,0X0,0X0,0X0,0,0
3,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0
4,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0X0,0,0

MBR not valid, assuming Super Floppy format.

volumeBegin failed. Is the card formatted?

There is something strange with OEM ID and Product.

Also tested SoftwareSPI sketch and it works at any clock speed.

I'm unsure if it's hardware or software issue.

Read then Write causes the SD card to become disfunctional

Hi, I'm using this library to write the files that I transfer from my PC to the SD card via Arduino. However when I open a file, read it's contents, close it, then
create a new file write the contents of the file and close it, then
remove the SD card from the shield and place it on my PC it is no longer readable.

The only solution is to format the SD card. This didn't happen with the SDFat library.

I'm using Arduino Uno a Shield SD, and Linux Mint 19.

getFile returns SFN

Hello,
I'm going to replace the old SdFat library on my project. (STM32 Rogers Core).
So far so good, after changing write/readBlocks to write/readSectors it works, BUT:
in SdFatConfig.h:
#define USE_LONG_FILE_NAMES 1
in my code:
file.getName(xstring, 20);
returns the SFN only. (like "BIBIUN~1")

Did I missed something?

regards
Matthias

SDFat doesn't work with the audio library

On
Arduino 1.8.12
Teensyduino 1.51

putting the following lines of code in:

#include <Audio.h>
#include "SdFat.h"

Causes a pretty big wall of errors to get dumped out, here are the first few:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:25:57: error: 'void (* SdFile::dateTime_)(uint16_t*, uint16_t*)' is not a static data member of 'class SdFile'

 void (*SdFile::dateTime_)(uint16_t* date, uint16_t* time) = NULL;

                                                         ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:33:28: error: no 'uint8_t SdFile::addCluster()' member function declared in class 'SdFile'

 uint8_t SdFile::addCluster() {

                            ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\utility\SdFile.cpp:46:35: error: no 'uint8_t SdFile::addDirCluster()' member function declared in class 'SdFile'

 uint8_t SdFile::addDirCluster(void) {

It seems like there is some kind of conflict between the built in sd lib, and this one.
I confirmed that the library was working without the audio.h include, so I'm pretty sure thats where the conflict is coming from.

Ardunio SD.h lib faster?

More of a mystery than a bug, reporting on the off chance it is of interet.

I'm able to run the OpenNext.ino example at SPI_HALF_SPEED but at SPI_FULL_SPEED I get

SD errorCode: 0X4,0X33

I understand there are a lot of possible causes for this, in particular long paths in the SPI circuit. The reason I'm reporting this is that I can connect the same circuit at full speed using the CardInfo.ino example and the Arduino SD.h lib.

I found my way to the beta from greiman/SdFat#16

(Looks like among other things, the beta configures the SPI layer to use automatically, which is nice. 👍)

Using https://github.com/greiman/SdFat with #define SD_SPI_CONFIGURATION 1 I'm able to run on the M0 Pro, but as with SdFat-beta, only at half speed.

I've run with each s/w config a dozen times and the results are consistent.

The mystery is how the standard Arduino library could be faster than SdFat.

Environment

  • Board: Arduino M0 Pro
  • SD card reader connected by hw SPI pins, no other peripherals
  • no breadboard, jumper wires about 15cm long
  • Arduino.org IDE 1.7.8

RTCTimeStampTest does not compile with ESP8266WiFi.h included

Using Arduino IDE.

The Sample RTCTimeStampTest (and some others examples also) does not compile with ESP8266WiFi.h included

#include <ESP8266WiFi.h>

if (!file.open("RtcTest.txt", FILE_WRITE)) {
exit status 1
'class fs::File' has no member named 'open'

How can i fix it?

Why does this not work?

void SD_file_download(String filename){
file.open(filename.c_str(), O_READ);
size_t sent = server.streamFile(file, "application/octet-stream");
file.close();
}`

My Includes:
#include "SdFat.h"
#include <ESP8266WiFi.h> // Built-in
#include <ESP8266WiFiMulti.h> // Built-in
#include <ESP8266WebServer.h> // Built-in
#include <ESP8266HTTPClient.h>
#include <ESP8266mDNS.h>

Line 13: #include <ESP8266WebServer.h>
Compiler Errors:
In file included from F:\Eigene Dateien\Arduino\esp_fileserver05\esp_fileserver05.ino:13:0:

C:\Users\pl\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WebServer\src/ESP8266WebServer.h: In instantiation of 'size_t esp8266webserver::ESP8266WebServerTemplate::streamFile(T&, const String&, HTTPMethod) [with T = SdFile; ServerType = WiFiServer; size_t = unsigned int]':

C:\Users\pl\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WebServer\src/ESP8266WebServer.h:177:50: required from 'size_t esp8266webserver::ESP8266WebServerTemplate::streamFile(T&, const String&) [with T = SdFile; ServerType = WiFiServer; size_t = unsigned int]'

F:\Eigene Dateien\Arduino\esp_fileserver05\esp_fileserver05.ino:223:67: required from here

C:\Users\pl\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WebServer\src/ESP8266WebServer.h:185:58: error: 'class SdFile' has no member named 'size'

_streamFileCore(file.size(), file.name(), contentType);

C:\Users\pl\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.7.1\libraries\ESP8266WebServer\src/ESP8266WebServer.h:185:58: error: 'class SdFile' has no member named 'name'

exit status 1
Fehler beim Kompilieren für das Board LOLIN(WEMOS) D1 R2 & mini.

The server is running.

Any suggestions?

Play well with other SPI devices

Developers like myself over at MarlinFirmware/Marlin#1226 are scratching our heads how to get SD card reading to work alongside SPI-driven thermocouples and other SPI devices. I'm not personally familiar with the use of chip-select lines, or whether these other devices are designed to play well on SPI buses either, but perhaps you can provide some insight to guide us in the right direction....?

MarlinFirmware/Marlin#1227

Reporting erased state of card

Would you consider reporting the value of the DATA_STAT_AFTER_ERASE bit (bit 55) of the SCR register in SDInfo.ino? This is the erased state of the flash memory, which can differ among manufacturers. This would require adding support for ACMD51 to the library source, or possibly erasing a block and reading back the first byte.

error: preAllocate Failed in the ExfatLogger

I am using ESP32 on Arduino but after format MicroSD by PC (ExFat format), when createBinFile done on ExFatLogger.ino, I get always "error: preAllocate Failed".
Could you please advice how to use it by ESP32 and related settings.
It is nice to mention that Bench.ino is working fine after modification on Line 37
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SD_SCK_MHZ(25))
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
2231.15,795,227,228
2080.73,76594,227,245

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
2148.69,245,236,237
2150.54,245,236,237

Possible bug: DBG_FAIL triggered when dir.exists(filename) is called and filename does not exist

when a file does not exist, checking for file existence returns false as expected. However, if I enable debugging it also triggers an unexpected DBG_FAIL before returning:

DBG_FAIL: FatFileLFN.cpp 418

the relevant code is:

create:
  // don't create unless O_CREAT and write mode
  if (!(oflag & O_CREAT) || !isWriteMode(oflag)) {
    DBG_FAIL_MACRO;
    goto fail;
  }

Although everything works fine with debugging turned off, this still seems like a possible bug because I can't see any reason why the code should be attempting to create a file when I am testing for file existence.

The initial call goes to FsFile.h at line 98:

  bool exists(const char* path) {
    return m_fFile ? m_fFile->exists(path) :
           m_xFile ? m_xFile->exists(path) : false;
  }

This is a Fat32 card, so the first branch is taken to FatFile.h at 258:

  bool exists(const char* path) {
    FatFile file;
    return file.open(this, path, O_RDONLY);
  }

This leads to FatFile.cpp at 412:

//------------------------------------------------------------------------------
bool FatFile::open(FatFile* dirFile, const char* path, oflag_t oflag) {
  FatFile tmpDir;
  fname_t fname;

  // error if already open
  if (isOpen() || !dirFile->isDir()) {
    DBG_FAIL_MACRO;
    goto fail;
  }
  if (isDirSeparator(*path)) {
    while (isDirSeparator(*path)) {
      path++;
    }
    if (*path == 0) {
      return openRoot(dirFile->m_vol);
    }
    if (!tmpDir.openRoot(dirFile->m_vol)) {
      DBG_FAIL_MACRO;
      goto fail;
    }
    dirFile = &tmpDir;
  }
  while (1) {
    if (!parsePathName(path, &fname, &path)) {
      DBG_FAIL_MACRO;
      goto fail;
    }
    if (*path == 0) {
      break;
    }
    if (!open(dirFile, &fname, O_RDONLY)) {
      DBG_FAIL_MACRO;
      goto fail;
    }
    tmpDir = *this;
    dirFile = &tmpDir;
    close();
  }
  return open(dirFile, &fname, oflag);

fail:
  return false;
}

Which leads finally to FatFileLFN.cpp at 302, with the DBG_FAIL occurring at line 418 at bottom:

//------------------------------------------------------------------------------
bool FatFile::open(FatFile* dirFile, fname_t* fname, oflag_t oflag) {
  bool fnameFound = false;
  uint8_t lfnOrd = 0;
  uint8_t freeNeed;
  uint8_t freeFound = 0;
  uint8_t order = 0;
  uint8_t checksum = 0;
  uint8_t ms10;
  uint16_t freeIndex = 0;
  uint16_t curIndex;
  uint16_t date;
  uint16_t time;
  DirFat_t* dir;
  DirLfn_t* ldir;
  size_t len = fname->len;

  if (!dirFile->isDir() || isOpen()) {
    DBG_FAIL_MACRO;
    goto fail;
  }
  // Number of directory entries needed.
  freeNeed = fname->flags & FNAME_FLAG_NEED_LFN ? 1 + (len + 12)/13 : 1;

  dirFile->rewind();
  while (1) {
    curIndex = dirFile->m_curPosition/32;
    dir = dirFile->readDirCache(true);
    if (!dir) {
      if (dirFile->getError()) {
        DBG_FAIL_MACRO;
        goto fail;
      }
      // At EOF
      goto create;
    }
    if (dir->name[0] == FAT_NAME_DELETED || dir->name[0] == FAT_NAME_FREE) {
      if (freeFound == 0) {
        freeIndex = curIndex;
      }
      if (freeFound < freeNeed) {
        freeFound++;
      }
      if (dir->name[0] == FAT_NAME_FREE) {
        goto create;
      }
    } else {
      if (freeFound < freeNeed) {
        freeFound = 0;
      }
    }
    // skip empty slot or '.' or '..'
    if (dir->name[0] == FAT_NAME_DELETED || dir->name[0] == '.') {
      lfnOrd = 0;
    } else if (isLongName(dir)) {
      ldir = reinterpret_cast<DirLfn_t*>(dir);
      if (!lfnOrd) {
        if ((ldir->order & FAT_ORDER_LAST_LONG_ENTRY) == 0) {
          continue;
        }
        lfnOrd = order = ldir->order & 0X1F;
        checksum = ldir->checksum;
      } else if (ldir->order != --order || checksum != ldir->checksum) {
        lfnOrd = 0;
        continue;
      }
      size_t k = 13*(order - 1);
      if (k >= len) {
        // Not found.
        lfnOrd = 0;
        continue;
      }
      for (uint8_t i = 0; i < 13; i++) {
        uint16_t u = lfnGetChar(ldir, i);
        if (k == len) {
          if (u != 0) {
            // Not found.
            lfnOrd = 0;
          }
          break;
        }
        if (u > 255 || lfnToLower(u) != lfnToLower(fname->lfn[k++])) {
          // Not found.
          lfnOrd = 0;
          break;
        }
      }
    } else if (isFileOrSubdir(dir)) {
      if (lfnOrd) {
        if (1 == order && lfnChecksum(dir->name) == checksum) {
          goto found;
        }
        DBG_FAIL_MACRO;
        goto fail;
      }
      if (!memcmp(dir->name, fname->sfn, sizeof(fname->sfn))) {
        if (!(fname->flags & FNAME_FLAG_LOST_CHARS)) {
          goto found;
        }
        fnameFound = true;
      }
    } else {
      lfnOrd = 0;
    }
  }


found:
  // Don't open if create only.
  if (oflag & O_EXCL) {
    DBG_FAIL_MACRO;
    goto fail;
  }
  goto open;

// ***********************************************
// **HERE IS WHERE THE DBG_FAIL OCCURS **
create:
  // don't create unless O_CREAT and write mode
  if (!(oflag & O_CREAT) || !isWriteMode(oflag)) {
    DBG_FAIL_MACRO;
    goto fail;
  }

vfs etc. with Teensy 4 SdFat

Bill,
In 2016 I used a zip file from stepl https://forum.pjrc.com/threads/45647-k6x-LAN8720(A)-amp-lwip to test T3.6 SDHC with lwIP servers (httpd, ftpd, tftpd). Teensy 4.1 will have Ethernet, so I re-visited the 2016 T3.6 tests. I can use SdFat-beta to read/write files on T4 builtin-sdcard, but the lwIP servers require the higher level abstractions like vfs. So I can't build those lwIP servers with the Teensy 4. The 2016 zip file was using SdFat lib (v1.0.3) and it still works with T3.6 proto ethernet. I looked at how to inject your T4 SDHC support into v1.0.3 or how to add vfs et al to SdFat-beta, both were beyond my pay-grade.

Any chance the VFS abstractions will be added to SdFat-beta or ??

thanks

Missing define?

SdSpiSTM32F1.cpp references both SPI_DMAC_RX_CH and SPI_DMAC_TX_CH, but neither of those are defined. There are defines for SPI1_DMAC_RX_CH and SPI1_DMAC_TX_CH, but I'm not entirely up to snuff on the DMA-stuff yet and I'm not sure if it's just a typo or something else.

createContiguous not available in ExFile and FsFile

Hi Bill,
Is there a way to create a contiguous file if I declare a file of type ExFile or FsFile ?
I am trying to use this in a low-latency application modeled on the original LowLatencyLogger (which, BTW I do not see in the SD Beta Examples folder).
I am getting the following error:
SDDirectTest.ino: 126:15: error: 'class FsFile' has no member named 'createContiguous
if (!binFile.createContiguous(TMP_FILE_NAME, 512 * FILE_BLOCK_COUNT))

Thank You,
Ram

Configuration of multiple SD cards on different buses

From a functional perspective, SdFat v2.0b is absolutely fabulous. The ExFat support is great, and it has completely resolved longstanding issues with the episodic high-latency blocking writes that prevented me from using SD cards for many years. The news that you have lost interest in developing SdFat is deeply saddening to all of us who have derived so much benefit from your knowledge and your efforts over the years, but we are thankful for what we have.

The support for drop-in replacement of SD.h in so many different settings is great for everybody, but there are so many #ifdef #else sections of the code that it leaves me confused about the "right" way to instantiate support for multiple SD cards using different buses.

In particular, I am confused about the "right" way to configure for two cards where one is the Teensy 3.6 built-in (using FIFO_SDIO) and the other is using SPI with MOSI 7; MISO 12; SCLK 14; and CS 10 (the SD adaptor on the TeensyAudioBoard).

I assume that for the built-in adaptor I can just continue to instantiate SdFs and call begin(SdioConfig(FIFO_SDIO)).

For the Audio board adaptor my best guess is that I should instantiate my own SPI_x, call setMOSI (et al.) myself and then instantiate SdFs with begin(SdSpiConfig(10, xx, xx, &SPI_x)).

However, I see library code that calls setMOSI for the high pin numbers of the teensy built-in adaptor when used in SPI mode, and it sort of looks as if that code will be executed on the teensy if SPI_DRIVER_SELECT is 0, except maybe not if an SPI instance is already defined, except that the macros make the code take dependencies on other things that I can't easily follow.

So do I also need to set SPI_DRIVER_SELECT 1 to prevent use of the Teensy custom SPI driver that calls setMOSI (et al.) and thus sets everything to the #defined high pin numbers for the built-in SD adaptor?

Or perhaps I should leave SPI_DRIVER_SELECT 0 but pre-define SDCARD_SPI to prevent the high pin number definitions from being #defined? However, that seems to affect things beyond the teensy...

Alternatively, perhaps I should just change the high pin number #defines for SDCARD_MOSI etc. in the section intended for using SPI with the teensy built-in SD? This has an off odor, and it seems as if it would be impossible to use both SD cards in SPI mode under this approach.

I have asked the community, but have not received any truly useful answers. Many people are using SdFatV2.0b successfully, but their scenarios are different. Any guidance at all would be appreciated!

Beta2 - Excellent !!

Bill:
Personal thanks for all your work in developing SdFat - without which many uMakers worldwide would not be using sd cards! Needed your Beta 2 to finally get a my logger working on Teensy 3.6 with 2 I2C buses and RTC. Look forward to updated SdInfo that works with Sdio and ExFat.
Thanks again.
Gary Evans - [email protected]

DMA Writes

Hi - first I would like to thank you for the great work.

I was wondering if the SD FS Libraries can support DMA writes and would it improve write speeds?

Not sure if it is possible to come up with an interface that can be supported by underlying hardware such as Arduino, Teensy, ESP32 etc.

read/write failures on new T4.1 builtin SD card

On T4.1 builtin SD card, reading a file would terminate with an error (DEBE DECE bits set). Sketch with same uSD card would work on T4.1 with teensy SD lib, and it would work on T4.0 with SdFat-beta.
Fix was to change DSE(4) back to DSE(1) SdioTeensy.cpp. Not sure if that breaks something else, or why you changed it to DSE(4). additional testing ongoing ...

Problem

Hi i download beta version SdFat, when replace 1:1 with stable 1.1.2 and now have error: 'mbr_t', 'mbr', 'part_t', 'pt' was not declared in this scope. My program was tested on Your stable version 1.0.7 and 1.1.2 so maybe something is with this beta version.
errors.txt

sdfat does not name a type

I have sdfat installed in the ard lib corrrectly. however, when compiling, i keep getting

SdFat' does not name a type WHEN the <sdfat.h> is including in NON INO files.

please advise,

System hangs when repeatedly triggering a wav file on Teensy 4.0

Hello! first off thanks for the great lib. its amazing how many projects must be using SDfat now : )

I am trying to rid my system of clicks and pops when loading multiple WAVs on Teensy 4.0, several people have mentioned the issues with SD.h so I am trying sdfat on T4. SdFormatter, SdInfo and TeensySdioDemo are all working well! I can even get one wav playing using my own code and its seems the dropouts when a single wav is triggered repeatedly are much improved. Sadly when I try and trigger 4 wavs at the same time, although they play I loose control of the system at the serial window until they have finished playing. If I trigger two wavs at the same time, I can retrigger a couple of times and then I loose control. I also have the cash register sound that I can trigger as it is handy for debug.

Here is the code... (super lean to keep it simple)

`#define USE_SdFat_ // uncomment for SdFat.h, comment for SD.h lib.
#include "SdFat.h"
SdFat sd;

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>

// GUItool: begin automatically generated code
AudioPlayMemory sound0; //xy=257,200
AudioPlaySdWav playSdWav2; //xy=296,375
AudioPlaySdWav playSdWav3; //xy=313,439
AudioPlaySdWav playSdWav1; //xy=324,292
AudioPlaySdWav playSdWav4; //xy=345,516
AudioMixer4 mixer1; //xy=802,203
AudioMixer4 mixer2; //xy=851,322
AudioOutputI2S i2s1; //xy=1069,248
AudioConnection patchCord1(sound0, 0, mixer1, 1);
AudioConnection patchCord2(sound0, 0, mixer2, 2);
AudioConnection patchCord3(playSdWav1, 0, mixer1, 0);
AudioConnection patchCord4(playSdWav1, 1, mixer2, 1);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer2, 0, i2s1, 1);
// GUItool: end automatically generated code

// Use these with the Teensy Audio Shield
//#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14

// SDCARD_SS_PIN is defined for the built-in SD on some boards.
#ifndef SDCARD_SS_PIN
const uint8_t SD_CS_PIN = SS;
#else // SDCARD_SS_PIN
// Assume built-in SD is used.
const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
#endif // SDCARD_SS_PIN

// Use these for the SD+Wiz820 or other adaptors
//#define SDCARD_CS_PIN 4
//#define SDCARD_MOSI_PIN 11
//#define SDCARD_SCK_PIN 13
int inByte = 0;
byte newDATAin = 1;

#include "AudioSampleCashregister.h" // http://www.freesound.org/people/kiddpark/sounds/201159/

void setup() {
Serial.begin(115200);

// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(100);

//SPI.setMOSI(SDCARD_MOSI_PIN);
///SPI.setSCK(SDCARD_SCK_PIN);
if (!sd.begin(SdioConfig(FIFO_SDIO))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
}

void loop() {

switch (Serial.read()) {

case 's': {
Serial.println("s");
// envelope1.noteOff();
// envelope2.noteOff();tttttttttttt
playSdWav1.stop();
playSdWav2.stop();
playSdWav3.stop();
playSdWav4.stop();
//playSdWav5.stop();
//playSdWav6.stop();
//playSdWav7.stop();
//playSdWav8.stop();
sound0.play(AudioSampleCashregister);

}
break;

case 't': {

sound0.stop();

playSdWav1.play("10BAB1.WAV");

playSdWav2.play("10BAB2.WAV");

playSdWav3.play("10BAB3.WAV");
playSdWav4.play("10BAB4.WAV");

}
break;

case 'y': {

sound0.stop();

playSdWav1.play("10BAB2.WAV");

delay(5);

//playSdWav2.play("10BAB2.WAV");

//playSdWav3.play("10BAB3.WAV");
//playSdWav4.play("10BAB4.WAV");

}
break;

}
}`

Here is the audio used in the above example: http://donjohnstonmusic.co.uk/tr/sinewavs.zip

I am aware three of the wav players are not connected to any outputs, they still play and cause the issue and its the same when they are connected. is there something in the SDfat settings I can tweak to prevent this hang?

all help very gratefully received, I am properly stuck

Error when compiling on Arduino Nano Every

Sketch:

#include <SdFat.h>

Target:

Arduino Nano Every

Dump:
Arduino:` 1.8.12 (Windows 10), Board: "Arduino Nano Every, None (ATMEGA4809)"

In file included from c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiArduinoDriver.h:94:0,

             from c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\sdspidriver.h:134,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdCard/SdSpiCard.h:35,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdCard/SdCard.h:28,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdFat.h:32,

             from C:\Users\Christofer\Desktop\Arduino\Einzelbeispiele\Test\Test.ino:2:

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h: In member function 'uint8_t SdSpiArduinoDriver::receive(uint8_t*, size_t)':

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:52:3: error: 'SPDR' was not declared in this scope

SPDR = 0XFF;

^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:52:3: note: suggested alternative: 'SPI'

SPDR = 0XFF;

^~~~

SPI

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:54:14: error: 'SPSR' was not declared in this scope

 while (!(SPSR & _BV(SPIF))) {}

          ^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:54:14: note: suggested alternative: 'SPI'

 while (!(SPSR & _BV(SPIF))) {}

          ^~~~

          SPI

In file included from c:\users\christofer\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

             from c:\users\christofer\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/String.h:31,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Print.h:24,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Stream.h:25,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Client.h:22,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/ArduinoAPI.h:29,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/Arduino.h:23,

             from sketch\Test.ino.cpp:1:

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:54:25: error: 'SPIF' was not declared in this scope

 while (!(SPSR & _BV(SPIF))) {}

                     ^

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:54:25: note: suggested alternative: 'SPI'

In file included from c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiArduinoDriver.h:94:0,

             from c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\sdspidriver.h:134,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdCard/SdSpiCard.h:35,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdCard/SdCard.h:28,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdFat.h:32,

             from C:\Users\Christofer\Desktop\Arduino\Einzelbeispiele\Test\Test.ino:2:

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:62:12: error: 'SPSR' was not declared in this scope

while (!(SPSR & _BV(SPIF))) {}

        ^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:62:12: note: suggested alternative: 'SPI'

while (!(SPSR & _BV(SPIF))) {}

        ^~~~

        SPI

In file included from c:\users\christofer\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:99:0,

             from c:\users\christofer\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/String.h:31,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Print.h:24,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Stream.h:25,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/Client.h:22,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/api/ArduinoAPI.h:29,

             from C:\Users\Christofer\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.6\cores\arduino/Arduino.h:23,

             from sketch\Test.ino.cpp:1:

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:62:23: error: 'SPIF' was not declared in this scope

while (!(SPSR & _BV(SPIF))) {}

                   ^

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:62:23: note: suggested alternative: 'SPI'

In file included from c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiArduinoDriver.h:94:0,

             from c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\sdspidriver.h:134,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdCard/SdSpiCard.h:35,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdCard/SdCard.h:28,

             from C:\Users\Christofer\Documents\Arduino\libraries\SdFat-beta-master\src/SdFat.h:32,

             from C:\Users\Christofer\Desktop\Arduino\Einzelbeispiele\Test\Test.ino:2:

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h: In member function 'void SdSpiArduinoDriver::send(const uint8_t*, size_t)':

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:75:3: error: 'SPDR' was not declared in this scope

SPDR = *buf++;

^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:75:3: note: suggested alternative: 'SPI'

SPDR = *buf++;

^~~~

SPI

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:78:14: error: 'SPSR' was not declared in this scope

 while (!(SPSR & (1 << SPIF))) {}

          ^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:78:14: note: suggested alternative: 'SPI'

 while (!(SPSR & (1 << SPIF))) {}

          ^~~~

          SPI

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:78:27: error: 'SPIF' was not declared in this scope

 while (!(SPSR & (1 << SPIF))) {}

                       ^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:78:27: note: suggested alternative: 'SPI'

 while (!(SPSR & (1 << SPIF))) {}

                       ^~~~

                       SPI

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:84:12: error: 'SPSR' was not declared in this scope

while (!(SPSR & (1 << SPIF))) {}

        ^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:84:12: note: suggested alternative: 'SPI'

while (!(SPSR & (1 << SPIF))) {}

        ^~~~

        SPI

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:84:25: error: 'SPIF' was not declared in this scope

while (!(SPSR & (1 << SPIF))) {}

                     ^~~~

c:\users\christofer\documents\arduino\libraries\sdfat-beta-master\src\spidriver\SdSpiAvr.h:84:25: note: suggested alternative: 'SPI'

while (!(SPSR & (1 << SPIF))) {}

                     ^~~~

                     SPI

exit status 1
Error compiling for board Arduino Nano Every.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

ARM Processor does not like the UserDataType.h file.

After much mucking around with my Adafruit feather M0
I got the MPU6050RawLowLatencyLogger.ino finally working.
Please change it to the following.


#ifndef UserDataType_h
#define UserDataType_h
struct data_t {
  unsigned long time;
  int16_t ax;
  int16_t ay;
  int16_t az;
  int16_t gx;
  int16_t gy;
  int16_t gz;
};
#endif  // UserDataType_h

as int ax; etc does NOT work with this processor.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.