Problems in using cmake with standalone SDK



  • On Ubuntu 16.04, using Sipeed M1w Dan Dock (By the way, someone really needs to standardize the names used for each board, it is currently too confusing. A table of comparison would be nice too).

    Using the excellent all-in-one script from manageryzy I was able to install the toolchain and standalone SDK and the test seems to compile fine.

    But I can't seem to build my own .bin files using cmake. In $HOME/kendryte/kendryte-standalone-sdk/src/hello_world there is already a main.c file which contains the following code:

    #include <stdio.h>
    #include "bsp.h"
    
    int core1_function(void *ctx)
    {
        uint64_t core = current_coreid();
        printf("Core %ld Hello world\n", core);
        while(1);
    }
    
    
    int main()
    {
        uint64_t core = current_coreid();
        printf("Core %ld Hello world\n", core);
        register_core1(core1_function, NULL);
        while(1);
    }
    

    To generate a new .bin file, I type this in a new terminal window:

    cd kendryte/kendryte-standalone-sdk/
    mkdir build && cd build
    cmake .. -DPROJ=hello_world -DSDK_ROOT=\$STANDALONE_SDK_DIR -DTOOLCHAIN=\$K210_TOOLCHAIN && make
    

    This produces the following error in the terminal:

    ld -DSDK_ROOT=\$STANDALONE_SDK_DIR -DTOOLCHAIN=\$K210_TOOLCHAIN && make
    PROJ = hello_world
    -- Check for RISCV toolchain ...
    -- Using $K210_TOOLCHAIN RISCV toolchain
    -- The C compiler identification is unknown
    -- The CXX compiler identification is unknown
    CMake Error at CMakeLists.txt:17 (project):
      The CMAKE_C_COMPILER:
    
        $K210_TOOLCHAIN/riscv64-unknown-elf-gcc
    
      is not a full path and was not found in the PATH.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
      the compiler, or to the compiler name if it is in the PATH.
    
    
    CMake Error at CMakeLists.txt:17 (project):
      The CMAKE_CXX_COMPILER:
    
        $K210_TOOLCHAIN/riscv64-unknown-elf-g++
    
      is not a full path and was not found in the PATH.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
      to the compiler, or to the compiler name if it is in the PATH.
    
    
    -- Configuring incomplete, errors occurred!
    See also "/home/mcx/kendryte/kendryte-standalone-sdk/CMakeFiles/CMakeOutput.log".
    See also "/home/mcx/kendryte/kendryte-standalone-sdk/CMakeFiles/CMakeError.log".
    

    CMakeOutput.log

    The target system is: Generic -  - 
    The host system is: Linux - 4.15.0-39-generic - x86_64
    

    CMakeError.log

    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-gcc 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu11;-Wno-pointer-to-int-cast;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers;-Wno-old-style-declaration
    Id flags: 
    
    The output was:
    No such file or directory
    
    
    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-gcc 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu11;-Wno-pointer-to-int-cast;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers;-Wno-old-style-declaration
    Id flags: -c
    
    The output was:
    No such file or directory
    
    
    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-gcc 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu11;-Wno-pointer-to-int-cast;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers;-Wno-old-style-declaration
    Id flags: -Aa
    
    The output was:
    No such file or directory
    
    
    Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-g++ 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu++17;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers
    Id flags: 
    
    The output was:
    No such file or directory
    
    
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-g++ 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu++17;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers
    Id flags: -c
    
    The output was:
    No such file or directory
    
    
    Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
    

    How do I fix these errors?