3

I am trying to use vTaskList function to monitor tasks being used. In order to use vTaskList, I configure the macro below.

#define configUSE_TRACE_FACILITY        1
#define configUSE_STATS_FORMATTING_FUNCTIONS 1

and below is task code to display task list.

  void TASK_LIST()
    {
        signed char pWriteBuffer[2048];
        for(;;)
        {
            vTaskList(pWriteBuffer);
            printf("task_name   task_state  priority   stack  tasK_num\n");
            printf("%s\n", pWriteBuffer);
        }
        vTaskDelete(NULL);
        return;
    }

However, the error just showed up for undefined reference

What caused this error?

Thank you.

Ps. For my original situation, there is no macro for configUSE_STATS_FORMATTING_FUNCTIONS in FreeRTOSConfig.h. so I add it manually.

Now I am searching building command to build whole project enter image description here

黃銘賢
  • 73
  • 2
  • 9

1 Answers1

0

It looks from code source as it depends on FreeRTOS kernel version...

I checked several demo applications for your particular version, e.g. this one, and also code source for tasks.c. And it should be enough to set those two macros which you mentioned. So, the actual reason of linking error looks like not related to configuration itself. Check if tasks.c source file is rebuilt after configuration change (if not, dependencies in project are not handled properly). Double check also that those defines are real "1" - digit (not "l" (small "L" letter) or "I" (capital "I" letter), which can be easily confused with "1" depending on used font).

UPDATE

Since you are using Eclipse IDE, take a look at this official guidance of how to setup project. Here you can find demo project for Eclipse for your version of FreeRTOS, check Makefile in particular, I guess your auto-generated Makefile missing lines like:

$(RTOS_SOURCE_DIR)/tasks.c \

PS

For v9.0.0 it should be enough to enable configurations as you did. But v10.0.0 there is also dependency on configSUPPORT_DYNAMIC_ALLOCATION: if in project's FreeRTOSConfig.h it's defined to something other than default ("1") - vTaskList will be excluded. This dependency, however, is neither mentioned in include header file task.h nor in online documentation.

pmod
  • 10,450
  • 1
  • 37
  • 50
  • My FreeRTOS is v7.5.3. I have also checked the documentation. I still don't get it... – 黃銘賢 Feb 22 '19 at 03:00
  • @黃銘賢 but 7.5.3 has configUSE_STATS_FORMATTING_FUNCTIONS https://svn.code.sf.net/p/freertos/code/tags/V7.5.3/FreeRTOS/Source/include/FreeRTOS.h did you mean configUSE_TRACE_FACILITY instead? – pmod Feb 22 '19 at 06:25
  • Yes I found it. However, even though I change the configuration in FreeRTOS.h It showed up the same error. Maybe I should include FreeRTOSConfig.h in task.c ? – 黃銘賢 Feb 22 '19 at 06:43
  • @黃銘賢 no, you shouldn't modify files in kernel, but it looks like your changes in FreeRTOSConfig.h are not applied for some reason. What if you just for test comment out #define configUSE_PREEMPTION for example - you should get compile error – pmod Feb 22 '19 at 20:25
  • Yes, I've tried to comment #define configUSE_PREEMPTION. And I get compiled error – 黃銘賢 Feb 27 '19 at 05:09
  • @黃銘賢 OK, then a new thought: are you sure tasks.c is re-compiled, can you build from scratch?? i.e. remove object files and run build, can you find tasks.o ? – pmod Feb 27 '19 at 13:03
  • Yes, there are only files in src built. I think this is the main problem that I can't use those functions – 黃銘賢 Feb 27 '19 at 15:21
  • @黃銘賢 then it's a project setup issue, not FreeRTOS... you should describe which IDE you are using and how you are building – pmod Feb 27 '19 at 17:25
  • Now I am using eclipse IDE and I use the build tool inside. In debug configuration, I enable "auto build". – 黃銘賢 Feb 28 '19 at 17:04
  • However, as what you have said, there were not all file built. – 黃銘賢 Feb 28 '19 at 17:05
  • Hello, I have checked makerfile in demo project. However, it seems different to mine. Besides, mine is autogenerated and the instruction is don't edit it. Can I just configure build path in Eclipse? – 黃銘賢 Mar 05 '19 at 11:20
  • @黃銘賢 Have you checked https://www.freertos.org/Project_Workspace_Relative_File_Paths_Eclipse.html ? It's important to setup FREERTOS_ROOT path variable. And if you already generated Makefile - you can compare with https://svn.code.sf.net/p/freertos/code/tags/V7.5.3/FreeRTOS/Demo/CORTEX_LM3Sxxxx_Eclipse/RTOSDemo/Makefile - does it have $(RTOS_SOURCE_DIR)/tasks.c ? – pmod Mar 05 '19 at 21:19