UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor benjaminbuck
Visitor
4,828 Views
Registered: ‎08-26-2016

Zynq / petalinux GPIO issue

Using a ZC702 development board, I'm having a ton of trouble using GPIO with the gpio-keys driver.  My very simple project is a Zynq SOC with a one bit wide EMIO GPIO pin connected to output G19 (SW5 on the ZC702).  I add an entry in my petalinux device tree to map this to the "up" keycode, build everything, boot up my board from SD card and do a "cat /dev/inputevent0 | hexdump"

 

Nothing shows up when I press the switch.  However, I noticed that when I removed the SD card I started getting events whether or not I was pressing the switch:

root@bmbSimple:~# cat /dev/input/event0 | hexdump
0000000 0698 0000 23c1 000b 0001 006c 0002 0000
0000010 0698 0000 23c1 000b 0000 0000 0001 0000
0000020 0698 0000 bfe6 000b 0001 006c 0002 0000
0000030 0698 0000 bfe6 000b 0000 0000 0001 0000
0000040 0698 0000 5c27 000c 0001 006c 0002 0000
0000050 0698 0000 5c27 000c 0000 0000 0001 0000
0000060 0698 0000 f866 000c 0001 006c 0002 0000
0000070 0698 0000 f866 000c 0000 0000 0001 0000
0000080 0698 0000 94a6 000d 0001 006c 0002 0000
0000090 0698 0000 94a6 000d 0000 0000 0001 0000
00000a0 0698 0000 30e6 000e 0001 006c 0002 0000
00000b0 0698 0000 30e6 000e 0000 0000 0001 0000
00000c0 0698 0000 cd25 000e 0001 006c 0002 0000
00000d0 0698 0000 cd25 000e 0000 0000 0001 0000
00000e0 0699 0000 2726 0000 0001 006c 0002 0000
00000f0 0699 0000 2726 0000 0000 0000 0001 0000
0000100 0699 0000 c366 0000 0001 006c 0002 0000
0000110 0699 0000 c366 0000 0000 0000 0001 0000
0000120 0699 0000 5fa5 0001 0001 006c 0002 0000

I think I'm missing something very fundamental here... this should be so simple but I cannot get it to work!  What is going on?

 

I added keys.dtsi as an include to my device tree:

&amba {
gpio-keys {
compatible = "gpio-keys";
#address-cells = <1>;
#size-cells = <0>;
autorepeat;
mysw {
label = "mysw";
gpios = <&gpio0 0 0>;
linux,code = <108>; //down
gpio-key,wakeup;
autorepeat;
};
};
};

And I attached a screenshot of my block diagram.

bmbSimple.png
0 Kudos
6 Replies
Explorer
Explorer
4,826 Views
Registered: ‎04-05-2016

Re: Zynq / petalinux GPIO issue

What version of Vivado are you using?  What version of Linux are you using?  Can you paste your dmesg output?

0 Kudos
Visitor benjaminbuck
Visitor
4,818 Views
Registered: ‎08-26-2016

Re: Zynq / petalinux GPIO issue

Vivado 2015.4, petalinux 2015.5.  dmesg below.

 

Booting Linux on physical CPU 0x0
Linux version 4.0.0-xilinx (be25424@ll99-bob) (gcc version 4.9.2 (Sourcery CodeBench Lite 2015.05-17) ) #4 SMP PREEMPT Fri Aug 26 12:31:20 EDT 2016
CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=18c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: bombSimple
bootconsole [earlycon0] enabled
cma: Reserved 16 MiB at 0x3f000000
Memory policy: Data cache writealloc
On node 0 totalpages: 262144
free_area_init_node: node 0, pgdat c0983080, node_mem_map eeff7000
  Normal zone: 1520 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 194560 pages, LIFO batch:31
  HighMem zone: 67584 pages, LIFO batch:15
PERCPU: Embedded 11 pages/cpu @eefd4000 s12672 r8192 d24192 u45056
pcpu-alloc: s12672 r8192 d24192 u45056 alloc=11*4096
pcpu-alloc: [0] 0 [0] 1
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260624
Kernel command line: console=ttyPS0,115200 earlyprintk
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 1013080K/1048576K available (4759K kernel code, 223K rwdata, 1708K rodata, 3020K init, 208K bss, 19112K reserved, 16384K cma-reserved, 253952K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xf0000000 - 0xff000000   ( 240 MB)
    lowmem  : 0xc0000000 - 0xef800000   ( 760 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc0658efc   (6468 kB)
      .init : 0xc0659000 - 0xc094c000   (3020 kB)
      .data : 0xc094c000 - 0xc0983de0   ( 224 kB)
       .bss : 0xc0983de0 - 0xc09b80f4   ( 209 kB)
Preemptible hierarchical RCU implementation.
        Additional per-CPU info printed with stalls.
        RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
NR_IRQS:16 nr_irqs:16 16
L2C: platform modifies aux control register: 0x72360000 -> 0x72760000
L2C: DT/platform modifies aux control register: 0x72360000 -> 0x72760000
L2C-310 erratum 769419 enabled
L2C-310 enabling early BRESP for Cortex-A9
L2C-310 full line of zeros enabled for Cortex-A9
L2C-310 ID prefetch enabled, offset 1 lines
L2C-310 dynamic clock gating enabled, standby mode enabled
L2C-310 cache controller enabled, 8 ways, 512 kB
L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x76760001
slcr mapped to f0006000
zynq_clock_init: clkc starts at f0006100
Zynq clock init
sched_clock: 64 bits at 333MHz, resolution 3ns, wraps every 3298534883328ns
timer #0 at f000a000, irq=17
Console: colour dummy device 80x30
Calibrating delay loop... 1332.01 BogoMIPS (lpj=6660096)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x481788 - 0x4817e0
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
Brought up 2 CPUs
SMP: Total of 2 processors activated (2664.03 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 1 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 4 bytes.
zynq-ocm f800c000.ocmc: ZYNQ OCM pool: 256 KiB @ 0xf0080000
vgaarb: loaded
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
media: Linux media interface: v0.10
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
EDAC MC: Ver: 3.0.0
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource arm_global_timer
NET: Registered protocol family 2
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
TCP: reno registered
UDP hash table entries: 512 (order: 2, 16384 bytes)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: CLS 0 bytes, default 64
hw perfevents: enabled with armv7_cortex_a9 PMU driver, 7 counters available
futex hash table entries: 512 (order: 3, 32768 bytes)
jffs2: version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
bounce: pool size: 64 pages
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
zynq-pinctrl 700.pinctrl: zynq pinctrl initialized
dma-pl330 f8003000.dmac: Loaded driver for PL330 DMAC-241330
dma-pl330 f8003000.dmac:        DBUFF-128x8bytes Num_Chans-8 Num_Peri-4 Num_Events-16
e0001000.serial: ttyPS0 at MMIO 0xe0001000 (irq = 145, base_baud = 3125000) is a xuartps
console [ttyPS0] enabled
bootconsole [earlycon0] disabled
xdevcfg f8007000.devcfg: ioremap 0xf8007000 to f006c000
[drm] Initialized drm 1.1.0 20060810
brd: module loaded
loop: module loaded
CAN device driver interface
libphy: MACB_mii_bus: probed
macb e000b000.ethernet eth0: Cadence GEM rev 0x00020118 at 0xe000b000 irq 147 (00:0a:35:00:1e:53)
macb e000b000.ethernet eth0: attached PHY driver [Marvell 88E1116R] (mii_bus:phy_addr=e000b000.etherne:07, irq=-1)
e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
e1000e: Copyright(c) 1999 - 2014 Intel Corporation.
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
usbcore: registered new interface driver usb-storage
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
cdns-i2c e0004000.i2c: 400 kHz mmio e0004000 irq 142
Xilinx Zynq CpuIdle Driver started
Driver 'mmcblk' needs updating - please use bus_type methods
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
sdhci-arasan e0100000.sdhci: No vmmc regulator found
sdhci-arasan e0100000.sdhci: No vqmmc regulator found
mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
NET: Registered protocol family 17
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
Registering SWP/SWPB emulation handler
input: amba:gpio-keys as /devices/soc0/amba/amba:gpio-keys/input/input0
/opt/pkg/petalinux-v2015.4-final/components/linux-kernel/xlnx-4.0/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
ALSA device list:
  No soundcards found.
Freeing unused kernel memory: 3020K (c0659000 - c094c000)
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SS08G 7.40 GiB
 mmcblk0: p1
FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
random: dd urandom read with 1 bits of entropy available
mmc0: card aaaa removed
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SS08G 7.40 GiB
 mmcblk0: p1
mmc0: card aaaa removed
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SS08G 7.40 GiB
 mmcblk0: p1
mmc0: card aaaa removed
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SS08G 7.40 GiB
 mmcblk0: p1
random: nonblocking pool is initialized
mmc0: card aaaa removed
0 Kudos
Visitor benjaminbuck
Visitor
4,816 Views
Registered: ‎08-26-2016

Re: Zynq / petalinux GPIO issue

That is Petalinux 2015.4, not 2015.5... whoops.

0 Kudos
Explorer
Explorer
4,810 Views
Registered: ‎04-05-2016

Re: Zynq / petalinux GPIO issue

I don't see anything immediately obvious. I would double check your XDC file to ensure that you are going to the pin you think you are going to, and that you are switching the switch you think you are.
0 Kudos
Visitor benjaminbuck
Visitor
4,807 Views
Registered: ‎08-26-2016

Re: Zynq / petalinux GPIO issue

XDC file confirms that it is routed to pin G19.  See attached screenshot.  G19 is SW5 on the ZC702.

bmbSimpleSch.png

0 Kudos
Visitor benjaminbuck
Visitor
4,801 Views
Registered: ‎08-26-2016

Re: Zynq / petalinux GPIO issue

whoops... realized this is the wrong forum.  Moving to the Zynq forum.

 

https://forums.xilinx.com/t5/Zynq-All-Programmable-SoC/Zyqn-petalinux-GPIO-issue/td-p/717961

0 Kudos