Skip to content

Commit cda0573

Browse files
committed
Fix exFAT validLength dataLength, RP2350B QFN-80.
Fix exFAT use of validLength and dataLength, add SDIO for RP2350B QFN-80.
1 parent a4ecec6 commit cda0573

File tree

260 files changed

+19624
-12215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+19624
-12215
lines changed

README.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
### Warning: This version has major internal changes.
2+
SdFat version 2.3.1 corrects handling of the exFAT fields validLength
3+
and dataLength.
24

3-
SdFat version 2.3.0 has major changes to implement RP2040/RP2350 SDIO.
5+
In exFAT, validLength represents how far user data has been written and
6+
dataLength represents the total space allocated to the file.
47

5-
In addition there are number of bug fixes.
8+
These two fields are equal unless space has been preallocated. In the past, I
9+
returned EOF when a read hit validLength and didn't allow seek beyond
10+
validLength. This does not conform to the exFat specification here:
611

7-
Begin by running the Rp2040SdioSetup example to try RP2040/RP2350 SDIO.
12+
https://learn.microsoft.com/en-us/windows/win32/fileio/exfat-specification
13+
14+
Now read will return zeroes beyond validLength and EOF at dataLength. If a
15+
file is positioned beyond validLength, write will fill the area between
16+
validLength and the current position with zeroes and then write user data.
17+
18+
If you are preallocating space with the preAllocate() call, you should remove
19+
unused space with the truncate() call so applications do not read zeroes
20+
beyond validLength.
21+
22+
Support has been added for the SDIO on RP2350B QFN-80 with 48 GPIO pins.
23+
Each PIO block is still limited to 32 GPIOs at a time, but GPIOBASE
24+
selects which 32.
25+
26+
GPIOBASE can only have value of zero or 16 so all SDIO pins must be in the
27+
range 0-31 or 16-47.
28+
29+
Run the Rp2040SdioSetup example to try RP2040/RP2350 SDIO.
830

931
This example requires a SDIO Card socket with the following six lines.
1032

1133
* CLK - A clock signal sent to the card by the MCU.
1234
* CMD - A bidirectional line for for commands and responses.
1335
* DAT[0:3] - Four bidirectional lines for data transfer.
36+
1437
CLK and CMD can be connected to any GPIO pins. DAT[0:3] can be connected
1538
to any four consecutive GPIO pins in the order DAT0, DAT1, DAT2, DAT3.
1639

doc/Doxyfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,12 +955,12 @@ INPUT = ../src \
955955
../src/iostream \
956956
../src/common \
957957
../src/SdCard \
958-
../src/SpiDriver \
959958
mainpage.h \
960959
../src/FsLib \
961-
../src/FsLib \
962960
../src/SdCard/TeensySdio \
963-
../src/SdCard/Rp2040Sdio
961+
../src/SdCard/PioSdio \
962+
../src/SdCard/SdSpiCard \
963+
../src/SdCard/SdSpiCard/SpiDriver
964964

965965
# This tag can be used to specify the character encoding of the source files
966966
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

doc/SdErrorCodes.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Code,Symbol - failed operation
4646
0X28,SD_CARD_ERROR_ERASE_SINGLE_SECTOR - Card does not support erase
4747
0X29,SD_CARD_ERROR_ERASE_TIMEOUT - Erase command timeout
4848
0X2A,SD_CARD_ERROR_INIT_NOT_CALLED - Card has not been initialized
49-
0X2B,SD_CARD_ERROR_INVALID_CARD_CONFIG - Invalid card config
50-
0X2C,SD_CARD_ERROR_FUNCTION_NOT_SUPPORTED - Unsupported SDIO command
51-
0X2D,SD_CARD_ERROR_UNKNOWN - Unknown error
49+
0X2B,SD_CARD_ERROR_ADD_PIO_PROGRAM - Add PIO program
50+
0X2C,SD_CARD_ERROR_INVALID_CARD_CONFIG - Invalid card config
51+
0X2D,SD_CARD_ERROR_FUNCTION_NOT_SUPPORTED - Unsupported SDIO command
52+
0X2E,SD_CARD_ERROR_UNKNOWN - Unknown error

doc/html.zip

204 KB
Binary file not shown.

doc/mainpage.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2011-2024 Bill Greiman
2+
* Copyright (c) 2011-2025 Bill Greiman
33
* This file is part of the SdFat library for SD memory cards.
44
*
55
* MIT License
@@ -149,7 +149,9 @@ will open "/music/BigBand.wav" on sd2.
149149
150150
\section Install Installation
151151
152-
You must manually install %SdFat by renaming the download folder %SdFat
152+
You can use the Arduino Library Manager to install release versions.
153+
154+
You must manually install %SdFat beta by renaming the download folder %SdFat
153155
and copy the %SdFat folder to the Arduino libraries folder in your
154156
sketchbook folder.
155157
@@ -247,10 +249,11 @@ debug folder - Some of my debug programs - will be remove in the future.
247249
248250
DirectoryFunctions - Use of chdir(), ls(), mkdir(), and rmdir().
249251
250-
examplesV1 folder - Examples from SdFat V1 for compatibility tests.
252+
examplesV1 folder - Examples from SdFat V1 soon to be removed.
251253
252254
ExFatLogger - A data-logger optimized for exFAT features.
253255
256+
254257
MinimumSizeSdReader - Example of small file reader for FAT16/FAT32.
255258
256259
OpenNext - Open all files in the root dir and print their filename.
@@ -261,6 +264,10 @@ ReadCsvFile - Function to read a CSV text file one field at a time.
261264
262265
rename - demonstrates use of rename().
263266
267+
RingBufLogger - Use of RingBuf class for fast data logging.
268+
269+
Rp2040SdioSetup - Setup test for fast PIO SDIO.
270+
264271
RtcTimestampTest - Demonstration of timestamps with RTClib.
265272
266273
SdErrorCodes - Produce a list of error codes.
@@ -271,7 +278,7 @@ SdInfo - Initialize an SD card and analyze its structure for trouble shooting.
271278
272279
SoftwareSpi - Demo of limited Software SPI support in SdFat V2.
273280
274-
STM32Test - Example use of two SPI ports on an STM32 board.
281+
SpiLoopBackTest - Loop-back test of SPI pins.
275282
276283
TeensyDmaAdcLogger - Fast logger using DMA ADC.
277284

examples/AvrAdcLogger/AvrAdcLogger.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef AnalogBinLogger_h
2-
#define AnalogBinLogger_h
1+
#pragma once
32
const size_t BLOCK_SIZE = 64;
43
//------------------------------------------------------------------------------
54
// First block of file.
@@ -30,4 +29,3 @@ struct block16_t {
3029
unsigned short overrun; // count of overruns since last block
3130
unsigned short data[DATA_DIM16];
3231
};
33-
#endif // AnalogBinLogger_h

examples/BufferedPrint/BufferedPrint.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Test and benchmark of the fast bufferedPrint class.
22
//
33
// Mainly for AVR but may improve print performance with other CPUs.
4-
#define DISABLE_FS_H_WARNING // Disable warning for type File not defined.
4+
#ifndef DISABLE_FS_H_WARNING
5+
#define DISABLE_FS_H_WARNING // Disable warning for type File not defined.
6+
#endif // DISABLE_FS_H_WARNING
57
#include "SdFat.h"
68
#include "BufferedPrint.h"
79
// SD_FAT_TYPE = 0 for SdFat/File as defined in SdFatConfig.h,
@@ -30,9 +32,9 @@ const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
3032
// Try to select the best SD card configuration.
3133
#if defined(HAS_TEENSY_SDIO)
3234
#define SD_CONFIG SdioConfig(FIFO_SDIO)
33-
#elif defined(RP_CLK_GPIO) && defined(RP_CMD_GPIO) && defined(RP_DAT0_GPIO)
34-
// See the Rp2040SdioSetup example for RP2040/RP2350 boards.
35-
#define SD_CONFIG SdioConfig(RP_CLK_GPIO, RP_CMD_GPIO, RP_DAT0_GPIO)
35+
#elif defined(HAS_BUILTIN_PIO_SDIO)
36+
// See the Rp2040SdioSetup example for boards without a builtin SDIO socket.
37+
#define SD_CONFIG SdioConfig(PIN_SD_CLK, PIN_SD_CMD_MOSI, PIN_SD_DAT0_MISO)
3638
#elif ENABLE_DEDICATED_SPI
3739
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
3840
#else // HAS_TEENSY_SDIO

examples/DirectoryFunctions/DirectoryFunctions.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/*
22
* Example use of chdir(), ls(), mkdir(), and rmdir().
33
*/
4+
#ifndef DISABLE_FS_H_WARNING
45
#define DISABLE_FS_H_WARNING // Disable warning for type File not defined.
6+
#endif // DISABLE_FS_H_WARNING
57
#include "SdFat.h"
68
#include "sdios.h"
79

@@ -31,9 +33,9 @@ const uint8_t SD_CS_PIN = SDCARD_SS_PIN;
3133
// Try to select the best SD card configuration.
3234
#if defined(HAS_TEENSY_SDIO)
3335
#define SD_CONFIG SdioConfig(FIFO_SDIO)
34-
#elif defined(RP_CLK_GPIO) && defined(RP_CMD_GPIO) && defined(RP_DAT0_GPIO)
35-
// See the Rp2040SdioSetup example for RP2040/RP2350 boards.
36-
#define SD_CONFIG SdioConfig(RP_CLK_GPIO, RP_CMD_GPIO, RP_DAT0_GPIO)
36+
#elif defined(HAS_BUILTIN_PIO_SDIO)
37+
// See the Rp2040SdioSetup example for boards without a builtin SDIO socket.
38+
#define SD_CONFIG SdioConfig(PIN_SD_CLK, PIN_SD_CMD_MOSI, PIN_SD_DAT0_MISO)
3739
#elif ENABLE_DEDICATED_SPI
3840
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
3941
#else // HAS_TEENSY_SDIO

examples/ExFatLogger/ExFatLogger.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Avoid IDE problems by defining struct in septate .h file.
22
// Pad record so size is a power of two for best write performance.
3-
#ifndef ExFatLogger_h
4-
#define ExFatLogger_h
3+
#pragma once
54
const size_t ADC_COUNT = 4;
65
struct data_t {
76
uint16_t adc[ADC_COUNT];
87
};
9-
#endif // ExFatLogger_h

examples/ExFatLogger/ExFatLogger.ino

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
// Note: This is an old example. See the RingBufLogger example for use of
2+
// the RingBuf class. The RingBuf class can be used for text and binary data.
3+
// RingBuf can be use to log from a ISR - see the TeensyDmaAdcLogger example.
4+
//
15
// Example to demonstrate write latency for preallocated exFAT files.
26
// I suggest you write a PC program to convert very large bin files.
37
//
48
// The maximum data rate will depend on the quality of your SD,
59
// the size of the FIFO, and using dedicated SPI.
6-
#define DISABLE_FS_H_WARNING // Disable warning for type File not defined.
10+
#ifndef DISABLE_FS_H_WARNING
11+
#define DISABLE_FS_H_WARNING // Disable warning for type File not defined.
12+
#endif // DISABLE_FS_H_WARNING
713
#include "SdFat.h"
8-
#include "ExFatLogger.h"
914
#include "FreeStack.h"
15+
#include "ExFatLogger.h"
1016
//------------------------------------------------------------------------------
1117
// This example was designed for exFAT but will support FAT16/FAT32.
1218
// Note: Uno will not support SD_FAT_TYPE = 3.
@@ -72,9 +78,9 @@ const uint32_t PREALLOCATE_SIZE_MiB = 1024UL;
7278
// Try to select the best SD card configuration.
7379
#if defined(HAS_TEENSY_SDIO)
7480
#define SD_CONFIG SdioConfig(FIFO_SDIO)
75-
#elif defined(RP_CLK_GPIO) && defined(RP_CMD_GPIO) && defined(RP_DAT0_GPIO)
76-
// See the Rp2040SdioSetup example for RP2040/RP2350 boards.
77-
#define SD_CONFIG SdioConfig(RP_CLK_GPIO, RP_CMD_GPIO, RP_DAT0_GPIO)
81+
#elif defined(HAS_BUILTIN_PIO_SDIO)
82+
// See the Rp2040SdioSetup example for boards without a builtin SDIO socket.
83+
#define SD_CONFIG SdioConfig(PIN_SD_CLK, PIN_SD_CMD_MOSI, PIN_SD_DAT0_MISO)
7884
#elif ENABLE_DEDICATED_SPI
7985
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
8086
#else // HAS_TEENSY_SDIO

0 commit comments

Comments
 (0)