Altera_Forum
Honored Contributor
13 years agoUsing nios2-elf-gprof with UCOS-II?
Hello All,
Is it possible to use the Nios II GNU profiler with applications that use an OS (such as UCOS-II) with multitasking? I have followed the the "Profiling Nios II Systems" guide (unable to post link at the time - google title). However, when I execute the necessary commands, the gmon.out file is not created. Thus, I can not do any profiling. Here is what I have done: 1) Set enable_gprof and enable_exit to true in my applications BSP settings. 2) Regenerated BSP and re-built. 3) Opened two terminals, let's call them terminal A & B. 4) In terminal A, I executed the following command: --- Quote Start --- nios2-terminal --- Quote End --- 5) In terminal B, I then execute the following command: --- Quote Start --- nios2-download -g --write-gmon gmon.out my_eth_app.elf --- Quote End --- 6) I run my application and then exit with Ctrl-l C. 7) I then noticed that no gmon.out file is created. Is there something I am missing? One thing that the guide above states is to verify that your main function returns. However, in an UCOS-II application, main should not return as tasks are continually running. Typically, the UCOS-II API, OSStart(), is called from main, which starts multitasking and never returns. As an example of main, have a look at the code below.
int main (int argc, char* argv, char* envp)
{
INT8U error_code;
/* Clear the RTOS timer */
OSTimeSet(0);
error_code = OSTaskCreateExt(initial_task,
NULL,
(void *)&initial_task_stack,
INITIAL_TASK_PRIORITY,
INITIAL_TASK_PRIORITY,
&initial_task_stack,
TASK_STACKSIZE,
NULL,
0);
alt_uCOSIIErrorHandler(error_code, 0);
/*
* As with all MicroC/OS-II designs, once the initial thread(s) and
* associated RTOS resources are declared, we start the RTOS. That's it!
*/
OSStart();
while(1); /* Correct Program Flow never gets here. */
return -1;
}
As you can see from above, main will not return. Is this my issue? Do I have to look at other options to profile my application? Thanks for your help and I look forward to any feedback. -JQ