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: 
Scholar helmutforren
Scholar
1,670 Views
Registered: ‎06-23-2014

XGpio_SetDataDirection hangs

Jump to solution

I'm using Vivado 2018.1. 

 

I've created the example Hello_World program from microblaze-quick-start-guide.pdf .  This worked fine.

 

I'm using a KC705 board that has both LEDs and buttons.  The Hello_World example started off with an AXI GPIO to drive the LEDs.  I figured out how to do this by finding other examples online, and this worked.

 

The Hello_World example does NOT, however, try to read the buttons of the KC705 board.  So in the block diagram I added a 2nd GPIO channel to the AXI GPIO, with 5 bits for 5 of the KC705 buttons.  I built the bitstream and exported the hardware.  I ran my existing Hello_World program as a baseline and it continues to blink the LEDs.  However, when I try to read the buttons, I get a hang.


Specifically, I have these two lines of code:

XGpio_SetDataDirection(&gpio, 1, 0x00000000); // set LED GPIO channel tristates to All Output
XGpio_SetDataDirection(&gpio, 2, 0x0000001F); // set BTN GPIO channel tristates to All Input (only 5 bits defined)

 

The first line executes as it did in the past, no problem.  The second line, which is the new line to set the buttons as inputs, hangs.

 

The only doc I find is at https://xilinx.github.io/embeddedsw.github.io/gpio/doc/html/api/group__gpio__v4__3.html#gabee6bcad28382ef5ecd336887647c238 and this does NOT suggest the function should be blocking.

 

However, it does say the function will "assert" if the hardware isn't built for dual channels.  Well, a couple things:

  1. How do I easily recognize such an "assert"?  Note that in debug mode I can pause the program.  The assembly window shows up -- yes, I've seen this many many times in regular C programming.  That window has the instruction pointer on a a line "bnei r3,0 ; addr=0x00001058: Xil_Assert + 0x0000003c".  This certainly SEEMS like it's trying to assert.  But I would have thought I would have seen a console message, which I did NOT see.  Is there a specific window to look in to see the assert and perhaps the meaning?
  2. Nevertheless, I'm sure the hardware is indeed built for two channel GPIO.  I revisit the Vivado Diagram and I see the GPIO2 output going to my external btn_5bits signal.  I'm sure I did Generate Block Design, but I do it again anyway.  It was super fast. I right click on the OOC base_mb and select Regenerate Output Products.  Now it says "Using cached IP results" in the Design Runs window for the base_mb line.  I'm not liking this.  I want to force the sucker to rebuild.  Is this where my problem is?  Note I told the system to auto handle the wrapper way back when.  I generate output products again.  Still says using cached IP results.  Just for grins I change axi gpio default output values, trying to force an update.  Finally Design Runs says base_mb is "Submodule Runs Not Started".  Now I build bitstream...  Finally I see it running synth on base_mb as it should have long ago.  It took 50 seconds.  (Yeh!, I like all this more than my prior 45 minutte RTL builds, although I hear of multi-day builds.)  Export hardware.  Say YES to overwrite.  SDK already loaded.  From SDK program FPGA.  Trivial edit, save and recompile helloworld.c.  Run debug.  STILL HANGS ON SECOND XGpio_SetDataDirection.

Obviously I'm new to IP Integrator as well as SDK-specific source code level debugging, even though I've been using Vivado for over a year and ISE for several years, and debugging regular code for 43 years, who knows how many at source level. 

 

Any hints about why this is hanging?

 

[EDIT: I ready that I must define my own Xil_AssertCallback function.  I now give myself meaningful info, even though I still don't know WHY my XGpio_SetDataDirection() call is asserting.  Reference https://forums.xilinx.com/t5/Embedded-Development-Tools/standart-printf-source-of-annoying-behaviour/td-p/741719 and https://forums.xilinx.com/t5/Embedded-Development-Tools/How-to-make-use-of-assert/td-p/771741 ]

0 Kudos
1 Solution

Accepted Solutions
Scholar helmutforren
Scholar
1,726 Views
Registered: ‎06-23-2014

Re: XGpio_SetDataDirection hangs

Jump to solution

I find that XGpio_Initialize() sets up the gpio structure with BaseAddress=0x40000000 and IsReady=0x11111111 and InterruptPresent=0.  These seem fine.  However, it also sets up isDual=0.  This is the ROOT of the problem.  When I manually set isDual to 1 after XGpio_Initialize(), the hang goes away but the XGpio_DiscreteRead()'s don't work.  I'm confident that XGpio_Initialize() **should** have set isDual to 1, but it did not.

 

Why??? 

 

I double checked the diagram in Vivado.  The second GPIO channel is enabled.  Note that I enabled it myself, the original hello world example having only a single.  I rebuilt the bitstream, exported hardware, reloaded the closed SDK.  [EDIT: note in Vivado in the Design tab, selecting axi_gpio_0, in the Block Properties window, selecting Properties, I find that C_IS_DUAL has a value of 1.  So in Vivado it's known to be dual.  But not in my programming running from SDK.]

 

Did helloworld set some other thing that's keeping the software thinking the AXI GPIO is not dual?

 

[EDIT: XGpio_LookupConfig() returns structure with isDual zero.  It should be returning 1.]

 

[EDIT: ACTUAL REASON GPIO SET DATA DIRECTION WAS HANGING WAS BECAUSE SDK WAS OUT OF SYNC.  See https://forums.xilinx.com/t5/Embedded-Development-Tools/Having-update-issues/m-p/859412#M45623  ]

View solution in original post

0 Kudos
8 Replies
Moderator
Moderator
1,662 Views
Registered: ‎09-12-2007

Re: XGpio_SetDataDirection hangs

Jump to solution

There is example code you can use that is delivered with the driver in the SDK install. 

 

You should try this. 

0 Kudos
Scholar helmutforren
Scholar
1,656 Views
Registered: ‎06-23-2014

Re: XGpio_SetDataDirection hangs

Jump to solution

Thanks, @stephenm .  How do I locate this example code?  I search <install dir...>SDK/2018.1 and don't see anything obvious.  I search with Win10 and find 7699 .c?? files.  Dunno how to search for only .c files.


Finally I search for *gpio*.c and find some candidates, which lead me to the folder:

...\2018.1\data\embeddedsw\XilinxProcessorIPLib\drivers\gpiops_v3_2\examples

 

So that tells me where the drivers are, and for each driver there seems to be an examples folder.  NOTE AS WELL I seem to see both interrupt and polled examples.  Interrupt speaks to my other post at https://forums.xilinx.com/t5/AXI-Infrastructure/First-base-MicroBlaze-AXI-interrupts-BARE-METAL/td-p/858170  .  So these example, HIDDEN down in here, may be pure gold...  [EDIT: HOWEVER, ARE THESE BARE METAL EXAMPLES?  I'm concerned they are NOT.]

 

So I found the location of the answer you gave.  I've documented it here a little for others.

0 Kudos
Moderator
Moderator
1,654 Views
Registered: ‎09-12-2007

Re: XGpio_SetDataDirection hangs

Jump to solution

Yep, The interrupt examples will assume you have the gpio interrupt connected via axi intc

0 Kudos
Scholar helmutforren
Scholar
1,651 Views
Registered: ‎06-23-2014

Re: XGpio_SetDataDirection hangs

Jump to solution

@stephenm I think these examples are NOT for bare metal.  Do you know to the contrary that they are?  Or do you know where I can find bare metal examples?


Specifically, both polled and interrupt examples call XGpioPs_SetDirectionPin() which is a different function from the bare metal function XGpio_SetDataDirection().

0 Kudos
Moderator
Moderator
1,642 Views
Registered: ‎09-12-2007

Re: XGpio_SetDataDirection hangs

Jump to solution

All the driver code delivered in SDK install is bsremetal. Why do you think they are not baremetal?

 

By the way, there are ps gpio and axi gpio driver, so don’t confuse these. 

0 Kudos
Scholar helmutforren
Scholar
1,636 Views
Registered: ‎06-23-2014

Re: XGpio_SetDataDirection hangs

Jump to solution

Thanks.   I guess I'm confusing PS and AXI gpio.  What's PS?

 

Nearby to the gpiops_v3_2 and gpiops_v3_3 folders I find a gpio_v4_3, which I assume is AXI.  Inside I find the examples.  included is an interrupt example.  The main example, xgpio_example.c is using the familiar functions.

 

This SHOULD get me closer for the interrupt thing (other post).

 

For the hanging thing, it might be that the block diagram for the AXI GPIO had the second channel manually enabled by me.  Then I see on the wizard Board tab that the second GPIO Board Interface was "Custom".  I changed that to "push buttons 5bits".  This subsequently created more constraints conflicts.  As with the clock in a different post, I fell back to the default example signal name, a 5-bit vector.  I expect this to subsequently run without assert.  NOTE: Still hangs.

 

THE QUESTION REMAINS about the darned pin connections and constraints.  See my post at

https://forums.xilinx.com/t5/Design-Entry/Can-I-mix-IP-Integrator-Block-Diagram-and-custom-RTL/m-p/858148#M16892

 

I am going to need to customize this in the future for our own custom board, slightly different from the KC705.  That's why I'm so concerned about it.

 

0 Kudos
Scholar helmutforren
Scholar
1,727 Views
Registered: ‎06-23-2014

Re: XGpio_SetDataDirection hangs

Jump to solution

I find that XGpio_Initialize() sets up the gpio structure with BaseAddress=0x40000000 and IsReady=0x11111111 and InterruptPresent=0.  These seem fine.  However, it also sets up isDual=0.  This is the ROOT of the problem.  When I manually set isDual to 1 after XGpio_Initialize(), the hang goes away but the XGpio_DiscreteRead()'s don't work.  I'm confident that XGpio_Initialize() **should** have set isDual to 1, but it did not.

 

Why??? 

 

I double checked the diagram in Vivado.  The second GPIO channel is enabled.  Note that I enabled it myself, the original hello world example having only a single.  I rebuilt the bitstream, exported hardware, reloaded the closed SDK.  [EDIT: note in Vivado in the Design tab, selecting axi_gpio_0, in the Block Properties window, selecting Properties, I find that C_IS_DUAL has a value of 1.  So in Vivado it's known to be dual.  But not in my programming running from SDK.]

 

Did helloworld set some other thing that's keeping the software thinking the AXI GPIO is not dual?

 

[EDIT: XGpio_LookupConfig() returns structure with isDual zero.  It should be returning 1.]

 

[EDIT: ACTUAL REASON GPIO SET DATA DIRECTION WAS HANGING WAS BECAUSE SDK WAS OUT OF SYNC.  See https://forums.xilinx.com/t5/Embedded-Development-Tools/Having-update-issues/m-p/859412#M45623  ]

View solution in original post

0 Kudos
Participant sruthi@1
Participant
1,439 Views
Registered: ‎06-13-2018

Re: XGpio_SetDataDirection hangs

Jump to solution

Hi,

 

I have implemented an LWIP bare metal application in ZC706 successfully and now I want to add an LED GPIO to my project.

 

I have done the required hardware changes in Vivado and imported it to SDK but the execution stops at XGpio_WriteReg() inside XGpio_SetDataDirection() as per my understanding.

 

A standalone LED blinking application is working fine but same when added to my LWIP project hangs.Is there any particular configuration needed to be done or might there be any conflicting configurations in my project?

 

Please help.

 

Thank you.

0 Kudos