User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13395
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Adding a second SD-Card slot

Sat Apr 21, 2012 12:22 am

It would be very handy to have a second SD-card slot, as using the Raspberry without a second SD-card slot there are a lot of things you cannot do, such as backing up data to another SD-Card, downloading and creating a new Linux disto on a second card, resizing a partition on a card, etc etc. Obviously you could connect a card-reader to the USB slot, but if you do that you need a third USB slot, or you need to abandon the mouse, and only use the keyboard.

There IS a simply way to add a second SD-card slot though, although access to it would slower than the normal SD-Card.

On the GPIO is an SPI interface (with two device selects), you could wire that to a second SD-card slot, and that should work, as normally SD-cards can also be driven *though slower) through an SPI interface. Obviously A driver is needed, but there are many more systems that use SPI for the SD-card interface, so a driver should be easily adaptable.

This card slot could be put on a small PCB so that it sits above the original  SD-Card, and would be very cheap as al the electronics is already available, the GPIO port should be able to provide enough power, so for the price of the connector, and a very small PCB this could be added to the Raspberry PI.

User avatar
jbeale
Posts: 3736
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Adding a second SD-Card slot

Sat Apr 21, 2012 1:03 am

Doing the SD card access that way is definitely possible but slower, as you say. Isn't it easy enough just to use a USB hub if you need more USB slots? They are pretty cheap, and also compact (especially if one is built into the keyboard).

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13395
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Adding a second SD-Card slot

Sat Apr 21, 2012 2:48 pm

Yes, I was anticipating such a reply, (USB seems to be the answer for everything these days) but I was aiming for a very low cost and compact solution. Especially for third world applications, where having a second SD-cards will be even more a necessity than here.

My solution is like building in a "second floppy drive" into your existing (single floppy and no hard-disk) system, not adding an external "intelligent" one at relatively large expense, and bulk.

I do know its not a solution for anyone, but for me its a logical one.

Perhaps its a solution that can be pre-built and sold, or even sold as a kit.

If the board uses female pin headers (on the underside) with its long pins (on top) protruding to form a new GPIO connector,  the module can be placed and still leave the GPIO accessable.

The SPI interface has two chip selects, so SPI is still available, it would even be possible to piggy back two of these SD-card boards to add two SD cards to the R-PI.

The board could also be complemented with a real time clock with a battery.

BertM
Posts: 30
Joined: Wed Feb 08, 2012 4:12 pm

Re: Adding a second SD-Card slot

Sat Apr 21, 2012 3:40 pm

Knowing this:

- The RPi hardware can speak SPI by itself, and SD cards speak SPI as well (in 1-bit mode)

- The RPi GPIO provides 3.3V, SD cards use 3.3V

It should therefore be almost trivial to add SD cards without having to resolve to bit-banging. Also, hardware SPI can be fast enough for normal operation. The maximum bitrate (in theory) for SD cards in 1-bit mode is 50Mbit/s, if the Broadcom SoC is able to keep up with that.

If it would be possible to have DMA handle the incoming/outgoing data (in chunks of 512 bytes), the processor would be offloaded as well.

Adding multiple SD cards could be a pain however, as each of them may consume 100mA on the 3.3V line.

If you would use microSD cards, the extension boards can be very small and cheap (think a few dollars). Thinking of that, I still have 10 microSD sockets (the fancy ones with spring mechanism) around here somewhere, but I don't expect to have a RPi in the next couple of months.

Michael
Posts: 340
Joined: Sat Jul 30, 2011 6:05 pm

Re: Adding a second SD-Card slot

Sat Apr 21, 2012 5:14 pm

The Broadcom SoC supports a second SD card on GPIOs 22-27.  22-25 are available on the GPIO connector and 27 is available on the CSI connector, its only GPIO26 that's missing so might be a candidate for adding in v2 along with Gert's preferences of GPIO 19 and 20.

BertM
Posts: 30
Joined: Wed Feb 08, 2012 4:12 pm

Re: Adding a second SD-Card slot

Sat Apr 21, 2012 5:33 pm

Just a small sidenote: the maximum permissible current draw on the 3.3V of the GPIO is 50mA according to the wiki, so the board would have to incorporate a 5V -> 3.3V stepdown converter (or LDO linear regulator).

User avatar
rew
Posts: 438
Joined: Fri Aug 26, 2011 3:25 pm

Re: Adding a second SD-Card slot

Sun Apr 22, 2012 8:35 am

From the schematics: I'd say that 100mA was possible too.

Pete is very conservative, so he wants to test if everything is ok before he gives out a larger number. Keep an eye on the 3.3V regulator near the big capacitor to prevent it from overheating.

Sounds like a plan to make a micro-SD card slot for the SPI bus on the GPIO.

[update]

I've measured my SD card that I bought for use with the RPI. It uses about 20mA.
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

BertM
Posts: 30
Joined: Wed Feb 08, 2012 4:12 pm

Re: Adding a second SD-Card slot

Mon Apr 23, 2012 12:14 am

I recall once using a normal sized SD(HC) card in a project, that peeked at around 120mA, which was quite ridiculous in my opinion.

Well, production of the necessary PCB should cost at most €1 (Seeed studio, 10pcs @ $10), a microSD connector can be found for less than $0.50, the only thing left is a small 100nF - 4.7uF capacitor for decoupling. Which means a DIY kit should cost no more than €2 per piece (in quantities of 10).

Adding an LDO regulator should cost no more than $0.50 extra, but I doubt whether it will be necessary. The datasheet for the onboard NCP1117 (the 3.3V regulator) states that it has a current limit, safe operating and thermal shutdown protection. So the worst you can do is crash the processor (which is resolved by a reboot).

Also, 100mA should be safe. The RPi is said to consume 1W under full load, let's assume a safe 1.2W. That would equal to 360mA @ 3.3V. The copper area around the regulator is specified to be 400mm2 (designed to dissipate 800mW), which would give a current of 470mA @ 3.3V (assuming a 1.7V drop). Hence, there is 110mA left for playing. Even better, 400mm2 of copper should be enough for the regulator to be able to dissipate 1.4W according to the datasheet, which would give a stunning 820mA and therefore 460mA of headroom for your experiments. Adding a tiny heatsink might help as well.

@rew, if you are in need of microSD sockets, you know where to find me at CO.

User avatar
rew
Posts: 438
Joined: Fri Aug 26, 2011 3:25 pm

Re: Adding a second SD-Card slot

Mon Apr 23, 2012 5:38 am

I have a few already. Thanks.
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

User avatar
meltwater
Posts: 1015
Joined: Tue Oct 18, 2011 11:38 am

Re: Adding a second SD-Card slot

Fri Aug 30, 2013 11:36 am

Just digging this thread up since I was having similar thoughts about attaching an SD Card to the SPI.

Anyone managed this, even as a proof of concept.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

Heater
Posts: 16874
Joined: Tue Jul 17, 2012 3:02 pm

Re: Adding a second SD-Card slot

Fri Aug 30, 2013 12:04 pm

Is there a Linux kernel driver that can handle that SD cards on that SPI interface?
Memory in C++ is a leaky abstraction .

plugwash
Forum Moderator
Forum Moderator
Posts: 3701
Joined: Wed Dec 28, 2011 11:45 pm

Re: Adding a second SD-Card slot

Fri Aug 30, 2013 12:22 pm

Ages ago bootc hooked up a SD card and ENC28j60 ethernet controller to the SPI to use for mass storage while working on the kernel. AIUI the drivers are already in the kernel but you have to do some magic to bind them to the SPI controller and i'm not sure exactly that that magic is.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Adding a second SD-Card slot

Fri Aug 30, 2013 12:29 pm

Heater wrote:Is there a Linux kernel driver that can handle that SD cards on that SPI interface?
It's hard to get a definitive answer, but there's lots of snippets of info out there which suggests it should be possible
https://duckduckgo.com/?q=SPI+linux+mmc+sd+card+driver

User avatar
meltwater
Posts: 1015
Joined: Tue Oct 18, 2011 11:38 am

Re: Adding a second SD-Card slot

Fri Aug 30, 2013 9:20 pm

Humm, from what I've looked at so far, getting data to and from a card isn't a massive issue (using SPI commands), but wouldn't know where to start with doing it correctly with file systems, drivers etc.

Anyway, when I get chance will try to look into it further. Just seemed like an interesting project at some stage.
______________
http://www.themagpi.com/
A Magazine for Raspberry Pi Users
Read Online or Download for Free.

My new book: goo.gl/dmVtsc

Meltwater's Pi Hardware - pihardware.com

Like the MagPi? @TheMagP1 @TheMagPiTeam

mcauser
Posts: 2
Joined: Mon Sep 08, 2014 1:42 pm

Re: Adding a second SD-Card slot

Sat Sep 13, 2014 1:45 am

I purchased one of these add-on boards:
http://imall.iteadstudio.com/developmen ... dd-on.html

It has a MicroSD socket attached to the SPI interface. CE0, MOSI, MISO, SCLK.

I contacted the manufacturer but they do not offer any drivers or code snippets for interacting with the SPI interface.

Does a linux kernel driver mean you could connect to the drive using native filesystem commands? eg. ls, cp, mv.

If anyone has any tips, recommendations or could point me in the right direction that would be greatly appreciated!

I'm going to go learn what SPI is now and what these SPI commands are you speak of :D

RBISWASX
Posts: 31
Joined: Thu Jan 09, 2014 5:30 pm

Re: Adding a second SD-Card slot

Sat Jul 04, 2015 5:39 am

Yes, here is Blog that i have written, about how to interface an External MICROSD Card Adapter with RaspberryPi. I have considered Elm Chan's generic FATFS Library for FATFS Api's and DISKFs API's, and using plain GPIOs to simulate the SPI signals of MISO, MOSI, CS and SCLK. Here is my blog below, in which i have covered it step by step...

http://blogsmayan.blogspot.in/p/interfa ... -card.html

MohitBagur
Posts: 18
Joined: Wed May 27, 2015 5:47 am
Location: Bangalore,Karnataka,India

Re: Adding a second SD-Card slot

Tue Jul 07, 2015 2:12 pm

Can someone post a detailed guide to doing this completely DIY? The parts you all are suggesting are not available here.. By parts I mean the readymade module.

User avatar
JoanTheSpark
Posts: 33
Joined: Sun Feb 21, 2016 5:36 am

Re: Adding a second SD-Card slot

Tue Mar 15, 2016 7:37 am

Michael wrote:The Broadcom SoC supports a second SD card on GPIOs 22-27.  22-25 are available on the GPIO connector and 27 is available on the CSI connector, its only GPIO26 that's missing so might be a candidate for adding in v2 along with Gert's preferences of GPIO 19 and 20.
Did this ever make it?
I don't understand much about the BCM SoC (as there is no real pinout,etc. available) but if the BCM2835 and BCM2836 are nearly identical and the 40 pin headers on the current models bring out all above mentioned pins (GPIO 22 - 27), doesn't that mean this solution is possible?
Anyone worked on that?
Does this need RPi Foundation driver support/enabling in the kernel etc..?

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: Adding a second SD-Card slot

Tue Mar 15, 2016 8:05 am

Yes, working, see here: viewtopic.php?f=45&t=137710

User avatar
JoanTheSpark
Posts: 33
Joined: Sun Feb 21, 2016 5:36 am

Re: Adding a second SD-Card slot

Tue Mar 15, 2016 10:25 am

Cool!
Thanks @gregeric

Return to “General discussion”