written at 21:19 by faberman
GPIO detection

If you should ever be in a situation where you have a piece of hardware on your bench without schematics, nobody to answer questions and you have to figure out where those pins are connected to.. gpiofinder to the rescue!

gpiofinder utilizes all GPIOs not already in use (e.g. because configured as dedicated periphery) and performs a binary search, so within log2(N) steps you should have your pin identified.

Why not as shell script? Embedded systems often have minimal shells with very limited features. Before building a full featured bash, hacking together a small C program seemed more feasable.

USAGE

  1. Connect an oscilloscope or level meter to the GPO you are identifying
  2. Run gpiofinder with the maximum number of gpios as argument, e.g. 223 on the i.MX6
  3. Answer the questions with y/n:
    $ ./gpiofinder 223 Initializing all GPOs to 0.. Is the level you are looking for currently low? (y/n) y Beginning search.. Enabling 0..111..did the level go up? (y/n) y Enabling 0..55..did the level go up? (y/n) y Enabling 0..27..did the level go up? (y/n) y Enabling 0..13..did the level go up? (y/n) n Enabling 14..27..did the level go up? (y/n) y Enabling 14..20..did the level go up? (y/n) y Enabling 14..17..did the level go up? (y/n) n Enabling 18..20..did the level go up? (y/n) y Enabling 18..19..did the level go up? (y/n) y Enabling 18..18..did the level go up? (y/n) n Enabling 19..19..did the level go up? (y/n) y GPIO=19

SOURCE

gpiofinder_v1.tgz