nRF Connect: How to build from command line after doing automatic install

I followed the instructions to install the nRF Connect SDK using the automatic method:

http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html

That worked and I was able to build sample applications and run them on the DK. Now I would also like the ability to build from the command line. The instructions say you need to start a new shell from the toolchain manager. This also works. However I cannot build from the shell if I start the shell without using the toolchain manager. How can I do that?

It seems my build problems are fixed if I set the environment variable ZEPHYR_SDK_INSTALL_DIR. I noticed this variable is set when I start my shell from the Toolchain Manager but it is not set when I launch a shell normally. 

ZEPHYR_SDK_INSTALL_DIR=/opt/nordic/ncs/toolchains/v2.1.0/opt/zephyr-sdk

So.. If I start a regular shell (without using toolchain manager) and set this variable the builds are working. Is this a valid way to use the SDK? 

Parents
  • Let me add some background here. When I started using nRF Connect I chose the automatic installation method. This seems like the best choice to get started quickly. Then I enrolled in the nRF Connect SDK Fundamentals course. So far so good. But now I started using some of the sample projects and they all seem to use the command line to build & flash. This works fine if you open the terminal from the toolchain manager. What is not clear to me is how to switch between command line and VS Code on the same project. For example, some of the example projects use kconfig overlay files which are listed on the build commands. If I switch over to VS Code I guess I need to edit the application setup and add the kconfig file there? This behavior is new to me. I'm used to running 'make' from the command line with no options because all the details are stored in the makefiles. Then your IDE can just run the same make command. 

    In short, I was hoping to learn how to use VS Code and the command line on the same project. In the short term I want to make this work for the sample projects but later I need to get the same behavior working with my own project.

  • Hello,

    The thing that happens when you start the shell from toolchain manager is that it sets up the environmental variables for a given SDK version.

    You can add those variables by yourself if desired in your ~/.bashrc file for example.

    VS Code runs the same west commands under the hood as you would in the terminal. There should be no need to do things differently.

    When you build in VS Code you should be able to see the exact command used to build the application in the compiler output.

    Best regards,

    Michal

  • I compared the env vars between a regular shell and the ‘ncs’ shell and manually copied over the changes to my shell. Seems crude but so far it seems to work. As for vs code, I did figure out how to build the app using vs code, but the trick was manually configuring the extra kconfig files required by the app. You can close this out. 

  • Hello,

    Thank you for the information, I will close it then.

    Best regards,

    Michal

Reply Children
Related