Page 2 of 2

Re: New "gpio" config.txt command announcement

Posted: Mon Apr 02, 2018 12:08 pm
by Gavinmc42
It's handled by start.elf and its variants
Thanks I was hoping for that ;)
Good way to get GPIO set quickly before any OS messes them up ;)
Are they set near the start of start.elf, ie quickly after booting <400ms?
Big difference between file sizes of start_cd and start_x
So quickest GPIO setting is done by reading start_cd from SD?

Hmm should be able to use two Pi's to test that now 8-)
One Pi has small OS that changes a pin state, the other Pi resets the first and can test how long start.elf takes to boot and change the pin and then how long the OS takes to change it back.

This simple Ultibo OS returns 3000C1EF, a simple GPIO status display.
Basically reading the GPIO as fast as I can to make a logic analyser.
I have set GPIO4 as GPCLK0 and I can see GPIO toggling between 3000C1EF and 3000C1FF.
By changing the clock speed it tests my capture rate, more useful when DMA/SMI reads gets going.

Some pins like the i2c have pullups, not much I can do about them ;)
But a Pi setup as a logic analyser does not need pins set as outputs on boot.

Code: Select all

  while True  do 
    Begin
     data:=GPIORead(BCM2835_GPLEV0);
     ConsoleWindowWriteLn(WindowHandle,'GPIO 0-31 = ' + IntToHex(data, 8));
    end;          
Should be able to do GPIO level interrupt timing ;)
Very weird thinking about using Pi's as test equipment :o
With the above code I have a build in logic level detector fast enough to capture i2c etc.
Pi's can have built in test equipment for self diagnostics, which is going to take some more thinking about.
Propeller is the only other one I know that can do this easily.

Hmm Digital Multimeter Hat, had not thought of that one before :lol:
Hmm logging Multimeter with bluetooth and wifi, now that could be really useful :shock:

Zero's must be the cheapest and most flexible pieces of kit I have these days.
And you guys just keep on improving them :D

Re: New "gpio" config.txt command announcement

Posted: Fri Apr 06, 2018 11:42 pm
by TimG
jamesh wrote:
Fri Mar 23, 2018 10:57 am
Does anyone actually have anything useful to say on this cool new feature?
It seems to work well to enable pull-ups on overlays that don't otherwise support them (eg. the i2c-gpio overlay which provides extra bit-banged i2c ports). So, thanks for this cool new feature!

Re: New "gpio" config.txt command announcement

Posted: Sat Apr 07, 2018 2:06 am
by Gavinmc42
Does anyone actually have anything useful to say on this cool new feature?
It is cool, this means other OS's and/or baremetal can use this to set initial GPIO state after boot.
Devicetree is for Linux and not everyone(0.0001%) uses Linux ;) some don't even use Raspbian :o

Since start.elf source code is not open we cannot give you a pat on the back for everything we don't know about.
The VCOS interface is documented and there are some examples but most apply only to Raspbian Linux.

This feature helps make Pi's a bit more useful for IoT apps.
Please stick it in the documentation and don't leave it buried in a few forum posts :D
Perhaps in bootmodes doc? It is very important info and feature.

Re: New "gpio" config.txt command announcement

Posted: Mon Apr 09, 2018 6:32 am
by gwideman
dh - Driving high (for outputs)
dl - Driving low (for outputs)

Do these options set the default output level (logic 1 = high, logic 0 = low), or do they select between the two drive strength options (16mA = high, and 8mA = low)? Thanks.

Re: New "gpio" config.txt command announcement

Posted: Mon Apr 09, 2018 6:39 am
by PhilE
They set the logic levels - dh for 1, dl for 0.

Re: New "gpio" config.txt command announcement

Posted: Thu May 17, 2018 6:05 pm
by Embring
Is it possible to turn off the I2C drivers forced repeated starts in the new "gpio" config.txt?
It would be great! Really have problems with this issue. The old kernel doesn't work on my brand new 3B+

Re: New "gpio" config.txt command announcement

Posted: Thu Aug 23, 2018 9:38 am
by aBUGSworstnightmare
Hi jamesh,

would like to try this new feature on my custom carrier board.
A custom dt-blob.bin is used atm to configure GPIO to correct function and required initial state. Think this only adds complexity and I'm looking for simpler way.

Question:
will this feature allow to configure PWM (GPIO40 + 41) pins, setting PWM frequency and initial duty cycle? If yes, how?

Re: New "gpio" config.txt command announcement

Posted: Thu Sep 06, 2018 5:16 pm
by aBUGSworstnightmare
aBUGSworstnightmare wrote:
Thu Aug 23, 2018 9:38 am
Question:
will this feature allow to configure PWM (GPIO40 + 41) pins, setting PWM frequency and initial duty cycle? If yes, how?
maybe last post went unnoticed, so let me ask again if PWM can be initialized as well.

Re: New "gpio" config.txt command announcement

Posted: Thu Sep 06, 2018 5:59 pm
by 6by9
aBUGSworstnightmare wrote:
Thu Sep 06, 2018 5:16 pm
aBUGSworstnightmare wrote:
Thu Aug 23, 2018 9:38 am
Question:
will this feature allow to configure PWM (GPIO40 + 41) pins, setting PWM frequency and initial duty cycle? If yes, how?
maybe last post went unnoticed, so let me ask again if PWM can be initialized as well.
Afaik no. It only allows setting pin muxing and pulls, same as the raspi-gpio command can.
I'd expect that any settings that did get set in there would get overwritten as soon as the Linux kernel driver starts up anyway.

Re: New "gpio" config.txt command announcement

Posted: Thu Feb 28, 2019 4:12 am
by Gord_Fi
I tried the commands in terminal and most work, but I have an issue the I hope can be explained. Terminal mode write pin 18 works for 1 and 0 but I have an led connected between that and the 3.5 v supply via 470 ohm resistor. What happens is, when I write to pin 18, the readall command reports changes on that pin, but it doesn't happen in real life. Maybe I have to use a transistor driver instead so the sink current isn't to high? When I use the C program from wiki using pigpio.h, the led flashes as it is supposed to. Only issue I have with that is, the terminal screen is locked out when the program is running, ie. when I put printf commands in that timing loop, it's buffered until I Ctrl-C exit the program.. Than all the printf data is dumped. Also, what is the flashing green led indicating? SD IO or WiFi IO?

Any way I can have printf work with the timer, or is there another hardware "tick" I can use instead? I find it difficult to work with the hardware when software isn't cooperating. And the documentation for this is all over the place depending on where you look.

Thanks for any suggestions...

Re: New "gpio" config.txt command announcement

Posted: Thu Feb 28, 2019 7:32 am
by 6by9
The gpio command (and the majority of others) work using the chip gpio number, and not the pin number on the header. Pigpio is the exception in often using the header pin number.
Pin 18 is gpio 24. See https://pinout.xyz for a complete mapping.

Re: New "gpio" config.txt command announcement

Posted: Mon Jul 22, 2019 3:52 am
by walterwoj
I hope no one minds me bringing this back from the dead but I have a question about the implementation:

Doe the order of the commands reflect the order they are executed?

IE, If I do

Code: Select all

gpio mode 16 output
then the pin will go LOW into output mode (which in my case triggers a relay to the 'on' state), THEN I can do

Code: Select all

gpio write 16 1
and it will switch.

BUT .... If i do

Code: Select all

 gpio write 16 1
then

Code: Select all

gpio mode 16 output
it will go HI into output mode.

Does

Code: Select all

gpio=16=op, dh
go LOW then HIGH like above?

And does

Code: Select all

gpio=16=dh,op
go directly to HIGH without the detour to LOW?

Re: New "gpio" config.txt command announcement

Posted: Fri Jul 26, 2019 12:28 am
by walterwoj
I have been testing this out and it would appear this does not apply to all pins. I put this in my config file:

Code: Select all

# Set GPIO Default Positions
# Set to Pull Up Output
gpio=22,23,24,25,26,27,28,29=pu,dh,op
# Set To Pull Up Input
gpio=1,4,5,6,10,11,12,13,14,15,16,=pu,ip
And MOST of the pins change, but not all. In my case the pins 13, 23, 24, 28 and 19 are still 'floating' and the pull up resistor is not engaged. I can engage it manually from the command line and the pins respond but not through the config file. I have even tried the commands individually and those pins do not obey the config file. I have watched them during boot and they do not flicker or change then change back so I don't think there is another file conflicting with it.. I have also only modified the one file for this purpose, so any conflicts would be from stock raspbian.

Any thoughts or guidance?

Re: New "gpio" config.txt command announcement

Posted: Sat Jul 27, 2019 1:33 pm
by neilgl
Please see the other replies to this in the Beginners section. @walterwoj