Page 1 of 1

Adding SDHC Support (Success!)

Posted: Sat Feb 11, 2012 3:41 pm
by _Nold_
Hi,

the last 2 days i were working on SDHC support for Gc-Linux..
The init-handshake works fine now, i can even see the Partitions...

But then if he tries to load the rootfs, he gets an error.. Since i have nearly no idea of this stuff, i hope on your help!
If i interpret it correctly, he tries to read from a block, which is MUCH too high for my SDHC-Card.

I'm using a 8GB Card, so it has 15523840 512-Byte blocks..


Here is the error, i'm getting:

sd_generic_read: read, offset=2206839808, len=512
sd_generic_read: crc=8340, calc_crc=ffff, failed
sd_read_single_block: start=2206839808, data=c0377400, len=512, retval= -61


If you need anymore informations, just ask..

Re: Adding SDHC Support

Posted: Sun Feb 12, 2012 12:23 pm
by emu_kidid
SDHC does not read by BYTE address, it reads by block address. So this means you need to send offset in form of 512 byte blocks (and write a wrapper to handle mis-aligned blocks if you're reading partial sectors, but my guess is gc-linux already handles all this).

So, if SDHC, use block address (512byte sized blocks).

This page was really helpful for me a long time ago: http://elm-chan.org/docs/mmc/mmc_e.html CMD17-CMD18 :)

Also, the same goes for writing blocks.

Re: Adding SDHC Support

Posted: Sun Feb 12, 2012 3:40 pm
by _Nold_
Hm, ok, thanks for that so far.. the problem is, that the whole gcn-sd driver is only reading single blocks (CMD17)..
That's why i have no idea where the problem is, since he even can read out the partition-table..

I also tried "reallocating" before.. i just did a if(offset > capacity_blks) { offset = offset/512; }
Just to try it out.. no access... he gives me the error i had right after i finished the initialisation process..
"Can not open root device "gcnsda2" or unknown block(61,2)"

So it seems that i really need some kind of reallocation... :/

I never did something like this before, but i got so far, i need to get that going :D

EDIT:
Ok, i just did a little change, now he tries to read the first sectors of my ext3 partition.. but he dosn't seem to find a filesystem...

Re: Adding SDHC Support

Posted: Sun Feb 12, 2012 4:30 pm
by infact
noldor, the sd driver is a bit messy i think, it adds things to the (outdated) mmc compatibility layer and should be rewritten completely. i also had some issues with it when i tried to add sdhc support (i don't remember how far i got, but it recognized the card and then some kind of kernel panic). take a look at the other sdhc drivers (but not only the wii one)

Re: Adding SDHC Support

Posted: Sun Feb 12, 2012 4:37 pm
by _Nold_
Yea, i was looking at nearly every patch ever made on linux mmc/sd drivers XD

Now i'm getting:
"EXT3-FS: Magic mismatch, very weird"

That's not bad at all in my eyes xD

Re: Adding SDHC Support

Posted: Sun Feb 12, 2012 9:54 pm
by emu_kidid
Noldor, perhaps put the file you have up on a pastie.org kind of site and we can have a look.

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 7:06 am
by _Nold_
Here you go: http://pastebin.com/awLU4cBL

But i have to warn you, it's not really nice coded, for the moment. :D


The most interesting part should be sd_generic_read, as i told you the initialisation works fine and all CSD Data seems to be ok, too...

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 8:27 am
by emu_kidid
On line 1165, don't shift. Cause it looks like you're doing 1*512bytes*512blocks per read... :)

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 10:07 am
by _Nold_
No, that's fine, i just tried that again...
block_len just tells him, that a block is 512byte long...

//EDIT: Oh man, you were rigth! but i can't change block_len, what i need to change is only the start-offset!!
AND FUCK YES IT WORKS!!! That's so awesome!! Thank you so much! *~*

Now i just need to do a lot of cleanup ^^
I'm so happy that it works :D that's just too cool!

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 10:50 am
by emu_kidid
Told you... time to setup a distro with sdhc for us to use ;)

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 10:56 am
by liquitt
next step: patching the 3.x kernel ;)

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 11:06 am
by _Nold_
hehe, that would be cool, too. But i can't see any advantage in using a 3.X Kernel :/
Building a nice little distro seems much more usefull in my eyes :/

But the next step for me is to go to bed and get healthy <.<
After that i will clean up my code and build back the SD-Support ^^

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 12:04 pm
by liquitt
get well soon!

don't forget to send this to the gc-linux mailing list :)

Re: Adding SDHC Support

Posted: Mon Feb 13, 2012 1:50 pm
by emu_kidid
nice work Noldor, rest well for a new SDHC distro awaits ;)

Re: Adding SDHC Support (Success!)

Posted: Mon Feb 13, 2012 4:16 pm
by _Nold_
So much to do, but so little time.. ^^

I updated my old thread with some testing kernels, hope you can give it a try..
Thanks again emu :)

Re: Adding SDHC Support (Success!)

Posted: Tue Feb 14, 2012 4:58 pm
by julius
So cool!!That means more compatibility for Linux based emus or possibility to use it through ide-exi? Man please, tell me it is true at least one of these possibilities.

Re: Adding SDHC Support (Success!)

Posted: Tue Feb 14, 2012 5:00 pm
by liquitt
julius wrote:So cool!!That means more compatibility for Linux based emus or possibility to use it through ide-exi? Man please, tell me it is true at least one of these possibilities.
tell me where you see the connection between sdhc and the ide-exi ;)

Re: Adding SDHC Support (Success!)

Posted: Tue Feb 14, 2012 5:23 pm
by _Nold_
Both are using EXI :D

IDE-EXI would be cool.. but i havn't got one :/ ..
I was thinking about building a complete new batch (about 10).. They would be pretty cheap but i think we should wait until FoxxOTG finishes his project...

Re: Adding SDHC Support (Success!)

Posted: Tue Feb 14, 2012 6:43 pm
by liquitt
well they use exi but a sdhc driver won't help you with an ide harddrive ;)

but....
http://www.gc-linux.org/wiki/EXI:IDEHostAdapter

:)

Re: Adding SDHC Support (Success!)

Posted: Tue Feb 14, 2012 8:39 pm
by infact
yep, it is already coming ;-)