AWS IoT Device SDK C: Task Pool

That is probably because you only added header files and not their corresponding implementation (.c) files.

The GitHub repo only provides 2 source files for task pool: iot_taskpool.c and iot_taskpool_static_memory.c. I have already added these files. Rest all are only header files. I have added them as well. Also, there is no guide to setup this library so its difficult to know what is to be done.

Add the following files -

I have added these files and now I am trying to resolve more errors due to these files. Is there any document which describes the task pool library init process?

This library is not used by latest versions of our libraries which are standalone consumable. Therefore, there is no specific document to explain the use of this library. Please post what errors you are facing and we will try to help you.

Currently, my project has the following header(.h) files:

  • iot_clock.h
  • iot_config.h
  • iot_error.h
  • iot_init.h
  • iot_linear_containers.h
  • iot_logging.h
  • iot_logging_setup.h
  • iot_logging_task.h
  • iot_platform_types.h
  • iot_platform_types_freertos.h
  • iot_static_memory.h
  • iot_taskpool.h
  • iot_taskpool_internal.h
  • iot_taskpool_types.h
  • iot_threads.h
  • logging_levels.h

And the following source (.c) files:

  • iot_clock_freertos.c
  • iot_init.c
  • iot_logging.c
  • iot_logging_task_dynamic_buffers.c
  • iot_static_memory_common.c
  • iot_taskpool.c
  • iot_taskpool_static_memory.c
  • iot_threads_freertos.c

I am getting the following errors:

../src/iot_logging_task_dynamic_buffers.c:43:6: error: #error configPRINT_STRING( x ) must be defined in FreeRTOSConfig.h to use this logging file. Set configPRINT_STRING( x ) to a function that outputs a string, where X is the string. For example, #define configPRINT_STRING( x ) MyUARTWriteString( X )
../src/iot_logging_task_dynamic_buffers.c:47:6: error: #error configLOGGING_MAX_MESSAGE_LENGTH must be defined in FreeRTOSConfig.h to use this logging file. configLOGGING_MAX_MESSAGE_LENGTH sets the size of the buffer into which formatted text is written, so also sets the maximum log message length.
../src/iot_logging_task_dynamic_buffers.c:51:6: error: #error configLOGGING_INCLUDE_TIME_AND_TASK_NAME must be defined in FreeRTOSConfig.h to use this logging file. Set configLOGGING_INCLUDE_TIME_AND_TASK_NAME to 1 to prepend a time stamp, message number and the name of the calling task to each logged message. Otherwise set to 0.
../src/iot_logging_task_dynamic_buffers.c: In function 'prvLoggingTask':
../src/iot_logging_task_dynamic_buffers.c:210:13: warning: implicit declaration of function 'configPRINT_STRING'
../src/iot_logging_task_dynamic_buffers.c: In function 'prvLoggingPrintfCommon':
../src/iot_logging_task_dynamic_buffers.c:237:35: error: 'configLOGGING_MAX_MESSAGE_LENGTH' undeclared (first use in this function)
../src/iot_logging_task_dynamic_buffers.c:237:35: note: each undeclared identifier is reported only once for each function it appears in
../src/iot_threads_freertos.c: In function '_threadRoutineWrapper':
../src/iot_threads_freertos.c:86:5: warning: implicit declaration of function 'pvPortFree'
../src/iot_threads_freertos.c: In function 'IotMutex_Create':
../src/iot_threads_freertos.c:147:9: warning: implicit declaration of function 'xSemaphoreCreateRecursiveMutexStatic'
../src/iot_threads_freertos.c: In function 'prIotMutexTimedLock':
../src/iot_threads_freertos.c:193:9: warning: implicit declaration of function 'xSemaphoreTakeRecursive'
../src/iot_threads_freertos.c: In function 'IotMutex_Unlock':
../src/iot_threads_freertos.c:230:9: warning: implicit declaration of function 'xSemaphoreGiveRecursive'
../src/iot_threads_freertos.c: In function 'IotSemaphore_TryWait':
../src/iot_threads_freertos.c:311:29: warning: unused variable 'internalSemaphore'

thread_manager.c is the file where I shall be utilizing the APIs. I am able to see that certain errors such as #error configPRINT_STRING are because my FreeRTOSConfig.h doesn’t have these implementations. These can be fixed by adding implementations.

After resolving the errors related to configPRINT_STRING, configLOGGING_MAX_MESSAGE_LENGTH and configLOGGING_INCLUDE_TIME_AND_TASK_NAME, I get the same errors as posted AWS IoT Device SDK C: Task Pool - #16 by hrm2519. The current errors are as follows:

build/default/production/_ext/1360937237/iot_logging_task_dynamic_buffers.o(.text+0x13e): In function `.L36':
: undefined reference to `_xTaskGetSchedulerState'
build/default/production/_ext/1360937237/iot_threads_freertos.o(.text+0xc): In function `.LFB30':
: undefined reference to `_pvPortFree'
build/default/production/_ext/1360937237/iot_threads_freertos.o(.text+0x10): In function `.LFB30':
: undefined reference to `_vTaskDelete'
build/default/production/_ext/1360937237/iot_threads_freertos.o(.text+0x48): In function `.LBB2':
: undefined reference to `_pvPortFree'
build/default/production/_ext/1360937237/iot_threads_freertos.o(.text+0x5e): In function `.LBB3':
: undefined reference to `_xSemaphoreCreateRecursiveMutexStatic'
build/default/production/_ext/1360937237/iot_threads_freertos.o(.text+0x92): In function `.LBB4':
: undefined reference to `_xSemaphoreTakeRecursive'
build/default/production/_ext/1360937237/iot_threads_freertos.o(.text+0xb8): In function `.LBB5':
: undefined reference to `_xSemaphoreGiveRecursive'
build/default/production/_ext/1360937237/iot_threads_freertos.o(.text+0xc0): In function `_IotSemaphore_Create':
: undefined reference to `_xQueueCreateCountingSemaphoreStatic'
build/default/production/_ext/1360937237/iot_clock_freertos.o(.text+0x6): In function `.LFB30':
: undefined reference to `_pvTimerGetTimerID'
build/default/production/_ext/1360937237/iot_clock_freertos.o(.text+0x22): In function `.L5':
: undefined reference to `_xTimerGenericCommand'
build/default/production/_ext/1360937237/iot_clock_freertos.o(.text+0xa0): In function `_IotClock_TimerCreate':
: undefined reference to `_xTimerCreateStatic'
build/default/production/_ext/1360937237/iot_clock_freertos.o(.text+0xb0): In function `_IotClock_TimerDestroy':
: undefined reference to `_xTimerIsTimerActive'
build/default/production/_ext/1360937237/iot_clock_freertos.o(.text+0xc4): In function `.L26':
: undefined reference to `_xTimerGenericCommand'
build/default/production/_ext/1360937237/iot_clock_freertos.o(.text+0xc8): In function `.L23':
: undefined reference to `_xTimerIsTimerActive'
build/default/production/_ext/1360937237/iot_clock_freertos.o(.text+0xde): In function `_IotClock_TimerArm':
: undefined reference to `_xTimerGenericCommand'

Could you help me with these?

Yep these are all linking issues:

  • xTaskGetSchedulerState, vTaskDelete would come from tasks.c in the FreeRTOS Kernel
  • pvPortFree should be vPortFree - assuming you are using this file, you will want to change this line from pvPortFree to vPortFree, since vPortMalloc seems to be linking fine, I’m assuming that you have a heap implementation included correctly. If not they can be found here. You just need one of these and you can decide which works best for you based on FreeRTOS - Memory management options for the FreeRTOS small footprint, professional grade, real time kernel (scheduler). I recommend just sticking with heap_4.c.
  • The xSemaphore… calls come from the semphr.h file but will require that you set configUSE_RECURSIVE_MUTEXES and configSUPPORT_STATIC_ALLOCATION to 1 in FreeRTOSConfig.h.
  • The xQueueCreateCountingSemaphoreStatic comes from queue.c and requires that you set configUSE_COUNTING_SEMAPHORES and configSUPPORT_STATIC_ALLOCATION to 1 in FreeRTOSConfig.h.
  • The timer functions come from timers.c and the static function requires configSUPPORT_STATIC_ALLOCATION be set to 1 in FreeRTOSConfig.h.

To summarize, make sure the above files are being linked in your project and update FreeRTOSConfig.h to have the configs mentioned.

1 Like

To summarize:

  1. Define the following in your FreeRTOSConfig.h:
#define INCLUDE_xTaskGetSchedulerState 1
#define configUSE_TIMERS 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES  1
#define configSUPPORT_STATIC_ALLOCATION 1
  1. Compile one of the heap files in your project - FreeRTOS-Kernel/portable/MemMang at main · FreeRTOS/FreeRTOS-Kernel · GitHub
1 Like

Thank you Jason and Gaurav for the detailed resolution. I was able to resolve most of the errors yesterday by referring to FreeRTOS documentation.
Currently, I have enabled both static and dynamic memory allocation. The plan is to move to static memory allocation completely. Apart from FreeRTOSConfig and implementations for communication objects, what are the other important changes when switching from dynamic memory to static memory allocation?

You also need to implement 2 hooks for supplying memory for idle and timer tasks. Here is an example -