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: 
Adventurer
Adventurer
1,941 Views
Registered: ‎10-11-2017

SDK: debug code runaway

Jump to solution

Hello everyone!

I creat block design include Microblaze,AXI QUAD SPI and AXI GPIO.When I debug my code in SDK,I found a strange problem.Here is my code.

 

#include "xparameters.h"
#include"xspi.h"
#include "xspi_l.h"
#include"xgpio.h"

#define SPI_MASTER_ID XPAR_SPI_0_DEVICE_ID
#define LED_ID XPAR_GPIO_0_DEVICE_ID
#define LED_CHANNEL 1
#define LED 1
#define SLAVE_SELECT_MASK 1

int main(void)
{
XSpi spi_master;
XGpio led;
int Status;

XSpi_Config *ConfigPtr;
ConfigPtr = XSpi_LookupConfig(SPI_MASTER_ID);
if(ConfigPtr==NULL){
return XST_FAILURE;
}

Status = XSpi_CfgInitialize(&spi_master, ConfigPtr,ConfigPtr->BaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
/************GPIO***************/
Status=XGpio_Initialize(&led,XPAR_GPIO_0_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
XGpio_SetDataDirection(&led,LED_CHANNEL,~LED);
XGpio_DiscreteWrite(&led,LED_CHANNEL,LED);
return XST_SUCCESS;
}

 

 

When I debug in step over mode,It will runaway when execute  the function XSpi_CfgInitialize,The arrow disappears and I don't know which line of  code is executing.Then I click 'Suspend' ,It shows in 'Disassembly' window:4.png

It looks like stop at  the function xil_assert,It means my application code isn't  satisfying certain conditions.But I don't konw what's wrong with my code.

 

But When  I click 'RUN',It seems run OK and the LED in my customer board is light.I don't konw even  if there is something wrong with my code.

 

I try to use the official code example--xspi_polled example.When debug in step over mode.It will runaway too.

I am using sdk2017.2  in Windows7. 

 

Any idea?

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
2,854 Views
Registered: ‎10-11-2017

Re: SDK: debug code runaway

Jump to solution

Thanks!@johnmcd

I have solved it.

I found that when configure Microblaze without check 'Use Instruction and Data Caches',it will work normally.

But I don't konw why.

0 Kudos
8 Replies
Xilinx Employee
Xilinx Employee
1,916 Views
Registered: ‎02-01-2008

Re: SDK: debug code runaway

Jump to solution

This might be related to an issue in 2017.2 where a re-exported hdf is not correctly handled in the sdk workspace. It's only a guess, but I'm wondering if you are debugging an elf that doesn't match the src and therefore the pointers are incorrect.

 

See this reply: https://forums.xilinx.com/t5/Embedded-Development-Tools/Exporting-new-hardware-quot-corrupts-quot-SDK-project/m-p/781003#M42394

 

 

0 Kudos
Adventurer
Adventurer
1,900 Views
Registered: ‎10-11-2017

Re: SDK: debug code runaway

Jump to solution

Thanks!@johnmcd

I didn't re-exported hdf.I have try to creat a new project but it still doesn't work.

There is only one elf in my project and  it match the src.

0 Kudos
Adventurer
Adventurer
1,891 Views
Registered: ‎10-11-2017

Re: SDK: debug code runaway

Jump to solution

I found it will runaway when execute the scentence 'XSpi_Reset(InstancePtr)' which is the last  scentence in the function XSpi_CfgInitialize(...). If I delete the 'XSpi_Reset(...)',It will run ok. The data of the XSpi  *InstancePtr struct can be assigned correctly.It's very strange.I don't know why it is happen.

0 Kudos
Adventurer
Adventurer
1,889 Views
Registered: ‎10-11-2017

Re: SDK: debug code runaway

Jump to solution

I checked the function XSpi_Reset(...),I found it will runaway when execute the scentence

Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

If I delete this scentence,it will run ok.

But this scentence can not be wrong since InstancePtr->IsReady is already assigned by XSpi_CfgInitialize(..) before XSpi_Reset(...) executed.The value of InstancePtr->IsReady actually is XIL_COMPONENT_IS_READY.I don't konw  what's wrong with it.

0 Kudos
Xilinx Employee
Xilinx Employee
1,830 Views
Registered: ‎02-01-2008

Re: SDK: debug code runaway

Jump to solution

You could try assembly mode and single step into XSpi_Reset to see the actual access that blows up.

 

I'm wondering if this issue could be stack related or memory getting trampled on. I see that Xil_AssertVoid() is a macro.

 

If you double click on the elf while in sdk, it will do an objectDump and show you the assembly that should be in your memory. So assembly mode single step would be a good 'next step'.

0 Kudos
Adventurer
Adventurer
1,822 Views
Registered: ‎10-11-2017

Re: SDK: debug code runaway

Jump to solution

Thanks!@johnmcd

I double click on the elf in the SDK.It shows:

1.png

But I don't konw how to single step in assembly mode.Do I need to set some properties in the debug window?

 

Besides,If I debug as 'Launch on hardware(system debug)',I step into the function  XSpi_CfgInitialize(...),It will show 'Disassembly' window:

2.png

Then I single step over and over,It will execute right and return XST_SUCCESS. It's wired.

The function XSpi_CfgInitialize(...) will run error when in  Step Over mode,But  it can run right when Step into the function  and  then single step over by over.I have totally no idea why this is happen.

 

 

 

0 Kudos
Highlighted
Adventurer
Adventurer
2,855 Views
Registered: ‎10-11-2017

Re: SDK: debug code runaway

Jump to solution

Thanks!@johnmcd

I have solved it.

I found that when configure Microblaze without check 'Use Instruction and Data Caches',it will work normally.

But I don't konw why.

0 Kudos
Xilinx Employee
Xilinx Employee
1,773 Views
Registered: ‎02-01-2008

Re: SDK: debug code runaway

Jump to solution

See my response to your other 2 threads regarding why cache should not be enabled.

0 Kudos