cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Participant
Participant
268 Views
Registered: ‎10-15-2019

Porting Interrupt-based Application from GPIO to UIO

Hi, 

I have an Ultra96v2 with a Grove Sensors Mezzanine Shield. My goal is to cause an interrupt when I press a push button which then would toggle some LEDs. I already have code that does that. My problem is that it uses the GPIO (Xilinx GPIO IP Product Guide ) driver. I would like to port my code to UIO. However, my port does not work as expected. I can toggle the LEDs without any issues but the interrupt does not work. The device trees only differ in the compatible string for the GPIO.

There are two ways in which it would not work. The first invocation of the program after every boot yields immediate returns for every call of read on the UIO file descriptor suggesting immediate (unintended) interrupts. Subsequent invocations of the program lead to the calls on read simply not returning, suggesting that no interrupts are generated. Pressing the button after that has no effect. I find this quite puzzling. Any ideas?

Non-working UIO program first invocation after boot:

Trying to open UIO device.
File descriptor is 3.
Scanning size_fp into uio_size resulted in: Success.
uio_size is 4096.
The base address is 0x7f8c24e000
Writing 0x0 to offset 0x4 = 0x7f8c24e004
Writing 0x10 to offset 0x4 = 0x7f8c24e004
Reading 0x1 from offset 0x120 = 0x7f8c24e120
Writing 0x1 to offset 0x128 = 0x7f8c24e128
Reading 0x1 from offset 0x128 = 0x7f8c24e128
Writing 0x80000000 to offset 0x11c = 0x7f8c24e11c
Reading 0x80000000 from offset 0x11c = 0x7f8c24e11c
Init done.

Debounced 12895494 times since the call of poll.
Reading 0x10 from offset 0x0 = 0x7f8c24e000
lseek on uio_fd returns 0
reading uio_fd returns 4
pending is 1
Reading 0x10 from offset 0x0 = 0x7f8c24e000
Interrupt occurred. Data register contains: 0x10
Reading 0x1 from offset 0x120 = 0x7f8c24e120
Writing 0x1 to offset 0x120 = 0x7f8c24e120
Reading 0x0 from offset 0x120 = 0x7f8c24e120
Reading 0x10 from offset 0x0 = 0x7f8c24e000
Reading 0x10 from offset 0x0 = 0x7f8c24e000
Writing 0xf to offset 0x0 = 0x7f8c24e000
LEDs toggled.
Reenabled interrupt.


Debounced 12902024 times since the call of poll.
Reading 0x1f from offset 0x0 = 0x7f8c24e000
lseek on uio_fd returns 0
reading uio_fd returns 4
pending is 2
Reading 0x1f from offset 0x0 = 0x7f8c24e000
Interrupt occurred. Data register contains: 0x1f
Reading 0x1 from offset 0x120 = 0x7f8c24e120
Writing 0x1 to offset 0x120 = 0x7f8c24e120
Reading 0x0 from offset 0x120 = 0x7f8c24e120
Reading 0x1f from offset 0x0 = 0x7f8c24e000
Reading 0x1f from offset 0x0 = 0x7f8c24e000
Writing 0x0 to offset 0x0 = 0x7f8c24e000
LEDs toggled.
Reenabled interrupt.


Debounced 12904993 times since the call of poll.
Reading 0x10 from offset 0x0 = 0x7f8c24e000
lseek on uio_fd returns 0
reading uio_fd returns 4
pending is 3
Reading 0x10 from offset 0x0 = 0x7f8c24e000
Interrupt occurred. Data register contains: 0x10
Reading 0x1 from offset 0x120 = 0x7f8c24e120
Writing 0x1 to offset 0x120 = 0x7f8c24e120
Reading 0x0 from offset 0x120 = 0x7f8c24e120
Reading 0x10 from offset 0x0 = 0x7f8c24e000
Reading 0x10 from offset 0x0 = 0x7f8c24e000
Writing 0xf to offset 0x0 = 0x7f8c24e000
LEDs toggled.
Reenabled interrupt.


Debounced 12904296 times since the call of poll.
Reading 0x1f from offset 0x0 = 0x7f8c24e000
lseek on uio_fd returns 0
reading uio_fd returns 4
pending is 4
Reading 0x1f from offset 0x0 = 0x7f8c24e000
Interrupt occurred. Data register contains: 0x1f
Reading 0x1 from offset 0x120 = 0x7f8c24e120
Writing 0x1 to offset 0x120 = 0x7f8c24e120
Reading 0x0 from offset 0x120 = 0x7f8c24e120
Reading 0x1f from offset 0x0 = 0x7f8c24e000
Reading 0x1f from offset 0x0 = 0x7f8c24e000
Writing 0x0 to offset 0x0 = 0x7f8c24e000
LEDs toggled.
Reenabled interrupt.

Non-working UIO program subsequent invocations output:

 

Trying to open UIO device.
File descriptor is 3.
Scanning size_fp into uio_size resulted in: Success.
uio_size is 4096.
The base address is 0x7fa7218000
Writing 0x0 to offset 0x4 = 0x7fa7218004
Writing 0x10 to offset 0x4 = 0x7fa7218004
Reading 0x1 from offset 0x120 = 0x7fa7218120
Writing 0x1 to offset 0x128 = 0x7fa7218128
Reading 0x1 from offset 0x128 = 0x7fa7218128
Writing 0x80000000 to offset 0x11c = 0x7fa721811c
Reading 0x80000000 from offset 0x11c = 0x7fa721811c
Init done.

Debounced 12901111 times since the call of poll.
Reading 0x10 from offset 0x0 = 0x7fa7218000
lseek on uio_fd returns 0

 

Working GPIO program output:

value511 is: 1

Debounced 0 times since the call of poll.
Interrupt counter increased to 1.
Occurred event is OTHER (may be multiple) (fds.revents = 10).
Toggling LEDs.
unsigned long size: 8
value507str is: 0
value508str is: 0
value507 is: 0 
value508 is: 0 
inverted value507 is: 1 
inverted value508 is: 1 
value507 after write is: 1
value508 after write is: 1

... (same output repeated 9 more times except for toggled LED 
values and increased interrupt counter)

Attached are the source code of each program, the device tree and the block diagram of the design created in Vivado 2019.1.

Tags (2)
bd.png
0 Kudos
0 Replies