I can't reproduce the problem with CS = D5, SPI_CONFIGURATION == 1
I ran TryMeFirst and bench.
I downloaded the 0.5.1 firmware from gitHub and updated a photon:
put the Photon in DFU mode
cd modules
make PLATFORM=photon clean all program-dfu
I edited the configuration for TryMeFirst like this:
// Pick an SPI configuration.
// See SPI configuration section below (comments are for photon).
#define SPI_CONFIGURATION 1 <------------------------------Change from zero to one
//------------------------------------------------------------------------------
// Setup SPI configuration.
#if SPI_CONFIGURATION == 0
// Primary SPI with DMA
// SCK => A3, MISO => A4, MOSI => A5, SS => A2 (default)
SdFat sd;
const uint8_t chipSelect = SS;
#elif SPI_CONFIGURATION == 1
// Secondary SPI with DMA
// SCK => D4, MISO => D3, MOSI => D2, SS => D1
SdFat sd(1);
//const uint8_t chipSelect = D1;
const uint8_t chipSelect = D5; <-------------------- Use D5
#elif SPI_CONFIGURATION == 2
I did the same with bench. Here is the result:
FreeMemory: 29700
Type is FAT32
Card size: 15.93 GB (GB = 1E9 bytes)
Manufacturer ID: 0X3
OEM ID: SD
Product: SL16G
Version: 8.0
Serial number: 0X91203A25
Manufacturing date: 4/2014
File size 5 MB
Buffer size 32768 bytes
Starting write test, please wait.
write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
1571.21,105882,20108,20822
Starting read test, please wait.
read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
1699.91,20389,19242,19276
Done
Type any character to start
There have been major changes in the SPI driver. I have a bug fix/workaround in SdFat for a bug in 0.4.x.
You could remove it and see if that helps.
Edit SdSpiParticle.cpp and use the following code for the two functions with workarounds.
uint8_t SdSpi::receive(uint8_t* buf, size_t n) {
spiPtr[m_spiIf]->transfer(0, buf, n, 0);
return 0;
}
void SdSpi::send(const uint8_t* buf , size_t n) {
spiPtr[m_spiIf]->transfer(const_cast<uint8_t*>(buf), 0, n, 0);
}