boilerplate.cmake not found because ZEPHYR_BASE isn't set

Hi,

I'm very confused by this error.

I have a project with the following CMakeLists.txt file

When the project is tried to be built at the startup of VScode, I get the following error message

When I open a terminal, I ran echo $ZEPHYR_BASE, but it came out empty.
Therefore, I go into the nRF Connect SDK folder that I'm using (v2.2.0-rc1), run source zephyr/zephyr-env.sh and then the terminal finally recognizes where ZEPHYR_BASE is.

To rebuild, I just do a dummy modification to the file (use :w since I'm using vim within vscode), and then application tries to rebuild again, but I keep the same error.

If I go to the nRF Connect extension section, I see my folder under applications, but it's followed by "no build configurations", because of this problem.

What should I do?

Parents
  • Hi,

    ZEPHYR_BASE should be set correctly if you use VS Code with the nRF Connect for VS Code extension and has selected the correct SDK and toolchain. If you go to the welcome page of the extension and Quick Setup, what is nRF Connect SDK and nRF Connect Toolchain set to?

    You can also set ZEPHYR_BASE in your environment variables. The path of this should be the zephyr directory of your nRF Connect SDK installation, so for example something like /home/ernesto/ncs/v2.1.0/zephyr.

    Best regards,

    Marte

  • Quick setup

    Welcome to nRF - Quick Setup

    Settings in workspace

    Should I replace the settings in the workspace by the absolute path?

  • Hi,

    Could you try using "west build" command from the terminal opened from Toolchain Manager?

    Best regards,
    Dejan

  • I just tried "west build --build-dir /home/ernesto/ncs/bike_finder/build /home/ernesto/ncs/bike_finder" from the terminal opened from the toolchain manager. I did it from /home/ernesto/ncs/bike_finder/.

    Got the same errors I copied above. Yet, doing echo $ZEPHYR_BASE still outputs .../v2.2.0-rc1/zephyr, which is correct.

  • Hi,

    You could try to do pristine build. If the same error appears, try removing build folder first and then do pristine build again.

    Best regards,
    Dejan

  • If I do pristine build from Vs code, I get the same error.
    If I delete the build directory and run the west command from terminal opened from the toolchain manager, then I get the original error I mentioned previously:

  •   

    Ok, looks like I was right.
    If instead of "#include <zephyr.h>" I write "#include<zephyr/zephyr.h>" then I get a different warning about this header file being deprecated and that I should use <zephyr/kernel.h> instead.

    This is happening because the build command, as I said in a previous response to you, is only including the zephyr directories up to .../include, which is the reason why all my headers work now if I prepend an extra "zephyr/" in my includes.

    However, I got a lot of includes, so my final question to you is:

    How can I add the directories up to .../include/zephyr so that I don't have prepend "zephyr/" in each of my includes? Is there a way to set this in VS Code?

Reply
  •   

    Ok, looks like I was right.
    If instead of "#include <zephyr.h>" I write "#include<zephyr/zephyr.h>" then I get a different warning about this header file being deprecated and that I should use <zephyr/kernel.h> instead.

    This is happening because the build command, as I said in a previous response to you, is only including the zephyr directories up to .../include, which is the reason why all my headers work now if I prepend an extra "zephyr/" in my includes.

    However, I got a lot of includes, so my final question to you is:

    How can I add the directories up to .../include/zephyr so that I don't have prepend "zephyr/" in each of my includes? Is there a way to set this in VS Code?

Children