[En-Nut-Discussion] SDCARD Interfacing with SAM7X

Tim DeBaillie debaillie at ciholas.com
Thu Mar 1 20:58:32 CET 2007


On Thu, 1 Mar 2007, Tim DeBaillie wrote:

> OK, I have traced it down to the MmCardMount function in dev/mmcard.c.
>
> The actually failure is on the check for fcb->fcb_part.part_type==PTYPE_EMTPY
>
> PTYPE_EMTPY is defined as 0x00, and sure enough fcb->fcb_part.part_type==0.
>
> The whole fcb setup in MmCardMount is rather odd to me, but I will see if I 
> can trace it further.  If anyone can help please do so.

Ok, I believe I have found a bug.  The "partno" variable in MmCardMount 
(dev/mmcard.c) is always set to 0 when you use:

_open(MY_BLKDEV_NAME ":1/" MY_FSDEV_NAME, _O_RDWR | _O_BINARY)

(in my case MY_BLKDEV_NAME = "MMC0" and MY_FSDEV_NAME="PHAT0")

The problem is that _open in crt/open.c splits the first paramater string 
into "MMC0" and ":1/PHAT0".  It then calls MmCardMount with these two 
strings.  Then MmCardMount uses "atoi" to get the partition number.  It 
unfortunately is using atoi on the first character in ":1/PHAT0", which 
returns 0, not 1.

So, if I am correct, one of two things should be changed:

1) _open in crt/open.c should pass "MMC0" and "1/PHAT0" (no : in the 
second string)

2) MmCardMount should increment the pointer in the second string before 
using partno=atoi.

Once I overwrote the partno with partno=1, I was able to use all three of 
my SD cards in binary write mode.

Comments, problems, suggestions welcome,

Tim



More information about the En-Nut-Discussion mailing list