It looks like this thread is receiving exquisitely little attention from any experts. However, I would still like to add my experiences and cry for help to it.
I have a newly purchased LPC-2478STK board from Olimex. It does exactly the same thing as leilani describes during mmc_init. The system is recognizing the SD card, but the hang seems to occur when the fat driver tries to read the first block of the disk. Not sure yet if this is a software problem or a hardware problem.
I have turned on the board many times using the same SD card, and just one time it actually made it past the hang and booted into Linux. However, I have not been able to repeat this result. Have no idea what made the difference, except maybe bumping the card just right, a funny look on my face, or maybe a well-placed static discharge. It might be associated with fiddling with an ethernet plug. I tried getting a different SD card, but it still hangs.
FWIW, the system always boots just fine from USB. However, I need the USB port to drive a UBW, so can’t give it up for a boot drive. There’s no really good reason not to be able to boot from SD, especially since the quick start documentation gives that as one of the options.
Please, Olimex, if you are listening, help us solve this problem so we don’t have to struggle through this.
it would not hang and then after it all works goed and I can even boot from mmc.
however I still was not able to automatic start from mmc.
Are you distinguishing Mulit-Media Card from Secure Digital? I am using an SD card, not an MMC.
It sounds like you are saying that you are able to boot from card (which I assume is actually an SD unless you correct me) as long as you start it up manually first, rather than having uBoot start it automatically. I would have to recheck this, but my experience is that manual startup has no different a result than automatic startup. Furthermore, there is not obvious reason why it should be different, since the automatic startup is just a script that executes the same commands one would issue manually.
Are you sure that you have exactly the same problem? Specifically, the problem is that the card hangs during startup, and at a very specific point: just after reading the card info and during the attempt to read the first block of the volume.
“startup” = the process of activating the device for reading
“boot” = loading the OS into memory and handing execution over to it
There are two problems with the u-boot code as it comes from Olimex:
The interrupt vectors are not properly copied to SRAM during initialization. This causes the board to crash when it first tries to run code that depends on interrupts. MMC code is the prime instance of this. But note that USB code does not use interrupts (at least as far as I could tell).
The MMC code uses block size in an inconsistent way. When using larger sized media, this causes buffer overruns on the stack, crashing the system.
Solutions:
Fix the u-boot initialization: in board/lpc_2478_stk/lowlevel_init.c, at the top of lowlevel_init(), find the code commented “move vectors to beginning of SRM” and modify the assembly code to read as follows:
" ldmia r0!, {r3-r10} \n"
" stmia r2!, {r3-r10} \n"
" ldmia r0, {r3-r10} \n"
" stmia r2, {r3-r10} \n" : : :
Leave all the other code above and below these 4 lines the same. What this does is remove the “NE” condition from each opcode, so that they always execute rather than executing conditionally. This also copies an additional 4 bytes that aren’t currently used, but that could be used if one wrote FIQ code.
Fix MMC: in board/lpc_2478_stk/mmc.c, within mmc_block_read(), modify this line
for ( j = 0; j < hw_sect_size; j+=4 )
to instead read
for ( j = 0; j < BLOCK_LENGTH; j+=4 )
This hack enables my SD cards sized >= 1GiB to work. I also modified DEFAULT_SECTOR_SIZE in disk/part_dos.h, but it proved unnecessary for some reason (don’t remember now). The mmc code, and perhaps the part_dos code as well, requires further attention by someone who really understands it.
king_8210:
I have already modified mmc.c and part_dos.h.
But the result is the same.
My SD card (512MB) can work , but another (4GB) can’t .
It’s hard to help without sitting there with you and your code. Some suggestions:
There are several paths through part_dos.h that set DEFAULT_SECTOR_SIZE, depending on your configuration. The key is to make sure that it is defined to be at least as large as the physical read size of your device. I believe the physical read size is printed out when mmc initializes the device. Just comment out all relevant #ifdefs and hard code the size to be at least what you need. Otherwise, you get a buffer overrun on the stack when it reads a block from disk, which crashes the system when it attempts to return from the function call. (Like I said before, it seems that I ended up not needing this fix for some reason, but don’t remember why, so maybe it really is necessary after all.)
There may be issues with the file system. Is you 4GiB card formatted to FAT32?
In general, the way I figured stuff out was to put a lot of print statements in the code, leading up to the point of failure. Basically, read the code, figure out how it is expecting to work, and then print out key variables and see if they satisfy those assumptions. Eventually, you will find the breakage.