jeremynz
Posts: 20
Joined: Fri Sep 05, 2014 12:20 am

Initial configuration of GPIO pins

Fri Sep 05, 2014 1:30 am

Hi,

Long time reader, first time poster.

I'm running Raspbian Wheezy and I want to configure the GPIO (pull-ups, pull-downs, inputs, outputs, initial values) at boot-time.

From the page at http://www.raspberrypi.org/documentatio ... uration.md , I can do this by adding a /boot/dt-blob.bin file

The sample .dts listed on that same page has a number of configurations for pins_rev1, pins_rev2, pins_bplus, pins_cm. How is the configuration chosen?

Do I need to specify all of these configurations in my custom .dts?

User avatar
mad-hatter
Posts: 419
Joined: Sun Feb 26, 2012 2:58 pm
Location: By the UK seaside

Re: Initial configuration of GPIO pins

Fri Sep 05, 2014 4:01 pm

Hello,

Google search:- raspberry pi gpio pins initial state
http://www.raspberrypi.org/forums/viewt ... 29&t=47965
http://www.raspberrypi.org/forums/viewt ... 44&t=35321
These are an old posts, not sure if still good, or if this helps.

Regards

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5195
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Initial configuration of GPIO pins

Sun Sep 07, 2014 1:11 pm

Personally, unless I was absolutely certain** of what I was doing (which most of the time I'm not ;) ), I'd use a script containing wiringPi "gpio" commands since:
1) That tool "understands" different board revisions
2) and, AIUI, "only" allows you to change the GPIO's that are "safe to use"
(wiringPi's author has also noted, in previous thread's, that there are "no certain default startup settings")
Trev.
** I think the "dt-blob.bin" "thing" is mainly intended for B+ HAT use (see the B+ Addons topic).
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Initial configuration of GPIO pins

Sun Sep 07, 2014 1:28 pm

jeremynz wrote:Hi,

Long time reader, first time poster.

I'm running Raspbian Wheezy and I want to configure the GPIO (pull-ups, pull-downs, inputs, outputs, initial values) at boot-time.

From the page at http://www.raspberrypi.org/documentatio ... uration.md , I can do this by adding a /boot/dt-blob.bin file

The sample .dts listed on that same page has a number of configurations for pins_rev1, pins_rev2, pins_bplus, pins_cm. How is the configuration chosen?

Do I need to specify all of these configurations in my custom .dts?
The firmware determines which pi you have and loads the configuration from the appropriate section.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6074
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Initial configuration of GPIO pins

Sun Sep 07, 2014 1:41 pm

FTrevorGowen wrote: ** I think the "dt-blob.bin" "thing" is mainly intended for B+ HAT use (see the B+ Addons topic).
A dt-blob can be programmed into the HAT eeprom, but that part of documentation was mostly written for compute module users. It's best not to make assumptions about what the CM's pins will be used for, so aside from the UART pins, they're all set to input. However, this prevents the camera from working, for example, so a custom dt-blob is required.

The same approach can be used for all the pi models, but I'm not sure it's the way to go. I strongly believe that the application that uses the pins should be in charge of configuring them and until that happens, you shouldn't make assumptions about the state they're in. There are exceptions of course and I don't know the OPs use case, so I don't know what the right approach here is.

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5195
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: Initial configuration of GPIO pins

Sun Sep 07, 2014 9:47 pm

ShiftPlusOne wrote:
FTrevorGowen wrote: ** I think the "dt-blob.bin" "thing" is mainly intended for B+ HAT use (see the B+ Addons topic).
A dt-blob can be programmed into the HAT eeprom, but that part of documentation was mostly written for compute module users. It's best not to make assumptions about what the CM's pins will be used for, so aside from the UART pins, they're all set to input. However, this prevents the camera from working, for example, so a custom dt-blob is required.
The same approach can be used for all the pi models, but I'm not sure it's the way to go. I strongly believe that the application that uses the pins should be in charge of configuring them and until that happens, you shouldn't make assumptions about the state they're in. There are exceptions of course and I don't know the OPs use case, so I don't know what the right approach here is.
Thank's for the clarification - my memory was/is a bit "hazy" w.r.t. "blobs" (or is the case that a blob, by definition, is "somewhat vague"? :) ) .
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

jeremynz
Posts: 20
Joined: Fri Sep 05, 2014 12:20 am

Re: Initial configuration of GPIO pins

Sun Sep 07, 2014 11:52 pm

Thanks all for your replies. I know I can run a script at start-up to configure the GPIO, but it can take ~30s for the RPi to boot.

My question was really around whether adding a dt-blob.bin was a way to configure the GPIO much earlier in the boot process, and how this was defined.

Related to this, if I want to set GPIO upon system halt/shutdown, should I just use a script in /etc/init.d?

Return to “Advanced users”