Skip to main content

Control your DUT with GPIO and relays from the CLI

A bench can reach into your DUT's hardware through GPIO pins and relays: it can hold a boot strap, press a button, or switch power. This guide shows how to check each pin or relay channel with the mimick CLI, change it, and put it back.

What each pin or channel does depends on how your bench is wired to your DUT. Your org admin gives them names in the bench's peripheral config, so the names tell you what they're for.

Prefer the browser? See Control your DUT with relays in the web app.

What you need​

Changes reach your DUT immediately and affect anyone using it.

Step 1 · Pick your bench​

Make the bench wired to your DUT the active bench:

mimick bench use <your-bench>

Later commands target this bench until you pick another one. To target a different bench for a single command, pass --bench <your-bench> instead.

Step 2 · Find the peripheral​

List the GPIO and relay peripherals on the bench:

mimick peripheral list | grep -E 'LOCATION|\.(gpio|relay)'

A GPIO peripheral's location ends in .gpio and a channel number, usually .gpio0 (.gpio1 on a MIMICK HWI v2), and a relay board's ends in .relay0. The NAME column tells you which is which, and STATUS must be present. You pass the location to every command below with -p, for example -p buttons.relay0.

Step 3 · Control a relay​

  1. List the relay's channels and their current state:

    mimick relay list -p <location>

    Note the state of the channel you want, so you can put it back later.

  2. Switch the channel on or off. Use the channel's number or its name, and quote a name that has spaces:

    mimick relay write -p <location> '<channel>' on

    The CLI prints the channel number and its new state, such as 3=on.

  3. Read the channel back at any time:

    mimick relay read -p <location> '<channel>'
  4. When you're done, put the channel back the way you found it:

    mimick relay write -p <location> '<channel>' off

    When a channel has a name, you can leave out -p: the CLI finds the relay that carries it, for example mimick relay write 'Power button' on. A number still needs -p, because every relay starts at channel 1.

A relay channel switched on with mimick relay write, read back, and switched off again

Step 4 · Control a GPIO pin​

  1. List the pins and check which ones are outputs:

    mimick gpio list -p <location>

    The DIR column shows output for a pin you can set, and input for a pin that only reports what your DUT is doing.

  2. Read the pin's current level, and note it so you can put it back later:

    mimick gpio read -p <location> '<pin>'
  3. Set the pin. Use the pin's number or its name, and quote a name that has spaces. The level is high or low, and on or off works too:

    mimick gpio write -p <location> '<pin>' low
  4. Read the pin again to confirm the change. mimick gpio write prints the level you asked for, and mimick gpio read reports what the pin is at.

  5. When you're done, put the pin back the way you found it:

    mimick gpio write -p <location> '<pin>' high

    A pin with a name works without -p too, for example mimick gpio write reset_n low. A bench does not accept a config where two pins, or two relay channels, share a name, so the name finds one interface. On an older bench that still has such a config, the CLI lists the interfaces that share the name and asks you to pass -p.

A GPIO pin listed, read, set low, read back, and set high again

warning

Only write to pins that mimick gpio list shows as output. Writing to an input pin turns it into an output, so the bench starts driving a line your DUT may be driving too.

An output stays where you set it after the command ends, until you or someone else changes it.

The names, the pins, and the channels depend on how your bench is set up, so yours won't match these examples.

If it doesn't work​

What you seeWhat to do
not signed inRun mimick auth login.
no active benchRun mimick bench use <your-bench>, or pass --bench.
the bench "<name>" is offlineCheck that the bench has power and a network connection. It shows as connected in mimick bench list once it's back.
not authorized for that benchAsk your org admin for the Operator grant on the bench.
The peripheral shows as missing in mimick peripheral listThe bench can't reach the GPIO or relay board. Check its cable, or its network connection for a networked relay.
unknown pin or unknown relayThe name doesn't match. The message lists the names you can use.
The command works, but your DUT doesn't reactThe pin or channel may not be wired to the part of the DUT you expect. Ask your org admin to check the bench's wiring and config.