Due: SPI speed problem when using 2 interfaces

HW: Due/R3 + 2x identical cheapo ebay SD module with 5v and 3.3v (there is a 3.3 vregulator onboard that presumably drops the 5v)
SW: IDE 1.5.1r2
Libraries:
#include <SPI.h>
#include <SD.h>

I have a very simple SD card cloner set up as follows: MISO,MOSI,SCK on ICSP header, with SS for src drive on 4, SS for dst drive on 10
Before we continue I must make it clear that it works perfectly when I init both SPI channels with SPI_HALF_SPEED, i.e. I have exactly cloned an SD card on this rig. Both ebay cheapo readers running at 5v. So the code and wiring look good, hence not including complete details. I call the src and dst A and B for convenience.

The problem starts when I try SPI_FULL_SPEED, and it gets weird. I have tried the following with 7 different SD or Mini SD cards, ranging from good quality Kingston SDHC 4 through noname 128MB and sizes of 1GB 2GB 4GB. The following issue occurs exactly the same each time, no matter which card I use in A or B:

early code:

#define SRC  4
#define DST  10

Sd2Card src;
Sd2Card dst;

With any/all of the cards in A, with B empty, the following code correctly reports the size:

Serial.println(src.init(SPI_FULL_SPEED,SRC));
Serial.println(src.cardSize());

The same is true for any/all cards in B with A empty::

Serial.println(dst.init(SPI_FULL_SPEED,DST));
Serial.println(dst.cardSize());

Also reports correct size

B U T if both A and B are populated, either/both code snippet fail with init returning zero! Remember, at SPI_HALF_SPEED, the amended code reports correctly in all circumstances / permutations

Summary: When both SD readers are populated,BOTH inits fail if they are initialised at full speed, even on two cards that both successfully init'ed at FULL_SPEED when mounted solo, in either reader!

H E L P!!! I want full speed, half speed gives me about 9MB/s which translates to a loooooooong time even for 1GB

Any ideas?

I recommend disabling all SPI devices before initializing any of them. In your case:

void setup() {

  // disable src SD
  pinMode(SRC, OUTPUT);
  digitalWrite(SRC, HIGH);

  // disable dst SD
  pinMode(DST, OUTPUT);
  digitalWrite(DST, HIGH);

  // Now start the SD cards

How does that do?

I might have found the answer...from wikipedia

In practice, cards are rarely ganged together because open-collector operation has problems at high speeds and increases power consumption. Newer versions of the SD specification recommend separate lines to each card

I will try init at a very low speed, then ramp up the clock before subsequent accesses and see how that works.

ps tried the disable first technique...no joy

The SPI bus is not open collector. It is tri-state.

edit: I suspect this is the problem:

HW: Due/R3 + 2x identical cheapo ebay SD module with 5v and 3.3v (there is a 3.3 vregulator onboard that presumably drops the 5v)

The cheapo ebay SD readers do not normally have a logic level converter. They mostly use a pullup resistor to the 3.3v power only. This could cause problems two ways.

  1. the resistors could put a load on the MOSI line that the Atmel IC cannot overcome quickly.
  2. the 3.3v logic inputs exposed to 5v output from the Atmel could cause the same problem.