Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Creating a FreeRTOS Static Library

Posted by groger57 on July 7, 2016

HI, I'm not sure if doing this is OK, possible or downright dumb. (or all 3) I want to build FreeRTOS into a static library such that I can call it from a C++ application in IAR/EWARM. Besides the FreeRTOS files I usually set up in EWARM, what else is required? I set up an EWARM project and included all the source C files, the heap2.c, portasm.s, and port.c (from the FreeRTOSV8.2.0FreeRTOSSourceportableIARARM_CM4F directory) so there are 9 files. It builds OK into a lib file (.a) and I can add it into my C++ project. The FreeRTOS headers are enclosed in the C++ file as:

.#ifdef __cplusplus extern "C" { .#endif
.#include "FreeRTOS.h" .#include "task.h" .#include "semphr.h"
.#ifdef __cplusplus } .#endif

On build, I am getting an error that is telling me applicationTickHook isn't defined, but the function is in my C++ file. *Error[Li005]: no definition for "vApplicationTickHook" [referenced from tasks.o(FreeRTOSLIB.a)] *

When I build the static lib, do I need a "main.c" file with applicationTickHook included in there? Or, if not, what am I missing?

Thanks, Gary


Creating a FreeRTOS Static Library

Posted by rtel on July 7, 2016

Try placing the "vApplicationTickHook" prototype in an extern "C" block as it is called from C code.


Creating a FreeRTOS Static Library

Posted by groger57 on July 7, 2016

Well, that makes perfect sense (after the fact) and it works. Now that I've done that, I can see the other C calls needing to be set up this way.

Thanks!


Creating a FreeRTOS Static Library

Posted by groger57 on July 7, 2016

All seemed to have gone well, until I uncommented the call to start the scheduler. Now I am getting this error:

Error[Li005]: no definition for "vPortEnableVFP" [referenced from port.o(FreeRTOSLIB.a)] Error[Li005]: no definition for "vPortStartFirstTask" [referenced from port.o(FreeRTOSLIB.a)]

This one I cannot see, because I do not know where these functions exist. I should mention that I am using Richard Damon's C++ wrapper, but this shouldn't make any difference as it seems to create the task OK - from his TaskCPP.h file:

Task taskTCB("Task", taskfun, TaskPrioLow, configMINIMALSTACK_SIZE); void taskfun( void *parm ) { while(1) { vTaskDelay(1); printf("having funn"); } }

Any suggestions as to what the linker errors are caused by?

Thanks again, always appreciate the great help on thios forum. Gary


Creating a FreeRTOS Static Library

Posted by rtel on July 8, 2016

In the IAR port both vPortEnableVFP() and vPortStartFirstTask() are called from a C file (port.c), but implemented in an asm file (portasm.s). Their prototypes are in the C file, not in a header file, so I'm guessing you need to add extern "C" around their prototypes too. Currently the prototypes appear in the C file as:

/*
  * Start first task is a separate function so it can be tested in 
isolation.
  */
extern void vPortStartFirstTask( void );

/*
  * Turn the VFP on.
  */
extern void vPortEnableVFP( void );


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists