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
-
- Posts: 3
- Joined: Mon Jun 04, 2012 10:22 am
Re: Power on behaviour
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:
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/
Re: Power on behaviour
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.
Rather unfortunate. Thanks for the heads-up.
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 5710
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: Power on behaviour
@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
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
- Gert van Loo
- Posts: 2487
- Joined: Tue Aug 02, 2011 7:27 am
- Contact: Website
Re: Power on behaviour
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?
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?
Re: Power on behaviour
Just curious what is the strength of the built-in pullup and pulldowns? 10 uA, 100 uA?
- mahjongg
- Forum Moderator
- Posts: 13692
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Power on behaviour
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
Re: Power on behaviour
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 (?)
- mahjongg
- Forum Moderator
- Posts: 13692
- Joined: Sun Mar 11, 2012 12:19 am
- Location: South Holland, The Netherlands
Re: Power on behaviour
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.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 (?)
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.
-
- Posts: 3
- Joined: Mon Jun 04, 2012 10:22 am
Re: Power on behaviour
@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.
@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.
- Gert van Loo
- Posts: 2487
- Joined: Tue Aug 02, 2011 7:27 am
- Contact: Website
Re: Power on behaviour
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.jbeale wrote:Just curious what is the strength of the built-in pullup and pulldowns? 10 uA, 100 uA?
-
- Posts: 3
- Joined: Mon Jun 04, 2012 10:22 am
Setting the record straight
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.
The next trace shows the three states, high impedence, low and high.
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...
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.
The next trace shows the three states, high impedence, low and high.
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...
-
- Posts: 3
- Joined: Mon Sep 17, 2012 6:50 am
Re: Power on behaviour
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
- Gert van Loo
- Posts: 2487
- Joined: Tue Aug 02, 2011 7:27 am
- Contact: Website
Re: Power on behaviour
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.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
As soon as the SW gets it's fingers in there is no absolute grantee but it is unlikely to have changed.
Re: Power on behaviour
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
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
Re: Power on behaviour
I use pins 17 and 23 to relay control (as well as 18, 22, 27).wfold wrote:gpio 17,23,24,25 did enable on power on for ~1sec
I do not have such issue (there is no relay click on poweron or reboot)
Re: Power on behaviour
Could somebody give an update on what the situation is like with the new configurable GPIO?