GPIO default value ignored in script.bin for PC3 / PC03

Started by sylvain, January 11, 2017, 01:19:58 PM

Previous topic - Next topic

sylvain

Hello

I have modified the configuration of PC3 pin (SATA power enable) on my OLinuXino A20-Lime2 rev.G to allow direct control.

Extract from my new script.fex (only modified lines):

[sata_para]
sata_power_en =

[gpio_para]
gpio_num = 65
gpio_pin_65 = port:PC03<1><default><default><1>

[gpio_init]
pin_65 = port:PC03<1><default><default><1>

I have regenerated /boot/script.bin using the edited fex.

Note for people playing with SATA power switching: FET1 has some leakage, and you need to put some modest load on 5V_SATA_PWR to be able to see when it's ON or OFF. Using a voltmeter with no load, I always get 5.0V. Using a standard green LED + resistor, I can see it switch ON and OFF. That may or may not be an issue on a real disk drive (eg. controller having enough 5V to start, but being reset as soon as it tries to spin the motor) but that's not the point of my post.

When the system boots, PC03 is driven high, I assume due to Uboot being configured to switch it so boot on SATA is possible. Not an issue for me.

The issue is when I assume manual control of the pin using the following command
echo 65 > /sys/class/gpio/export
... the LED I've plugged on 5V_SATA_PWR immediately switches OFF :o

I was expecting /sys/class/gpio/gpio65_pc3/direction to be "out" and /sys/class/gpio/gpio65_pc3/value to be 1, given the value port:PC03<1><default><default><1> I have set in the gpio_init section. But no ...

root@A20:~# cat /sys/class/gpio/gpio65_pc3/direction
in
root@A20:~# cat /sys/class/gpio/gpio65_pc3/value
0


Where/what setting should I change to set the initial value of PC03 when I enable direct control of the GPIO pin if this section of the script.bin is ignored?

And yes, I know I could use PB8 instead of PC3, but I would have to cut/bridge a pad, and I would try to avoid doing that on dozens of boards ;D