GPIO activation during startup

Hi,

I need to set a GPIO output high as early as possible during the startup and keep it active until the system shuts down. What I did so far:

  • Use GPIO 0.7 for testing
  • Set GPIO0.7 high in python script automatically after startup → GPIO becomes high approx. 24s after power-on
  • Modify device tree to set GPIO0.7 high → GPIO becomes high approx. 9s after startup
  • Set GPIO0.7 high in u-boot scipt (/boot/boot.scr) → GPIO becomes high after approx. 3.5s, but becomes low again after approx. 6s

My problem now is that the GPIO becomes low for approx. 3s after it was set by u-boot and before the device tree. I guess I need to understand the kernel boot process a little bit better. Any suggestion, where to start or any hint where to look at?

Regards

Axel

use the 'gpio-hog' option so the kernel doesn't re-set the gpio upon startup...

See the example to keep the eMMC in reset:

https://github.com/beagleboard/linux/blob/4.1/arch/arm/boot/dts/am335x-boneblack-overlay.dts#L28-L36

Regards,

Add a pullup or just use a GPIO that defaults to high. Nothing is faster than that.

Gerald

Hi Robert,

thanks, that improved the situation, but the GPIO is still going low for approx. 500ms. Any further suggestion?

Regards

Axel

Hi Gerald,

thanks, I need to check, if this is a possible solution. I want to use the output to keep the BBB powered, when the external start signal goes low and power the whole system down depending on some software decisions. Therefore the output is connected to a shutdown pin of a voltage regulator, whcih provides the 5V. I’m afraid adding a pullup here will keep the system active forever…

Regards

Axel

Here a picture to show, what I measured. KL 15 is the external start signal, BBB 3.3V is the 3.3V line of the BBB and POWER HOLD is GPIO0.7. At T1 the power is switched on and at T2 I think that the GPIO is set by the device tree configuration.

Regards

Axel

That is odd.. the point of "gpio-hog" was to leave the specified gpio
output in a specific state, even during gpio initialization.

What kernel is this btw?

Regards,

Pullup is large. Your SW can always override it and take it low when you are ready.

Gerald

debian@beaglebone:~$ uname -a
Linux beaglebone 4.1.3-ti-r7 #1 SMP PREEMPT Thu Jul 30 20:00:23 UTC 2015 armv7l GNU/Linux

Now I synchronized my measurements with the serial console output.

Loaded script from /boot/boot.scr
gpio: pin 56 (gpio 56) value is 1
Running bootscript from mmc1:1 …

Executing script at 82000000

Output becomes high here
gpio: pin 7 (gpio 7) value is 1
Checking for: /boot/uEnv.txt …
gpio: pin 55 (gpio 55) value is 1
1604 bytes read in 30 ms (51.8 KiB/s)
Loaded environment from /boot/uEnv.txt
Checking if uname_r is set in /boot/uEnv.txt…
gpio: pin 56 (gpio 56) value is 1
Running uname_boot …
loading /boot/vmlinuz-4.1.3-ti-r7 …
8211648 bytes read in 481 ms (16.3 MiB/s)
loading /boot/dtbs/4.1.3-ti-r7/am335x-boneblack.dtb …
57645 bytes read in 64 ms (878.9 KiB/s)
loading /boot/initrd.img-4.1.3-ti-r7 …
4570423 bytes read in 1222 ms (3.6 MiB/s)
debug: [console=tty0 console=ttyO0,115200n8 bone_capemgr.enable_partno=BB-CAN1 root=/dev/mmcblk0p1 rootfstype=ext4 rootwait fixrtc coherent_pool=1M] …
debug: [bootz 0x82000000 0x88080000:45bd37 0x88000000] …
Kernel image @ 0x82000000 [ 0x000000 - 0x7d4cc0 ]

Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000
Using Device Tree in place at 88000000, end 8801112c

Output becomes low 0.645s after the last serial message and 2.571s before the next

Starting kernel …

[ 0.000000] Booting Linux on physical CPU 0x0
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 4.1.3-ti-r7 (root@b2-omap5-uevm-2gb) (gcc version 4.9.2 (Debian 4.9.2-10) ) #1 SMP PREEMPT Thu Jul 30 20:00:23 UTC 2015
[ 0.000000] CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[ 0.000000] Machine model: TI AM335x BeagleBone Black
[ 0.000000] cma: Reserved 24 MiB at 0x9e000000
[ 0.000000] Memory policy: Data cache writeback