Welcome! Log In Create A New Profile

Advanced

SD-Card support in the uBoot

Posted by Mindsmith 
Mindsmith
SD-Card support in the uBoot
September 05, 2010 11:28AM
Hello,

what must be changed in the uBoot, that i can install the Debian on the SDHC Card?
I check the Pinout of the Dockstar and find the Pin´s to add a SDHC Card, it works well.
http://plugapps.com/forum/viewtopic.php?f=6&t=258
But now? how can i change the uBoot that i can use a Debian installed on the SD Card?

Cheers
Re: SD-Card support in the uBoot
September 05, 2010 12:26PM
You'll probably just need to #define CONFIG_CMD_MMC in include/configs/sheevaplug.h and recompile/reflash uBoot. After that, you should be able to boot with something like this:

mmcinit
ext2load mmc 0 0x1100000 /uInitrd
ext2load mmc 0 0x800000 /uImage
bootm 0x800000 0x1100000

-- Jeff
Mindsmith
Re: SD-Card support in the uBoot
September 07, 2010 08:33AM
hmm, i never compile an uBoot :-((
Will you add the SD-Card support in a new uBoot version?
Twi
Re: SD-Card support in the uBoot
September 08, 2010 04:56AM
Always see that hardware people don't get into software much. Good thing opensource has a cooperative nature.

I wound love to see pictures of your SD card connected. :D Love to add SD myself but the connection points are rather tiny. Pictures = encouragement !
Mindsmith
Re: SD-Card support in the uBoot
September 10, 2010 04:28AM
I make some updates in this thread:
http://plugapps.com/forum/viewtopic.php?f=6&t=258
New Pinouts, RTC, I2S, SPI and also a picture of the SD Card connected to the Dockstar
mindsmith
Re: SD-Card support in the uBoot
September 13, 2010 02:27AM
I try to compile the uBoot with the SD-Card support. I add the #define CONFIG_CMD_MMC in include/configs/sheevaplug.h, when i compile the new uBoot i have some errors. Can somebody try it, if i make something wrong?
Re: SD-Card support in the uBoot
September 15, 2010 03:22PM
@mindsmith

I'll try it as soon as I am able to compile a good u-boot from the dockstar.
Re: SD-Card support in the uBoot
September 18, 2010 10:10PM
I compiled with CONFIG_CMD_MMC defined and I get an error as well.

u-boot/common/cmd_mmc.c:50: undefined reference to `mmc_legacy_init'

I found this thread regarding SD support for the sheevaplug MMC/SD support in u-boot that might help you.
Elfish
Re: SD-Card support in the uBoot
September 22, 2010 03:31AM
Hi,

i was wondering too if there are any news about booting from the internal sd slot?
i thought about adding it to my dockstar heh
Re: SD-Card support in the uBoot
September 22, 2010 04:15AM
You can use this patch.

http://www.mail-archive.com/u-boot@lists.denx.de/msg37087.html

We have tested and its working.

If you have flashed the DockStar with Jeff's u-boot, take a look here http://forum.doozan.com/read.php?3,1032

___
Joc
Elfish
Re: SD-Card support in the uBoot
September 22, 2010 04:27AM
Hi,

looks pretty complicated tho. could u make your pre-compiled image available somewhere?
does it include jeff's uboot changes?
would be cool if you write some kind of guide for it :).

thanks in advance
Elfish
Re: SD-Card support in the uBoot
September 22, 2010 04:40AM
I forgot to add what i'm actually trying to do.

i'd like to boot debian off a sd card instead of a usb stick. as far as i understand the stuff u wrote that should work right?
Re: SD-Card support in the uBoot
September 22, 2010 10:39AM
At the moment we have no pre-compiled image is in development stage.
The boot order part is in work. Attached is the SD patch file you can use.

Patch the downloaded uboot and go ahead with Jeff's patch.
Attachments:
open | download - dockstar_mv_sdio.patch (38.5 KB)
Re: SD-Card support in the uBoot
November 08, 2010 09:16AM
jeff is there any chance you could add sd-boot support to your uboot version?

//edit
fixed a typo



Edited 1 time(s). Last edit at 11/08/2010 04:55PM by Elfish.
Re: SD-Card support in the uBoot
November 15, 2010 04:53AM
my sd card slot should arrive soon.

any news yet? :o
Geka
Re: SD-Card support in the uBoot
November 20, 2010 10:44AM
Hye all,

You can find a revised version of the SDIO/MMC patch support for Kirkwood.

http://lists.denx.de/pipermail/u-boot/2010-November/082108.html
http://lists.denx.de/pipermail/u-boot/2010-November/082109.html

Tested on SheevaPlug.

Regards,
G.K.
awh4992
Re: SD-Card support in the uBoot
November 22, 2010 04:39PM
Yeah I have Jeff's u-boot (the latest released u-boot) patched w/ Gerald's patch above. His patch obviously only patches sheevaplug.h, but the stuff added can be copied to dockstar.h (in include/configs/) and MMC support gets built into Jeff's u-boot.

I'm relatively new at this (patching and building uboot/linux), so maybe I just don't know what I'm doing, but copying Gerald's patch outta the mailing list link and putting it into a patch file resulted in the patch command barfing on some of the lines w/ a malformed patch error. Essentially what happened is there's some lines in the patch that are supposed to be on a previous line, but they got wrapped to the next. For instance,

+ pr_debug("Error! cmd : %d, err : %04x\n", (unsigned int)cmd,
readw(SDIO_REG(SDIO_ERR_INTR_STATUS))) ;

on the mailing list needs to actually be one single line in the .patch file. Just copy/pasting results in a newline after "(unsigned int)cmd," and the patch command doesn't like this. I removed all the newlines that got copied in for long lines and then both of the patches patched fine.

Anyways, I did hack on a microsd socket to the dockstar (more or less using the pictures mindsmith provided to figure out which sd signals go where on the dockstar). The only addition I made was hooking up the SD card detect line to the correct pin on the kirkwood, which isn't pictured in midsmith's pictures. The sd card may work w/o the card detect line, but I don't know for sure. I dunno if the driver even uses the card detect line or not. Regardless, the dockstar boots debian squeeze off the microsdhc card. I didn't use Jeff's squeeze installer to install to the microsd card though. I grabbed the debian installer for arm and tftp'd that to the dockstar and ran it. Squeeze partitioned and installed nicely to the microsdhc.

If you're interested in adding the sd detect line, connect one side of the sd detect switch in your sd card socket to GND and wire the other pin of the sd detect switch to the side of R305 closest to the CPU (the square chip w/ the rubbery heat transferring stuff on it). R305 is on the top of the board (same side the CPU and most of the parts are on) pretty close to the CPU.

On an unrelated note, I also have the RTC ticking away by using mindsmith's pictures. I added parts as shown in the Marvell ref schematic and the crystal starts and my RTC saves the time between power cycles.

Andy
Re: SD-Card support in the uBoot
November 22, 2010 05:24PM
i just finished the hardware mod. i hooked up all the pins mindsmith provided by his pictures and after that i started my debian install from ubsstick.

debian detect the card without any problems. so i dont think sd-card-detect pins needed.

oh and all i need to add to dockstar.h is
#define CONFIG_CMD_MMC

right?
to enable mmc support?
awh4992
Re: SD-Card support in the uBoot
November 22, 2010 11:16PM
Well the card detect is more for detecting when a card is inserted/removed, but the kernel driver could be polling for that instead of interrupting on card detect, regardless, if the kernel sees it, that's a good sign. Anyways, you need 2 things to enable mmc in uboot: a sdio driver for Marvell kirkwood, and the proper #defines set in dockstar.h.

Gerald's patches above get you 98% of the way there as the patch provides the Marvell sdio driver and sets the necessary #defines, but sets them in sheevaplug.h instead of dockstar.h. Yes, you do need #define config_cmd_mmc, but there's like 4 other lines of #defines the patch puts in sheevaplug.h that need to be copied over to dockstar.h. I don't have the necessary lines on hand right now, but the block you need is right between the ethernet and USB block of defines (as described in the comments) in sheevaplug.h.

This is all assuming you've applied Gerald's (Geka's) patches above as they provide the sdio driver and modify other files to fully support mmc/sdio.

Hope this helps.

Andy
Re: SD-Card support in the uBoot
November 23, 2010 02:48AM
i'll try to edit the dockstar.h today and add the changes that are needed.

i somehow got a problem with the sd card. after a while the card isnt detected anymore. before that i'm able to read and write to the sd card. after some time the system hangs if i try to do fdisk -l. it seems like it's looking for the mmc card but it isnt able to find it. any idea whats wrong with it? i dont have another sd card to try :(.

regards
awh4992
Re: SD-Card support in the uBoot
November 23, 2010 09:07AM
Hmm...yea that's hard to say what's wrong there. I don't know enough about the SD support in linux to say "oh yeah, it's this problem or that problem". I suppose a good place to start would be to check your logs for any hints (/var/log). Lots of junk gets put into dmesg and syslog. Those might help you out. I'd doubt it's a software issue though as it sounds like the card does work...for a while. If you can, make your SD card wires really short (mindsmith's wires are waaaay too long in my opinion) as you might have signal integrity problems. Since I hacked on a microSD card socket, I was able to stick that right to the dockstar board and my wires are about 1/2 inch long. Avoid using ribbon cable too if you can help it. Discrete wires don't look as nice, but you should have less crosstalk between the signals which could be causing issues. If you really want the longer cable and want it to be a ribbon cable, find a wider ribbon cable such that you can tie every other wire in the cable to GND on the dockstar end. You've got plenty of GND points on the dockstar, so that shouldn't be an issue (all the bare copper lands on the perimeter of the top of the board). This'll provide some shielding to try and defeat crosstalk. Or, better yet, scavenge an old 80-conductor IDE cable as that's specifically designed for high-speed data transfers (I'm fairly certain every other wire in the cable is grounded). Believe it or not, but your SD card can be a high-speed data transfer device. Still, try to keep the whole cabling mess as short as you can.

Also be sure you're getting 3.3V for the card from a real 3.3V source, not a pull-up resistor by accident. You can get 3.3V from the opposite end of any of the resistors you soldered wires to for the SD card.

This doesn't always work, but try measuring the resistance across the resistors you're soldering wires to. They should all read around 10K. You shouldn't find any that are 0-ohm. Also, the only other real difference between what I did and what mindsmith did is I replicated the Marvell ref. schematic. I pulled out all the 10K pull ups that were installed and replaced them w/ 4.7k's as shown in the schematic. I also added the 33 ohm series termination resistor on the sd clk line as shown in the schematic (should be placed as close to the CPU as possible). My next dockstar I'm not going to replace the resistors and see how that affects things. I'd bet the 10k pullups vs. 4.7k aren't going to matter for this though.

Another thing you might need to add is a decoupling capacitor (a 0.1uF ceramic) on the SD card socket itself across 3.3V and GND. If your wires are long (long as in an inch or longer), there could be enough additional resistance in the power wires that the SD card can get starved for voltage if it takes a big gulp of current (on writes for example). The marvell schematic shows a 0.1uF and a 10uF for decoupling the sd card. Adding both would be ideal, but it's hard enough to get even 1 cap on the SD card socket let alone 2 caps. Don't use electrolytics (the can looking capacitors), as their internal series resistance makes them crappy for decoupling caps; they're meant more for bulk capacitance around the board.

What debian are you running? Just curious...

Andy
Re: SD-Card support in the uBoot
November 23, 2010 01:56PM
Thanks for your LONG reply :).

i installed a syslog daemon and got the following result:

http://pastebin.com/PqyGhMZw

doesnt seem to look that good. the cables are 20-30 cm long. and it's a ribbon cable... i guess that's why it's so shitty lol.

i might shorten the cables and try again.
i can't meassure the voltage atm.

oh and i'm running debian squeeze
Re: SD-Card support in the uBoot
November 23, 2010 02:38PM
Yeah I was just kind of spewing ideas =). Hopefully one or more of them can help you or others.

Anyways, with the log it kinda seems like your card went into a funky state as it's trying to access all sorts of sectors... I dunno, just searching google on "response 0x400b00" brings up a lot of similar problems as yours. Doesn't seem like anyone's found a solution. Maybe the SD controller doesn't like your card or the card is going bad?

I know you said you don't have another card to try, but maybe find a way to try another card before shortening your wires as that's a sucky task. You can get name brand cards pretty cheaply. Although I do have a no-name card (literally nothing stamped on it) and some sandisk 8GB cards that work fine. I have a 2gb kingston that I can mount and all, but I can't boot from it, but that's a uboot issue not linux. Once in linux I can read/write the card just fine. Although now I'm curious if I just leave it go for a while if it'll have similar issues to what you're reporting.

I was just curious about the version of debian you were using as I had issues w/ the SD when trying to get lenny going (after I couldn't get squeeze going). But then I figured out my issue w/ booting squeeze and everything was fine after that.

So...i'm pretty much out of ideas. Good luck w/ the card!

Andy
Re: SD-Card support in the uBoot
November 23, 2010 03:46PM
i might have another card at home but i can't try it before the weekend :(

the card works fine on my windows laptop. i already shortnend the wires :P
didn't help aswell

they're now single wires with a length of max 5cm

those are the messages i get after inserting the sd card.

Nov 23 22:36:38 dockstar user.warn kernel: [ 1316.300195] mmc0: host does not support reading read-only switch. assuming write-enable.
Nov 23 22:36:38 dockstar user.info kernel: [ 1316.308784] mmc0: new SD card at address e624
Nov 23 22:36:38 dockstar user.info kernel: [ 1316.314691] mmcblk0: mmc0:e624 SU01G 968 MiB
Nov 23 22:36:38 dockstar user.info kernel: [ 1316.324930]  mmcblk0: p1

thanks for your help i might try the capacitator or something if a new/other card doesnt work aswell....

i also attached a pic of the sd card socket i bought

i soldered the following scheme:

first number = pin number on the reader
second number = spot number on mindsmiths pics

1 -> 16
2 -> 17
3 -> 13
4 -> 3.3V J1 connector (see below)
5 -> 12
6 -> GND J1 connector (see below)
7 -> 14
8 -> 15
9 -> (not connected)
G -> (not connected)

J1 connector:

Pin1 >>           3.3V | GND
   JTAG RESET ? SRST ? | UART TxD
              JTAG TDI | UART RxD
          JTAG TMS CPU | JTAG NRST ? TRST ? SRST?
              JTAG CLK | JTAG TDO



Edited 1 time(s). Last edit at 11/23/2010 03:46PM by Elfish.
Attachments:
open | download - MSD_SOCKET_3.jpg (78.8 KB)
Re: SD-Card support in the uBoot
November 23, 2010 04:23PM
It looks like you've got the connections correct. I'd try a different card before trying other hardware modifications (although the ones you performed can really only help you out). The places you're pulling 3.3V and GND from are good too. That read-only switch "error" is normal as the card controller in the kirkwood doesn't support that read-only switch a lot of SD cards have as there's no pin from the CPU/controller to go to the socket =).

The only other idea I have is to try changing the partitions to a linux partition (I'm guessing it's currently a FAT partition if your windows laptop can read it?) while linux can still access the card. It almost sounded like a few people may have solved the card access issue once the card was repartitioned/reformatted. You could also stick a microsd card in a SD card adapter and try that, unless you don't have such an adapter. I'm just suggesting it since most everyone's phone seems to have a microsd card sitting in it these days.

My new dockstars should be here early next week so I'll try the mod on those w/o my additions and see what happens.

Andy
Re: SD-Card support in the uBoot
November 23, 2010 05:19PM
the sd card was formated in ext2 in the first place.

since i wanted to try it out if it even works i formated it in fat to do some tests in windows.

i'd be glad to know your test results on a "blank" dockstar :p
Re: SD-Card support in the uBoot
November 29, 2010 10:45AM
So I tried w/ a new dockstar and did the mod just as described above. Everything seems to work fine as far as I can tell. So I guess the only differences between my setup and yours are probably the SD card itself (I'm also using microsdhc, but that shouldn't matter), I have the SD detect line hooked up, and shorter wires (probably don't matter too much as you shortened yours quite a bit).

Were you able to try out a different card?
Re: SD-Card support in the uBoot
November 29, 2010 02:54PM
yup i just tested a different card
works just fine. it's a sandisk 16gb class card. i didn't hook up the sd detect line so far. will i expect any errors if i wont do so?

here are some logs:

Nov 29 21:43:25 dockstar user.warn kernel: [  406.713848] mmc0: host does not support reading read-only switch. assuming write-enable.
Nov 29 21:43:25 dockstar user.info kernel: [  406.722216] mmc0: new high speed SDHC card at address aaaa
Nov 29 21:43:25 dockstar user.info kernel: [  406.750042] mmcblk0: mmc0:aaaa SU16G 14.8 GiB
Nov 29 21:43:25 dockstar user.info kernel: [  406.754702]  mmcblk0: p1

elfish@dockstar:/tmp$ sudo hdparm -Tt /dev/mmcblk0

/dev/mmcblk0:
 Timing cached reads:   530 MB in  2.00 seconds = 264.47 MB/sec
 Timing buffered disk reads:   52 MB in  3.00 seconds =  17.33 MB/sec
Re: SD-Card support in the uBoot
November 29, 2010 03:48PM
I honestly don't know..... I'm planning on swapping cards while the unit is on and remounting...etc, but if the driver isn't using the SD detect line anyways, it won't matter.

I dunno, I'm probably gonna remove that wire and see if it still detects the card's removal.

Glad to hear everything's working fine!

Andy
Re: SD-Card support in the uBoot
November 29, 2010 04:40PM
sadly one if the wires lost its connection :(
and i dont got my solder iron with me.

gotta wait to finish my case mod until next weekend :( :(

well my card is auto detected and i guess using automount with udev rules would work aswell.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: