PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

New "gpio" config.txt command announcement

Thu Mar 22, 2018 1:11 pm

This topic is for discussion of and questions about the announcement of the new "gpio" config.txt command, which can be found here.

calleblyh
Posts: 86
Joined: Thu Feb 12, 2015 6:14 pm
Location: Southwest Finland

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:14 pm

gpio readall doesnot behave as it used to when running PI3B+ under 2018-3-13. Is there a problem ? I have posted this question earlier in Beginners before I found this announcement.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:26 pm

The error message is fairly clear:
```
Oops - unable to determine board type... model: 13
```
gpio is part of the WiringPi package maintained by Gordon Henderson (gordon@drogon.net). He needs to add the type for 3B+ (13) to the list - I'll ping him an email.

But that is nothing to do with this announcement, which is about a new config.txt setting.

User avatar
ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6394
Joined: Fri Jul 29, 2011 5:36 pm

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:30 pm

PhilE wrote:
Thu Mar 22, 2018 5:26 pm
The error message is fairly clear:
```
Oops - unable to determine board type... model: 13
```
gpio is part of the WiringPi package maintained by Gordon Henderson (gordon@drogon.net). He needs to add the type for 3B+ (13) to the list - I'll ping him an email.

But that is nothing to do with this announcement, which is about a new config.txt setting.
He has updated it, we just don't have it in apt yet.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:30 pm

Unsurprisingly, Gordon has already updated WiringPi - it's just the the Raspbian packages haven't picked up the latest build (2.46). You can download directly from drogon.net like this:

Code: Select all

cd /tmp
wget https://unicorn.drogon.net/wiringpi-2.46-1.deb
sudo dpkg -i wiringpi-2.46-1.deb
I'll redirect my ping to ShiftPlusOne to pull in the update.

User avatar
DougieLawson
Posts: 42379
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:44 pm

PhilE wrote:
Thu Mar 22, 2018 1:11 pm
This topic is for discussion of and questions about the announcement of the new "gpio" config.txt command, which can be found here.
How do we avoid your gpio command conflicting with Gordon's (long time) existing gpio command? It appears you've missed the clashing of names or is it a copy of his code with new function?
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

hippy
Posts: 13326
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:45 pm

From the announcement; "the syntax is based on the raspi-gpio utility"

Can someone provide a link to where that is described for those of us not familiar with raspi-gpio. I Googled but what I found seemed to have a very different syntax to the examples shown in the announcement.

I don't know how relevant what it is based on is so it might be best not to even mention that, just describe the syntax used.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:45 pm

@DougieLawson Read the post (or even just the bit you quoted) - it is a config.txt setting.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:47 pm

Code: Select all

pi@raspberrypi:~ $ raspi-gpio help

WARNING! raspi-gpio set writes directly to the GPIO control registers
ignoring whatever else may be using them (such as Linux drivers) -
it is designed as a debug tool, only use it if you know what you
are doing and at your own risk!

The raspi-gpio tool is designed to help hack / debug BCM283x GPIO.
Running raspi-gpio with the help argument prints this help.
raspi-gpio can get and print the state of a GPIO (or all GPIOs)
and can be used to set the function, pulls and value of a GPIO.
raspi-gpio must be run as root.
Use:
  raspi-gpio get [GPIO]
OR
  raspi-gpio set <GPIO> [options]
OR
  raspi-gpio funcs [GPIO]
OR
  raspi-gpio raw

GPIO is a comma-separated list of pin numbers or ranges (without spaces),
e.g. 4 or 18-21 or 7,9-11
Note that omitting [GPIO] from raspi-gpio get prints all GPIOs.
raspi-gpio funcs will dump all the possible GPIO alt funcions in CSV format
or if [GPIO] is specified the alternate funcs just for that specific GPIO.
Valid [options] for raspi-gpio set are:
  ip      set GPIO as input
  op      set GPIO as output
  a0-a5   set GPIO to alternate function alt0-alt5
  pu      set GPIO in-pad pull up
  pd      set GPIO pin-pad pull down
  pn      set GPIO pull none (no pull)
  dh      set GPIO to drive to high (1) level (only valid if set to be an output)
  dl      set GPIO to drive low (0) level (only valid if set to be an output)
Examples:
  raspi-gpio get              Prints state of all GPIOs one per line
  raspi-gpio get 20           Prints state of GPIO20
  raspi-gpio get 20,21        Prints state of GPIO20 and GPIO21
  raspi-gpio set 20 a5        Set GPIO20 to ALT5 function (GPCLK0)
  raspi-gpio set 20 pu        Enable GPIO20 ~50k in-pad pull up
  raspi-gpio set 20 pd        Enable GPIO20 ~50k in-pad pull down
  raspi-gpio set 20 op        Set GPIO20 to be an output
  raspi-gpio set 20 dl        Set GPIO20 to output low/zero (must already be set as an output)
  raspi-gpio set 20 ip pd     Set GPIO20 to input with pull down
  raspi-gpio set 35 a0 pu     Set GPIO35 to ALT0 function (SPI_CE1_N) with pull up
  raspi-gpio set 20 op pn dh  Set GPIO20 to ouput with no pull and driving high

User avatar
DougieLawson
Posts: 42379
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:50 pm

So it's not a "gpio" command, it's new function in your "raspi-gpio" command. Which really isn't clear from what you've written (unless you're applying Humpty Dumpty's rules).
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:54 pm

So it's not a "gpio" command, it's new function in your "raspi-gpio" command. Which really isn't clear from what you've written (unless you're applying Humpty Dumpty's rules).
Really?
New "gpio" config.txt command announcement
The latest firmware - build date 21/03/18 or later - includes a new config.txt command
The "gpio" command respects the "[...]" section headers in config.txt,

User avatar
DougieLawson
Posts: 42379
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 5:58 pm

It's NOT a "command" it's a "keyword with operands" in config.txt. In my vocabulary a "command" is usually a program in /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin or /usr/local/sbin that runs from a command line.
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 6:02 pm

It is interpreted and acted upon as it is encounted, as opposed to simply setting a flag for use layer, so I think the word command is reasonable and reflects the imperative nature. I considered the word directive, but that's a bit highbrow.

This is turning into a bikeshed discussion.

PiGraham
Posts: 5235
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 6:07 pm

DougieLawson wrote:
Thu Mar 22, 2018 5:50 pm
So it's not a "gpio" command, it's new function in your "raspi-gpio" command. Which really isn't clear from what you've written (unless you're applying Humpty Dumpty's rules).
It looks like a new gpio command modelled on an existing raspi-gpio shell command, but the new one applies only in config.txt.

So this sets pullup on GPIO20 from command prompt or script file:

Code: Select all

 raspi-gpio set 20 pu
And this will do the same thing from config.txt at boot:

Code: Select all

 gpio set 20 pu
I think that's what it means.

hippy
Posts: 13326
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 6:08 pm

From the announcement ...

"np - No pull"

From raspi-gpio help ...

"pn set GPIO pull none (no pull)"

hippy
Posts: 13326
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 6:10 pm

PiGraham wrote:
Thu Mar 22, 2018 6:07 pm
So this sets pullup on GPIO20 from command prompt or script file:

Code: Select all

 raspi-gpio set 20 pu
And this will do the same thing from config.txt at boot:

Code: Select all

 gpio set 20 pu
I think that's what it means.
My reading of the announcment is the last should be as follows when in config.txt ...

Code: Select all

gpio=20=pu
I think that perhaps the reference to raspi-gpio has got everyone confused.

PiGraham
Posts: 5235
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: New "gpio" config.txt command announcement

Thu Mar 22, 2018 7:42 pm

hippy wrote:
Thu Mar 22, 2018 6:10 pm
PiGraham wrote:
Thu Mar 22, 2018 6:07 pm
So this sets pullup on GPIO20 from command prompt or script file:

Code: Select all

 raspi-gpio set 20 pu
And this will do the same thing from config.txt at boot:

Code: Select all

 gpio set 20 pu
I think that's what it means.
My reading of the announcment is the last should be as follows when in config.txt ...

Code: Select all

gpio=20=pu
I think that perhaps the reference to raspi-gpio has got everyone confused.
You seem to be correct on both counts.

:?:

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32227
Joined: Sat Jul 30, 2011 7:41 pm

Re: New "gpio" config.txt command announcement

Fri Mar 23, 2018 10:57 am

Does anyone actually have anything useful to say on this cool new feature?
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

hippy
Posts: 13326
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: New "gpio" config.txt command announcement

Fri Mar 23, 2018 2:29 pm

jamesh wrote:
Fri Mar 23, 2018 10:57 am
Does anyone actually have anything useful to say on this cool new feature?
There's that discrepancy I noted in my earlier post -

viewtopic.php?f=44&t=208747#p1290616

nixy82
Posts: 63
Joined: Sat Sep 12, 2015 9:19 am

Re: New "gpio" config.txt command announcement

Sat Mar 24, 2018 8:48 am

This is great!

We’re a step closer to not needing custom device tree blobs in our compute module application now :D

Any chance you can do something for camera (dual) configuration in a similar style?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Sat Mar 24, 2018 11:45 am

Any chance you can do something for camera (dual) configuration in a similar style?
By that you mean add the ability to assign a pin number to one of the named roles - CAMERA_0_SDA_PIN etc.? The plumbing internally is likely to be the hardest part, but I can take a look.

CCMike
Posts: 4
Joined: Thu Mar 29, 2018 2:01 pm

Re: New "gpio" config.txt command announcement

Thu Mar 29, 2018 5:32 pm

Will this, or has it already, be back-ported into Jessie? Thanks!

User avatar
ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6394
Joined: Fri Jul 29, 2011 5:36 pm

Re: New "gpio" config.txt command announcement

Thu Mar 29, 2018 5:36 pm

CCMike wrote:
Thu Mar 29, 2018 5:32 pm
Will this, or has it already, be back-ported into Jessie? Thanks!
Jessie is unsupported, but you might have luck with using rpi-update to get the required firmware update.

User avatar
Gavinmc42
Posts: 7300
Joined: Wed Aug 28, 2013 3:31 am

Re: New "gpio" config.txt command announcement

Mon Apr 02, 2018 6:03 am

What reads the config.txt and sets the GPIO pins? bootcode.bin, start.elf or is it passed to the kernel?
Basically is this config.txt option available to those who don't use Linux.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4924
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: New "gpio" config.txt command announcement

Mon Apr 02, 2018 6:43 am

It's handled by start.elf and its variants, so the mechanism should be usable with any operating system that doesn't overwrite the pin states at boot time.

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