Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A13 => Topic started by: Thomas on November 08, 2012, 04:24:57 PM

Title: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: Thomas on November 08, 2012, 04:24:57 PM
Hi.
I'm using A13-Olinuxino-WiFi with your Debian image in A13-olinuxino-SD.

When I'm typing as root "lsmod", I do not see sun4i_gpio (=gpio driver).
In addition, the directory /sys/devices/virtual/misc/sun4i_gpio does not exist.

As it is said in the Olimex wordpress, these drivers are supposed to be in this SDcard. (http://olimex.wordpress.com/2012/10/23/a13-olinuxino-playing-with-gpios)

Any suggestion ?
Thank you.

Here is my lsmod output :

root@debian:~# lsmod
Module Size Used by
bfcon 35991 70
bitblit 4187 1 fbcon
softcursor 1123 1 bitblit
font 7767 1 fbcon
8192cu 511517 0
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: vinifr on November 09, 2012, 04:08:49 AM
Fisrt, you need compile it. Preferably as a module. In source code directory type:
# make ARCH=arm menuconfig
Choice: Device Drivers -> (*)Misc Devices -> <M> An ugly sun4i gpio driver
So, Exit, Exit, Exit, yes to save.

After, anywhere type:
# modprobe sun4i-gpio
Thereafter, the file device will be created. But your script.bin need to be configured to work.
My script.bin/script.fex: http://dl.dropbox.com/u/22273442/script.fex (http://dl.dropbox.com/u/22273442/script.fex)
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: David Goadby on November 09, 2012, 09:07:26 PM
I too am using A13-Olinuxino-WiFi with the Debian SD purchased from Olimex. If I type lsmod then I do have sun4i_gpio. In fact my lsmod output has a lot more entries than yours including usbnet and asix (for Ethernet). 

I also checked the folder /sys/devices/virtual/misc/sun4i_gpio and that exists too.

As you might expect the GPIO commands work as per the recent blog entry too.

Since I have the latest SD card from Olimex (arrived here on October 25th) then I have to assume that your SD card is either corrupt or not the correct one for the A13.


Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: Thomas on November 12, 2012, 06:27:21 PM
Hi,
@viniciusfre Thank you, I'm going to try it now.
@David Goadby I purchased mine on october 17th... I must be unlucky. Could you write your full lsmod output please ? Thanks.
@Olimex moderator, can you tell me more about those missing drivers on your SD card ? Thank you.

Thomas.
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: Thomas on November 12, 2012, 07:11:12 PM
Allright,
I'm able to launch sun4i_gpio now, it appears in lsmod.
Vinciusfre (or anyone), could you tell me where I must put the script.fex file and how to use it ?

Thanks !
Thomas.
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: Thomas on November 12, 2012, 08:08:23 PM
Now I can see the files (modprobe sun4i-gpio worked) in /sys/devices/virtual/misc/sun4i_gpio

This shell command to light up the green LED works well :
echo 1 > /sys/devices/virtual/misc/sun4i-gpio/pin/pg9

However, as I expected, I miss the mapping in the script.fex file, that's why nothing happens in running the following C code :

    #include "gpio-mmap.h"

    int main() {
    gpio_map();
    gpio_output(2,1); //bank 2 bit 1 = GPIO65 the LED on board
    while (1) {
    GPIO_WRITE_PIN(65,1);
    GPIO_WRITE_PIN(65,0);
    }
    }


Please help me I need this script.fex mapping :(

PS : The command and the C code were found here : http://olimex.wordpress.com/2012/10/23/a13-olinuxino-playing-with-gpios/
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: vinifr on November 14, 2012, 06:40:19 PM
If there is pg9 into .../sun4i-gpio/ then your script.bin/script.fex is ok.

I guess the problem lies in the functions you are using. Try this: https://github.com/hno/Allwinner-Info/blob/master/A13/test1/gpio.c (https://github.com/hno/Allwinner-Info/blob/master/A13/test1/gpio.c)
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: Thomas on November 15, 2012, 05:21:16 PM
Hi vinciusfre,
Thank you for your help.
Any of your functions result in "segmentation fault".
I tried :

gpio_get_value(number);

with number from 1 to 100, but "segmentation fault" occurs all the time.
Is it the right usage ?

Thanks.
Thomas.
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: vinifr on November 15, 2012, 06:42:59 PM
Well, I have not yet tested.  ;D

Try this:
#include "gpio.h"

int main()
{
   gpio_set_value(SUNXI_GPG(9), 1); // set pg9

   return 0;
}


Do not forget to include into gpio.h:
int gpio_get_value(unsigned gpio);
int gpio_set_value(unsigned gpio, int value);

Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: Thomas on November 15, 2012, 10:34:46 PM
segmentation fault.

:(

Thank you anyway for persevering. Because other people apparently do not have this problem, maybe the easier solution is just to buy another SD card ?

Anyway, your code works for your A13 ?

Thomas.
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: vinifr on November 23, 2012, 04:26:42 AM
Sorry for the delay. Here is the answer:

<vinifm> hno: first i load sun4i-gpio...
<vinifm> complete code: http://dl.dropbox.com/u/22273442/gpio.tar.gz
<hno> That code is for running bare-bone within u-boot. You need some small changes to use it in linux.
<hno> gpio driver is not needed. But you need to mmap the PIO registers and bang on them..
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: Thomas on November 23, 2012, 02:26:09 PM
Thank you, anyway...

(http://dl.dropbox.com/static/images/psychobox.png)
ERROR (404)
We can't find the page you're looking for. Check out our Help Center and forums for help, or head back to home.

Please could you upload it again ? :)
Title: Re: Problem with the drivers in the SDcard A13-olinuxino-SD
Post by: vinifr on November 23, 2012, 06:12:58 PM
Here: http://dl.dropbox.com/u/22273442/A13/gpio.tar.gz (http://dl.dropbox.com/u/22273442/A13/gpio.tar.gz), but the result is the same:
Segment Fault

As hno said, we must adapt to linux.  ;D

There a driver newer: http://dl.dropbox.com/u/22273442/A13/sun4i-gpio.patch (http://dl.dropbox.com/u/22273442/A13/sun4i-gpio.patch)

But, I still have not tested.