Project

General

Profile

Linux App Visual Studio Code

Objective

This wiki page will describe how to setup Visual Studio Code so it can be used to build and debug an ARM Linux user-level program on the AM62x.

References

General setup

Vscode CMake Hello World Example

  • Create a project directory
    mkdir helloworld
    cd helloworld
    code .
    
  • Open the Command Palette Ctrl Shift P and run the CMake: Quick Start command:
    • Enter name: "Hello_World"
    • Language: C
    • Project Type: Executable
    • Additional Options: CTest
  • CMake: Edit User-Local CMake Kits
    • Add the following code to the end of cmake-tools-kits.json
      Replace <CRITICAL_LINK_PROCESSOR_SDK> with location of toolchain installed in General Setup
      Example:/home/<yourhome>/arago-2023.10-aarch64-linux-tisdk-mitysom-am62x-SDK10.01.10_43
        {
          "name": "CL SDK 10.01 am62x",
          "compilers": {
            "C": "<CRITICAL_LINK_PROCESSOR_SDK>/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc",
            "CXX": "<CRITICAL_LINK_PROCESSOR_SDK>/sysroots/x86_64-arago-linux/usr/bin/aarch64-oe-linux/aarch64-oe-linux-g  " 
          },
          "environmentSetupScript": "<CRITICAL_LINK_PROCESSOR_SDK>/environment-setup",
          "toolchainFile": "<CRITICAL_LINK_PROCESSOR_SDK>/sysroots/x86_64-arago-linux/usr/share/cmake/OEToolchainConfig.cmake" 
        }
      
  • Open the Command Palette Ctrl Shift P and run the CMake: Select a kit command:
    • Select kit for helloworld: CL SDK 10.01 am62x
  • Open the Command Palette Ctrl Shift P and run the CMake: Configure command
  • Open the Command Palette Ctrl Shift P and run the CMake: Build command or press F7 (default hotkey)
  • Copy the Hello_World binary to your target
    scp build/Hello_World target_62x:
    
  • Run the program
    ssh target_62x ./Hello_World
    

Additional CMake Commands

  • CMake: Clean - Cleans the build environment
  • CMake: Clean Rebuild - Cleans the build environment and then rebuilds
  • CMake: Select Variant - Easily change from debug build to release, and others

Debugging

  • Create a launch.json file
  • In the "Run and Debug" tab on the left side of the vscode window select "create a launch.json file"
  • Copy the following into the launch.json file
    {
        "version": "0.2.0",
        "configurations": [
            {
                "type": "cppdbg",
                "request": "launch",
                "name": "Attach to target_62x",
                "program": "${workspaceFolder}/build/Hello_World",
                "miDebuggerServerAddress": "localhost:10000",
                "stopAtEntry": true,
                "externalConsole": false,
                "MIMode": "gdb",
                "cwd": "${workspaceRoot}",
                "valuesFormatting": "prettyPrinters",
                "miDebuggerPath": "/usr/bin/gdb-multiarch" 
            },
        ]
    }
    
  • Debug the program
    • start gdbserver on target
      ssh target_62x gdbserver :10000 ./Hello_World
      
    • start debug session
      • In the "Run and Debug" tab select Attach to target_62x
      • Should stop with arrow at the std::cout
      • Select "continue" in the debug toolbar or press F5
      • Should see "Hello, from Hello_World!" in ssh console
      • Click the disconnect icon or shift F5
  • VSCode debugger quirks
    • Only plant or remove breakpoints when the target is stopped, not when the target is running.
    • Only disconnect a debug session when the target is stopped.
    • Doing these operations while the target is running will cause confusion. You may have to kill the gdbserver manually on the target and you will have to start a new debug session.

Summary

A sample debug session with a simple hello world project has been demonstrated.

Go to top
Add picture from clipboard (Maximum size: 1 GB)