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 Hakon,

    Thanks a lot for taking a look at my issue. For now I can use Clion to browse and edit the code and can even compile files, so thats good edough. 

    The cmake error is weird and seems to be in some subprocess that is probably no having its environment set correctly. I think if I better understand the west commands I can probably try and bridge the gap in Clion. However, I think I'm good for now. 

    Thanks again for the help.

Reply
  • Hi Hakon,

    Thanks a lot for taking a look at my issue. For now I can use Clion to browse and edit the code and can even compile files, so thats good edough. 

    The cmake error is weird and seems to be in some subprocess that is probably no having its environment set correctly. I think if I better understand the west commands I can probably try and bridge the gap in Clion. However, I think I'm good for now. 

    Thanks again for the help.

Children
No Data
Related