Renesas RSK64M demo build errors (undefined external symbol _sprintf)

There are 33 errors when trying to build the RX600_RX64M_RSK_Renesas_e2studio demo. The root cause is a call to the undefined sprintf() function in MessageBufferAMP.c (2 instances) and MessageBufferDemo.c (6 instances).

Commenting these calls out results in a successful build and loading the program onto the RSK+RSK64M development board correctly blinks the LED.

E0562310: Undefined external symbol "_sprintf" referenced in ".\Source\Common_Demo_Source\Minimal\MessageBufferAMP.obj
E0562310: Undefined external symbol "_sprintf" referenced in ".\Source\Common_Demo_Source\Minimal\MessageBufferDemo.obj

Renesas E2 Studio Version 3.0.1.09
FreeRTOS version 10.3.1 release

You do not need hardware to reproduce this issue. Simply download the latest E2 studio from Renesas website [Windows only] and import the RX64M demo as described on the FreeRTOS website (https://www.freertos.org/RX64M_RTOS_Renesas_GCC_e2studio.html). The initial build fails.

Work-around (in-progress): In the E2 Studio IDE, select Project > Properties > Standard Library > Contents and then check the box marked “stdio.h”. This resolves the 2 sprintf linker errors, but does not resolve other 31 linker errors such as "Description Resource Path Location Type
E0562310: Undefined external symbol “_vStreamBufferDelete” referenced in “.\Source\Common_Demo_Source\Minimal\MessageBufferDemo.obj”

Hmm, sounds like the project needs updating to the latest tools - especially as you say updating the compiler options fixes the sprintf() issue (sprintf being a standard library function, rather than a FreeRTOS function). Thanks for reporting.

Thanks for the reply Richard. I did get the demo working today, but I can’t simply push my local changes to GitHub because my workspace is based on the FreeRTOS zip file as opposed to a git clone of the master branch.

Until I have time to make a GitHub account and push the changes, here is my complete work-around for future readers:

  1. Add stdio.h to your libc build.
    E2 Studio IDE > Project > Properties > Standard Library > Contents: Check the box marked “stdio.h” to resolve the “undefined external symbol sprintf” linker errors.

  2. Import stream_buffer.c into your project.
    E2 Studio IDE > Right Click “Source” directory > Import > Import… > General > File System > Next > Browse… > Select “stream_buffer.c” source file > Advanced: Check the box marked “Create links in workspace” > Finish. This resolves the various linker errors related to undefined stream buffer symbols.

Hello, (This post is basically a copy of https://github.com/FreeRTOS/FreeRTOS/pull/195#issuecomment-672605197)

I have an impression that this and the following solution is not better for this build error bug because demo functions for StreamBuffer/MessageBuffer are not perfomed in this RTOSDemo program i.e. the main_full() does not call demo functions for StreamBuffer/MessageBuffer.

I think that better way is to exclude (at least) the following files from build.

MessageBufferAMP.c
MessageBufferDemo.c
StreamBufferDemo.c
StreamBufferInterrupt.c

Probably more files are not used in this RTOSdemo program because main_full() calls only the following functions.

void main_full( void )
{
    /* Start all the other standard demo/test tasks.  They have no particular
    functionality, but do demonstrate how to use the FreeRTOS API and test the
    kernel port. */
    vStartInterruptQueueTasks();
    vStartDynamicPriorityTasks();
    vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
    vCreateBlockTimeTasks();
    vStartCountingSemaphoreTasks();
    vStartGenericQueueTasks( tskIDLE_PRIORITY );
    vStartRecursiveMutexTasks();
    vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
    vStartMathTasks( mainFLOP_TASK_PRIORITY );
    vStartTimerDemoTask( mainTIMER_TEST_PERIOD );
    vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );
    vStartEventGroupTasks();
    vStartLEDFlashTasks( mainFLASH_PRIORITY );

   ...omit...

Best regards,
NoMaY

Hello,

Now I understand everything perfectly. We have to exclude MessageBuffer*.c and StreamBuffer*.c using resource filter like the following screen copy of the e2 studio’s properties page. Some files (alt*.c, com*.c, cr*.c, sp_flop.c) had been already excluded but newly added files (i.e. MessageBuffer*.c and StreamBuffer*.c) has not been excluded because the project has not been updated after the project was created. And maybe TaskNotifyArray.c has to be excluded.

(Please note that tool bar is customized by me.)

[Added]

One more information. Newer project such as ‘RX700_RX71M_RSK_Renesas_e2studio’ uses include type resource filter like the following screen copy of the e2 studio’s properties page.

Best regards,
NoMaY

Hello,

The following screen copies show the steps to build RSK64M demo using e2 studio v7.8.0 and FreeRTOS v10.3.1.

Step1) Import the project
Step2) Upgrade the project
Step3) Select toolchain type and toolchain version in the project setting properties page.
Step4) Exclude MessageBuffer*.c and StreamBuffer*.c from build (Using ‘exclude from build’ was my tentative method)
Step5) Then build.
Step6) Finished.

Best regards,
NoMaY