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 monthadar
Visitor
10,775 Views
Registered: ‎09-16-2008

can't run main_thread in Xilkernel

Jump to solution

Hi!

 

I was trying to program something with xilkernel, so I thought of making a simple example:

#include <stdio.h>
#include "xmk.h"

int main()
{
    xilkernel_main();
    return 0;
}

int main_thread()
{
    xil_printf("Hi! Lets begin !\r\n");
    return 0;
}

 

and I have configure the compiler with -lxilkernel, and platform settings for the os:

sysint_spec: xps_intc_0

stdout: RS232_DCE

stdin: RS232_DCE

enhanced feature: true

config_shed: true

config_pthread_support: true

system_interval: 10

system_freq: 50,000,000

 systemr_dev: xps_timer_1

 and other settings to false.

 

It compiles and downloads without any problem. But I don't see the printout on hyperterminal. (printout works I tested first to printout before calling xilkernel_main()).

 

So where am I doing it wrong?

Thank you in advance.

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Observer torinford
Observer
12,908 Views
Registered: ‎06-23-2008

Re: can't run main_thread in Xilkernel

Jump to solution

In your .mss file (software platform settings dialog) you need to make sure you have main_thread set as a static pthread.  So in the .mss file you would see something like this:

 

PARAMETER static_pthread_table = ((main_thread,1))

 

In the UI, go to Software Platform Settings -> OS and Libraries -> config_pthread_support -> static_pthread_table and add that thread and a priority.  In my example that priority value is 1.

 

Torin

9 Replies
Highlighted
Observer torinford
Observer
12,909 Views
Registered: ‎06-23-2008

Re: can't run main_thread in Xilkernel

Jump to solution

In your .mss file (software platform settings dialog) you need to make sure you have main_thread set as a static pthread.  So in the .mss file you would see something like this:

 

PARAMETER static_pthread_table = ((main_thread,1))

 

In the UI, go to Software Platform Settings -> OS and Libraries -> config_pthread_support -> static_pthread_table and add that thread and a priority.  In my example that priority value is 1.

 

Torin

Visitor monthadar
Visitor
10,751 Views
Registered: ‎09-16-2008

Re: can't run main_thread in Xilkernel

Jump to solution

Thank you very much :)

Message Edited by monthadar on 09-19-2008 04:50 PM
0 Kudos
10,525 Views
Registered: ‎10-08-2008

Re: can't run main_thread in Xilkernel

Jump to solution

Hello,

I have the same problem. I did what you have explained. But the compiler gives the error below:

 

../../ppc440_0_sw_platform/ppc440_0/lib/libxil.a(init.o):(.sdata+0x0): undefined reference to `main_thread'

 

I think I am missing a point. I could compile an example (downloaded from Xilinx). I compared all the files of both projects, but couldn't find any difference.

It is strange because the BSP can not be dependent on a sw project.

Is there anything that I should do in addition to your explanations?

Thanks.

Özgür 

0 Kudos
Xilinx Employee
Xilinx Employee
10,520 Views
Registered: ‎08-07-2007

Re: can't run main_thread in Xilkernel

Jump to solution
Hi Özgür,

Do you have main_thread thread defined in your application? If not, please define one.

-XF
0 Kudos
10,509 Views
Registered: ‎10-08-2008

Re: can't run main_thread in Xilkernel

Jump to solution

Yes it is defined.

I was trying to insert a new sw project to one of the examples.

Then I created a new XPS project with BSB. And then add a sw project and copied all the sources.

Then it worked.

But still the other project does not compile. And I don't know the reason.

It makes me a bit uncomfortable about the sw development using Xilinx tools. There is not enough documentation especially about XilKernel.

Most of the sample projects are for standalone systems. There a few using XilKernel. 

Any experience about this?

Thanks

Özgür

0 Kudos
10,499 Views
Registered: ‎10-08-2008

Re: can't run main_thread in Xilkernel

Jump to solution

Hello,

I should correct my response.

The problem continues. The same error occurs when the function name (in static_pthread_table) is different than "main". In the previous trial it was left as "main". If it is "main" it compiles, but of course this is meaningless.

Any idea about what I should do?

 

Thanks

Özgür 

0 Kudos
Observer torinford
Observer
10,492 Views
Registered: ‎06-23-2008

Re: can't run main_thread in Xilkernel

Jump to solution
Are you using C or C++? Your application needs a function called main. Directly or indirectly, this main needs to call xilkernel_main. If you want other threads to be started by xilkernel_main, then you add them to the static pthread table as described above. If you're using C++, you're main and your static pthread functions need to be wrapped by:

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/

blah main(blah) { ....}

blah somethread(blah) {...}

#if defined(__cplusplus)
}
#endif /* __cplusplus */

Torin
10,377 Views
Registered: ‎10-08-2008

Re: can't run main_thread in Xilkernel

Jump to solution

Yes, you are right. I couldn't realize that.

It worked. 

Thank you. 

0 Kudos
Visitor naz56
Visitor
7,560 Views
Registered: ‎05-22-2010

Re: can't run main_thread in Xilkernel

Jump to solution

HELLO

 

i did the same but still print in main_thread() is not displaying...plz help..

 added xps timer...microblaze processor..congigured OS n lib..added timer...but all in a vain..

 

when i added  interrupt  peripheral  XPS_INTC_0 in kernal libraries setting....error returned...

 

-------------------------

Running DRCs for OSes, Drivers and Libraries ... 

ERROR:MDT - issued from TCL procedure "::sw_xilkernel_v4_00_a::kernel_drc" line

   13

    xilkernel () - Xilkernel for Microblaze requires a system timer device to be

   specified. Please choose a valid peripheral instance in the systmr_dev

   parameter.

 

 

y it is like this??

THANX

 

 

0 Kudos