Adding SDHC Support (Success!)

Discussion for GC-Linux on Gamecube & Wii
Post Reply
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Adding SDHC Support (Success!)

Post by _Nold_ » Sat Feb 11, 2012 3:41 pm

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..
Last edited by _Nold_ on Mon Feb 13, 2012 2:40 pm, edited 1 time in total.
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
User avatar
emu_kidid
Site Admin
Posts: 4485
Joined: Mon Mar 29, 2010 10:06 am
Location: Australia
Contact:

Re: Adding SDHC Support

Post by emu_kidid » Sun Feb 12, 2012 12:23 pm

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.
Image
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Re: Adding SDHC Support

Post by _Nold_ » Sun Feb 12, 2012 3:40 pm

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...
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
User avatar
infact
Posts: 347
Joined: Tue Mar 29, 2011 4:35 am
Location: Germany

Re: Adding SDHC Support

Post by infact » Sun Feb 12, 2012 4:30 pm

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)
infact
Image Image
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Re: Adding SDHC Support

Post by _Nold_ » Sun Feb 12, 2012 4:37 pm

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
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
User avatar
emu_kidid
Site Admin
Posts: 4485
Joined: Mon Mar 29, 2010 10:06 am
Location: Australia
Contact:

Re: Adding SDHC Support

Post by emu_kidid » Sun Feb 12, 2012 9:54 pm

Noldor, perhaps put the file you have up on a pastie.org kind of site and we can have a look.
Image
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Re: Adding SDHC Support

Post by _Nold_ » Mon Feb 13, 2012 7:06 am

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...
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
User avatar
emu_kidid
Site Admin
Posts: 4485
Joined: Mon Mar 29, 2010 10:06 am
Location: Australia
Contact:

Re: Adding SDHC Support

Post by emu_kidid » Mon Feb 13, 2012 8:27 am

On line 1165, don't shift. Cause it looks like you're doing 1*512bytes*512blocks per read... :)
Image
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Re: Adding SDHC Support

Post by _Nold_ » Mon Feb 13, 2012 10:07 am

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!
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
User avatar
emu_kidid
Site Admin
Posts: 4485
Joined: Mon Mar 29, 2010 10:06 am
Location: Australia
Contact:

Re: Adding SDHC Support

Post by emu_kidid » Mon Feb 13, 2012 10:50 am

Told you... time to setup a distro with sdhc for us to use ;)
Image
User avatar
liquitt
Posts: 1753
Joined: Thu Apr 01, 2010 5:43 am
Location: neverland
Contact:

Re: Adding SDHC Support

Post by liquitt » Mon Feb 13, 2012 10:56 am

next step: patching the 3.x kernel ;)
please search before you ask - a lot has been discussed already!
(or use google with "site:gc-forever.com *term*")
http://is.gd/MDmZcr

we also have a wiki filled with knowledge
http://is.gd/dX58Rm
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Re: Adding SDHC Support

Post by _Nold_ » Mon Feb 13, 2012 11:06 am

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 ^^
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
User avatar
liquitt
Posts: 1753
Joined: Thu Apr 01, 2010 5:43 am
Location: neverland
Contact:

Re: Adding SDHC Support

Post by liquitt » Mon Feb 13, 2012 12:04 pm

get well soon!

don't forget to send this to the gc-linux mailing list :)
please search before you ask - a lot has been discussed already!
(or use google with "site:gc-forever.com *term*")
http://is.gd/MDmZcr

we also have a wiki filled with knowledge
http://is.gd/dX58Rm
User avatar
emu_kidid
Site Admin
Posts: 4485
Joined: Mon Mar 29, 2010 10:06 am
Location: Australia
Contact:

Re: Adding SDHC Support

Post by emu_kidid » Mon Feb 13, 2012 1:50 pm

nice work Noldor, rest well for a new SDHC distro awaits ;)
Image
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Re: Adding SDHC Support (Success!)

Post by _Nold_ » Mon Feb 13, 2012 4:16 pm

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 :)
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
julius
Posts: 201
Joined: Thu Nov 04, 2010 5:11 pm

Re: Adding SDHC Support (Success!)

Post by julius » Tue Feb 14, 2012 4:58 pm

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.
User avatar
liquitt
Posts: 1753
Joined: Thu Apr 01, 2010 5:43 am
Location: neverland
Contact:

Re: Adding SDHC Support (Success!)

Post by liquitt » Tue Feb 14, 2012 5:00 pm

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 ;)
please search before you ask - a lot has been discussed already!
(or use google with "site:gc-forever.com *term*")
http://is.gd/MDmZcr

we also have a wiki filled with knowledge
http://is.gd/dX58Rm
User avatar
_Nold_
Posts: 213
Joined: Mon Nov 14, 2011 7:55 am
Location: Germany
Contact:

Re: Adding SDHC Support (Success!)

Post by _Nold_ » Tue Feb 14, 2012 5:23 pm

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...
| DOL-001 (EUR) Indigo | WKF Plug'n'Play Diskdrive Replacement | BBA |
| Internalised: WaveBird, Keyboard Adapter, MemoryCard, SD-Adapter |

| DOL-001 (EUR) | >> First Gamecube Portable - Worklog
User avatar
liquitt
Posts: 1753
Joined: Thu Apr 01, 2010 5:43 am
Location: neverland
Contact:

Re: Adding SDHC Support (Success!)

Post by liquitt » Tue Feb 14, 2012 6:43 pm

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

:)
please search before you ask - a lot has been discussed already!
(or use google with "site:gc-forever.com *term*")
http://is.gd/MDmZcr

we also have a wiki filled with knowledge
http://is.gd/dX58Rm
User avatar
infact
Posts: 347
Joined: Tue Mar 29, 2011 4:35 am
Location: Germany

Re: Adding SDHC Support (Success!)

Post by infact » Tue Feb 14, 2012 8:39 pm

yep, it is already coming ;-)
infact
Image Image
Post Reply