russellstrong
Posts: 3
Joined: Mon Jun 04, 2012 10:22 am

Power on behaviour

Mon Jun 04, 2012 10:42 am

Just discovered some rather odd and unexpected behaviour. The RPi configures most GPIO as OUTPUT initially after power on. This lasts for about 1 second before they go high impedance ( INPUT ). This makes the GPIO unusable, going through uncommanded transient states before software can run to take control

Can this be changed? What is controlling the GPIO in the first few microseconds after power on? I would have expected GPIO to remain high impedance until commanded otherwise.

A couple of other questions as well:

1. Can alternate functions be selected via the kernel command line. Any later would further drive the GPIO through startup transients. Particularly, can the UART be disabled if I wanted to use it as GPIO? Kernel messages controlling a relay is not good!

2. Using the sysfs interface for GPIO I am unable to set the output value before changing the direction to output. Do others have this problem too? If so, is there another way that people are using to avoid this kind of transient condition?

Thanks,
Russell

User avatar
jbeale
Posts: 3570
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Power on behaviour

Mon Jun 04, 2012 10:12 pm

Wow, that's bad about the 1-sec output mode. I'm sure this can be changed by appropriate code in the initial boot process. I assume the "binary blob" which is not opensource so we'll have to wait for someone like Dom to fix that.

You can certainly disable the UART function:
The serial device is at ‘/dev/ttyAMA0′ and by default, outputs kernel messages at 115200 baud. This is configured in /boot/cmdline.txt and you can remove the option, or alter the connection speed it outputs at.
from http://benosteen.wordpress.com/2012/04/ ... onnection/

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Power on behaviour

Mon Jun 04, 2012 10:35 pm

That sound nastily like it would require a redesign of the chip, although I hope it's the blob. It's not entirely unsupportable in an embedded system, although it would take a moderately complex power-on reset circuit to do it.

Rather unfortunate. Thanks for the heads-up.

dom
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5378
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge

Re: Power on behaviour

Mon Jun 04, 2012 11:07 pm

@russellstrong
I've had a think about this, and the best guess is that loader.bin may be doing this.
loader.bin hasn't been built for ages, and possibly was built for a slightly different platform where the GPIO mapping is different.

I've rebuilt it for the right platform, and it's on github (Hexxeh's rpi-update tool should get it for you). Can you test it?

Should look like:
md5sum loader.bin
788cea3913d701537a0a943a8f7d601c loader.bin

User avatar
Gert van Loo
Posts: 2486
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Power on behaviour

Mon Jun 04, 2012 11:21 pm

Short question: How do you now the pins are all set to output?
Don't forget that most GPIO pins have a pull-up or pull-down which is always active after reset. The behavior may change (a second) later when the pins are set to their real I/O mode.
Are you sure you are not seeing that effect?

User avatar
jbeale
Posts: 3570
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Power on behaviour

Mon Jun 04, 2012 11:47 pm

Just curious what is the strength of the built-in pullup and pulldowns? 10 uA, 100 uA?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12514
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Power on behaviour

Mon Jun 04, 2012 11:49 pm

GPIO outputs are programmable, that is the "drive strength" of GPIO output ports is programmable, but actually I have no clue what that means in practice, or if it even relates to internal pullups on GPIO inputs. I've not seen a "functional diagram" of RPI GPIO's, but normally internal pullups provide just enough "force" to guarantee that the inputs are read as '1'. I have to guess that means they are comparable to say 33K resistors, and thus, if you short them to ground, draw about 0.1 mA, or 100 uA

User avatar
jbeale
Posts: 3570
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Power on behaviour

Mon Jun 04, 2012 11:56 pm

I thought the "drive strength" was the current delivered while the port is set as an output, whereas the pullup or pulldown is active only when the port is an input (?)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12514
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Power on behaviour

Tue Jun 05, 2012 12:01 am

I thought the "drive strength" was the current delivered while the port is set as an output, whereas the pullup or pulldown is active only when the port is an input (?)
Perhaps you were writing this while I was still editing my comment. yes drive strength is about GPIO outputs, and pullups are about inputs. As I said my "educated guess" is a pullup strength of about 100 uA, but I could indeed be wrong by a factor ten, Gert should know more, perhaps he can provide us with a "functional diagram" of the GPIO, including pullup strengths, and more info about how "drive strength" works.

P.S. I would be very surprised, (and concerned) if the GPIO would, at any point in the boot process, really be set as outputs. I do think that what you see is indeed the turning on, and later off, of weak pullups.

russellstrong
Posts: 3
Joined: Mon Jun 04, 2012 10:22 am

Re: Power on behaviour

Tue Jun 05, 2012 1:12 am

@dom, I'll try the new loader tonight if I get a chance (I have guests staying over), thanks for building a one.

@Gert van Loo, My circuit has pullups on the external circuit ( opto coupled relay ) that only an output logic 0 could drive. Also it appears the GPIO4 (broadcom name) is not driving the relay, i.e. is not an output, but all others do.

User avatar
Gert van Loo
Posts: 2486
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Power on behaviour

Tue Jun 05, 2012 10:30 am

jbeale wrote:Just curious what is the strength of the built-in pullup and pulldowns? 10 uA, 100 uA?
About 60K equivalent. So on 3V3 that is about 55 uA. To test if the output is active or if it is the pull up/down load the pin with a resistor (e.g. 10K) and see if that changes the start-up behavior.

russellstrong
Posts: 3
Joined: Mon Jun 04, 2012 10:22 am

Setting the record straight

Thu Jun 07, 2012 10:02 am

I have jumped to conclusions about my pull up resistors / sensitivity of my circuit to the pull down resistors. The RPi is not setting the GPIO to output when first booted. It is turning on a pull down resistor for 740 milliseconds.

I have used two 18K resistors ( 3v3 -> GPIO -> GND ) to look at exactly what is going on with the pins.
Here is the trace. Blue line is 3v3 power, yellow line is GPIO line.
pulldown.jpeg
pulldown.jpeg (45.71 KiB) Viewed 6725 times
The next trace shows the three states, high impedence, low and high.
range.jpeg
range.jpeg (49.75 KiB) Viewed 6725 times
Thanks for looking at this and apologies if I've caused any alarm.

I have tried the firmware update above as well. The startup trace is the same, but the machine did not boot. I've had to go back to the original debian image to boot again. Don't know why yet...

daneloctober
Posts: 3
Joined: Mon Sep 17, 2012 6:50 am

Re: Power on behaviour

Mon Feb 04, 2013 8:04 am

Has nothing changed for the new board (512 MB), i.e., is this essentially a software thing? I'm going to utilize some of the information here to design a circuit using the GPIOs, I'm just checking if it's not outdated yet... thank you! =D

User avatar
Gert van Loo
Posts: 2486
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Power on behaviour

Mon Feb 04, 2013 1:44 pm

daneloctober wrote:Has nothing changed for the new board (512 MB), i.e., is this essentially a software thing? I'm going to utilize some of the information here to design a circuit using the GPIOs, I'm just checking if it's not outdated yet... thank you! =D
There is a mixture of SW and HW here. Until the SW kicks in the outputs will have their hardware settings. That is static and is not changed.
As soon as the SW gets it's fingers in there is no absolute grantee but it is unlikely to have changed.

wfold
Posts: 1
Joined: Fri Feb 22, 2013 3:50 am

Re: Power on behaviour

Fri Feb 22, 2013 4:02 am

not being an EE or having dug too deep on this
I have noticed that at least gpio 7,8 do not display this behavior with my relay boards.
gpio 17,23,24,25 did enable on power on for ~1sec

I have not checked any other pins

edo1
Posts: 151
Joined: Sun Jun 15, 2014 3:33 pm
Location: Russia

Re: Power on behaviour

Tue Mar 29, 2016 9:18 pm

wfold wrote:gpio 17,23,24,25 did enable on power on for ~1sec
I use pins 17 and 23 to relay control (as well as 18, 22, 27).
I do not have such issue (there is no relay click on poweron or reboot)

Return to “Interfacing (DSI, CSI, I2C, etc.)”