Important

For RH850, RL78, RX, RZ, R-Car projects please follow the instructions in section 2.1. Using CMake Toolchain Scripts.

For Renesas RA device family projects, please refer to section 2.2. Using Smart Configurator for RA Projects (RA SC) for creating RA project from scratch using Smart Configurator and building the project.

For Renesas RZ/N device family projects, please refer to section 2.3. Using Smart Configurator for RZ/N Projects (RZ/N SC) for creating RZ/N project from scratch using Smart Configurator and building the project.

For Renesas RX device family projects, please refer to section 2.4. Using Smart Configurator for RX Projects (RX SC) for creating RX project from scratch using Smart Configurator.

Please also refer to Introductory Videos for C++ in Visual Studio Code documents for handling projects and working with CMake.

2.1. Using CMake Toolchain Scripts

2.1.1. Opening the Project

For RH850, RL78, RX, RZ, R-Car projects created in e2 studio, projects can be opened in VS Code by simply opening the project folder and then following the instructions below:

  1. In [Explorer] view, select [Open Folder] button if available. If not, select [File] → [Open Folder…​] menu item.

    IDE 54291 11
    IDE 54291 12
  2. In [Open Folder] dialog, browse to project folder and click [Select Folder] button.

    IDE 54291 13

Besides, there are alternative methods to open a project in VS Code, you can check the alternative methods in "Productivity Tips" section 4.1.6. Alternative ways for opening a project in VSCode

2.1.2. Creating CMake Toolchain Scripts

  1. Open [Command Palette] and type "Create" to filter the commands. Currently, the Renesas Build Utilities extension provide the following commands:

    • Create CC-RH project files

    • Create CC-RL project files

    • Create CC-RX project files

    • Create GCC RL78 project files

    • Create GCC RX project files

    • Create GCC RZ project files

    • Create LLVM for RL78 project files

    • Create RCar CMake (Development board / SoC) project files

    • Create RCar CMake (Instruction Set Simulators) project files

      vscode create project files menu
  2. Select the desired command, [Select Folder] dialog will appear. Browser to project folder and click [Select Folder] button to open the project.

    image2022 12 19 11 12 39
  3. After opened, notice that some additional files are added. These files are used to build the project with CMake.

    image2022 12 19 11 13 58

Note: How to handle notifications after installing Renesas Build Utilities extension

When installing the Renesas Build Utilities extension for the first time, a notification may appear as shown below:

IDE 61546 1

Please select [Disable IntelliSense]

IDE 61546 2

Please select [Install]

Then select [Reload window]

IDE 61546 3

After using [Create xxx project files] command, necessary files listed below are going to be created.

  • .vscode/settings.json - this file contains the settings for CMake.

  • .vscode/tasks.json - this file contains the build definitions for VSCode.

  • <file name>.cmake - this file contains the information about the toolchain to use.

  • CMakeLists.txt - this file contains the information about the building project (which files to build, which options to set etc.).

2.1.2.1. settings.json file’s general content

File .vscode/settings.json - this file contains the settings for CMake.

settings.json file’s general content
{
    "cmake.configureArgs": [
        "-DCMAKE_TOOLCHAIN_FILE=<absolute/relative path of toolchain information file (<file name>.cmake file)"
    ],
    "cmake.sourceDirectory": "<absolute/relative path of the folder containing the root CMakeLists.txt file>"
}

2.1.2.2.tasks.json file’s general content

File .vscode/tasks.json - this file contains the build definitions for VSCode.

tasks.json file’s general content
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build Project",
      "group": "build",
      "type": "renesas-build",
      "command": "build",
      "deviceFamily": "<Device family (e.g. RA, RCAR, RH850, RL78, RX or RZ)>",
      "toolchain": "<Toolchain (e.g. gcc, cc-rl, cc-rx, llvm)>"
    }
  ]
}

2.1.2.3. <file name>.cmake file’s general content

<file name>.cmake - this file contains the information about the toolchain to use.

<file name>.cmake file’s general content
# Specify toolchain path
SET(CMAKE_FIND_ROOT_PATH "<absolute path of toolchain's bin folder>")

# Specify the C compiler and necessary options
SET(CMAKE_C_COMPILER ${CMAKE_FIND_ROOT_PATH}/<C compiler executable file>)

# Specify the CPP compiler and necessary options
SET(CMAKE_CXX_COMPILER ${CMAKE_FIND_ROOT_PATH}/<CPP compiler executable file>)

# Specify the assembler and necessary options
SET(CMAKE_ASM_COMPILER ${CMAKE_FIND_ROOT_PATH}/<assembler executable file>)

# Specify the linker and necessary options
SET(CMAKE_LINKER ${CMAKE_FIND_ROOT_PATH}/<linker executable file>)

# Specify the library generator and necessary options
SET(CMAKE_LIBRARY ${CMAKE_FIND_ROOT_PATH}/<library generator executable file>)

# Specify the converter and necessary options
SET(CMAKE_CONVERTER_EXECUTABLE ${CMAKE_FIND_ROOT_PATH}/<converter executable file>)

2.1.2.4. CMakeLists.txt file’s general content

CMakeLists.txt - this file contains the information about the building project (which files to build, which options to set etc.).

CMakeLists.txt file’s general content
cmake_minimum_required(VERSION 3.16)

# Set project name
project("<project name>")

enable_language(C ASM)

# Collect source files
FILE (GLOB_RECURSE SOURCE ${CMAKE_CURRENT_SOURCE_DIR}
"*.c" "*.cpp" "*.asm"
)
add_executable(${PROJECT_NAME} ${SOURCE})

# Set C compiler command
SET(CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILER} <specify C compiler options here>")

# Set C++ compiler command
SET(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILER} <specify C++ compiler options here>")

# Set Assembler command
SET(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_ASM_COMPILER} <specify assembler options here>")

# Set Linker command
SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_LINKER} <specify linker options here>")

# Set Library generator command
add_custom_COMMAND(
 TARGET ${CMAKE_PROJECT_NAME}
 PRE_LINK
 COMMAND ${CMAKE_LIBRARY} <specify library generator options here>
 COMMENT "Libgen:"
 VERBATIM
)

# Set Converter Command
add_custom_command (
 TARGET ${CMAKE_PROJECT_NAME}
 COMMAND ${CMAKE_CONVERTER_EXECUTABLE} <specify converter options here>
 COMMENT "Converter:"
 VERBATIM
)

Note: <File name>.cmake requires the project name to configure and build. Please make sure to modify the project name to be built.

2.1.3. Building a Project with CMake Toolchain Scripts

Once all the necessary files are in place, run build task in VS Code to build the project as described below:

  • To run build task, either press [Ctrl+Shift+B] or select [Terminal] → [Run Build Task…​] from the menu.

    image build from menu

2.1.4. Specific Example

The details of some specific devices will be presented here.

SDK Projects

Sample projects can be found in the samples folder inside the SDK directory.

The package is typically installed in the default path: "C:/Renesas/rcar-xos"

SDK default path
SDK samples

Using [Create RCar CMake (Development board / SoC) project files] command, necessary files listed below are going to be created.

  • .vscode/settings.json

  • .vscode/tasks.json

  • cross.cmake

  • CMakeLists.txt

  • module.cmake

Contents of the .vscode/settings.json file

{
    "C_Cpp.updateChannel": "Insiders",
    "workbench.iconTheme": "vs-minimal",
    //For Linux.
    //"cmake.generator": "Unix Makefiles"
    //For Window:
    "cmake.generator": "MinGW Makefiles",
    "cmake.buildDirectory": "${workspaceFolder}/build/rcar.debug.DevBoard",
    "cmake.configureArgs": [
        "-DCMAKE_TOOLCHAIN_FILE=${workspaceFolder}/cross.cmake"
    ],
    "cmake.sourceDirectory": "${workspaceFolder}",
    "cmake.configureOnOpen": true,
    "C_Cpp.intelliSenseEngineFallback": "enabled"
}

Contents of the .vscode/tasks.json file

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build Project",
            "group": "build",
            "type": "renesas-build",
            "command": "build",
            "deviceFamily": "RCAR",
            "toolchain": "gcc"
        }
    ]
}

Contents of the cross.cmake file

# Set the environment root directory
# It can be used to specify the target environment location
# e.g compiler's location. This variable is most useful when crosscompiling.
#(Should avoid spaces in the path or have to escape them)

# Please modify rcar-xos platform location and its version
set (PLATFORM_FIND_ROOT_PATH  "C:/Renesas/rcar-xos")
set (VERSION_SDK "v3.24.0")

# Check rcar-xos platform
if (NOT PLATFORM_FIND_ROOT_PATH)
  message(WARNING "rcar-xos PLATFORM_FIND_ROOT_PATH is not defined\n"
                  "Builds scripts will search rcar-xos platform in environment paths.\n"
                  "Use PLATFORM_FIND_ROOT_PATH variable to set a specific platform folder.")
elseif (NOT PLATFORM_FIND_ROOT_PATH MATCHES "/$")
  set(PLATFORM_FIND_ROOT_PATH "${PLATFORM_FIND_ROOT_PATH}/")
endif()

# Check rcar-xos platform version
if (NOT VERSION_SDK)
  message(WARNING "rcar-xos VERSION_SDK is not defined\n"
                  "Builds scripts will search rcar-xos platform version in environment paths.\n"
                  "Use VERSION_SDK variable to set a specific platform version.")
elseif (NOT VERSION_SDK MATCHES "/$")
  set(VERSION_SDK "${VERSION_SDK}/")
endif()

# Include module.cmake file
include("${CMAKE_CURRENT_LIST_DIR}/module.cmake")

# Set SDKROOT
Set(SDKROOT ${PLATFORM_FIND_ROOT_PATH}/${VERSION_SDK}/tools/toolchains/poky)

# Set CMake folder
set(CMAKE_PREFIX_PATH ${PLATFORM_FIND_ROOT_PATH}/${VERSION_SDK}/cmake)

# Set Device. Example: V3U, V3H1, V3H2, V3M2,..
set(RCAR_SOC V4H2)

# Set IMP Debug level variable
# R_CAR_DEBUG_IMP_LEVEL_CPU:  Only CPU Code
# R_CAR_DEBUG_IMP_LEVEL_CVE_DEBUG: CVe (Shader) debugging
set(R_CAR_DEBUG_IMP_LEVEL_VAR R_CAR_DEBUG_IMP_LEVEL_CVE_DEBUG)

# Build target
set(R_CAR_BUILD_TARGET_VAR aarch64-gnu-linux)

# Include cmake toolchain files as following
include("${CMAKE_PREFIX_PATH}/toolchain_poky_3_1_11_adas.cmake")

Note: Information about the samples corresponding to which device is available in:

"C:/Renesas/rcar-xos/<version SDK>/samples/SUPPORTED_ENVIRONMENT.html"

Example:

"C:/Renesas/rcar-xos/v3.24.0/samples/SUPPORTED_ENVIRONMENT.html"

CMakeLists.txt and module.cmake files are overridden with their corresponding files from the project.

SDK project path
SDK project sample

2.2. Using Smart Configurator for RA Projects (RA SC)

For RA device family projects, it is recommended to use RA Smart Configurator to create a project for VS Code. Please follow the following instructions to create and build a project for RA device family.

2.2.1. Creating an RA Project with Smart Configurator

Smart Configurator could be directly used from VS Code command palette for creating a project for RA device family.

  1. Open [Command Palette] and select [Renesas: Create RA Project with Smart Configurator] from the commands.

    rasc cp create project
  2. VSCode will show installed [RA Smart Configurator] list, select a [Smart Configurator] from the list.

    rasc cp create select rasc
    Note

    If no RA Smart Configurator detected automatically, "No RA Smart Configurator installation found!" message will appear in VSCode:

    rasc cp no rasc found

    For Linux and Windows operating systems, please click to the "Browse RA SC", then select the location of the RA Smart Configurator binary ("rasc.exe" for Windows; "rasc" for Linux), when a select file dialog window appears. Extension will automatically register the location of the RA Smart Configurator for the next use.

    For macOS operating systems, please follow the instructions in chapter 4.1.9.3 Instructions for macOS Environment.

  3. Select a [Folder] to create the project.

    rasc cp create select folder
  4. Enter [Project name] and click [Next].

    rasc create project1
  5. Configure your board, device type and preferred toolchain from the toolchains list, then click [Next].

    rasc create project2
  6. Choose "No RTOS" for the sample project and click [Next].

    rasc create project3
  7. Choose one of the project templates then click [Finish] to complete the project creation steps.

    rasc create project4
  8. Close [RA Smart Configurator] after generation of the project files completed.

    rasc create project5

2.2.2. Building an RA Project created in Smart Configurator

For building a project, which created with RA Smart Configurator, please follow the steps below:

  1. When the project is opened for the first time, CMake configure and the CMake Kit selection operations must be performed. In order to do these operations, open the [Command Palette] in VSCode and select [CMake: Configure] from the commands.

    rasc build project1
  2. Then, a kit selection menu will be shown. Select "ARM GCC - Ninja" from the menu.

    rasc build project2
    Note

    Missing the selection of the CMake Kit or wrong selection can cause build problems. If you missed the CMake Kit selection or selected a wrong kit, you can re-select the CMake Kit by running "CMake: Select a kit" command from the VSCode Command Palette.

    rasc build project2 sak
  3. Now, go to and click "Terminal" ⇒ "Run Build Task" from the menu.

    rasc build project3
  4. Build options will be shown, select the "Build Project" option.

    rasc build project4

After the build operation, by default, build output (<project name>.elf) can be found in "build/<Build Type>/CMakeFiles/<project name>.elf.dir/" folder.

Tip
For more information about RA Smart Configurator, click here to visit RA Smart Configurator page.

2.3. Using Smart Configurator for RZ/N Projects (RZ/N SC)

Note

Projects that are generated with RZ/N Smart Configurator require "MinGW Makefiles" as the CMake Generator for Windows. If you are planning to use RZ/N Smart Configurator during project generation, please follow the additional installation instructions in chapter "4.2.11. Setting up a build environment with MinGW over MSYS2 for Windows" for installing the build prerequisites.

For RZ/N device family projects, it is recommended to use RZ/N Smart Configurator to create a project for VS Code. Please follow the following instructions to create and build a project for RZ/N device family.

2.3.1. Creating an RZ/N Project with Smart Configurator

Smart Configurator could be directly used from VS Code command palette for creating a project for RZ/N device family.

  1. Open [Command Palette] and select [Renesas: Create RZ/N Project with Smart Configurator] from the commands.

    rasc rzn cp create project
  2. VSCode will show installed [RZ/N Smart Configurator] list, select a [Smart Configurator] from the list.

    rasc rzn cp create select rasc
  3. Select a [Folder] to create the project.

    Note

    If no RZ/N Smart Configurator detected automatically, "No RZ/N Smart Configurator installation found!" message will appear in VSCode:

    rasc rzn cp no rasc found

    Please click on "Browse RZ/N SC", then select the location of the RZ/N Smart Configurator binary (rasc.exe), when the select file dialog window appears. The extension will automatically register the location of the RZ/N Smart Configurator for the next use.

    rasc rzn cp create select folder
  4. Enter [Project name] and click [Next].

    rasc rzn create project1
  5. Configure your board and device type and click [Next].

    rasc rzn create project2
  6. Continue without RTOS selection and click [Next].

    rasc rzn create project3
  7. Choose one of the project templates then click [Finish] to complete the project creation steps.

    rasc rzn create project4
  8. Close [RZ/N Smart Configurator] after generation of the project files completed.

    rasc rzn create project5
  9. Open [Config.cmake] file and set [CMAKE_FIND_ROOT_PATH] variable with the path of toolchain’s bin folder. E.g.

    rasc rzn create project6

Config.cmake

# Configuration file for user settings
# This file should include the path for toolchain and other settings that user would like to override.
# Example toolchain path definitions
set(CMAKE_FIND_ROOT_PATH "D:/Toolchains/GCC/gcc-arm-none-eabi-9-2019-q4-major-win32/bin")

2.3.2. Building an RZ/N Project created in Smart Configurator

For building a project, which created with RZ/N Smart Configurator, please follow the steps below:

  1. In VS Code Command Palette, run "CMake: Delete Cache and Reconfigure" command.

    rasc rzn build project1
  2. In the first time of running, a kit selection is shown. Select "[Unspecified]".

    rasc rzn build project2
  3. Then, run "CMake: Build" command.

    rasc rzn build project3
  4. By default, executable file (<project name>.elf) can be found in "build/CMakeFiles/<project name>.elf.dir/" folder.

Tip
For more information about RZ/N Smart Configurator, click here to visit RZ/N Smart Configurator page.

2.4. Using Smart Configurator for RX Projects (RX SC)

For RX device family projects, it is recommended to use RX Smart Configurator to create a project for VS Code. Please follow these instructions to create and build a project for RX device family.

Note

Before creating a project for the RX device family, please install RX support files from the [Renesas Support Files Manager] by following the instructions in chapter 4.1.1. Managing Support Files.

2.4.1. Creating an RX Project with Smart Configurator

Smart Configurator can be accessed from the VS Code command palette to create a project for the RX device family.

  1. Open [Command Palette] and select [Renesas: Create RX Project with Smart Configurator] from the commands.

    rxsc rx cp create project
  2. Select a [RX Smart Configurator].

    Note

    The Smart Configurator detection feature is currently disabled for RX, "No RX Smart Configurator installation found!" message will appear in VSCode:

    rxsc rx cp no rxsc found

    Please click "Browse RX SC", then select the location of the RX Smart Configurator binary ("SmartConfigurator.exe" for Windows). When a select file dialog window appears, the extension will automatically store the location of the RX Smart Configurator for the next use.

    rxsc rx cp create select rxsc
  3. Select a [Folder] to create the project.

    rxsc rx cp create select folder
  4. Enter [File name], configure your board and device type, select either [Renesas RXC Toolchain] or [GCC RX Toolchain], and then click [Next].

    rxsc rx create project1
  5. Choose one of the [Bank mode setting] (applicable for some devices) then click [Finish] to complete the project creation steps.

    rxsc rx create project2
  6. Click [Generate Code] and close [RX Smart Configurator] after generation of the project files completes.

    rxsc rx create project3
  7. Modify [Config.cmake] files

    For selecting [Renesas RXC Toolchain]:

    Open the [Config.cmake] file, set the [RENESAS_TOOLCHAIN_PATH] variable to the path of the toolchain’s bin folder. Then set the [RENESAS_UTILITIES_PATH] variable to the path of the Renesas utilities folder containing [renesas_cc_converter.exe]. E.g.

    rxsc rx create project ccrx

    Config.cmake

    set(RENESAS_TOOLCHAIN_PATH "C:/Program Files (x86)/Renesas/RX/3_6_0/bin")
    set(RENESAS_UTILITIES_PATH "C:/Users/mypc/.eclipse/com.renesas.platform_1421162095/Utilities")

    For selecting [GCC RX Toolchain] :

    Open the [Config.cmake] file, set the [RENESAS_TOOLCHAIN_PATH] variable to the path of the toolchain’s bin folder. Then set the [RENESAS_UTILITIES_PATH] variable to the path of the toolchain’s utilities folder. E.g.

    rxsc rx create project gccrx

    Config.cmake

    set(RENESAS_TOOLCHAIN_PATH "C:/ProgramData/GCC for Renesas RX 8.3.0.202405-GNURX-ELF/rx-elf/rx-elf/bin")
    set(RENESAS_UTILITIES_PATH "C:/ProgramData/GCC for Renesas RX 8.3.0.202405-GNURX-ELF/Other Utilities")

2.4.2. Building an RX Project created in Smart Configurator

For building a project, which created with RX Smart Configurator, please follow the steps below:

  1. In VS Code, click to [Terminal] ⇒ [Run Build Task] from the menu. Alternatively, press ctrl+shift+B to quickly open the Build task.

    rxsc rx build project1
  2. Select [Build Project] from the commands.

    rasc build project4
Tip
For more information about RX Smart Configurator, click here to visit the RX Smart Configurator page.

2.5. Using Audio Development Platform (ADP) for Dialog DA148xx device family

Renesas VS Code extensions support project development for DA148xx family of integrated audio processors. Customers can have access to the Audio Development Platform software upon request and start their Dialog project development by using Dialog Audio Development Platform (ADP). The ADP comes with ready to start, predefined project samples inside the package. Please follow the instructions below to start developing a Dialog device project:

  1. From the ADP sample projects, open a desired start up project in VSCode.

    Note

    Sample projects in the ADP can be found inside the following directories:

    • <ADP_ROOT>/Software/Source/projects/bare_metal

    • <ADP_ROOT>/Software/Source/projects/freertos

  2. After your project is opened in VSCode, open the settings file of the project in .vscode/settings.json path and check the cmake.configureSettings configuration. Make sure the BOARD, BOOT and DEVICE settings are correct for the targeted development. Configure them if necessary.

    dialog project settings
  3. Then, open "Command Palette" (by using "View"" ⇒ "Command Palette" menu), and run the "CMake: Select a Kit" command.

  4. From the list, select the CMake Kit related to the "GNU Arm Embedded Toolchain 9 (2019-Q4)" toolchain.

    Note

    Please note that:

    • Naming of the CMake Kit related to the "GNU Arm Embedded Toolchain 9 (2019-Q4)" toolchain can vary on local configuration, search and look for "GCC 9".

    • If no CMake Kit for "GNU Arm Embedded Toolchain 9 (2019-Q4)" toolchain is visible in the list, make sure the toolchain is already installed and the binaries folder of the toolchain is added to the "Path" environment variable. Then, open the VS Code Command Palette and run the "CMake: Scan for Kit" command to refresh the list of the CMake Kits.

    dialog cmake select kit
  5. In the VS Code Command Palette, run "CMake: Delete Cache and Reconfigure" command.

    dialog cmake reconfigure
  6. Then, run the "CMake: Build" command.

    dialog cmake build
  7. By default, the executable file (<project name>.elf) is generated into the "build/syscpu" folder.


< 1. Installation

3. Debugging a Project >