Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
3,788 Views

mounting 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, 

Asaf
0 Kudos
37 Replies
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

thanks but I'm into the free stuff :) 

maybe I configured somthing wrong in the IP...
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

Hi, 

 

 

--- Quote Start ---  

Hi everyone, 

http://www.nioswiki.com/operatingsystems/uclinux/mmcsd 

didn't work... 

 

--- Quote End ---  

 

 

What claims does your kernel say? 

 

Kazu
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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!
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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 

mmc0: new SD card on SPI mmcblk0: mmc0:0000 TWTTI 124672KiB mmcblk0: p1 p2 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 type 

root> mount -t vfat /dev/mmcblk0p1 /mnt 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? 

 

Kazu 

 

 

0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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?
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

btw, I'm using Terasic's DE0 dev board if it helps...

0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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 

 

mount -t vfat /dev/mmcblk0 /mnt 

 

I get Invalid argument error 

any ideas?
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

I have the same problem&#65292;don't know how to handle it. 

just display the message above ,no other messages,who can give me helps? 

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
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

... This output seems OK. What is the problem ?  

-Michael
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

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 

... 

 

but when I try to moun it 

 

/> mount -t vfat /dev/mmcblk0p1 /mnt 

mount: mounting /dev/mmcblk0p1 on /mnt failed: No such device or address 

 

 

 

I have insert 4GB SDcard&#65292;but cannot found the message above and cannot mount it. 

———————————————————————————————— 

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 

——————————————————————————————————
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

(using the drivers as modules), to allow for Linux and Windows formatted cards, which uses different partition tables)I do this: 

 

modprobe mmc_block 

modprobe mmc_spi# sd card formatted by Windows (no parition table) 

mount -t vfat /dev/mmcblk0 /mnt/sdcard# sd card formatted by Linux (first parition) 

mount -t vfat /dev/mmcblk0p1 /mnt/sdcard
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

I want know why after I use nios2-terminal command, I cann't see the display messages above,is the hardware problem or pin assign problem? 

"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 

 

 

DO you means that I should download the zImage and mmc_block.o and mmc_spi.o at first ?and modprobe mmc_block and mmc_spi ?  

I make zImage with mmc_block.o and mmc_spi.o. 

 

"nios2-linux/uClinux-dist/linux-2.6.x/drivers/mmc/host/mmc_spi.o" 

"nios2-linux/uClinux-dist/linux-2.6.x/drivers/mmc/card/mmc_block.o"
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

Sorry. Most of your messagge does not make sense to me. Please rephrase. 

 

I suppose the "Read only switch" is not supported by the hardware. 

 

-Michael
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

again: 

 

At first, after command nios2-download and nios2-terminal,just display " 

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 other message as 

 

"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 

 

follow your suggestion ,I have donwnload zImage , mmc_block.o and mmc_spi.o,and modporbe it ,but display errors like  

:modprobe : chdir <2.6.30>no such file or directory.
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

I see this:  

 

 

========================================================== 

Command: mkdir /mnt/sdcard  

Command: /etc/mount_sdcard  

Shell invoked to run file: /etc/mount_sdcard  

Command: modprobe mmc_block  

Command: modprobe mmc_spi  

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  

Command: mount -t vfat /dev/mmcblk0 /mnt/sdcard  

mmc0: host does not support reading read-only switch. assuming write-enable.  

mmc0: new SD card on SPI  

mmcblk0: mmc0:0000 121 MiB  

mmcblk0:  

Command: mount -t vfat /dev/mmcblk0p1 /mnt/sdcard  

mount: mounting /dev/mmcblk0p1 on /mnt/sdcard failed: No such device or address  

Execution Finished, Exiting  

============================================================= 

 

Thus mmcblk0 is mounted, while mounting /dev/mmcblk0p1 fails, as this is a Windows-formatted SD-Card without a partition table.  

 

-Michael
0 Kudos
Highlighted
Valued Contributor III
10 Views

Re: mounting SD Card on uClinux

why I cannt see the message at the process of uclinux startup? 

like 

Command: mount -t vfat /dev/mmcblk0 /mnt/sdcard  

mmc0: host does not support reading read-only switch. assuming write-enable.  

mmc0: new SD card on SPI  

mmcblk0: mmc0:0000 121 MiB  

mmcblk0:  

Command: mount -t vfat /dev/mmcblk0p1 /mnt/sdcard  

mount: mounting /dev/mmcblk0p1 on /mnt/sdcard failed: No such device or address  

Execution Finished, Exiting  

 

and when I typed "mount -t vfat /dev/mmcblk0 /mnt/sdcard " 

also display "No such device or address 

"
0 Kudos