GPIO example using libgpiod.
Use the following command to build a container:
docker build --build-arg GCC_PREFIX=aarch64-linux-gnu --build-arg CROSS_TC_IMAGE_ARCH=arm64 --build-arg ARCH_ARG=linux/arm64 -t gpio-example
After image is built, it can be either uploaded to docker hub account/some other container registry or can be moved to target machine in portable tar archive file.
To move it to the target machine in portable tar archive file, execute
docker save -o gpio-image.tar gpio-example
docker load -i gpio-image.tar
Transfer the container to the module and use the following command:
docker run --rm -it --init --device /dev/gpiochip3 --device /dev/gpiochip4 gpio-example
The gpio bank number is the GPIO number x -1: GPIOx_y => /dev/gpiochip(x-1)_y ... Use the gpiod command line tools: There are currently six command-line tools available:
gpiodetect - list all gpiochips present on the system, their names, labels and number of GPIO lines
gpioinfo - list all lines of specified gpiochips, their names, consumers, direction, active state and additional flags
gpioget - read values of specified GPIO lines
gpioset - set values of specified GPIO lines, potentially keep the lines exported and wait until timeout, user input or signal
gpiofind - find the gpiochip name and line offset given the line name
gpiomon - wait for events on a GPIO line, specify which events to watch, how many events to process before exiting or if the events should be reported to the console.
Some examples:
GPIO5_13 as J1.79 at Pin#10 of J17 on Variscite Symphony Board gpioset /dev/gpiochip4 13=0 gpioset /dev/gpiochip4 13=1 gpiomon 4 13 gpioget 4 13 GPIO4_3 as J1.84 at Pin#3 of J17 on Variscite Symphony Board gpioset /dev/gpiochip3 3=0 gpioset /dev/gpiochip3 3=1 gpiomon 3 3 gpioget 3 3
Toggle a GPIO: gpio-toggle 3 3
Read GPIO Using Events (Interrupt Driven): gpio-event 4 13 3 3
Content type
Image
Digest
Size
44.2 MB
Last updated
almost 5 years ago
docker pull hachyang/gpio-example