This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF Connect SDK compile and run qemu in CLION

This is based on the article fround in devzone here

I'm compiling a simple Hello World  and followed the instructions as per the nrf Connect SDK Turorial Part 2.

To summarize, I created an application based manifest for a simple hello world main just as in the article and I targeted `qemu_cortex_m3`.

I can compile and run on the command line using `west` 

cd sample_ncs_project
# I have already run west init and west update 
west build -b qemu_cortex_m3 hello_world
west build -t run

The above works fine.

I added the following to my CMakeLists.txt to make it Clion consumable

set(ENV{BOARD} qemu_cortex_m3)
set(ENV{BOARD_DIR} $ENV{ZEPHYR_BASE}/boards/arm/qemu_cortex_m3)

set(ENV{GNUARMEMB_TOOLCHAIN_PATH} ~/gnuarmemb)
set(ENV{ZEPHYR_TOOLCHAIN_VARIANT} gnuarmemb)

set(ENV{CMAKE_AR} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-ar)
set(ENV{CMAKE_AS} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-as)
set(ENV{CMAKE_ASM_COMPILER} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc)
set(ENV{CMAKE_ASM_COMPILER_AR} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc-ar)
set(ENV{CMAKE_ASM_COMPILER_RANLIB} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc-ranlib)

set(ENV{CMAKE_ASM_FLAGS_DEBUG} -g)
set(ENV{CMAKE_ASM_FLAGS_MINSIZEREL} "-Os -DNDEBUG")
set(ENV{CMAKE_ASM_FLAGS_RELEASE} "-O3 -DNDEBUG")
set(ENV{CMAKE_ASM_FLAGS_RELWITHDEBINFO} "-O2 -g -DNDEBUG")

set(ENV{CMAKE_CXX_COMPILER} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-g++)
set(ENV{CMAKE_CXX_COMPILER_AR} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc-ar)
set(ENV{CMAKE_CXX_COMPILER_RANLIB} $ENV{GNUARMEMB_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc-ranlib)

As you can see I'm targeting QEMU and have setup the necessary Zephyr Base variables in the CMakeLists.txt file.

The build compiles but in the final step I see the following in the CLION

[ 93%] Built target kernel
[ 95%] Built target zephyr_prebuilt
[ 96%] Built target linker_pass_final_script_target
[ 97%] Linking C executable zephyr.elf
Generating files from zephyr.elf for board: qemu_cortex_m3
/bin/sh: 1: cmake: not found
make[3]: *** [zephyr/CMakeFiles/zephyr_final.dir/build.make:119: zephyr/zephyr.elf] Error 127
make[3]: *** Deleting file 'zephyr/zephyr.elf'
make[2]: *** [CMakeFiles/Makefile2:1954: zephyr/CMakeFiles/zephyr_final.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:1961: zephyr/CMakeFiles/zephyr_final.dir/rule] Error 2
make: *** [Makefile:248: zephyr_final] Error 2

I'm not sure why that is happening. Any ideas on how to get this to compile cleanly ? 

Also, can I actually run Qemu from CLION? Is it possible to flash a board like west flash via CLIon? 

Thanks

Parents
  • Hi,

     

    Haven't tried this myself, and we do not officially support clion, but I'll try to comment.

     

    I can compile and run on the command line using `west` 

    This is good, means that you have all the deps in order.

    /bin/sh: 1: cmake: not found

    This isn't good, clion (or the script for generating .elf / executable file) isn't able to find cmake. do you have the cmake executable in your $PATH?

     

    Also, can I actually run Qemu from CLION? Is it possible to flash a board like west flash via CLIon? 

     I suspect that you have followed this guide? https://devzone.nordicsemi.com/f/nordic-q-a/49730/howto-nrf9160-development-with-clion

    That is written by a forum user, and the steps might differ a bit from the time it was written (> 1 year ago); and it is also stated that the original poster used MacOS.

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    Haven't tried this myself, and we do not officially support clion, but I'll try to comment.

     

    I can compile and run on the command line using `west` 

    This is good, means that you have all the deps in order.

    /bin/sh: 1: cmake: not found

    This isn't good, clion (or the script for generating .elf / executable file) isn't able to find cmake. do you have the cmake executable in your $PATH?

     

    Also, can I actually run Qemu from CLION? Is it possible to flash a board like west flash via CLIon? 

     I suspect that you have followed this guide? https://devzone.nordicsemi.com/f/nordic-q-a/49730/howto-nrf9160-development-with-clion

    That is written by a forum user, and the steps might differ a bit from the time it was written (> 1 year ago); and it is also stated that the original poster used MacOS.

     

    Kind regards,

    Håkon

Children
No Data
Related