GPIO help

Started by Vinayakj70423, July 21, 2013, 05:11:04 PM

Previous topic - Next topic

Vinayakj70423

I am using A10s board with nand image loaded.
I was trying to control the GPIO via uart0.
The problem i am facing is that, the folder /sys/class/gpio_sw does not contain any files to read or write to.
just to be sure, incase that the echo statement is supposed to create the required files i ran the command

echo 1 > /sys/class/gpio_sw/PE3/mul_sel

this is the reply i got..

sh: cannot create /sys/class/gpio_sw/PE3/mul_sel: No such file or directory

Help would be much appreciated

martinayotte

#1
In an earlier post, I've mentionned that you can control the small green led on gpio :

According to schematic, the LED1 is connected to PE3(gpio21_pe3) and the page http://olimex.wordpress.com/2013/06/19/building-linux-for-a10s-from-scratch/

root@A10s:~# echo out > /sys/class/gpio/gpio21_pe3/direction
root@A10s:~# echo 1 > /sys/class/gpio/gpio21_pe3/value
root@A10s:~# echo 0 > /sys/class/gpio/gpio21_pe3/value

(But this is probably only for the Debian, I'm not sure about Android)

Vinayakj70423

Maybe i should've mentioned. I am using Android 4gb nand image.

The application that i am building needs android.

And in the filesystem i have found that /sys/class does not have a gpio folder.
It has gpio_sw folder, which does not have any files within it.

Vinayakj70423

Ok got the debugger working. I guess the board is set to debug mode by default.

Got adb to find the A10s board, and send shell command over usb-otg.

I am still having problems controlling the GPIO.

Same as before, no files in the /sys/class/gpio_sw folder.

Vinayakj70423

I have been looking online to see if anyone had the same problem.
Found quite a few people with similar problem on some other boards.  :D

Found this as the solution

Got into the script.bin, of /dev/block/nanda, using mount and ADB pull

converted the file to fex file, and to my surprise i did not find any gpio_para.

Modified it to have 5 gpio pins (PE01 to PE05). converted the fex file back to .bin, sent it back to /dev/block/nanda

restarted the board, and still nothing. :(

I am starting to think that the modifications i made are incorrect.
Mainly because, i have seen different people having the same problem on different boards, and each had to modify their script.bin file differently.  :-\


If anyone has GPIO working through android, could you be kind enough to share the script.bin file.

Thanks in advance.  ;D

martinayotte

what does following command gives you "lsmod | grep gpio" ?

On Debian we getting such :

root@A10s:~# lsmod | grep gpio
gpio_sunxi              6767  29

when you tried tweaking your script.fex, Is that syntax look like the one below which comes from my Debian ?

[gpio_para]
gpio_used = 1
gpio_num = 29
gpio_pin_1 = port:PB14<0><default><default><1>
gpio_pin_2 = port:PB13<0><default><default><1>
gpio_pin_3 = port:PB12<0><default><default><1>
...
gpio_pin_29 = port:PE11<0><default><default><1>

[gpio_init]
pin_1 = port:PB14<0><default><default><1>
pin_2 = port:PB13<0><default><default><1>
pin_3 = port:PB12<0><default><default><1>
...
pin_29 = port:PE11<0><default><default><1>


Vinayakj70423

The script.fex that i retrived did not have gpio_para or gopi_init.

I added a similar para and init to it, but with only 5 pins. It did not work, so went ahead searching online for answers.

I found this link which explained how to break open the img file, that had to be flashed into the board.

https://www.miniand.com/wiki/Allwinner/Unpacking+and+building+LiveSuit+images

Found out that the only kernel module with the name gpio in it was gpio_sw.ko.
Then i searched online a little more and found that, the normal kernel module used is sun4i_gpio.ko.


Well i am a noob at linux, android being faaaaar away, so i am trying to figure out what to do next..

Saw the reply just now.

The android image does not have grep, so had to lookup the result of lsmod manually

It has only one GPIO entry

gpio_sw 63245 0 - Live 0xbf0af000

I am hoping that the enrty 29 in your result means number of pins loaded, and my result will give you an idea on how to fix my problem.

Thanks for the reply.


martinayotte

I presume you've already saw this link :

http://olimex.wordpress.com/2013/05/23/a10s-olinuxino-android-gpio-control-led-toggle-app/

So, the question is why you don't see all those pins in /sys/class/gpio_sw/

Maybe it is a question of it needs to be "exported" first as some other people faced with Cubieboard :

http://www.cubieforums.com/index.php/topic,103.0.html

Do you have something like /sys/class/gpio/export ?

Since I also have a Android SDCard, tonight, I will boot it to see how /sys/class look like, and I will keep you posted.

Vinayakj70423

The real question is not why i don't see the pins, but really why i don't see any files what so ever in the gpio_sw folder.

nope.. no /sys/class/gpio folder.

Been reading up on writing kernel modules.

I can't go around using kernel modules compiled for other kernels..

the system does not have modprobe in its bin.. the shell just replies
/system/bin/sh: modprobe: not found


So i searched around to where the kernel modules are stored in the system.. they are present under /vendor/modules

the only module with gpio in its name i see there is gpio_sw.ko

Vinayakj70423

Worst part is i can't compile a kernel module for the system either.

The system does not have make command or gcc for that matter.

thought of cross compiling the module from my computer, but sadly no kernel sources. No clue where to find them as of yet..

Thought of pulling them out of the system, and then using.

Tried searching within the system at /usr/src but there is no /usr folder. :(

I am starting to think that this image was designed only for people developing android apps only. >:(

Well upside being that i am learning aloooot more then i would have other-wise.  ;D

Vinayakj70423

ok did aloooooot of learning in the last week.
-learned how to write kernel modules.
-got the source for the kernel within the nand_android_image
-compiled the kernel
-found the gpio_sw source
-modified the gpio_sw to echo out messeges into dmesg
-installed the modified gpio_sw

Here is what i learned at this point
The kernel module could not find the gpio_para within the script.bin

At this point i was totally confused, started thinking that something was wrong with my newely defined script.bin, so i modified the gpio_sw to search for uart_para0, and print to dmesg if found. insmoded the new kernel module and saw the dmesg. The kernel module found the usart_para0. Next thing i did was make a script.bin without the uart_para0 (changed to uart_para5), and put it into the boot partition (usual method).

this time i insmoded the previously compiled kernel module (the one searching for uart_para0), and the dmesg told me that it found the uart_para0

conclusion, for some reason the modifications that i make to script.bin within the bootloader are not being accepted.

to confirm this i pulled out the script.bin from within the boot, and converted it to fex, and to my suprise all the modifications that i had done to it were still there..

Now i am in a totally confused state. By whatever i have found out till now, the script.bin (and script0.bin) within /dev/block/nanda (bootloader partition) is t=not the script that script_parser_fetch() functions reads from.

Now i am trying to mount /dev/block/nandd (The boot partition). But i don't know what filetype it uses .  :(

Seriously need help at this point.

Vinayakj70423

Slight correction /dev/block/nandc is the boot partition

Vinayakj70423

ok latest update on my trials.

Got kernel and android sources from here
https://drive.google.com/folderview?id=0B5JCBCiZ1VAKUkVXQXd2LWFweE0&usp=sharing

and tried to compile the android image

failed, then read up online here, about using gcc 4.4 instead

http://blog.markloiseau.com/2012/07/how-to-compile-android-on-ubuntu-12-04/

Succedded in compiling the image, but no dice.
The board does not boot up at all with the image i compiled.
Even if i run it under an emulator, it does not work..

Figured that it is probably a problem with the kernel that i compiled, from the fact that, i am not receiving any debug information over uart0, or uart1.

I need to know exactely what to set in the configs of the kernel, when i use the command

lichee\linux-3.0\$ make ARCH=arm menuconfig.

Please help.

XFer

#13
I'm not familiar with the lichee branch, but you may try running

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- (or whatever your cross-compile chains is called) sun5i-defconfig sun5i_defconfig

Fernando

Vinayakj70423

@Xfer: Thanks for the help, but sun5i_defconfig has pre-written configurations, which obviously have not worked.

What i wanted to know, was what configurations to setup, so that it will work.

Fro menuconfig, i can load the sun5i_defconfig, and make changes to it.

But i don't know what changes to make. :(