17. Advanced Guidelines

17.1. Setup environment and debug multicore CA55 with CR52 using renesas-amalgamator

17.1.1. Overview

Support debug multicore with CA55 and CR52 for R-Car S4 device on VS code.

This item describes how to connect the S4 board to the PC host, install an extension, import the project, configure file launch.json, run and debug.

17.1.2. Connecting S4 board to PC host

We need to connect between board and PC to debug multicore ARM on VSCode as shown in the picture below:

_images/connecting-s4-board-to-pc-host.gif

Select the mode for S4 Spider Configuration tool -Renesas as shown below:

_images/s4-spider-config-tool.png

17.1.3. Setup debugger options

  1. Install the Renesas Debug extension to VSCode (please refer to Section 1: Installation).

  2. Import the built CA55 and CR52 projects into VS Code.

  3. In order to debug a project using VS Code and the Renesas Debug extension, a configuration file called launch.json needs to be created.

    1. Select [Run and Debug] view.

      _images/cacr-run-and-debug.png
    2. Select [Create a launch.json file] link.

      _images/creating-launch-json-config.png
    3. Select [Renesas Amalgamator].

      _images/renesas-amalgamator-debug-config-selection.png
    4. A launch.json file will be created inside .vscode folder with some default settings.

    5. For debugging multicore with multiple architectures on a single device, the configuration can be combined into a single launch entry.

    6. In the launch.json file, fill in the following fields.

      .launch.json
       1{
       2  // Use IntelliSense to learn about possible attributes.
       3  // Hover to view descriptions of existing attributes.
       4  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
       5  "version": "0.2.0",
       6  "configurations": [
       7    {
       8      "type": "renesas-amalgamator",
       9      "request": "launch",
      10      "name": "<display name of the configuration>",
      11      "children": [
      12        {
      13          "name": "<display name of core>",
      14          "debugAdapterRuntime": "node",
      15          "interfaceType": "GDB",
      16          "cortexArmList": [
      17            "CortexA55", //The first Cortex is launched as the primary session
      18            "CortexR52"  //All remaining Cortex-s are attached as secondary sessions
      19          ],
      20          "arguments": {
      21            "type": "renesas-hardware",
      22            "request": "launch",
      23            "hardwareBreakpoint": true,
      24            "isHeterogeneous": true, //Enables multi-architecture debugging
      25            "program": "<absolute path to project's executable file (.x, .elf,...)>",
      26            "target": {
      27              "deviceFamily": "RCAR",
      28              "device": "<CPU of the device>",
      29              "debuggerType": "<type of the debugger>"
      30            }
      31          }
      32        }
      33      ]
      34    }
      35  ]
      36}
      

      Example configuration file launch.json:

      .Example: launch.json
       1{
       2  // Use IntelliSense to learn about possible attributes.
       3  // Hover to view descriptions of existing attributes.
       4  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
       5  "version": "0.2.0",
       6  "configurations": [
       7    {
       8      "type": "renesas-amalgamator",
       9      "request": "launch",
      10      "name": "Debug Multiple",
      11      "children": [
      12        {
      13          "name": "proc1",
      14          "debugAdapterRuntime": "node",
      15          "interfaceType": "GDB",
      16          "cortexArmList": [
      17            "CortexA55",
      18            "CortexR52"
      19          ],
      20          "arguments": {
      21            "type": "renesas-hardware",
      22            "request": "launch",
      23            "hardwareBreakpoint": true,
      24            "isHeterogeneous": true,
      25            "program": "${cwd}/CACore_Project/build/release/ca55_loader.elf",
      26            "images": [
      27                {
      28                    "file": "${cwd}/CACore_Project/build/release/ca55_loader.elf",
      29                    "type": "image-and-symbols",
      30                    "program": true, //Specify the program for the first Cortex
      31                    "coreName": "CA55CPU0"
      32                },
      33                {
      34                    "file": "${cwd}/CRCore_Project/build/release/cr52_loader.elf",
      35                    "type": "image-and-symbols",
      36                    "program": true, //Specify the program for the second Cortex
      37                    "coreName": "CR52CPU0"
      38                },
      39            ],
      40            "target": {
      41              "deviceFamily": "RCAR",
      42              "device": "R8A779F0",
      43              "debuggerType": "E2ARM",
      44              "serverParameters": ["-uInteface=", "JTAG", "-w", "0", "-uConnectMode=", "RESET", "-uWorkRamAddress=", "0x0", "-uSyncMode=", "async", "--gdbVersion=", "7.2"]
      45            },
      46          }
      47        }
      48      ]
      49    }
      50  ]
      51}
      

17.1.4. Start debugging

  1. After setting up debugger options, a debug session can be started by selecting the created configuration and click [Start Debugging] button in [Run and Debug] view, or press [F5].

    _images/multiple-debug-config-button.png
  2. Waiting for the program to launch and debug successfully.

    _images/hitting-breakpoint-successfully.png
  3. Displaying variables, watch expression, call stack… are supported in VS Code:

    1. Select [View] -> [Open View…]

      _images/open-var-view.png
    2. Select the Views to be displayed on the window.

      _images/select-display-views.png

17.2. Setup environment and debug project ARM & G4MH using renesas-amalgamator

17.2.1. Overview

Support multiple different (ARM/G4MH) cores for R-Car S4 device on VS code.

This item describes how to debug (Project ARM+G4MH).

17.2.2. Connecting S4 board to PC host

We need to connect between board and PC to debug ARM and G4MH on VSCode as shown in the picture below:

_images/connecting-arm-and-g4mh-to-pc.gif

Select the mode for S4 Spider Configuration tool -Renesas as shown below:

_images/gm4h-spider-config-tool.png

17.2.3. Setup debugger options

  1. Install the Renesas Debug extension to VSCode (please refer to Section 1: Installation).

  2. Import the built G4MH and CR52 projects into VS Code.

  3. In order to debug a project using VS Code and the Renesas Debug extension, a configuration file called launch.json needs to be created.

    1. Select [Run and Debug] view.

      _images/cacr-run-and-debug.png
    2. Select [Create a launch.json file] link.

      _images/creating-launch-json-config.png
    3. Select [Renesas Amalgamator].

      _images/renesas-amalgamator-debug-config-selection.png
    4. A launch.json file will be created inside .vscode folder with some default settings.

    5. In the launch.json file, fill in the following fields

      .launch.json
       1{
       2  // Use IntelliSense to learn about possible attributes.
       3  // Hover to view descriptions of existing attributes.
       4  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
       5  "version": "0.2.0",
       6  "configurations": [
       7    {
       8      "type": "renesas-amalgamator",
       9      "request": "launch",
      10      "name": "<display name of the configuration>",
      11      "children": [
      12        {
      13          //RH850 Core G4MH
      14          "name": "<display name of core>",
      15          "debugAdapterRuntime": "node",
      16          "arguments": {
      17            "type": "renesas-hardware",
      18            "request": "launch",
      19            "program": "<absolute path to project's executable file (.x, .elf,...)>",
      20            "target": {
      21              "deviceFamily": "RCAR",
      22              "device": "<CPU of the device>",
      23              "debuggerType": "<type of the debugger>"
      24            }
      25          }
      26        },
      27        {
      28          //Core Arm (CA/CR)
      29          "name": "<display name of core>",
      30          "debugAdapterRuntime": "node",
      31          "arguments": {
      32            "type": "renesas-hardware",
      33            "request": "launch",
      34            "program": "<absolute path to project's executable file (.x, .elf,...)>",
      35            "target": {
      36              "deviceFamily": "RCAR",
      37              "device": "<CPU of the device>",
      38              "debuggerType": "<type of the debugger>"
      39            }
      40          }
      41        }
      42      ]
      43    }
      44  ]
      45}
      

      Example configuration file launch.json:

      .Example: launch.json
       1{
       2  // Use IntelliSense to learn about possible attributes.
       3  // Hover to view descriptions of existing attributes.
       4  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
       5  "version": "0.2.0",
       6  "configurations": [
       7    {
       8      "type": "renesas-amalgamator",
       9      "request": "launch",
      10      "name": "Debug Multiple",
      11      "children": [
      12        {
      13          //RH850 Core G4MH
      14          "name": "G4MH",
      15          "debugAdapterRuntime": "node",
      16          "arguments": {
      17            "type": "renesas-hardware",
      18            "request": "launch",
      19            "program": "${cwd}/G4MH/HardwareDebug/G4MH_Debug.x",
      20            "target": {
      21              "deviceFamily": "RCAR",
      22              "device": "R8A779F0",
      23              "debuggerType": "E2RH850",
      24              "serverParameters": ["-ulpdType=","15","-uJTagClockFreq=","Default","-setOptJtagLpd=","-uocdID=","0000000000000000000000000000000000000000000000000000000000000000","-ucustomerID=","0000000000000000000000000000000000000000000000000000000000000000","-uneedAuthentication=","0","-uWorkRamAddress=","0x0","-uTraceEnable=","PE0|PE1","-uTraceClock=","PE0|400|PE1|400","-uUseSyncTrace=","1","-uSyncTraceStandard=","0","-uTraceCore=","PE0","--gdbVersion=","7.2"]
      25            },
      26          }
      27        },
      28        {
      29          //Core Arm (CA/CR)
      30          "name": "ARM",
      31          "debugAdapterRuntime": "node",
      32          "arguments": {
      33            "type": "renesas-hardware",
      34            "request": "launch",
      35            "program": "${cwd}/BAREMETAL_CR52/Debug/MR_BAREMETAL_CR52.axf",
      36            "target": {
      37                "deviceFamily": "RCAR",
      38                "debuggerType": "E2ARM",
      39                "device": "R8A779F0_CR52",
      40                "serverParameters": ["-uInteface=", "JTAG", "-w", "0", "-uWorkRamAddress=", "0x0", "--gdbVersion=", "7.2"]
      41            },
      42          }
      43        }
      44      ]
      45    }
      46  ]
      47}
      

17.2.4. Start debugging

In the select box RUN AND DEBUG (ctrl+shift+D) select “Debug Multiple” option then click [Start Debugging] (F5) button.

_images/debug-multiple-arm-gm4h.png

Waiting for program to launch and debug successfully.

_images/arm-gm4h-successful-debug.png

17.3. Setup environment and debug multi-core ARM device R-Car S4 (CA55: CPU0 to CPU7)

17.3.1. Overview

Support debug multicore with CA55 (CPU0 -> CPU7) for R-Car S4 device on VS code.

This item describes how to connect the S4 board to the PC host, install an extension, import the project, configure file launch.json, run and debug.

17.3.2. Connecting S4 board to PC host

We need to connect between board and PC to debug multicore ARM on VSCode as shown in the picture below:

_images/connecting-s4-board-to-pc-host.gif

Select the mode for S4 Spider Configuration tool -Renesas as shown below:

_images/s4-spider-config-tool.png

17.3.3. Setup debugger options

  1. Install the Renesas Debug extension to VSCode. (please refer to Section 1: Installation).

  2. Import the built CA55 projects into VS Code.

  3. In order to debug a project using VS Code and the Renesas Debug extension, a configuration file called launch.json needs to be created.

    1. Select [Run and Debug] view.

    2. Select [Create a launch.json file] link.

    3. Select [Renesas GDB Hardware Target].

    4. A launch.json file will be created inside .vscode folder with some default settings.

    5. In the launch.json file, fill in the following fields.

      .launch.json
       1{
       2  // Use IntelliSense to learn about possible attributes.
       3  // Hover to view descriptions of existing attributes.
       4  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
       5  "version": "0.2.0",
       6  "configurations": [
       7    {
       8      "type": "renesas-hardware",
       9      "request": "launch",
      10      "name": "<display name of the configuration>",
      11      "program": "<absolute path to project's executable file (.x, .elf,...)>",
      12      "target": {
      13        "debuggerType": "<type of the debugger>",
      14        "device": "<CPU of the device>",
      15        "deviceFamily": "RCAR",
      16      }
      17    }
      18  ]
      19}
      

      Example configuration file launch.json:

      .Example: launch.json
       1{
       2    // Use IntelliSense to learn about possible attributes.
       3    // Hover to view descriptions of existing attributes.
       4    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
       5    "version": "0.2.0",
       6    "configurations": [
       7      {
       8        "type": "renesas-hardware",
       9        "request": "launch",
      10        "name": "RCAR Multicore CA55",
      11        "program": "${cwd}/Debug/MR_BAREMETAL_CA55.axf",
      12        "target": {
      13          "deviceFamily": "RCAR",
      14          "device": "R8A779F0_CA55",
      15          "debuggerType": "E2ARM",
      16          "serverParameters": ["-uInteface=", "JTAG", "-w", "0", "--gdbVersion=", "7.2"]
      17        },
      18      },
      19    ]
      20}
      

17.3.4. Start debugging

After setting up debugger options, a debug session can be started by selecting the created configuration and click [Start Debugging] button in [Run and Debug] view, or press [F5].

_images/multicore-ca55-debug-config.png

Waiting for the program to launch and debug successfully.

_images/waiting-for-ca55-to-debug-successfully.png

17.4. Setup environment and debug multi-core G4MH device R-Car S4 or device RH850

17.4.1. Overview

Support debug multicore with multi-core G4MH for R-Car S4 device (PE0, PE1) or device RH850 (PE0,PE1,PE2,PE3) on VS code.

This item describes how to connect the S4 board or RH850 board to the PC host, install an extension, import the project, configure file launch.json, run and debug.

17.4.2. Connecting S4 board to PC host

We need to connect between board and PC to debug multicore ARM on VSCode.

Select the mode for S4 Spider Configuration tool -Renesas if debug with R-Car S4 device.

17.4.3. Setup debugger options

  1. Install the Renesas Debug extension to VSCode. (please refer to Section 1: Installation).

  2. Import the built G4MH/RH850 projects into VS Code.

  3. In order to debug a project using VS Code and the Renesas Debug extension, a configuration file called launch.json needs to be created.

    1. Select [Run and Debug] view.

    2. Select [Create a launch.json file] link.

    3. Select [Renesas GDB Hardware Target].

    4. A launch.json file will be created inside .vscode folder with some default settings.

    5. In the launch.json file, fill in the following fields.

      Format of .launch.json:

       1{
       2  // Use IntelliSense to learn about possible attributes.
       3  // Hover to view descriptions of existing attributes.
       4  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
       5  "version": "0.2.0",
       6  "configurations": [
       7    {
       8      "type": "<type>",
       9      "request": "launch",
      10      "name": "<display name of the configuration>",
      11      "program": "<absolute path to project's executable file (.x, .elf,...)>",
      12      "target": {
      13        "deviceFamily": "<the device family name Eg.RCAR>",
      14        "device": "<CPU of the device>",
      15        "debuggerType": "<debugger type (type of the simulator or emulator)>"
      16      }
      17    }
      18  ]
      19}
      

      Sample configurations for launch.json file:

      Sample: launch.json for multi-core G4MH for R-Car S4 device (PE0, PE1)
      {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "configurations": [
          {
            "name": "G4MH",
            "type": "renesas-hardware",
            "request": "launch",
            "hardwareBreakpoint": true,
            "program": "${cwd}/HardwareDebug/G4MH_Debug.x",
            "target": {
              "deviceFamily": "RCAR",
              "device": "R8A779F0",
              "debuggerType": "E2RH850",
              "serverParameters": ["-ulpdType=","15","-uJTagClockFreq=","Default","-setOptJtagLpd=","-uocdID=","0000000000000000000000000000000000000000000000000000000000000000","-ucustomerID=","0000000000000000000000000000000000000000000000000000000000000000","-uneedAuthentication=","0","-uWorkRamAddress=","0x0","-uTraceEnable=","PE0|PE1","-uTraceClock=","PE0|400|PE1|400","-uUseSyncTrace=","1","-uSyncTraceStandard=","0","-uTraceCore=","PE0","--gdbVersion=","7.2"]
            }
          }
        ]
      }
      
      Sample: launch.json for multi-core device RH850 (PE0, PE1, PE2, PE3)
      {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "configurations": [
          {
            "name": "RH850",
            "type": "renesas-hardware",
            "request": "launch",
            "hardwareBreakpoint": true,
            "program": "${cwd}/HardwareDebug/Project_RH850.x",
            "target": {
              "deviceFamily": "RCAR",
              "device": "R7F702Z19A",
              "debuggerType": "E2RH850",
              "serverParameters": ["-ulpdType=", "15","-setOptJtagLpd=", "0", "-w", "1", "-usupplyVoltage=", "0", "-uocdID=", "0000000000000000000000000000000000000000000000000000000000000000"]
            }
          }
        ]
      }
      

17.5. Create and build G4MH project on R-Car SDK

17.5.1. Create G4MH Project

  1. From the menu bar select [File] > [New] > [Renesas C/C++ Project] > [Renesas R-Car]

    _images/creating-gm4h-project.png
  2. Select R-Car project template [Renesas CC-RH C Executable Project], then click [Next] button

    _images/selecting-rcar-project-template.png
  3. Input the project name then click [Next] button.

    _images/creating-ccrh-executable-project.png
  4. In New Renesas CC-RH Executable Project select Create Hardware Debug Configuration [E2 (RH850)], then click [Finish] button

    _images/create-ccrh-executable-set-target-and-debug-config.png
  5. Projects will be created.

    _images/gm4h-project-creation.png

17.5.2. Build Project G4MH

  1. Right-click on the project and select [Build Project]

    _images/gm4h-build-sample-project.png
  2. Or can click on the [Build ]icon on the toolbar.

    _images/gm4h-build-sample-project-button.png
  3. Project after built.

    _images/gm4h-build-sample-project-project-explorer.png

17.6. Build CVEngine project on R-Car SDK

17.6.1. Create Project

  1. From the menu bar select File > Import…

    _images/e2-studio-import-project.png
  2. Select Dialog Import “Existing Projects into Workspace”, then click Next button

    _images/import-existing-projects-into-workspace.png
  3. Select Dialog Import “Select archive file” > Select Browse… > Select the project you want to build in your directory, then click Finish button.

    _images/import-project-setting-archive-file.png
  4. Project after imported

    _images/imported-project-explorer.png

17.6.2. Build Project

  1. Right-click on the project and select “Clean Project

    _images/imported-project-clean-process.png
  2. Check Toolchain Configuration: From the menu bar select File > Window > Preferences

    _images/edit-default-toolchain-location.png
  3. Select Launch Configuration (the name of the project is imported), and Launch Target “V4H DevBoard” on the toolbar.

    _images/imported-project-debug-start.png
  4. Select “Edit” icon of Launch Target “V4H DevBoard” on the toolbar, then select Target Device “Development board / SoC” and IMP Debug Level “CVe (Shader debugging)”, then click Finish button.

    _images/edit-settings-imported-project.png
  5. Right-click on the project and select “Build Project

    _images/imported-project-build-step.png
  6. Project after built

    _images/imported-build-ensure-success.png

17.7. How to specify device specific parameters in CMake scripts

Note

The following instructions are applicable for non Smart Configurator projects. The projects generated by the Smart Configurators will already have the correct build scripts, including device specific parameters for the target device.

17.7.1. Creating CMake Toolchain Scripts and Building the Project

It is recommended to use the Smart Configurators in VS Code when creating new projects. When projects are generated by the Smart Configurators through VS Code, there is no need to perform additional steps to configure the CMake build scripts. On the other hand, Renesas extensions provide predefined scripts to define the build environment for Renesas C/C++ projects, which are generated with e2 studio. The predefined build scripts can be accessed in the “Create Project” view in the “Renesas” tab. The following list contains all the predefined script options under the various device families:

  • Create Renesas R-Car Project

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

    • Create RCar CMake (Instruction Set Simulators) project files

  • Create Renesas RH850 Project

    • Create CC-RH project files

  • Create Renesas RL78 Project

    • Create CC-RL project files

    • Create GCC RL78 project files

    • Create LLVM for RL78 project files

  • Create Renesas RX Project

    • Create CC-RX project files

    • Create GCC RX project files

  • Create Renesas RZ Project

    • Create GCC RZ project files

  1. Click the desired family to start the project files generation:

    _images/vscode-create-project-files-menu.png
  2. Then, select the desired toolchain and continue (e.g. sample options for RX shown below).

    _images/vscode-create-project-files-selection.png
  3. The VSCode will ask to select the project root folder, select the target project folder.

    _images/vscode-create-project-files-root-folder.png
  4. The commands will open the project and generate the VS Code settings files, as well as the CMake script files cross.cmake and CMakeLists.txt files:

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

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

    • Cross.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.).

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

    .settings.json file’s general content:

    1{
    2    "cmake.configureArgs": [
    3        "-DCMAKE_TOOLCHAIN_FILE=<absolute/relative path of toolchain information file (<file name>.cmake file)"
    4    ],
    5    "cmake.sourceDirectory": "<absolute/relative path of the folder containing the root CMakeLists.txt file>"
    6}
    

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

    .tasks.json file’s general content:

     1{
     2  "version": "2.0.0",
     3  "tasks": [
     4    {
     5      "label": "Build Project",
     6      "group": "build",
     7      "type": "renesas-build",
     8      "command": "build",
     9      "deviceFamily": "<Device family (e.g. RA, RCAR, RH850, RL78, RX or RZ)>",
    10      "toolchain": "<Toolchain (e.g. gcc, cc-rl, cc-rx, llvm)>"
    11    }
    12  ]
    13}
    

    Cross.cmake - this file contains the information about the toolchain to use.

    Cross.cmake file’s general content:

     1# Specify toolchain path
     2SET(CMAKE_FIND_ROOT_PATH "<absolute path of toolchain's bin folder>")
     3
     4# Specify the C compiler and necessary options
     5SET(CMAKE_C_COMPILER ${CMAKE_FIND_ROOT_PATH}/<C compiler executable file>)
     6
     7# Specify the CPP compiler and necessary options
     8SET(CMAKE_CXX_COMPILER ${CMAKE_FIND_ROOT_PATH}/<CPP compiler executable file>)
     9
    10# Specify the assembler and necessary options
    11SET(CMAKE_ASM_COMPILER ${CMAKE_FIND_ROOT_PATH}/<assembler executable file>)
    12
    13# Specify the linker and necessary options
    14SET(CMAKE_LINKER ${CMAKE_FIND_ROOT_PATH}/<linker executable file>)
    15
    16# Specify the library generator and necessary options
    17SET(CMAKE_LIBRARY ${CMAKE_FIND_ROOT_PATH}/<library generator executable file>)
    18
    19# Specify the converter and necessary options
    20SET(CMAKE_CONVERTER_EXECUTABLE ${CMAKE_FIND_ROOT_PATH}/<converter executable file>)
    

    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:

     1cmake_minimum_required(VERSION 3.16)
     2
     3# Set project name
     4project("<project name>")
     5
     6enable_language(C ASM)
     7
     8# Collect source files
     9FILE (GLOB_RECURSE SOURCE ${CMAKE_CURRENT_SOURCE_DIR}
    10"*.c" "*.cpp" "*.asm"
    11)
    12add_executable(${PROJECT_NAME} ${SOURCE})
    13
    14# Set C compiler command
    15SET(CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILER} <specify C compiler options here>")
    16
    17# Set C++ compiler command
    18SET(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILER} <specify C++ compiler options here>")
    19
    20# Set Assembler command
    21SET(CMAKE_ASM_COMPILE_OBJECT "${CMAKE_ASM_COMPILER} <specify assembler options here>")
    22
    23# Set Linker command
    24SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_LINKER} <specify linker options here>")
    25
    26# Set Library generator command
    27add_custom_COMMAND(
    28 TARGET ${CMAKE_PROJECT_NAME}
    29 PRE_LINK
    30 COMMAND ${CMAKE_LIBRARY} <specify library generator options here>
    31 COMMENT "Libgen:"
    32 VERBATIM
    33)
    34
    35# Set Converter Command
    36add_custom_command (
    37 TARGET ${CMAKE_PROJECT_NAME}
    38 COMMAND ${CMAKE_CONVERTER_EXECUTABLE} <specify converter options here>
    39 COMMENT "Converter:"
    40 VERBATIM
    41)
    

After generating these files, it is necessary to configure the toolchain information and device specific build settings in these files. The typical approach can be structured into the following steps:

  1. Open the cross.cmake file, and configure the toolchain path.

  2. Get the device specific build settings from e2 Studio by following the instructions below:

    1. Open the desired project in e2 studio.

    2. Go to [Project] => [Properties] menu.

    3. In the project properties windows, navigate to [C/C++ Build] => [Settings] section.

    4. In the “Tool Settings” tab, check the “Common”, “Compiler”, “Assembler”, “Linker” sections. Depending on the target device get the values of the device specific parameters. The following parameters are the most common device specific parameters:

      • -isa

      • -cpu

      • -fpu (generally either -fpu or -nofpu)

      • -rom

      • -start

    5. Now, open the project in VSCode, navigate to CMakeLists.txt and configure the device specific parameters in the CMake script.

  3. Once all the necessary files are in place, open the [Command Palette] and run the [CMake: Delete Cache and Reconfigure] operation.

  4. To run build task, either press [CTRL+SHIFT+B] ([CMD+SHIFT+B] for macOS) or select [Terminal] → [Run Build Task…] from the menu.

  5. Open the [Command Palette] in VSCode and click [CMake: Delete Cache and Reconfigure].

  6. In the first time of running, a kit selection is shown. Select “[Unspecified]”.

    _images/cmake-custom-scripts-build-toolchain.png

    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.

    _images/cmake-custom-scripts-sak.png
  7. Go to and click [Terminal] => [Run Build Task] from the menu.

    _images/cmake-custom-scripts-build-01.png
  8. Build options will be shown, select the [Build Project] option.

    _images/cmake-custom-scripts-build-02.png

17.7.2. Sample Scenario: Configuring CC/RX project CMake Files

In the following example, we are going to cover step by step instructions for converting the CMakeLists.txt script, and targeting it for the CCRX toolchain and an RX66T device.

  1. First, open your project in e2 Studio, (or create an new one using e2 Studio).

  2. Go to [Project] => [Properties] menu.

    _images/cmake-custom-scripts-e2-project-menu.png
  3. In the project properties windows, navigate to [C/C++ Build] => [Settings] section.

    _images/cmake-custom-scripts-e2-project-properties.png
  4. In parallel, open your project in VSCode.

  5. Navigate to [Renesas] tab, and click [Create Renesas RX Project] to start the project files generation:

    _images/vscode-create-project-files-menu.png
  6. Then, select the [Create CC-RX project files] and continue.

    _images/vscode-create-project-files-selection.png
  7. The VSCode will ask to select the project root folder, select the target project folder.

    _images/vscode-create-project-files-root-folder.png
  8. Now, VSCode will create the necessary files. Open the cross.cmake file and set the path of the toolchain as shown in the screenshot below.

    _images/cmake-custom-scripts-cross-cmake.png
  9. Now, VSCode will create the necessary files. Open the CMakeLists.txt file.

  10. In the e2 Studio Project Settings, navigate to [Common], take the -isa and fpu parameters, then replace them in the CmakeLists.txt in VSCode. Change the -isa=rxv1 parameter to -isa=rxv3, and replace the -nofpu parameters with -fpu.

    _images/cmake-custom-scripts-common-args.png
  11. In the e2 Studio Project Settings, navigate to [Linker], take the -rom and -cpu parameters, then replace the value of the -cpu and add the -rom parameter in the CMAKE_EXE_LINKER_FLAGS at CmakeLists.txt file.

    _images/cmake-custom-scripts-linker-args.png
  12. In the e2 Studio Project Settings, navigate to [Linker] => [Section], take the -start parameter, then replace the value of the -start parameter in the CMAKE_EXE_LINKER_FLAGS at CmakeLists.txt file.

  13. In the e2 Studio Project Settings, navigate to [Assembly], then take the -start parameter, then replace them in the CmakeLists.txt in VSCode.

    _images/cmake-custom-scripts-start-arg.png

    Note

    Please note that you may need to follow the escape character rules while setting the values, for example the -start parameter may include a $ character, which needs to be replaced with a double dollar sign $$ according to the CMake escape character usage:

    SU,SI,B_1,R_1,B_2,R_2,B,R/04,PResetPRG,C_1,C_2,C,C$*,D*,W*,L,PIntPRG,P/0FFF80000,EXCEPTVECT/0FFFFFF80,RESETVECT/0FFFFFFFC
    

    should be defined as:

    SU,SI,B_1,R_1,B_2,R_2,B,R/04,PResetPRG,C_1,C_2,C,C$$*,D*,W*,L,PIntPRG,P/0FFF80000,EXCEPTVECT/0FFFFFF80,RESETVECT/0FFFFFFFC
    
  14. Open the [Command Palette] in VSCode and click [CMake: Delete Cache and Reconfigure].

  15. In the first time of running, a kit selection is shown. Select “[Unspecified]”.

    _images/cmake-custom-scripts-build-toolchain.png

    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.

    _images/cmake-custom-scripts-sak.png
  16. Go to and click [Terminal] => [Run Build Task] from the menu.

    _images/cmake-custom-scripts-build-01.png
  17. Build options will be shown, select the [Build Project] option.

    _images/cmake-custom-scripts-build-02.png

For testing the project, you can use the RX Simulator (Simulator is only available for Windows operating systems).

  1. Go to the [Debug] tab in VSCode and generate a launch configuration for [Renesas GDB Simulator Debugging]. This will generate a sample Launch configuration in the .vscode/launch.json file.

  2. Open the Launch configuration and set the correct parameters for your target device. For example:

     1{
     2  // Use IntelliSense to learn about possible attributes.
     3  // Hover to view descriptions of existing attributes.
     4  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
     5  "version": "0.2.0",
     6  "configurations": [
     7    {
     8      "type": "renesas-simulator",
     9      "request": "launch",
    10      "name": "Renesas GDB Simulator Debugging",
    11      "target": {
    12        "deviceFamily": "RX",
    13        "device": "R5F566TE",
    14        "debuggerType": "SIMULATOR"
    15      }
    16    }
    17  ]
    18}
    
  3. Start your debug session.

    _images/cmake-custom-scripts-debug-start.png

17.7.3. Sample Scenario: Using Renesas R-Car SDK

The details of some specific devices will be presented here. 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”

_images/SDK-default-path.png _images/SDK-samples.png

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.

_images/SDK_project_path.png _images/SDK-project-sample.png