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. 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:
-
In [Explorer] view, select [Open Folder] button if available. If not, select [File] → [Open Folder…] menu item.
-
In [Open Folder] dialog, browse to project folder and click [Select Folder] button.
Besides, there are alternative methods to open a project in VS Code, you can check the alternative methods in "Productivity Tips" section 4.1.5. Alternative ways for opening a project in VSCode
2.1.2. Creating CMake Toolchain Scripts
-
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
-
-
Select the desired command, [Select Folder] dialog will appear. Browser to project folder and click [Select Folder] button to open the project.
-
After opened, notice that some additional files are added. These files are used to build the project with CMake.
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:
Please select [Disable IntelliSense]
Please select [Install]
Then select [Reload window]
After using [Create xxx project files] command, necessary files listed beloware 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.
{
"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.
{
"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.
# 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.).
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.
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 a RA Project with Smart Configurator
Smart Configurator could be directly used from VS Code command palette for creating a project for RA device family.
-
Open [Command Palette] and select [Renesas: Create RA Project with Smart Configurator] from the commands.
-
VSCode will show installed [RA Smart Configurator] list, select a [Smart Configurator] from the list.
NoteIf no RA Smart Cofigurator detected automatically, "No RA Smart Configurator installation found!" message will appear in VSCode:
Please click to "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.
-
Select a [Folder] to create the project.
-
Enter [Project name] and click [Next].
-
Configure your board, device type and prefered toolchain from the toolchains list, then click [Next].
-
Choose "No RTOS" for the sample project and click [Next].
-
Choose one of the project templates then click [Finish] to complete the project creation steps.
-
Close [RA Smart Configurator] after generation of the project files completed.
2.2.2. Building a RA Project created in Smart Configurator
For building a project, which created with RA Smart Configurator, please follow the steps below:
-
In VS Code, click to "Terminal" ⇒ "Run Build Task" from the menu.
-
On the first time, a kit selection menu will be shown. Select "ARM GCC - Ninja" from the menu.
Note
|
If you missed the kit selection or select a wrong kit, you can re-select the kit by running "CMake: Select a kit" command from the VSCode command palette. |
By default, executable file (<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)
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 a 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.
-
Open [Command Palette] and select [Renesas: Create RZ/N Project with Smart Configurator] from the commands.
-
VSCode will show installed [RZ/N Smart Configurator] list, select a [Smart Configurator] from the list.
-
Select a [Folder] to create the project.
NoteIf no RZ/N Smart Cofigurator detected automatically, "No RZ/N Smart Configurator installation found!" message will appear in VSCode:
Please click to "Browse RZ/N SC", then select the location of the RZ/N 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 RZ/N Smart Configurator for the next use.
-
Enter [Project name] and click [Next].
-
Configure your board and device type and click [Next].
-
Continue without RTOS selection and click [Next].
-
Choose one of the project templates then click [Finish] to complete the project creation steps.
-
Close [RZ/N Smart Configurator] after generation of the project files completed.
-
Open [Config.cmake] file and set [CMAKE_FIND_ROOT_PATH] variable with the path of toolchain’s bin folder. E.g.
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 a RZ/N Project created in Smart Configurator
For building a project, which created with RZ/N Smart Configurator, please follow the steps below:
-
In VS Code Command Palete, run "CMake: Delete Cache and Reconfigure" command.
-
In the first time of running, a kit selection is shown. Select "[Unspecified]".
-
Then, run "CMake: Build" command.
-
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. |