Can I/O on the A13 be re-purposed?

Started by mikenycz, March 28, 2014, 02:37:03 PM

Previous topic - Next topic

mikenycz

Hi,
      I was wondering if I/O on the A13 can be re-purposed? What I mean by that is, if I have an I/O for say the SPI interface, and I am not using the SPI interface, can I reuse that pin as a GPIO?

Specifically, in the script.bin section [spi2_para]...

spi_used = 1
spi_cs0 = port:PE00<4><default><default><default>
spi_sclk= port:PE01<4><default><default><default>

Can I set spi_used =0 and then add additional GPIO entries to the GPIO section....

Gpio_num = 16
gpio_pin_15 = port:PE00<1><default><default><default>
gpio_pin_16 = port:PE01<1><default><default><default>

I saw another post where someone asked this about the LCD interface pins. In the pin description in the manual it does not have a direction designation for the LCD pins (i.e. IO, Input, etc...) however the designation does exist for the interface pins. If someone has successfully done this please share your experiences.

Thank you,
Mike Nycz

vinifr


mikenycz

Good to hear. Is the method that I showed in my original post the way to do it?  :D

Thanks,
Mike Nycz

vinifr

#3
Yes, but you need to use a gpiolib + gpio driver: https://www.olimex.com/forum/index.php?topic=2989.0

By the whay, this method only works with old driver! New driver uses sys entries. I'm not sure, i must to check this!

mikenycz

OK, I tried to make the edits to script.bin that I listed in my initial post.

Specifically, in the script.bin section [spi2_para]...

spi_used = 1
spi_cs0 = port:PE00<4><default><default><default>
spi_sclk= port:PE01<4><default><default><default>

Can I set spi_used =0 and then add additional GPIO entries to the GPIO section....

Gpio_num = 16
gpio_pin_15 = port:PE00<1><default><default><default>
gpio_pin_16 = port:PE01<1><default><default><default>

I then used fex2bin to create a new script.bin. I then rebooted the machine and tried to use the export command in the /sys/class/gpio directory. The command I executed was...

echo 15 > /sys/class/gpio/export

The response was "invalid arguement". If I try to run with a number less than 15 it works fine. In addition to the edits above are there any other things that need to be changed to have the redefined pins picked up? I also went into the gpiochip1 directory and noticed that the file ngpio had a value of 14 in it. This kind of makes me think that the pins really did not get defined. One other thought, I assumed that script.bin (at least the one that is used during booting) resides in the /opt/sunxi-tools directory. When I make changes to the file does it need to be placed somewhere else in order to be picked up?

Thank you,
Mike Nycz

mikenycz

OK, I mistakenly thought that the copy of script.bin that was located in the directory /opt/sunxi-tools was the script.bin copy that the OS used when starting up. I tried changing this copy and there was no change to the pin definitions. I then tried putting a copy in /boot since I had seen another post in the A10 forum which implied that this was the location that script.bin should be in. There was no effect when I placed the file in /boot.

I then did a find |grep script.bin from the / directory and found that there was a script.bin located in directory... /media/70C9-2E3E. I replaced the copy that was in this directory and amazingly the pin configuration was updated. I don't know if all installs point to the same directory, but if you are having issues getting script.bin to be recognized I would look in the /media/... directory to see if a copy is there.
I hope this helps someone.

Mike Nycz

vinifr

script.bin does not affect GPIOs sys entries. It is used only with old gpio driver, but it was removed from the repository. https://github.com/linux-sunxi/linux-sunxi/commit/705194bf95d808e706d2dcc1ced2bf64221dd981