Git Product home page Git Product logo

raspi-gpio's Introduction

raspi-gpio

Tool to help debug / hack at the BCM283x GPIO.

You can dump the state of a GPIO or (all GPIOs).

You can change a GPIO mode and pulls (and level if set as an output).

Beware this tool writes directly to the BCM283x GPIO registers, ignoring anything else that may be using them (like Linux drivers).

Build from source

This tool is pre-installed in Raspberry Pi OS, but to build from source, you should be able to build and install raspi-gpio with:

sudo apt install automake
./configure
make
sudo make install

Usage

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

raspi-gpio's People

Contributors

6by9 avatar asavah avatar bennuttall avatar jimbojr avatar kukabu avatar lurch avatar pelwell avatar rwhelan avatar wren6991 avatar xecdesign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raspi-gpio's Issues

Cannot attenuate PWM

There appears to be no function for pwm apart from setting the GPIO pin mode. There should be an option to set PWM frequency and duty cycle. Example:

raspi-gpio set 18 a5 <duty cycle %>
raspi-gpio set 18 a5 1500 75

hwbase have no init

On debian, have no gpiomem so use /dev/mem and map use hwbase offset, but hwbase not inited.

How to make etc

For the not so smart, please explain what to do to install this tool on RPi4 or RPi3.

make?
make install?
sudo ./install-sh

Thanks to help me out.

raspi-gpio command does not work on Raspberry Pi 5

I am testing with Raspberry Pi OS with Desktop (released on October 10th 2023). I found the raspi-gpio command doesn't work on Raspberry Pi 5:

$ raspi-gpio get
Unexpected ranges data (7c000000 00000010 7c000000)
Must be root

Even if running it with sudo, it still doesn't work:

$ sudo raspi-gpio get
Unexpected ranges data (7c000000 00000010 7c000000)

When I put the same SD card on my Raspberry Pi 3, the raspi-gpio command works perfectly.

Does raspi-gpio command also works with Raspberry Pi 4B?

The command "sudo raspi-gpio help" shows the tool raspi-gpio is designed to debug BCM283X GPIO and it does not mention BCM2711 which the Raspberry Pi 4B used. Then, why is this "raspi-gpio" can be used in Raspberry pi 4B(I have checked this command on
Raspberry Pi 4B.)
I am looking forward to receiving your reply.

Thanks very much.

Feature request - set bank 0 pad features (drive strength, slew rate, hysteresis)

While users should not be routinely modifying pad controls, they are useful for debug - overshoots causing false edges, for example.

Adding a commandlet for manipulating the bits in the PADS bank0 register here -
https://github.com/raspberrypi/documentation/blob/develop/documentation/asciidoc/computers/raspberry-pi/gpio-pad-controls.adoc
would allow for this.

Mapping the pad control page requires the use of /dev/mem, which requires root - which is a useful hurdle to prompt users to think twice.

Won't set outputs on bank 1 of the compute module

I assume this is the same tool i get by sudo apt-get install raspi-gpio on raspbian?

I've just spent a long time trying to debug my GPIO pins. 12/13 on bank 0 work fine as outputs. But 32,34,35,36,37&44 (all on bank1) will not work as outputs. Input behaviour works fine.

Just tried using wiringPi's gpio utility which WILL manipulate my gpio pins on bank 1.

How to get pin level?

hi,

In terminal:
raspi-gpio get 4

returns:
GPIO 4: level=0 fsel=0 func=INPUT pull=UP

How can I just get the level, the state of the pin, the "0" or "1" out of this? For example, how can I use this in an if statement to determine pin state?

I'm in bash but any examples of using raspi-gpio in logic would be really awesome, I'm struggling.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.