Forum Discussion
Altera_Forum
Honored Contributor
16 years agomounting SD Card on uClinux
Hi everyone,
I'm trying to implement a fat file system on sd card I followed the instructions for Altera SPI Core on this page http://www.nioswiki.com/operatingsystems/uclinux/mmcsd didn't work... was I suppose to use SPI (3 wire) IP? thanks, Asaf37 Replies
- Altera_Forum
Honored Contributor
Yep.
Using the fast (nonSPI) SD-Card interface interface requires joining the SD-Card Organization and paying money for the license. So you need to stick with the slow SPI interface, unless you want to do so. There are commercial SD-Card IP-Cores available that enable the use of this interface. -Michael - Altera_Forum
Honored Contributor
thanks but I'm into the free stuff :)
maybe I configured somthing wrong in the IP... - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- Hi everyone, http://www.nioswiki.com/operatingsystems/uclinux/mmcsd didn't work... --- Quote End --- What claims does your kernel say? Kazu - Altera_Forum
Honored Contributor
well, I'm still stuck
I thought I'd see something like this --- Quote Start --- Freeing unused kernel memory: 676k freed (0x1f6000 - 0x29e000) mmc0: new SD card on SPI mmcblk0: mmc0:0000 TWTTI 124672KiB mmcblk0: p1 p2 --- Quote End --- on boot, as ashown in nioswiki so I thought of a few possible problems 1. pin assignments 2. IP core not configured as should 3. driver not loaded now I'm down to either it's an IP problem or driver problem so just to make sure again it is Altera's SPI (3 wire interface) IP, right? not someone else's similar IP? and if so could someone show me the right configuration? Thanks again, Asaf - Altera_Forum
Honored Contributor
I just recently went through getting the SD card working on my DE2-70 board and was able to finally mount my 4 GB SD card with a standard vfat file system. Here's what I did, let us know if this helps you get yours working...
1) I started my project by using the DE2_70_NET project found on Terasic's DE2-70 CD freely available on their site. I'd start with that if you happen to be using that board. In any case, it might be a good reference. I had to remove the GPIO pins they used for SD card access as it's not compatible with the uClinux MMC/SD/SDIO over SPI driver. Then I added a new component "SPI (3 wire serial)" to my SOPC builder design called mmc_spi (I think the name matters as uClinux drivers look for it) at base address 0x09606000 (address probably doesn't matter as long as there's no conflict). 2) I had to change the assignment of pins in the top level design (DE2_70_NET.v), removing references to SD_* components which no longer exist, and adding the following lines starting at 549 (seemed like a good place)... Line 549: // the_mmc_spi (SD Card Slot) Line 550: .SCLK_from_the_mmc_spi(oSD_CLK), Line 551: .MOSI_from_the_mmc_spi(SD_CMD), Line 552: .MISO_to_the_mmc_spi(SD_DAT), Line 553: .SS_n_from_the_mmc_spi(SD_DAT3), Then I compiled the design. 3) Changes to the Kernel config: (Anything not explicitly shown as added was kept as is, if it was added by default I left it alone and didn't remove it) -- forgive underscores here, I can't get this forum to properly indent with whitespace --> Device Drivers ___ * --> SPI Support _________* Altera SPI Controller --> Device Drivers ____* --> mmc/SD/SDIO Support _________* mmc/SD/SDIO over SPI --> File Systems ___--> Native Language Support _______* Codepage 437 (US, Canada) _______* NLS ISO 8859-1 (Latin 1... 4) Recompiled the kernel. 5) Booted the design. If things went well, you should see something like this as your kernel boots (without a card installed)... mmc_spi spi2.0: ASSUMING SPI bus stays unshared! mmc_spi spi2.0: ASSUMING 3.2-3.4 V slot power mmc_spi spi2.0: SD/MMC host mmc0, no DMA, no WP, no poweroff <No further mmc_sip messages at bootup> With my 4 GB SD card inserted it'll look like this... mmc_spi spi2.0: ASSUMING SPI bus stays unshared! mmc_spi spi2.0: ASSUMING 3.2-3.4 V slot power mmc_spi spi2.0: SD/MMC host mmc0, no DMA, no WP, no poweroff <A few other lines of booting messages> mmc0: host does not support reading read-only switch. assuming write-enable. mmc0: new SDHC card on SPI mmcblk0: mmc0:0000 SD04G 3.69 GiB mmcblk0:Command: mount -t proc proc /proc -o noexec,nosuid,nodev p1 Then at the command prompt provided mount is in your kernel's app config somewhere (I think it is by default?) just type the following... /> mount -t vfat /dev/mmcblk0p1 /mnt /> ls -l /mnt drwxrwxrwx 3 root root 4096 Oct 17 2009 FPGADev drwxrwxrwx 2 root root 4096 Nov 29 16:04 NewFolder -rwxr-xr-x 1 root root 20 Nov 2 2009 newerfile.txt /> Hopefully that'll show you what's on your SD card! I hope this helps you out. Good Luck! - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- so I thought of a few possible problems 1. pin assignments 2. IP core not configured as should 3. driver not loaded --- Quote End --- The kernel messages
show that your SD card has 124672Kbyte volume and 2 partitions. If it is right, please consider well why your kernel knows such thing. Without several communications between your kernel and SD, it can't display those information. And did you execute the 'mount' command? For example, please typemmc0: new SD card on SPI mmcblk0: mmc0:0000 TWTTI 124672KiB mmcblk0: p1 p2
to mount your SD's partition 1 for /mnt. (Opps, before to do this, please check the major number of /dev/mmcblk0p1 with 'ls /dev/mmcblk0p1 -l'. The number must be 179.:D) ...And, what is the claim? Kazuroot> mount -t vfat /dev/mmcblk0p1 /mnt - Altera_Forum
Honored Contributor
hi eltoddo,
thanks for the help but 1. my design is written in vhdl so, not *_top.v 2. I did the rest of the steps but with or without the sd card I get no mmc_spi message at boot any idea why? - Altera_Forum
Honored Contributor
btw, I'm using Terasic's DE0 dev board if it helps...
- Altera_Forum
Honored Contributor
ok, here's an update
it appears that there's a BIG difference between [*] and <M> (my bad;) ) so the good news are that it worked only when I selected my options as [*] the bad new are... well... when I use
I get Invalid argument error any ideas?mount -t vfat /dev/mmcblk0 /mnt - Altera_Forum
Honored Contributor
ok, now it's officialy closed!
I just needed to format my sd card using mkfs.vfat command or through windows :S anyway, thanks for all your help and support! :D