FS#7634 - SDHC support

Attached to Project: Rockbox
Opened by Barry Wardell (barrywardell) - Tuesday, 21 August 2007, 00:49 GMT
Last edited by Barry Wardell (barrywardell) - Wednesday, 22 August 2007, 00:33 GMT
Task Type Patches
Category Drivers
Status Closed
Assigned To Barry Wardell (barrywardell)
Operating System Sansa e200
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No


Current microSD cards only support sizes up to 2GB. In order to support larger card sizes up to 32GB, support for the SD specification version 2.00 is required ( This patch should add support for these microSD High Capacity cards, while maintaining backwards compatibility with older microSD cards.

Disclaimer: I've based this patch entirely on reading the SD specification version 2.00. It hasn't been tested on an e200 yet, so since it meddles with the disk access, if I've made a mistake somewhere it could lead to data loss both from the SD card and the e200's internal memory.
This task depends upon

Closed by  Barry Wardell (barrywardell)
Wednesday, 22 August 2007, 00:33 GMT
Reason for closing:  Accepted
Comment by Barry Wardell (barrywardell) - Tuesday, 21 August 2007, 01:02 GMT
Updated patch to not do the bank switching stuff for SDHC cards. Still untested.
Comment by Frank M. (framo) - Tuesday, 21 August 2007, 01:47 GMT
Hi Barry, many thanks for the quick posting of this patch after my comment on my problem with seeing a 4GB microSDHC card on my Sansa e280.
After applying the patch with today's svn code, I get the following error though: "ATA error: -219 Press ON to debug" and then a lot of numbers when I press the menue button.
Comment by Ben Kohler (iamben) - Tuesday, 21 August 2007, 02:00 GMT
same result here. after restoring a previous build, all is well (no corruption on SD or internal flash as far as i can tell). i look forward to seeing how this turns out, thanks for your hard work.
Comment by Barry Wardell (barrywardell) - Tuesday, 21 August 2007, 10:44 GMT
How about this?
Comment by Barry Wardell (barrywardell) - Tuesday, 21 August 2007, 13:58 GMT
I've just tried this with my own 4GB microSDHC on my Sansa and it seems to work fine. I haven't tested thoroughly though.
Comment by Jack Suter (chrisjs169) - Tuesday, 21 August 2007, 17:46 GMT
I just got a stack overflow when connecting the USB cable. No other patches added, except this one. While this is one of the first times I've gotten a stack overflow, AFAIK it usually says "*PANIC* Stkov [stack name]" though mine didn't have a "stack name" and just said "*PANIC* Stkov". I wasn't able to reproduce the error, but it could possibly be related I guess.
Comment by Frank M. (framo) - Tuesday, 21 August 2007, 19:44 GMT
Barry, you are a star, I can't believe it works!
My 4GB SanDisk microSDHC card is readable with this patch on my Sansa e280.
It shows up as a <microSD1> folder in the root directory and I am able to browse and play songs from it.
I can also use Rockbox to copy/paste between the SDHC card and the internal memory or rename/delete files.
Cut/Paste between the card and the internal memory gives a "failed" error message but it still works.
Thank you so much!
Comment by Barry Wardell (barrywardell) - Wednesday, 22 August 2007, 00:05 GMT
Updated version. Reads the CSD version 2.0 properly so we now have currcard->max_read_bl_len, currcard->block_size, currcard->numblocks and currcard->capacity are filled in properly. Probably won't make any operational difference.

The cut/paste bug is a separate issue that had gone unnoticed. I've committed a fix to SVN.

I'm not sure about the stkov problem, but I'm guessing that's a separate problem too.