Added an SPI connected SD card to Yun, now what?

I'm having a bit of an issue with an SPI connectsd SD card being recognized by both the Arduino and the DraginoHE side of the Yun (actually a Seeeduino Cloud). The SD card is on an Adafruit microSD breakout and is tied to the ICSP pins as well to D10 on the Arduino side and D17 which comes from the Yun side. This connection is via a diode OR gate and assumes active low for the CS function. The Arduino side works great but the Linux side fails to recognize the card. Any advice on what to do?

Thanks.

What a curious way to connect an SD card, what gave you the idea to try that?

This sounds like a recipe for disaster - assuming you could get both processors to recognize the card, you would have to make sure that both processors don't ever try to access the card at the same time. If they were to try accessing it at the same time, their requests would get interleaved, and the SD card and both controllers will get very confused. For example, if one processor starts a read sector operation, and starts clocking out data, and the other processor tries to perform a different read, the second command may get ignored and the second processor will be reading the data bound for the first processor without realizing it. Or, that second command will reset the SD card, and the first processor will keep trying to read sector data that isn't there anymore because it's now the data intended for the second processor.

Even if you could mediate simultaneous access and properly interleave complete operations, each processor is going to assume they have complete control over the card, and will not likely tolerate the state of the card changing out from under it. While one processor is idle, if the other processor writes or deletes files on the card, the first processor may not recognize because it will assume it knows the state of the card and won't realize that things changed while it isn't looking.

All in all, it sounds like a really bad idea. A recipe for data loss and corruption.

But the good news is that this is likely to never be a problem, because I don't believe the Linux processor will try to use the SPI interface to access the SD card. I'm not really familiar with the HE, but it is based on the same processor as the Yun, and uses essentially the same Linux system. On the Yun, the SD card has nothing to do with the SPI interface. Instead, the Yun uses a chip that is connected to the USB interface, and acts as an intelligent controller between the USB port and the SD card.

You may be able to figure out a way to get the HE to use the SPI interface, but I think it's a bad idea: both for the above reasons, and because the SPI interface shared with the Arduino side processor is a virtual bit-banged interface implemented with GPIO operations. If you could work out the concurrency issues, you would still be faced with a slow interface and poor performance.

What is your end game here? What are you actually trying to accomplish? The normal model is for the SD card to be directly connected to and controlled by the Linux side. Then the Arduino side uses the shared serial port to communicates with the Linux side to write data to or read data from the SD card.