Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

uClinux MMC SPI Driver

Altera_Forum
Honored Contributor II
3,735 Views

Just to let everyone know, an MMC SPI Driver for Alteras SPI Core (modified) is in the works.. currently, cards can be recognized, read/write, and even partitioned.. but some bugs are being worked out. If anyone is interested in an early release, let me know....

0 Kudos
56 Replies
Altera_Forum
Honored Contributor II
1,070 Views

Hi J, 

There is a new spi driver dir in kernel 2.6.16 . Maybe you want to look at it.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I wish I knew about this before I began... I wrote all my low-level routines. Is there a driver for the NIOS SPI Core, or not yet? I will probably release the driver with my own SPI Support, and then work on integrating it with the SPI layer after...

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I didn't notice it when I was working on 2.6.16-rc4. 

But there is no NIOS SPI.  

That's OK to usr your own.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I have completed an initial revision of the MMC SPI driver, it can be checked out/dl'ed from: 

 

http://via.dynalias.org/svn/uclinux/patche..._mmc/tags/0.1.1 (http://via.dynalias.org/svn/uclinux/patches/nios_mmc/tags/0.1.1

 

This the latest stable release, and the latest is always in trunk/. 

 

Read the README file for installation instructions. 

 

The files are in the form of diff patches based on the 2.6.16 kernel (see hippos buildroot guide).  

 

Please PLEASE PLEASE post your feedback if you use this driver in THIS THREAD. This is a much more complicated driver compared to the EPCS Driver I released, so I need more feedback. 

 

Note to hippo: When the driver seems stable, could you please get this in the uClinux tree? I will keep adding diff patches on the base version until then. 

 

Also, you guys can just get my complete 2.6.16 kernel tree if you want from the /svn/uclinux/linux-2.6.16 directory using SVN.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

J. 

Awesome, it is a hardwork. 

Sure, I will add it soon. It is very helpful to keep a svn access, too.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

Thanks hippo, 

 

I forgot to add this; there is support for a status LED, configured via make menuconfig. I STRONGLY suggest those who want to use the driver to enable this feature. The reason why is currently, there is no DMAing of data. So if you are transferring any files that are reasonably large (>1 MB), your uClinux system will lock up whenever the IO Scheduler kicks in to actually do the transfer. With the LED enabled, you can see when the MMC Card is being accessed, so you know why it locks up periodically.  

 

Also, card insertion/removal is fine if it's not done in the middle of a transfer. Make sure you mount/unmount al filesystems properly before removing a card, or it will crash the kernel. Im' not sure if this is a uClinux bug or a bug in the driver. If you want to see what I mean, create/mount a filesystem on the MMC card, mount it and write a couple of files to it. Wait until it's done, and then eject the card. If you try and do an 'ls' while you are inside the filesystem, it will hang because the dev. node is no longer active. This is a relatively minor bug though.  

 

The overall speed is more of an issue if anything. Suggestions are welcomed.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

..there seems to be a problem with large files. If you try to do a 'dd' command with something like 10 Megs for a filesize, something goes wrong, but it doesn't even seem to get to into the MMC Driver before it crashes. If anyone has any suggestions, or can replicate the same thing, let me know..

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

You may check the scatter list management. I will check on my hardware, too.

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I executed this command which causes it to crash: 

# dd if=/dev/zero of=./zero_file bs=1024 count=1000 

 

I don't think it's the MMC driver because I tried this on a mounted CF card, and it failed as well. This means it's either something in the kernel, or something else in my hardware (RAM likely).  

 

I am using 2.6.16.1. Could you try this when you get some time hippo? I'm quite sure it's not MMC because I can view debugging messages, as well as my status LED, and it doesn't even enter the MMC routines. Maybe the kernel bails because of lack of memory, but I don't get any errors on the console. 

 

I also don't think it's hardware because I downloaded a previous kernel build using 2.6.11 with a CF driver, and tried writing 10 Megs using the same command, and it worked without a problem. I couldn't try the MMC Driver because the MMC layer changed a bit. 

 

The only other thing I can think of is that I'm using an older version of busybox, so maybe it doesn't like the new kernel..
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I repeated the tests on a usb disk with kernel 2.6.16.1. It had page allocation failure for very large files (>200MB). I am checking other kernels.

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

so basically you don't think it's my kernel build, and it's something else? I removed the MMC driver completely from the build, and just left in the CF driver, and it bailed for files over 1 MB... maybe I will try it on a different board with the same kernel and see what happens.

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I think it should be a mm problem on all newer kernels. I have tested 2.6.15.6, it has the same failure.

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

Will you or anyone else be loooking into this problem? I have no clue where to start! I am going to try back-porting my driver to 2.6.11 since that's the last known working kernel for me. It's a shame because I switched to 2.6.16.1 because I thought it was better!

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I am checking this problem, and I think I should be able to solve it. Thank you for helping find out this problem, and sorry for it.

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

No need for apologies!! Bugs are inevitable, I just wasn't sure if you handled these kinds of problems... your work in releasing new kernels has been excellent so far though!  

 

Please let me know if you need any help resolving this... i'll hold off on back-porting my driver.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

There are some changes in kernel header include for newer kernels. And I track them step by step. I had similar problems before, and I have to search and find out from 2.6.11 , 2.6.12, 2.6.13 .... . 

It won't take long anyway.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

hey hippo, I was taking a look around kernel.org, and I browsed the changelog for 2.6.17-rc1. It had some stuff about paging in there.. would it be faster for you to patch your kernel tree instead of trying to find the problem?

0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

Thanks, I will try. 

The code that we shall fix are mostly in the arch/nios2nommu/ kernel and mm dir . 

 

This is how I port to a new kernel. 

First, add the patch of linux-2.6.xxx-uc0 from uClinux.org (if one is available). 

I would copy arch/nios2nommu and include/asm-nios2nommu to a new kernel. 

Then try to compile with only the minimal config. I will move other drivers last. 

When there are problems, I used to check them with other arch , eg, sh and h8300, to find the problem. 

Maybe you can help to find out.
0 Kudos
Altera_Forum
Honored Contributor II
1,070 Views

I would be more than happy to help out, but it's a very bad time for me right now (final exams), so I won't be able to do anything for a few weeks. I barely had time to finish off the first working version of the MMC driver... and I still need to get the I2C driver working for the OpenCores I2C Host component. If you haven't got around to it in a few weeks, I will take it up. Let me know of your progress if you do anything

0 Kudos
Altera_Forum
Honored Contributor II
999 Views

I am working on it , right now. Still cleaning from 2.6.11 to 2.6.12 .

0 Kudos
Reply