Re: Configuring UIO to handle GPIO interrupt #yocto #linux

Quentin Schulz

Hi Scott,

On Wed, Jul 08, 2020 at 07:15:17AM -0700, wrote:
Dear Yocto community,

I am hoping that you can provide advice on configuring UIO to handle a GPIO interrupt from user space. I found an excellent summary at and have tried to follow it as well as I can, being a newcomer to Yocto and embedded Linux.

We are using a Variscite DART-MX8M-MINI development kit, with the i.MX8M Mini processor on a System-on-Module. I have enabled spidev, which I am using to communicate with an ADS1299 EEG analog front end from TI. It generates a “data ready” interrupt DRDY# (active low). I’d like to be able to handle this falling-edge interrupt by connecting it to a GPIO (GPIO1_0) and either read() or poll() to wait for an interrupt, and can then read the acquired data using /dev/spidev0.0.

In my device tree, I have added the following under my &ecspi1 node. I am not certain this is the correct place to add this information, or if I can simply add it within the device tree “root” node “/ {“. I would appreciate your advice on the best place add this information!
// Added for DRDY# interrupt on GPIO1_0 from user space
user_io@0 {
compatible = "mydevice,generic-uio,ui_pdrv";
status = "okay";
interrupt-parent = <&gpio1>;
interrupts = <0 IRQ_TYPE_EDGE_FALLING>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_user_io>;

Under my dts &iomuxc node, the various pinctrl groups are defined. I added the following for GPIO1_0:
// Added for DRDY# interrupt on GPIO1_0 from user space
pinctrl_user_io: user_io-0 {
fsl,pins = <
This should configure the pin to enable a pull-up.

I have modified my kernel .config file via 'bitbake -c menuconfig virtual/kernel', and it contains the following entries:

The “y” setting for CONFIG_UIO was evidently due to other dependencies in the provided configuration. I then built the SD card image using 'bitbake fsl-image-qt5', and programmed it onto my SD card.
Up till there, this discussion would probably fit some kernel
communities more than the Yocto one.

A few things though:

- Bear in mind that using bitbake -c menuconfig virtual/kernel, the
changes aren't permanent. If there's a clean rebuild of the kernel for
some reason, your changes will be overwritten, you need to create a
patch for it (or take a defconfig) and add it to your kernel recipe (or
fork the kernel repo and add your own defconfig),

- Modules aren't shipped by default by Yocto, so you need either to
add kernel-modules to IMAGE_INSTALL or probably smarter to have it in
your machine configuration file in MACHINE_EXTRA_RRECOMMENDS, this will
install **all** kernel modules created by yocto,
or just add kernel-module-uio-pdrv-genirq (probably, don't know the exact
name of it) the same way to only have uio,


Join to automatically receive all group messages.