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
--- Quote Start --- Have you edited your dts file with mmc-spi-slot? See section 3.2 in my uClinux_nios2.pdf document. --- Quote End --- Hi, Thanks for your respond. I got it to work and thanks to Alex Hornung. Problem: 1) device tree spi_0: spi@0x140 { compatible = "ALTR,spi-altera_avalon_spi", "ALTR,spi-1.0"; reg = < 0x00000140 0x00000020 >; interrupt-parent = < &myCPU >; interrupts = < 3 >; /*# address-cells = < 1 >; */ <-comment out/*# size-cells = < 0 >; */ <-comment out mmc-spi@0 { <- make sure is named mmc-spi compatible = "mmc-spi-slot"; spi-max-frequency = < 10000000 >; reg = < 0x00000000 >; voltage-ranges = < 3300 3300 >; <-missing important piece }; //end mmc-slot@0 }; //end spi@0x140 (mmc_spi) 2) menuconfig - Make sure selection is [*] and not [M] 3) of_mmc_spi.c <-there is a bug for (i = 0; i < num_ranges; i++) { const int j = i * 2; u32 mask; u32 vdd_min = be32_to_cpu(voltage_ranges[j]); u32 vdd_max = be32_to_cpu(voltage_ranges[j + 1]); mask = mmc_vddrange_to_ocrmask(voltage_ranges[j],
voltage_ranges[j + 1]);
mask = mmc_vddrange_to_ocrmask(vdd_min, vdd_max); if (!mask) { ret = -EINVAL; dev_err(dev, "OF: voltage-range# %d is invalid\n", i); goto err_ocr; } oms->pdata.ocr_mask |= mask; }
- Altera_Forum
Honored Contributor
Hi
When i insert the SD card i get the below message and also can't mount the SD Card root:/dev> mmc0: SD Status: Invalid Allocation Unit size. mmc0: host does not support reading read-only switch. assuming write-enable. mmc0: new SD card on SPI mmcblk0: mmc0:0000 SD512 478 MiB mmcblk0: p1 root:/dev> mount -t vfat /dev/mmcblk0 /mnt mount: mounting /dev/mmcblk0 on /mnt failed: No such device root:/dev> mount -t vfat /dev/mmcblk0p1 /mnt mount: mounting /dev/mmcblk0p1 on /mnt failed: No such device root:/dev> I also format the sdcard with FAT32 and 512byte but it doesn't help Please give me some suggestion to fix the problem - Altera_Forum
Honored Contributor
Hi,
It's a good sign if you see it detect the SD Card size. I am using a 2 GB SD Card so perhaps you may want to try a bigger size memory? Also, to make sure you enabled the [*] fat32 in file system doing kernel setup. I hope this help. --- Quote Start --- Hi When i insert the SD card i get the below message and also can't mount the SD Card root:/dev> mmc0: SD Status: Invalid Allocation Unit size. mmc0: host does not support reading read-only switch. assuming write-enable. mmc0: new SD card on SPI mmcblk0: mmc0:0000 SD512 478 MiB mmcblk0: p1 root:/dev> mount -t vfat /dev/mmcblk0 /mnt mount: mounting /dev/mmcblk0 on /mnt failed: No such device root:/dev> mount -t vfat /dev/mmcblk0p1 /mnt mount: mounting /dev/mmcblk0p1 on /mnt failed: No such device root:/dev> I also format the sdcard with FAT32 and 512byte but it doesn't help Please give me some suggestion to fix the problem --- Quote End --- - Altera_Forum
Honored Contributor
Hi, all.
May be, it's too late to answer, but my message may help someone in the future and one question still left regarding this topic. --- Quote Start --- Please give me some suggestion to fix the problem --- Quote End --- Well, next step is definitely simple: Lets look at the devices, configured in the system:
OK, our MMC card is configured as block device and had major number 179./# cat /proc/devices Character devices: 1 mem 2 pty 3 ttyp 4 ttyS 5 /dev/tty 5 /dev/console 5 /dev/ptmx 10 misc 128 ptm 136 pts 153 spi 204 ttyUL Block devices: 1 ramdisk 259 blkext 179 mmc <--- Got it!
We see two devices with major = 179. The first one with minor number 0 is MMC (SD) card itself and the second with number 1 is the first (and last in my case) partition on the card. The problem is that "ls /dev/" command shows nothing about MMC, but we can make device node manually via mknod command:/# ls /sys/dev/block/ | grep 179 179:0 179:1
Thats it! Well, but I still do not know, how to make next step: say system to create /dev/mmcblk0p1 node automatically and have root partition on my SD card during boot. Thanks all for this topic, it was helpful. PS: Well, there was almost nothing magic. On BB: 1. Format your SD card in ext2 or ext3. 2. Copy busybox content into SD 3. (For paranoics like me :) ) Create static node /dev/mmcblk0p1 on SD using mknod with major:minor numbers 179:1 4. [MAGIC] Edit kernel boot parameters with "root=/dev/mmcblk0p1" and (this is important!) "rootdelay=3". The "rootdelay" parameter says kernel to wait until root partition initialization complete. Three seconds was enough in my case. [/MAGIC] Thats all, folks. :)/# mknod /dev/mmcblk0p1 b 179 1 /# mount /dev/mmcblk0p1 /mnt/ /# ls /mnt simpleImage.xilinx.ub vmlinux - Altera_Forum
Honored Contributor
Hello i am trying to implement SDCard in my DE2-115 and i've followed the steps described in the# 6 post. However i get this error in the linux boot process spi_altera: pobe of d000900.spi failed with error -16.
There appears to be a mmc in proc/devices though. Any ideas? Can i use the default clock frequency of SPI 3 wire? I think it's 128khz. Solved it! It was a problem with EPCS ADDRESS SPAM being too high, it was going in the SPI 3 wire address spam - Altera_Forum
Honored Contributor
I feel like it's really slow to read/write in the SDCard. It's formated with FAT file system and my NIOS2 is running at 100mhz.
Any tips? - Altera_Forum
Honored Contributor
Hi,
--- Quote Start --- I feel like it's really slow to read/write in the SDCard. It's formated with FAT file system and my NIOS2 is running at 100mhz. Any tips? --- Quote End --- Please refer to the next, http://www.alterawiki.com/wiki/linux_with_mmu_on_veek/t-pad or http://www.alteraforum.com/forum/showthread.php?t=25605 . Kazu