User avatar
STrRedWolf
Posts: 24
Joined: Fri Oct 05, 2012 1:47 am

Extra SD card HAT?

Sat Aug 30, 2014 10:18 pm

I noticed that the 40-pin connector breaks out some of the secondary SD-card controller pins, so a second SD card can be put in. I probably can assume we'll need a GPIO to detect card insertion and the write-protect signal.

So, with a spare 24LC256 and a old Sparkfun SD break-out board, I can prototype a storage HAT. As soon as a case comes in, I'll delve into I2C haberdashery.

Photo of the prototype

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2351
Joined: Thu Jul 11, 2013 2:37 pm

Re: Extra SD card HAT?

Sun Aug 31, 2014 12:05 pm

Yep. 4-bit SD on the alternate SD host pins is available on bank 0.

No driver for it, though. Or documentation.
Rockets are loud.
https://astro-pi.org

User avatar
STrRedWolf
Posts: 24
Joined: Fri Oct 05, 2012 1:47 am

Re: Extra SD card HAT?

Sun Aug 31, 2014 1:47 pm

Well, actually, if we're doing 4-bit SD on the regular card, we already have the driver -- it's in the kernel. I mucked with that on an old white BeagleBone.

The caveat is that we'd need two GPIO's for a card detect and write protect (the latter I think we can get away with). I'd have to research the device tree setup and how it interacts with the SD drivers.

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: Extra SD card HAT?

Mon Sep 01, 2014 8:39 am

jdb wrote:Yep. 4-bit SD on the alternate SD host pins is available on bank 0.

No driver for it, though. Or documentation.
There is a driver for 3.2.x. Only having to upport it.

dan3008
Posts: 1172
Joined: Wed Aug 15, 2012 1:05 pm

Re: Extra SD card HAT?

Mon Sep 01, 2014 9:48 am

Wow, Going to have to keep an eye on this, keep up the good work :)
dan3008 wrote:Pays your money, takes your choice

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

Re: Extra SD card HAT?

Mon Sep 01, 2014 10:27 pm

STrRedWolf wrote:Well, actually, if we're doing 4-bit SD on the regular card, we already have the driver -- it's in the kernel. I mucked with that on an old white BeagleBone.

The caveat is that we'd need two GPIO's for a card detect and write protect (the latter I think we can get away with). I'd have to research the device tree setup and how it interacts with the SD drivers.
Depends which 'kernel driver' you're talking about. You can go with raw bit-banged GPIO (which will be very slow), or you can go with mmc-over-spi using one of the Pis SPI interfaces (which will be a bit quicker, but probably still slower than you expect).
The BCM2835 includes a couple of hardware blocks for "proper" SD access, allowing much greater read/write speeds. The primary one on GPIOs 48-53 which is used by the in-built SD / microSD slot, and a secondary one on GPIOs 22-27, which is the one jdb refers to having no public driver or documentation yet (from what I've heard this is actually different from the primary SD block, so would need a different driver). :geek:

This is all just my personal understanding, I've never actually implemented an additional SD interface on the Pi.

User avatar
STrRedWolf
Posts: 24
Joined: Fri Oct 05, 2012 1:47 am

Re: Extra SD card HAT?

Mon Sep 01, 2014 10:37 pm

AndrewS wrote:The BCM2835 includes a couple of hardware blocks for "proper" SD access, allowing much greater read/write speeds. The primary one on GPIOs 48-53 which is used by the in-built SD / microSD slot, and a secondary one on GPIOs 22-27, which is the one jdb refers to having no public driver or documentation yet (from what I've heard this is actually different from the primary SD block, so would need a different driver). :geek:

This is all just my personal understanding, I've never actually implemented an additional SD interface on the Pi.
Guess I'm the first. The secondary SD port one is what is of interest to me, and if it's like what TI did with the Beaglebone's AM35xx, the primary driver also works the secondary port. A good trip into the kernel source will tell more.

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

Re: Extra SD card HAT?

Mon Sep 01, 2014 11:04 pm

I believe that this is the 3.2-only driver for the secondary SD interface that mimi123 was referring to https://github.com/raspberrypi/linux/bl ... 2708_mci.c

And just for comparison, this is the driver for the primary SD interface from the same kernel tree https://github.com/raspberrypi/linux/bl ... -bcm2708.c

http://www.raspberrypi.org/documentatio ... /README.md may or may not have additional useful info.

EDIT: And there's previously been similar posts about this too (e.g. http://www.raspberrypi.org/forums/viewt ... 44&t=26428 or http://www.raspberrypi.org/forums/viewt ... =44&t=8837 or http://www.raspberrypi.org/forums/viewt ... 29&t=80111 ) but AFAIK nothing ever went anywhere... it's generally much quicker, cheaper & easier to just buy a USB SD-reader and plug it into one of the Pi's USB ports ;)

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: Extra SD card HAT?

Tue Sep 02, 2014 8:51 am

AndrewS: Yes, it is that driver.

On the older B, it did not work because a SD1_DATA3 was not routed to GPIO. (that driver is used on Odroid-W, updated).

mimi123
Posts: 583
Joined: Thu Aug 22, 2013 3:32 pm

Re: Extra SD card HAT?

Tue Sep 02, 2014 8:56 am

STrRedWolf wrote:
AndrewS wrote:The BCM2835 includes a couple of hardware blocks for "proper" SD access, allowing much greater read/write speeds. The primary one on GPIOs 48-53 which is used by the in-built SD / microSD slot, and a secondary one on GPIOs 22-27, which is the one jdb refers to having no public driver or documentation yet (from what I've heard this is actually different from the primary SD block, so would need a different driver). :geek:

This is all just my personal understanding, I've never actually implemented an additional SD interface on the Pi.
Guess I'm the first. The secondary SD port one is what is of interest to me, and if it's like what TI did with the Beaglebone's AM35xx, the primary driver also works the secondary port. A good trip into the kernel source will tell more.
You may have to use some relays to SD card power as the Pi can boot from the secondary SD card interface.

technix
Posts: 121
Joined: Sat Jul 13, 2013 4:55 pm

Re: Extra SD card HAT?

Wed Sep 03, 2014 1:37 am

STrRedWolf wrote:Well, actually, if we're doing 4-bit SD on the regular card, we already have the driver -- it's in the kernel. I mucked with that on an old white BeagleBone.

The caveat is that we'd need two GPIO's for a card detect and write protect (the latter I think we can get away with). I'd have to research the device tree setup and how it interacts with the SD drivers.
Simple solution: a bank of 2 CD4066s making this entire HAT invisible when the SD card is not plugged in, or maybe just a MOSFET cutting the power? No card detect pin needed.

User avatar
STrRedWolf
Posts: 24
Joined: Fri Oct 05, 2012 1:47 am

Re: Extra SD card HAT?

Wed Mar 04, 2015 3:17 am

Okay, things got a bit crazy since I last posted (including having a new job now). So hopefully soon I will be able to get back on properly prototyping the new HAT. The Pi 2 did throw a wrench in the works, so I'm now waiting on an order from Pimoroni to update the Pi Coupe and get a new prototyping plate.

Ether way, I do need to work on the device tree spec and the EEPROM data.

Return to “HATs and other add-ons”