Adding GPIO and SPI to the mini2440 kernel

emeb
Hey all,

I've successfully added GPIO and SPI drivers to the 2.6.32-2 kernel of my
mini2440 board. I've described the process on my website here:

http://members.cox.net/ebrombaugh1/embedded/mini2440/index.html

I hope this is useful. Please let me know if you have any questions about
or corrections to the material.

fatbrain
Hi
Thanks emeb. I was using Angstrom kernel build for SPI & GPIO .
How about adding IRQ handling to userspace. For example in the angstrom
build I can do a select or poll on IRQ 52 (key 1)  in /proc/irq/52 I can
get a count of the times it has been pressed. 

--regards
fatbrain

emeb
fatbrain - 

Thanks for looking that over and your comments. I'll check into what's
required to add the user-space IRQ support. If it's just a config option it
should be pretty easy to do.

H4med
Thank you emeb :)
you tutorial works well, Now I have access to GPIO thru command line, But
do you have any C Programs that uses GPIO syscalls method for mini2440?
A very simple that just turns on and off a pin, say GPE15 will suffice.

Thanks in advance.

emeb
H4med -

I'm glad that was helpful for you. I don't yet have any C code to talk to
the GPIO sysfs, but that is something I need to do soon. I'll post it when
I get it working.

davef
Have a look at:

http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO

h4med
emeb -

I have a Problem, I've installed new complied Kernel, it has gpio class and
I have access to gpio thru command line and every thing is ok, but when I
reboot, the system dose not work at all just a black screen!
DNW says that linux loading... but the screen has nothing!
but if I reboot with DNW (by pressing 'b') it reboots correctly. It seems
that something dose not work well when I reboot manually...

manual Reboot:
---------------------------------------------------------------------
load Image of Linux...Uncompressing
Linux......................................................................
............................................................ done, booting
the kernel.
.
.
etc


DNW Reboot:
---------------------------------------------------------------------
Enter your selection: b
Copy linux kernel from 0x00060000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc
console=ttySAC0"
MACH_TYPE = 1999
NOW, Booting Linux......
Uncompressing
Linux......................................................................
............................................................ done, booting
the kernel.


pls help me!

emeb
Did you flip the NAND/NOR switch back to NAND position?

h4med
yes, that's ok.

h4med
in DNW Configuration, the USB address is always 0x30000000, or it differs
for bootloader, kernel etc.. ? it seems that it has an "boot address
loading problem"!

as I wrote before boot from DNW works well and as it shows below, DNW dose
some copy stuff!:

DNW Reboot:
---------------------------------------------------------------------
Enter your selection: b
Copy linux kernel from 0x00060000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc
console=ttySAC0"
MACH_TYPE = 1999
NOW, Booting Linux......
Uncompressing
Linux......................................................................
............................................................ done, booting
the kernel.
.
.
etc....

but manually rebooting dose not do that:

manual Reboot:
---------------------------------------------------------------------
load Image of Linux...Uncompressing
Linux......................................................................
............................................................ done, booting
the kernel.
.
.
etc ,...

emeb
Sorry - no idea what's wrong. Mine boots fine.

sunitha
Hi emeb,

 I am new to mini2440. I need to handle interrupts. 
You were planning to write some code to handle the interrupts
in userspace. Did you get to it?

If not, I want to write some driver to handle the interrupt.

I have done pci based drivers but am bit confused on how to
do a request_irq on this board. How would the kernel map
which IRQ to the isr. Is it that one generic ISR will be
 registered and  in the isr we will figure out which irq triggered.

Thanks

Xristos
emeb
in your manual you say "or else upgrade your entire NAND installation to
use more up-to-date firmware"
I am "in or else"!
Is there a manual of how to do this?
Is it enough το upgrade the supervivi to the last version or
replace it with u-boot from the friendlyARM-downloads?

emeb
Sunitha,

I don't recall saying I was going to work on interrupt processing. You must
be confusing me with someone else.

emeb
Xristos,

I don't know precisely what's required to update your entire NAND
installation - perhaps the Chinese version of the FriendlyARM manual has
details on how to do that. It should be fairly simple though - just
download the NAND images of the kernel and filesystem from the FriendlyARM
website and use supervivi to transfer them into the NAND.

Xristos
emeb,
I compiled a kernel according to your instruction and it seems to work. I
had problems with kernel partition size and I needed to enlarge it. but
when I tried to use the new file-system I encountered the problem I
describe here:
http://www.friendlyarm.net/forum/topic/661#lastpost
Now I flashed u-boot and I will try to run emdebian with your kernel since
I didn't fount a solution to the previous problem.
Do you happen to know, how do I add sys/class/gpio if I have a working
system? "which I hope to have soon".

Thanks for the help "the kernel instruction was wonderful :)

Chinmay Duvedi
Hello everyone

I am relatively new to handling the linux kernel

I have the linux kernel 2.6.29. I recompiled it to include the gpio drivers
But now the size of the zImage is going beyond 2MB.
What seems to be the problem?
Have i included some extra options while compiling?

PS I could not get make menuconfig to work... so i am using make config

Thanks in advance for any help

Cheers

davef
Do you get an error message when you try to do <menuconfig>?  Just a guess,
something to do with ncurses?

davef
Try left hand search function with
<big kernel>

Did you put more than gpio in?

Chinmay Duvedi
Hi davef
There is an error message.. and yes it is about ncurses
i could not manage to install ncurses on my pc
so i used <config> instead of <menuconfig>
But i have knid of solved the issue
I repartitioned the system... so that my kernel partition is now 3MB
instead of 2MB
I also shifted the root partition so as to avoid an overlap
Now i am able to port the kernel zImage with the configurations for gpio
and spi on my system

But now there is  a different problem
When i boot the system from the NOR flash... ie. from the BIOS menu it
works fine
But the system does not boot at all from the NAND flash 
what could be wrong

Th only changes i have made are:
1. repartitioning as explained above
2. In linux command line in the boot parameters i changed 
 "root=/dev/mtdblock2" to "root=/dev/mtdblock3"

Apart from this everything is the same

where am i going wrng?
Also could you give me a guideline as to what you mean by "mtdblock" and
"zImage"

sorry for the newbie questions

Thanks in advance
Chinmay

dave
Chinmay,

There have been several recent posts about your "won't boot from NAND
flash" problem.  I haven't tried changing kernel partition size.

zImage is created when you do a kernel compilation, it seems to be the
default.  A zImage is loaded by Supervivi.  If you want to use u-boot then
you use mkimage (with the correct switches) to generate a uImage.

You will find mtdblock in /dev, 
http://www.linux-mtd.infradead.org/faq/jffs2.html
and maybe try Wikopedia.

payam
hi emeb i watched your suggestioned webpage and i compilied a linux kernel
with that configuraton files but i can't use gpio from shell yet..whould
you please help me?

payam
my problem with gpio has solved...any body can tell me how i can use the
spi driver?

dave
Read this one:

http://members.cox.net/ebrombaugh1/embedded/mini2440/index.html

dave
payam,

Sorry, you must have it's at the top of the post.  Knew I found it
somewhere!

Chinmay Duvedi
hi dave
Thanks for the links

Chinmay

nabil
thanks a million emeb 
your tutorial is really rich and helpful

max2440
Hi emeb,
   I have micro2440 with 7'lcd & i followed your tutorial step by step
http://members.cox.net/ebrombaugh1/embedded/mini2440/index.html

after i port the zImage to board nothing comes up on the console nor on the
display need help.

davef
With the necessary changes in display type?

Regards,
not emeb

ecepero
hello
i not have a folder gpio y my system

What I do?

Kovax
Please, can anybody share the compiled version of Linux for Mini2440 with
enabled GPIO and SPI? It will help me a lot!

Thanks for it!

saeed
please help me
 i can not access the step by step guide website for spi. is there any
other resource that i can use? or any one can send me that tutorial?

srinivasan K
I am not able to open the link

Xristos
Here is a zip with the emeb's page and the needed files:
http://dl.dropbox.com/u/6983593/emeb_kernel.zip

I had downloaded the page in case it brakes one day.
open Compiling_kernel_emeb.zip inside to see the page.

It's an old kernel but it works.
You will have problems if you try to run new angstrom (openembedded)
filesystems ("/dev/misc/rtc: file not fount" or something like that).
I thing there is a work around if you are willing to modify .conf

I now try to add SPI support in a kernel built this way:
http://billforums.station51.net/viewtopic.php?f=4&t=20

I added spi with menuconfig but something is missing.
I will propably try to use the script from emeb kernel

Xristos
If you have the will to adapt the emeb kernel for new angstrom this will
probably help:
http://dominion.thruhere.net/koen/cms/recommended-kernel-config-options-...

Xristos
Attachment: mach-mini2440.c (21.38 KB)
I posted a more analytic answer here:
http://billforums.station51.net/viewtopic.php?f=4&t=792
And I attach the mini-mach