Skip to main content
Renesas Electronics America - Knowledgebase

How to use semihosting with a Synergy project

Latest Updated:10/04/2016


This article explains how to add and use a Semihosting Virtual Console to your Synergy projects.


After completing this how-to you will have added a Semihosting Virtual Console interface to a simple Synergy project. Blinky project will be used as a starting point for this example.

Important Note: For Synergy projects you need to be connected to the debugger or else the project will hang. You need to comment out the initialise_monitor_handles() call and every call to stdio (e.g.printf()) for stand alone operation.

An alternative approach is to use the below code to enable initialise and printf only when required:

    if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)==CoreDebug_DHCSR_C_DEBUGEN_Msk) {




    if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)==CoreDebug_DHCSR_C_DEBUGEN_Msk) {

        printf("S5 Button Interrupt\n");


Important Note: Using printf in this way can run very slowly. It is best to use this technique when speed isn't at all important and you are just looking for general debugging information. Use other techniques to zero in on time critical issues.


Creating new project

Begin by creating a Synergy Project using the blinky template (Blinky with BSP). In case you need to refresh your understanding of creating new project, please refer to the following guide. Build and debug the design so you know it works on your board. Once you have a blinking LED, exit the debugger and open the hal_entry.c file. You will update this file to add the semihosting capability.

Including console handles

Inside hal_entry.c file open add two lines after the hal_data.h include as seen below. NOTE: initialise is spelled with an 's' in the below example- type it in carefully.


Writing to console

With the hal_entry.c file still open, find the while loop with the LED level check function. Add the printf calls as shown in the image below.


Initializing console

Add the monitor initialization routine as shown in the image below:


Check the linker configuration

Make sure that the linker setup includes the option --specs=rdimon.specs to enable the semihosting feature.

You can verify this in the c/c++ Build properties, under Settings > Cross ARM C Linker > Miscellaneous


Build the project and initialize the debugger. You now need to create a window that you can see the output of the printf() functions. In the console tab of the debugger create a new Renesas Debug Virtual Console by clicking on the console pull-down menu  as shown below:


The window will open and you can now begin a debug session. The printf() output will show in the console window as seen below:


What's Next

You should now be able to follow the above procedure to use printf() calls in your Synergy projects.