Glomation

Peer Support Forums => GESBC-9260 => Topic started by: admin on December 29, 2008, 05:27:09 PM



Title: GPIO driver
Post by: admin on December 29, 2008, 05:27:09 PM
The attached file contains a simple GPIO driver that allows access of GPIO pins from user space.  The pre-built module is for Linux 2.6.25 and the following pins are configured,

    PA6
    PB0
    PB1
    PB2
    PB3

The test program simply reads the GPIO pins and print out the result.



Title: Re: GPIO driver
Post by: Jerry Wong on January 12, 2009, 06:30:54 PM
Which pins on the 9260 are configurable for GPIO?


Title: Re: GPIO driver
Post by: xfactor69 on January 13, 2009, 04:06:21 AM
I installed the gpio driver and did a modprobe on it.  The module seemed to load as lsmod shows:
Module                  Size  Used by
GPIO_driver             3332  0

The /dev/gpio device doesn't seem to be there and the gpio-test program show nothing when it runs.

Advice?

Thanks,
ml


Title: Re: GPIO driver
Post by: admin on January 13, 2009, 09:17:46 AM
The user's manuals lists GPIO in detail in table 7 for GESBC-9260 and table 6 for GESBC-9260S.  Any pin that is not listed in the function column can be used as GPIO by user.

The GPIO driver provided here is for demostration purpose only as the main line kernel will have GPIO driver available in new releases.  The GPIO driver does not create the device node automatically.  The /dev/gpio node should be created manually using the following command,

    mknod /dev/gpio c 250 0

The test program only reads and prints out the input of the GPIO pins "hard" configured by the GPIO driver.



Title: Re: GPIO driver
Post by: Rahim Pardhan on January 21, 2009, 11:40:26 PM
What is the maximum allowable voltage on GPIO? Also how do I switch between peripheral A and peripheral B?

Thanks,

Rahim


Title: Re: GPIO driver
Post by: admin on January 22, 2009, 09:11:07 AM
The GPIO pins are connected directly to the AT91SAM9260 CPU.  They are 3.3V I/O ports.

Please refer to AT91SAM9260 data sheet on how to configure multiplexed I/O pins.


Title: Re: GPIO driver
Post by: admin on July 03, 2009, 11:12:34 AM
The 2.6.30 kernel now has the GPIO support.  The following steps can be used to set GPIO as out put and control the value directly at command line,

echo {port number} > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio{port number}/direction
echo "1" > /sys/class/gpio/gpio{port number}/value
sleep 3
echo "0" > /sys/class/gpio/gpio{port number}/value

The port number of GPIO PA0 is 32, port number of PB0 is 64, and port number of PC0 is 96.

Attached is a pre-compiled 2.6.30 kernel image for GESBC-9260/B/S.  The kernel patch is available at http://maxim.org.za/at91_26.html (http://maxim.org.za/at91_26.html)


Title: Re: GPIO driver
Post by: billyc on July 30, 2009, 03:32:58 AM
My understanding is that the 2.6.30 kernel's GPIO driver also support button connected to GPIO. I would like to connect a button to one of GPIO pin. When the button is pressed, an event will be sent to user space application. Could you give us an example showing how to do that?


Title: Re: GPIO driver
Post by: admin on July 30, 2009, 09:42:38 AM
The button driver in the kernel is for 2 of the buttons on the AT91SAM9XXX-ek boards.  If you use other GPIO pins as button input you need to implement your own button driver.   See http://kerneltrap.org/mailarchive/git-commits-head/2009/6/30/6112383 (http://kerneltrap.org/mailarchive/git-commits-head/2009/6/30/6112383) and http://bec-systems.com/site/281/how-to-implement-an-interrupt-driven-gpio-input-in-linux (http://bec-systems.com/site/281/how-to-implement-an-interrupt-driven-gpio-input-in-linux)


Title: Re: GPIO driver
Post by: aldo82 on August 12, 2009, 05:42:59 PM

Hi, I've probed the AT91-GPIO driver, it works good. I've been trying to cross-compile the file GPIO-driver.c in order to generate the file GPIO-driver.ko, but I've had some problems.

I obtained a lot of mistakes when I put the next sentence:

[redes@localhost Prog_board]$ arm-unknown-linux-gnu-gcc -O2 -D__KERNEL__ -DMODULE -I/home/redes/pruebas/kernel1/linux-2.6.25/include - c GPIO-driver.c -o GPIO-driver.ko

What am I doing wrong??


The attached file contains a simple GPIO driver that allows access of GPIO pins from user space.  The pre-built module is for Linux 2.6.25 and the following pins are configured,

    PA6
    PB0
    PB1
    PB2
    PB3

The test program simply reads the GPIO pins and print out the result.


Title: Re: GPIO driver
Post by: admin on August 13, 2009, 08:03:05 AM
Cross compiling kernel module can be complicated as it needs to check running kernel version, symbol tables etc.  Easiest is compile it native.

Since the 2.6.30 now have GPIO support included in the kernel it is better to use the new version of the kernel.


Title: Re: GPIO driver
Post by: gaurav.joshi on September 02, 2009, 10:37:01 AM
Admin Quote:

"echo {port number} > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio{port number}/direction
echo "1" > /sys/class/gpio/gpio{port number}/value
sleep 3
echo "0" > /sys/class/gpio/gpio{port number}/value

The port number of GPIO PA0 is 32, port number of PB0 is 64, and port number of PC0 is 96."



I am trying to use PC23 to PC31 on the Table 6 on 9260S as GPIO pins. According to above port numbering scheme , this should correspond to port numbers  119 to 127. But it does'nt seem to take any values more than 99.

Suggestions/help?




Title: Re: GPIO driver
Post by: admin on September 02, 2009, 01:07:33 PM
The PC16 - PC31 lines are used data bus D16 - D31 on AT91SAM9260-ek and GESBC-9260.  The GESBC-9260S uses 16 bit wide data bus so the PC16 - PC31 is available as GPIO.  Because the mainline kernel is build for AT91SAM9260-ek board the PC16 - PC31 probably is not in the GPIO driver.  You need to check the kernel source code and may need modification to enable those lines.


Title: Re: GPIO driver
Post by: gaurav.joshi on September 02, 2009, 03:24:55 PM
Thanks but it doesn't seen to take any values > 99 (PC5) according to the table. Not Just that , it seem to be missing some value in between also like 79 , 80 etc ...
Is there a rule for that OR how can I enable them in kernel?



Title: Re: GPIO driver
Post by: admin on September 02, 2009, 03:33:23 PM
Best thing to do is to read the kernel GPIO driver source code to find out why.

The GPIO driver of kernel version 2.6.30 and up reads in the PIO_PSR register to determine if the GPIO pin requested is in alternate function mode and will enable the GPIO pin if it is not.  The GESBC-9260/B/S uses some of the pins that is set as alternate function on the AT91SAM9260-EK board as GPIO.  To use these pins as GPIO the kernel can be modified to set the desired GPIO pins to I/O functions.  Or use devmem2 utility to set the PIO_PER register in user space to enable them as GPIO pins for the GPIO driver.


Title: Re: GPIO driver
Post by: gaurav.joshi on September 03, 2009, 08:49:22 AM
Ok Thanks


Title: Re: GPIO driver
Post by: tom on January 08, 2010, 10:21:27 AM
Hi, Could someone explain how to install this driver and get it working? I have used the mknod command and this works, but when compiling the makefile it gives me a syntax error! I am a complete linux beginner so any help would be really appreciated.


Title: Re: GPIO driver
Post by: admin on January 08, 2010, 10:51:12 AM
Upgrade to a newer version of kernel to use the built-in GPIO driver is a better choice.


Title: Re: GPIO driver
Post by: tom on January 13, 2010, 08:34:52 AM
The 2.6.30 kernel now has the GPIO support.  The following steps can be used to set GPIO as out put and control the value directly at command line,

echo {port number} > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio{port number}/direction
echo "1" > /sys/class/gpio/gpio{port number}/value
sleep 3
echo "0" > /sys/class/gpio/gpio{port number}/value

The port number of GPIO PA0 is 32, port number of PB0 is 64, and port number of PC0 is 96.

Attached is a pre-compiled 2.6.30 kernel image for GESBC-9260/B/S.  The kernel patch is available at http://maxim.org.za/at91_26.html (http://maxim.org.za/at91_26.html)


Hi, I am very new to linux and am just trying to interface with the I/O pins. I have installed kernel 2.6.30 as suggested and tried to do the steps above but get the following error when i try the 2nd line. I have done the 1st line, which was...

/ # echo "out" > /sys/class/gpio/gpio{32}/

I got no error with this, which i assume means that it worked as expected.

error from 2nd line can be seen below...

/ # echo "out" > /sys/class/gpio/gpio{32}/direction
-sh: can't create /sys/class/gpio/gpio{32}/direction: nonexistent directory

I guess i'm probably making a really simple mistake, hopefully someone can help me?

also is there anyway to implement these command lines into a c file so that my gesbc-9260 is talking to I/O pins when it starts up?


Title: Re: GPIO driver
Post by: admin on January 14, 2010, 08:14:49 AM
The commands should be,

echo 32 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio32/direction
echo "1" > /sys/class/gpio/gpio32/value
sleep 3
echo "0" > /sys/class/gpio/gpio32/value

You can use system function call in your C program or use the sample program from here http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO#gpio-sysfs (http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO#gpio-sysfs)


Title: Re: GPIO driver
Post by: Maturity on January 24, 2010, 06:23:20 PM
...

Attached is a pre-compiled 2.6.30 kernel image for GESBC-9260/B/S.  The kernel patch is available at http://maxim.org.za/at91_26.html (http://maxim.org.za/at91_26.html)


Is there a emdebian rootfs image that works with this kernel?  Everything that I have tried for the 9260 from the Glomation support page seems to panic when it is starting.

M


Title: Re: GPIO driver
Post by: admin on January 25, 2010, 09:07:16 AM
The factory installed file system should work with any kernel.  Please check your U-boot MTD partition parameters.  The NAND FLASH name for the Atmel processor based hardware has been changed from kernel version 2.6.27 and up.


Title: Re: GPIO driver
Post by: Maturity on January 25, 2010, 01:47:13 PM
I will have a go at updating just the kernel to the 2.26.30 version with u-boot and see how that turns out.  Thank you.

m


Title: Re: GPIO driver
Post by: Maturity on January 29, 2010, 10:36:56 PM
I have managed to install the precompiled 2.6.30 kernel and even tried the 2.6.27.4 kernel but neither seem to present a /sys/class/gpio directory to write to. What step have I missed ?

# echo 32 > /sys/class/gpio/export
-sh: can't create /sys/class/gpio/export: nonexistent directory
# ls /sys/class
bdi           mem           net           scsi_disk     usb_host
display       misc          ppp           scsi_host     vc
firmware      mmc_host      rtc           tty           vtconsole
input         mtd           scsi_device   usb_endpoint

I even tried the 2.6.30 kernel from at91.com with unchanged result.


m


Title: Re: GPIO driver
Post by: admin on February 01, 2010, 08:36:10 PM
The 2.6.30 kernel posted in this thread has been verified to have a working GPIO driver.


Title: Re: GPIO driver
Post by: Maturity on February 02, 2010, 07:34:02 AM
Dear admin,

Before answering this question please keep in mind that we here are not experts in embedded devices, nor is that likely to change in the near term.  Our goal is just to get these things programmed and start deploying them.  To this end answers saying the NAND flash name had changed meant helped not that much.  But being told that it was changed from at91_nand to atmel_nand enabled us to figure out what to change and make some progress.

The 2.6.30 kernel posted in this thread has been verified to have a working GPIO driver.

That just reiterates what was stated previously in this thread.  We have two boards, one with the 2.26.30 kernel and the other with the factory image (2.6.27.4 I think).  They both respond as I have indicated in my earlier post.  Keeping mind our understanding level can you tell us :

1) in a simplified step-by-step fashion how to wiggle the IO's. Both devices have a /sys directory but not /sys/class/gpio/ and do not seem to respond positively to /sys/class/gpio/export or /sys/class/gpio/gpio*

2) where to find the C compiler includes and libraries that support writing to the IO's.  We have managed to find programs that apparently write to the gpio pins but they make use of functions like map() that are undefined when using the native or cross compiler solutions available on the glomationinc/support.html page.  FYI I have seen at least one other unanswered request for this particular info in this forum as well.

m


Title: Re: GPIO driver
Post by: admin on February 02, 2010, 10:00:40 AM
There isn't any step by step instructions on how to create the /sys/class/gpio.   When the 2.6.30 kernel is used with the factory installed file system the directory is created automatically.  The instructions in previous posts gave exact commands needed to operate the GPIO pins.



Title: Re: GPIO driver
Post by: Maturity on February 02, 2010, 12:56:49 PM
There is nobody in the office that can try it right at this moment but I will give it a go when I get back later this afternoon.  However I believe that we tried this combination already (the uImage-2.6.30 from your earlier append and the 9260rootfs.img from http://glomationinc.com/support.html ).  Or are you referencing a different rootfs imagemg as the "factory" version.

Below are the instructions that we have tried but the very first step failed in all cases (as shown previously).  So if the uImage02.6.30 is enabled for GPIO and the 9260rootfs.img is the right one there remains a missing link.

The 2.6.30 kernel now has the GPIO support.  The following steps can be used to set GPIO as out put and control the value directly at command line,

echo {port number} > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio{port number}/direction
echo "1" > /sys/class/gpio/gpio{port number}/value
sleep 3
echo "0" > /sys/class/gpio/gpio{port number}/value

The port number of GPIO PA0 is 32, port number of PB0 is 64, and port number of PC0 is 96.
...

m


Title: Re: GPIO driver
Post by: Maturity on February 05, 2010, 12:52:45 PM
Sorry for the delay in responding, I had some education and customer issues of my own to deal with. The bottom line is that We finally got it working! Here are some clues that might help the next person. Plus a couple more questions.

What we have determined is that the /sys/class/gpio only seems to appear when using the file system from Glomation :
http://glomationinc.com/Support/9260/9260rootfs.img
or the prebuilt one from at91.com :
ftp://www.at91.com/pub/oe/deploy/glibc/images/at91sam9263ek/Angstrom-console-image-demo-glibc.rootfs.jffs2

Also you must have the uImage-2.6.30 from this thread, we have found *no* other that will present /sys/class/gpio  the 2.6.27.4 kernel that is shipped on the board does not seem to present the gpio's.  This is the one you want.
http://glomation.net/smf/index.php?action=dlattach;topic=27.0;attach=20

IMHO I had hoped that the pre-built image from linux4sam would have worked as I really like the heartbeat pulse of the onboard LED.  It makes a nice indicator to see when opening the cabinet that the board is running.  Does anyone know if it is possible to write a user (non kernel) program to get this effect with the uImage-2.6.30 image? Or will there be a Glomation kernel that supports it?  In any case here is the kernel that has the heartbeat:
ftp://www.at91.com/pub/linux/2.6.30-at91/linux-2.6.30-at91-exp-at91sam9260ek.bin

So in summary you need
uImage: http://glomation.net/smf/index.php?action=dlattach;topic=27.0;attach=20
rootfs: http://glomationinc.com/Support/9260/9260rootfs.img

The other combinations of uImage and rootfs, including the emdebian stuff in the zip of 9260 files don't seem to present /sys/class/gpio.

~~~~~~
For those that are keen we have set up Eclipse environments to do the development in, it was fairly simple and should enable debug though nobody has needed to even try that yet.  This is what works for us on Linux.

Go to http://www.eclipse.org/downloads/ and download the version of "Eclipse IDE for C/C++ Developers (79 MB)" for your platform. Unpack it into /usr/local then add the following to your .bashrc :
export PATH=$PATH:/usr/local/eclipse

Start Eclipse and go to Help->Install_New_Software and click the Add... button.
In the dialog add Zylin CDT as the name and http://opensource.zylin.com/zylincdt as the location.  If you unpacked the archive as root then you will need to be doing this as root in order to update the files.  You should then be able to install "Zylin Embedded CDT".  Go ahead and install it then shutdown Eclipse.

Download the cross compiler from glomation's support page (http://glomationinc.com/support.html):
http://glomationinc.com/download/Generic-arm_gcc-4.2.3-glibc-2.3.3.tar.bz2
And unpack it to get it to end up in  /usr/local as well.  Then add another line to your .bashrc
export PATH=$PATH:/usr/local/arm/gcc-4.2.3-glibc-2.3.3/arm-unknown-linux-gnu/bin

Start Eclipse and create a C project.  When it is created right-click on it and bring up the properties.  Then in C/C++ Build->Settings change the compiler and linker from gcc to arm-unknown-linux-gnu-gcc and the assembler from as to arm-unknown-linux-gnu-as for [All Configurations].  Then go to C/C++ General->Paths and Symbols, make sure the Includes tab is selected then select C Source File. Next click add and navigate to the include directory of the cross compiler. It is /usr/local/arm/gcc-4.2.3-glibc-2.3.3/arm-unknown-linux-gnu/arm-unknown-linux-gnu/include IIRC.  If you need to manually add the libraries they would be at the same level as the include I think.

Additionally, I found that you can get a free Jazz (RTC) Express-C server and clients for 10 users. So the plan is to use RTC to track this work and source. 
https://jazz.net/downloads/rational-team-concert/releases/2.0.0.2?p=allDownloads#expressc
~~~~~~

Now to create an api set to manage the gpio's. With any luck our second development board will get updated to the same level of kernel and rootfs without problems as well.

m


Title: Re: GPIO driver
Post by: Maturity on February 12, 2010, 04:16:51 PM
A couple of observations if anyone is keen.

GPIO 41 appears to control the red LED on the board.

When you switch the direction to "out" the GPIO will be driven low from the floating high level of the input mode.  Even writing a 1 to the value beforehand does not seem to prevent this transition.

m


Title: Re: GPIO driver
Post by: admin on February 16, 2010, 09:49:03 AM
The kernel GPIO driver is only available from 2.6.30 and up.  That is already mentioned in previous posts.

The heart beat is a kernel feature that you can configure in your kernel build.



Title: Re: GPIO driver
Post by: anee_jose on February 18, 2010, 01:16:14 AM
hi,
i have compiled linux 2.6.30 with gpio driver support. i am using max7322 gpio expander chip. for normal gpio pins avaiable in at91sam9260-ek i could use the pin addresses like AT91_PIN_PA1, AT91_PIN_PB2... etc, how can i call set_gpio_output() function for the gpios in the expander chip? is there any macros defined for these gpios in the driver ?

thanks

Aneesh Jose


Title: Re: GPIO driver
Post by: Lorena on March 11, 2010, 06:24:24 AM
Sorry for the delay in responding, I had some education and customer issues of my own to deal with. The bottom line is that We finally got it working! Here are some clues that might help the next person. Plus a couple more questions.

What we have determined is that the /sys/class/gpio only seems to appear when using the file system from Glomation :
http://glomationinc.com/Support/9260/9260rootfs.img
or the prebuilt one from at91.com :
ftp://www.at91.com/pub/oe/deploy/glibc/images/at91sam9263ek/Angstrom-console-image-demo-glibc.rootfs.jffs2

Also you must have the uImage-2.6.30 from this thread, we have found *no* other that will present /sys/class/gpio  the 2.6.27.4 kernel that is shipped on the board does not seem to present the gpio's.  This is the one you want.
http://glomation.net/smf/index.php?action=dlattach;topic=27.0;attach=20

IMHO I had hoped that the pre-built image from linux4sam would have worked as I really like the heartbeat pulse of the onboard LED.  It makes a nice indicator to see when opening the cabinet that the board is running.  Does anyone know if it is possible to write a user (non kernel) program to get this effect with the uImage-2.6.30 image? Or will there be a Glomation kernel that supports it?  In any case here is the kernel that has the heartbeat:
ftp://www.at91.com/pub/linux/2.6.30-at91/linux-2.6.30-at91-exp-at91sam9260ek.bin

So in summary you need
uImage: http://glomation.net/smf/index.php?action=dlattach;topic=27.0;attach=20
rootfs: http://glomationinc.com/Support/9260/9260rootfs.img

The other combinations of uImage and rootfs, including the emdebian stuff in the zip of 9260 files don't seem to present /sys/class/gpio.

~~~~~~
For those that are keen we have set up Eclipse environments to do the development in, it was fairly simple and should enable debug though nobody has needed to even try that yet.  This is what works for us on Linux.

Go to http://www.eclipse.org/downloads/ and download the version of "Eclipse IDE for C/C++ Developers (79 MB)" for your platform. Unpack it into /usr/local then add the following to your .bashrc :
export PATH=$PATH:/usr/local/eclipse

Start Eclipse and go to Help->Install_New_Software and click the Add... button.
In the dialog add Zylin CDT as the name and http://opensource.zylin.com/zylincdt as the location.  If you unpacked the archive as root then you will need to be doing this as root in order to update the files.  You should then be able to install "Zylin Embedded CDT".  Go ahead and install it then shutdown Eclipse.

Download the cross compiler from glomation's support page (http://glomationinc.com/support.html):
http://glomationinc.com/download/Generic-arm_gcc-4.2.3-glibc-2.3.3.tar.bz2
And unpack it to get it to end up in  /usr/local as well.  Then add another line to your .bashrc
export PATH=$PATH:/usr/local/arm/gcc-4.2.3-glibc-2.3.3/arm-unknown-linux-gnu/bin

Start Eclipse and create a C project.  When it is created right-click on it and bring up the properties.  Then in C/C++ Build->Settings change the compiler and linker from gcc to arm-unknown-linux-gnu-gcc and the assembler from as to arm-unknown-linux-gnu-as for [All Configurations].  Then go to C/C++ General->Paths and Symbols, make sure the Includes tab is selected then select C Source File. Next click add and navigate to the include directory of the cross compiler. It is /usr/local/arm/gcc-4.2.3-glibc-2.3.3/arm-unknown-linux-gnu/arm-unknown-linux-gnu/include IIRC.  If you need to manually add the libraries they would be at the same level as the include I think.

Additionally, I found that you can get a free Jazz (RTC) Express-C server and clients for 10 users. So the plan is to use RTC to track this work and source. 
https://jazz.net/downloads/rational-team-concert/releases/2.0.0.2?p=allDownloads#expressc
~~~~~~

Now to create an api set to manage the gpio's. With any luck our second development board will get updated to the same level of kernel and rootfs without problems as well.

m



Hello,

Only a question. How did you update the root File System, I mean , I am flashing GESBC-9260 and updating kernel and file system to a 2.6.30 version. I am following the steps given in GESBC-9260 User`s Manual in "Loading Linux Kernel and root File System".The kernel was right updated but I am not sure how to update the root File System. What are the values of the parameters [available_nand_flash_memory_size] and &(filesize) for this comands:
nand erase 0x400000 [available_nand_flash_memory_size]
t 0x21000000 rootfs.img
nand write.jffs2 0x21000000 0x400000 &(filesize)

Thank you in advance!


Title: Re: GPIO driver
Post by: admin on March 11, 2010, 10:10:57 AM
The file system does not have to be updated when updating the kernel unless you build a new file system that must be used to replace the existing one.

The erase size parameter can be calculated with the following formula,

          NAND_FLASH_SIZE - 0x40000

The 0x400000 is used by the boot loader and kernel in the factory FLASH partition.
The 128MB FLASH is 0x8000000 in total size.  The erase size for the file system will be 0x8000000 - 0x400000 = 0x7c00000

The write size can be calculated by the U-boot itself.  The $(filesize) tells the U-boot to use the download data size.





Title: Re: GPIO driver
Post by: Lorena on March 12, 2010, 04:30:43 AM
The file system does not have to be updated when updating the kernel unless you build a new file system that must be used to replace the existing one.

The erase size parameter can be calculated with the following formula,

          NAND_FLASH_SIZE - 0x40000

The 0x400000 is used by the boot loader and kernel in the factory FLASH partition.
The 128MB FLASH is 0x8000000 in total size.  The erase size for the file system will be 0x8000000 - 0x400000 = 0x7c00000

The write size can be calculated by the U-boot itself.  The $(filesize) tells the U-boot to use the download data size.






Thanks for your soon reply!


Title: Re: GPIO driver
Post by: laszlo on March 14, 2010, 11:30:50 AM
I'm also having troubles with the GPIO classes.

First, if I use the pre-built 2.6.30 kernel, the "echo 32 >export" command does not create gpio32, so the subsequent commands fail with a non-existent directory error. But if I use 64 or 96 instead of 32, it works fine - gpio64 or gpio96 is created and I can manipulate it.

This is with the pre-compiled kernel image from message 6.

Second, I downloaded the 2.6.30 kernel sources from kernel.org, applied the patch from message 6, created a uImage and successfully booted it. In that case, only "echo 96 >export" works.

So 96 always works, 64 works with the precompiled image and 32 never works.

Any thoughts? Is there some initialization step missing? Would it be possible for you to post the .config file used to build the pre-compiled image?

Thank you,

Laszlo


Title: Re: GPIO driver
Post by: laszlo on March 14, 2010, 08:11:14 PM
I found the config file for the precompiled 2.6.30 kernel in /proc/config.gz and rebuilt with it. I now get the same results with my build of the kernel as with the precompiled kernel image - 32 doesn't work, but 64 & 96 do.

Laszlo


Title: Re: GPIO driver
Post by: admin on March 15, 2010, 08:44:56 AM
Almost all of the GPIOs are multiplexed pins.  The GPIO driver will check the port setting before it enables the GPIO function.  The kernel configuration can affect which GPIO pins are available because of the multiplexing.  Please check the processor data sheet and SBC user's manual to make sure your kernel configuration does not have conflict with your GPIO usage.  Certain GPIO pins that are not used by the kernel may not have the port function register (PIO_PER) set correctly.  You need to check the data sheet and set the port for GPIO in order to use them.


Title: Re: GPIO driver
Post by: Lorena on March 15, 2010, 09:56:46 AM
The button driver in the kernel is for 2 of the buttons on the AT91SAM9XXX-ek boards.  If you use other GPIO pins as button input you need to implement your own button driver.   See http://kerneltrap.org/mailarchive/git-commits-head/2009/6/30/6112383 (http://kerneltrap.org/mailarchive/git-commits-head/2009/6/30/6112383) and http://bec-systems.com/site/281/how-to-implement-an-interrupt-driven-gpio-input-in-linux (http://bec-systems.com/site/281/how-to-implement-an-interrupt-driven-gpio-input-in-linux)

Hello,

I need to implement an interrupt driven GPIO input in Linux for detecting changes of value in a GPIO pin. It isn´t a key. What is the right path for the driver?I don´t find the /dev/input directory.

Thank you very much.


Title: Re: GPIO driver
Post by: Lorena on March 17, 2010, 10:42:33 AM
Sorry for the delay in responding, I had some education and customer issues of my own to deal with. The bottom line is that We finally got it working! Here are some clues that might help the next person. Plus a couple more questions.

What we have determined is that the /sys/class/gpio only seems to appear when using the file system from Glomation :
http://glomationinc.com/Support/9260/9260rootfs.img
or the prebuilt one from at91.com :
ftp://www.at91.com/pub/oe/deploy/glibc/images/at91sam9263ek/Angstrom-console-image-demo-glibc.rootfs.jffs2

Also you must have the uImage-2.6.30 from this thread, we have found *no* other that will present /sys/class/gpio  the 2.6.27.4 kernel that is shipped on the board does not seem to present the gpio's.  This is the one you want.
http://glomation.net/smf/index.php?action=dlattach;topic=27.0;attach=20

IMHO I had hoped that the pre-built image from linux4sam would have worked as I really like the heartbeat pulse of the onboard LED.  It makes a nice indicator to see when opening the cabinet that the board is running.  Does anyone know if it is possible to write a user (non kernel) program to get this effect with the uImage-2.6.30 image? Or will there be a Glomation kernel that supports it?  In any case here is the kernel that has the heartbeat:
ftp://www.at91.com/pub/linux/2.6.30-at91/linux-2.6.30-at91-exp-at91sam9260ek.bin

So in summary you need
uImage: http://glomation.net/smf/index.php?action=dlattach;topic=27.0;attach=20
rootfs: http://glomationinc.com/Support/9260/9260rootfs.img

The other combinations of uImage and rootfs, including the emdebian stuff in the zip of 9260 files don't seem to present /sys/class/gpio.

~~~~~~
For those that are keen we have set up Eclipse environments to do the development in, it was fairly simple and should enable debug though nobody has needed to even try that yet.  This is what works for us on Linux.

Go to http://www.eclipse.org/downloads/ and download the version of "Eclipse IDE for C/C++ Developers (79 MB)" for your platform. Unpack it into /usr/local then add the following to your .bashrc :
export PATH=$PATH:/usr/local/eclipse

Start Eclipse and go to Help->Install_New_Software and click the Add... button.
In the dialog add Zylin CDT as the name and http://opensource.zylin.com/zylincdt as the location.  If you unpacked the archive as root then you will need to be doing this as root in order to update the files.  You should then be able to install "Zylin Embedded CDT".  Go ahead and install it then shutdown Eclipse.

Download the cross compiler from glomation's support page (http://glomationinc.com/support.html):
http://glomationinc.com/download/Generic-arm_gcc-4.2.3-glibc-2.3.3.tar.bz2
And unpack it to get it to end up in  /usr/local as well.  Then add another line to your .bashrc
export PATH=$PATH:/usr/local/arm/gcc-4.2.3-glibc-2.3.3/arm-unknown-linux-gnu/bin

Start Eclipse and create a C project.  When it is created right-click on it and bring up the properties.  Then in C/C++ Build->Settings change the compiler and linker from gcc to arm-unknown-linux-gnu-gcc and the assembler from as to arm-unknown-linux-gnu-as for [All Configurations].  Then go to C/C++ General->Paths and Symbols, make sure the Includes tab is selected then select C Source File. Next click add and navigate to the include directory of the cross compiler. It is /usr/local/arm/gcc-4.2.3-glibc-2.3.3/arm-unknown-linux-gnu/arm-unknown-linux-gnu/include IIRC.  If you need to manually add the libraries they would be at the same level as the include I think.

Additionally, I found that you can get a free Jazz (RTC) Express-C server and clients for 10 users. So the plan is to use RTC to track this work and source. 
https://jazz.net/downloads/rational-team-concert/releases/2.0.0.2?p=allDownloads#expressc
~~~~~~

Now to create an api set to manage the gpio's. With any luck our second development board will get updated to the same level of kernel and rootfs without problems as well.

m


Hello,

there is any tutoria for the cross compiler from glomation's support page???

Thank you very much


Title: Re: GPIO driver
Post by: Lorena on March 19, 2010, 06:13:13 AM
The 2.6.30 kernel now has the GPIO support.  The following steps can be used to set GPIO as out put and control the value directly at command line,

echo {port number} > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio{port number}/direction
echo "1" > /sys/class/gpio/gpio{port number}/value
sleep 3
echo "0" > /sys/class/gpio/gpio{port number}/value

The port number of GPIO PA0 is 32, port number of PB0 is 64, and port number of PC0 is 96.

Attached is a pre-compiled 2.6.30 kernel image for GESBC-9260/B/S.  The kernel patch is available at http://maxim.org.za/at91_26.html (http://maxim.org.za/at91_26.html)



Hello!

I need to configure a GPIO as input and configure it for interrupting when there is an edge falling. I have installed the pre-compiled 2.6.30 kernel image and I have checked that exits /sys/class/gpio. But now, What I have to do with the patch?
On the other hand, I know I have to implement a driver Linux and then compiling with the cross compiler from glomation, but the asm/gpio.h doesn´t exist in the gcc-4.2.3-glibc-2.3.3/arm-unknown-linux-gnu/arm-unknown-linux-gnu/include.

Could anybody give me advice?

Thank you!


Title: Re: GPIO driver
Post by: admin on March 19, 2010, 07:53:38 AM
You don't need GPIO driver if you are going to write your own driver using GPIO pin as interrupt source.

The header files probably should be in the Linux header package.  Please install the latest Linux header file package for your development system.


Title: Re: GPIO driver
Post by: Lorena on March 19, 2010, 08:27:52 AM
You don't need GPIO driver if you are going to write your own driver using GPIO pin as interrupt source.

The header files probably should be in the Linux header package.  Please install the latest Linux header file package for your development system.


I´m so sorry but I didn´t understand the answer.
I have installed the kernel 2.6.30. This version includes gpio driver. This kernel+ patch is enough for configuring a GPIO pin as interrupt?

If no, so I suppose that I have to implement a driver or something based on GPIO driver from 2.6.30 kernel. So I will have to make my own source.c and compiling it with cross compiler from glomation. But this compiler doesn´t include the gpio.h. so I can´t use commands like: gpio_request (AT91_PIN_PC6, "IRQ")?

Sorry, but I am beginner. Thank you very much!


Title: Re: GPIO driver
Post by: admin on March 19, 2010, 08:54:07 AM
You should implement a driver to respond to the interrupt from the GPIO pin rather than using the kernel GPIO driver.  The kernel GPIO driver does not have any implementation to process your interrupt event.

As mentioned in the previous post the header files that define the GPIO functions should  be in the Linux kernel header package.  You need to install the latest kernel header files on your development system in order to compile your driver that access the GPIO functions.


Title: Re: GPIO driver
Post by: Lorena on March 22, 2010, 11:42:49 AM
You should implement a driver to respond to the interrupt from the GPIO pin rather than using the kernel GPIO driver.  The kernel GPIO driver does not have any implementation to process your interrupt event.

As mentioned in the previous post the header files that define the GPIO functions should  be in the Linux kernel header package.  You need to install the latest kernel header files on your development system in order to compile your driver that access the GPIO functions.




Hello!

Thank you for your reply. I followed your advice and I downloaded the kernel header files on my development system but I think there is a conflict between the include from cross compiler and the include from the kernel files when I build in Eclipse. Is the cross compiler from glomation´s  suport page for a specific version kernel linux?

Thank you.


Title: Re: GPIO driver
Post by: SteveMartins on April 26, 2010, 09:15:48 AM
I have added:

        {
                .gpio           = AT91_PIN_PB8,
                .code           = KEY_A,
                .desc           = "A",
                .active_low     = 1,
                .wakeup         = 1,
        }

and:

        at91_set_gpio_input(AT91_PIN_PB8, 1);  /* btn1 */
        at91_set_deglitch(AT91_PIN_PB8, 1);


to /arch/arm/mach-at91/board-sam9260ek.c which enables 9 as an input. I can see the input by creating a node:

mknod /dev/input/event0 c 13 64

(major and minor values from cat /sys/class/input/event0/dev)

Can anyone tell me if its possible to have this as a keyboard input, so when i press the button the letter 'A' appears on the console?

thanks,

Steve


Title: Re: GPIO driver
Post by: admin on April 28, 2010, 04:00:36 PM
You can write a program to constantly pulling the GPIO pin to accomplish what you wanted but that will use a lot of system resources.  The best way to do this is to implement as a driver with the GPIO pin set as interrupt source.