miniSD card code examples... VC21BR1 manual says there are some....

14 views
Skip to first unread message

PeterW

unread,
May 3, 2008, 10:31:09 PM5/3/08
to Virtual Cogs
I wanted to get the SD card working on the BreakOut Cog (Or the MX21
Cog), and reading the manual it says there is example code availabel
on the wiki.. but the wiki just refers you to the manual ... infinite
loop.

Is there any code available, I'm doing this natively, no linux
involved.

And pushing ,my luck here.. is there a read/write implementation of
FAT32 available by any chance :-) (I'll be using a High Capacity SDHC
card)

Cheers..

Oh.. and can I just say how much I'm impressed with the Virtual Cogs
hardware and the support... and with CrossWorks from Rowley.co.uk, for
the personal license its a great deal with all sorts of examples
including a free multitasking environment...awesome.

Dan Foisy

unread,
May 4, 2008, 11:42:44 AM5/4/08
to virtu...@googlegroups.com
Hi Peter,

Unfortunately, we were supposed to get the standalone MMC/SD stuff
working (in SPI mode only) for another project but that fell through and
we just never around to getting some code together. The controller is
relatively simple to use and more info on the MMC cards can be found here:
http://elm-chan.org/docs/mmc/mmc_e.html - general explanation and link
to FAT file system
http://www.sandisk.com/Assets/File/OEM/Manuals/ProdManRS-MMCv1.3.pdf
http://www.mmca.org/compliance/buy_spec/

Note that this is all working in Linux though...

Dan

--
Daniel Foisy
Virtual Cogs Embedded Systems Inc.
Unit 4, 5694 Highway 7 East, Suite 311
Markham, Ontario, Canada L3P 1B4
www.virtualcogs.com
416-238-2231

"Your future is modular"

Peter

unread,
May 4, 2008, 7:03:50 PM5/4/08
to virtu...@googlegroups.com
No problem Dan.

Actually although the english is a little suspect, the discussion is
quite useful and there is some code linking to a 'standard' library of
FAT32/16/12 code in this link off one of the pages you pointed to..
http://elm-chan.org/fsw/ff/00index_e.html

I'll let you know how I get on...

Thanks,

Peter

RCrowder

unread,
May 5, 2008, 5:50:31 PM5/5/08
to Virtual Cogs
Hi Peter,

I was looking at just this at the end of last year. Alas other
projects and paid work have hampered further progress. One interesting
thing I did manage to achieve was the use of the uMon API. Annoyingly
my long post here on this, is hidden away in another post;
http://groups.google.com/group/virtualcogs/browse_thread/thread/a0413bdfbcdfa9c4/c414d1ef94b41a9c?hl=en&lnk=gst&q=crowder#c414d1ef94b41a9c

If you upgrade to the latest uMon, it is now supplied with DOSFS (v1.9
added the support). The only thing you need, when you recompile uMon,
is to flip some #defines and supply two functions to block read/write
to the BR1 SD card (if my memory recalls correctly). With it all setup
it can then be possible to use the uMon API to access FAT file system
on the BR1 SD card :)

Hope that helps, Richard.

RCrowder

unread,
May 29, 2008, 7:12:39 AM5/29/08
to Virtual Cogs
I've spent some time having a look further at this. Following the
reference manual and application notes for the i.MX21, I've got the
SDHC-2 module setup, sorted out card initialisation mode clock rate,
and managed to get the SD card reset and CMD0 sent. At the moment I'm
stuck issuing the ACMD41 (getting response timeouts). All of this is
being setup using the uMon API, with the latest uMon version (so
includes FAT/DOS FS support).

Quick questions;
Is there an external pull-down resistor connected to DAT3 (SD2_D3
line)? Maybe through PA25?
Is the driving strength important? (DS_SLOW7 of DSCR1)?
Should I really be doing this via SPI instead of the SDHC-2 module? :)

Thanks, Richard.

RCrowder

unread,
May 30, 2008, 6:24:42 PM5/30/08
to Virtual Cogs
I think I've now got these initial questions solved. I've been making
headway reading through the coglinux source code, as well as finding
better documentation and example code (i.MX based). Hopefully by the
end of the weekend I'll have moved from Card Identification mode to
Data Transfer mode :) and then onto setting up cfInit, cfRead, and
cfWrite (uMon needed function hooks for FAT/DOS FS).

A few further links for others following..
An easier doc to read than the SanDisk Product Manuals -
http://www.sdcard.org/about/host_controller/
Someone else using an i.MX SDHC - http://www.rtems.com/ml/rtems-users/2005/december/msg00051.html
Freescale have a few useful Application Notes -
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=i.MX21&nodeId=0162468rH311432973ZrDR&fpsp=1&tab=Documentation_Tab

RCrowder

unread,
Jun 1, 2008, 12:56:51 PM6/1/08
to Virtual Cogs
YAY!!! I've just managed to call 'fatfs ls' and 'fatfs cat
testfile.txt' from within uMon to a SD card in the VC21BR1 (using the
latest uMon tarball v1-15)

The code is really raw at the moment, and has limited support for SDHC
cards. SD card initialization, single block reads (no DMA), works fine
with a SanDisk 16MB card and a SanDisk 1GB card. Now I need to look at
using DMA for block reading. Then that can be duplicated for the block
writing code :)
Finally tidy up the code, add more error checking, and work out how
this can be published for beta testing, so others can get there hands
on this new feature..

Regards, Richard.

Randy Smith

unread,
Jun 1, 2008, 9:44:49 PM6/1/08
to virtu...@googlegroups.com
Nice work Richard! Hope you'll finalize your code very soon. :P

RCrowder

unread,
Jun 5, 2008, 9:21:33 AM6/5/08
to Virtual Cogs
Thanks Randy. I'm progressing, slowly, but getting there.

Just come across Spectec microSD SDIO devices :O (http://
www.spectec.com.tw/index.htm). So a bit distracted looking at the SDIO
manuals...

RCrowder

unread,
Jun 15, 2008, 8:22:43 AM6/15/08
to Virtual Cogs
So here's where I have got to so far;

Card Initialization;
This has been working great with Sandisk 16MB and Sandisk 1GB microSD
cards. Support has been added to detect MMC, SD, SDHC, and SDIO. Only
the SD path has been tested. I don't have access to a SDHC or SDIO
card, so that needs further testing. Plus I don't think MMC cards fit
into the VC21BR1 microSD slot, so don't envisage further work on the
MMC path. I'm hoping that at least the SDHC path is correct.

Read/Write;
Single block read/write (no interrupts or DMA) has been tested in
isolation. Writing 128 single blocks of test patterns works, and they
can be read back correctly. Support has been added to loop across
multiple blocks, but that hasn't been tested. SDHC card (and 4 bit
bus) support has been added but not tested.

uMon FATFS/DOSFS;
Using the latest version of uMon (v1.15), cf functions have been added
that hook into the SD init, read, and write functions. CF can
initialize the SD card and provided the function hooks to DOSFS. FATFS
can then be used to ls, cat, and get a file from the SD card into TFS.
I came across problems using rm, qry, and put FATFS commands. put
command seemed to work, but Windows (XP and Vista) complained that the
file was corrupt :S So I tried a different route to test the SD init,
read, and write functions...

EFSL (Embedded Filesystems Library);
I grabbed the latest stable CVS version of EFSL (v0.2.9), and updated
it with Martin Thomas's upgrades (see link below). Then dropped in
support for VCMX212. A simple uMon API based test program using this
EFSL library, can read a text file from the SD card, and write out a
copy of the file contents to a new file on the SD card. Windows can
read this new text file back from the SD card :)

EFSL - http://efsl.be/
Martin's changes - http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/efsl_arm/index.html


So... Not sure how to share all this with the group?
I could wrap up and document the upgrade procedure for uMon...
Zip up my working EFSL library directory and test program...
Email people the couple of C/H files that implement the SDHC code...

Any suggestions?


On Jun 5, 2:21 pm, RCrowder <richard_crow...@btinternet.com> wrote:
> Thanks Randy. I'm progressing, slowly, but getting there.
>
> Just come across Spectec microSD SDIO devices :O (http://www.spectec.com.tw/index.htm). So a bit distracted looking at the SDIO

RCrowder

unread,
Jun 16, 2008, 3:20:48 PM6/16/08
to Virtual Cogs
I've had a look at SourceForge and GoogleCode, deciding to try out
GoogleCode.
Here's a link to the project http://code.google.com/p/robotvisionexp/
The 'Source' tab allows you to browse the SVN repository, with
instructions on how to check-out from it.

craighyatt

unread,
Jul 25, 2008, 2:30:35 PM7/25/08
to Virtual Cogs
Nonworking Sandisk miniSD card?

The Sandisk microSD cards with miniSD adapter kits (http://
www.sandisk.com/Products/ProductInfo.aspx?ID=2327) may not work
because, as mentioned earlier, the microSD cards aren't required to
support SPI.

The original non-adapter miniSD cards (http://www.sandisk.com/OEM/
ProductCatalog(1268)-miniSD_Memory_Card.aspx) work fine with the
original unmodified Virtual Cogs code.

If you want to do a quick test without modifying any VC code, try a
non-adapter miniSD 256MB available in camera shops, etc. for about
$10USD and, if that works OK, look for a larger capacity device.
Reply all
Reply to author
Forward
0 new messages