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

New "gpio" config command

Thu Mar 22, 2018 1:12 pm

The latest firmware - build date 21/03/18 or later - includes a new config.txt command for configuring pins at boot time. It can be considered an easier alternative to a custom dt-blob.bin for applications that don't need to reassign the named pins (e.g. "LAN_RUN") or create custom clocks.

The new command is called "gpio", and the syntax is based on the raspi-gpio utility. Each line applies the same settings (or at least makes the same changes) to a set of pins, either a single pin ('3'), a range ('3-4'), or a comma-separated list of either ('3-4,6,8'). The pins are followed by an '=', then one or more comma-separated attributes from this list:

Code: Select all

      ip - Input
      op - Output
      a0-a5 - Alt0-Alt5
      dh - Driving high (for outputs)
      dl - Driving low (for outputs)
      pu - Pull up
      pd - Pull down
      pn/np - No pull
gpio commands are applied in order, so those appearing later override those appearing earlier.

Examples:

Code: Select all

      # Select Alt2 for GPIOs 0 to 27 (for DPI24)
      gpio=0-27=a2

      # Set GPIO12 to be an output set to 1
      gpio=12=op,dh

      # Change the pull on (input) pins 18 and 20
      gpio=18,20=pu

      # Make 17 to 21 inputs
      gpio=17-21=ip
Pins configured by this command are not reserved in any way, so they won't stop kernel drivers or the user-space sysfs GPIO interface from claiming and using them.

The "gpio" command respects the "[...]" section headers in config.txt, so it is possible to use different settings based on the model, serial number and EDID.

You can discuss this post and ask questions here.

Return to “Announcements”