Build kendryte using eclipse


  • Staff

    I tested visual studio, clion and eclipse for k210. i can build elf and bin using all of them, but the only one IDE I can debug is eclipse. Here is how i use eclipse to compile and debug.

    SOFTWARE NEEDED

    • eclipse cdt( Version: 2018-09 (4.9.0) i used)
    • ninja
    • unofficial build of riscv toolchain for windows( gdb have bug in official toolchain for windows. if you use linux it's okay, if you use windows you have to build yourself or find prebuilt from somewhere like sifive)
    • cmake
    • cmake4eclipse plugin

    STEPS

    • add ${toolchain}/bin to path env
    • add so search path (if you use linux)
    • put ninja to your search path
    • run eclipse cdt new c/c++ project
    • add cmakelists.txt like this:
    cmake_minimum_required(VERSION 3.0)
    
    set(SDK_ROOT "C:/tools/kendryte/kendryte/kendryte-standalone-sdk")
    set(TOOLCHAIN "C:/Users/manag/kendryte/kendryte-toolchain/bin")
    
    set(BUILDING_SDK "yes" CACHE INTERNAL "")
    
    include(${SDK_ROOT}/cmake/common.cmake)
    project(k210)
    
    # config self use headers
    include(${SDK_ROOT}/cmake/macros.internal.cmake)
    INCLUDE_DIRECTORIES(${SDK_ROOT}/lib/arch/include ${SDK_ROOT}/lib/utils/include)
    header_directories(${SDK_ROOT}/lib)
    
    # build library first
    add_subdirectory(${SDK_ROOT}/lib lib)
    
    
    # compile project
    add_source_files(src/*.c src/*.s src/*.S src/*.cpp)
    include(${SDK_ROOT}/cmake/executable.cmake)
    
    
    • configure cmake. using generate "Eclipse Ninja"
    • build project
    • launch openocd with -m0
    • add debug config "gdb hardware debug"
    • configure gdb using "localhost:3333" and configure
    • start debugging

  • Staff

    oh, and i found both visual studio and clion can get right lint. but eclipse can't found symbol