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
  • For anyone ending up here with the same need for a way to setup the environment without using the toolchain manager to launch a shell, the toolchain manager itself provides a way to export the current environment as a script:

    ~/ncs-lcs/nrfutil toolchain-manager env --as-script

  • OMG, what a mission. Here's what worked for me on macOS, based on your excellent suggestion:

    1. I couldn't find nrfutil anywhere on my system despite much searching, so I downloaded it fresh from https://www.nordicsemi.com/Products/Development-tools/nrf-util
    2. It just comes as a binary, so then I put it on my path with:  sudo mv ~/Downloads/nrfutil /usr/local/bin/
    3. And made it executable: sudo chmod 755 /usr/local/bin/nrfutil
    4. And then worked around the developer signing issue by opening the folder in Finder with open /usr/local/bin , right-clicking the file, selecting "Open", and approving the unverified executable.
    5. I still couldn't run the command until I installed toolchain manager with nrfutil install toolchain-manager
    6. Finally, the command worked and the output looked good: nrfutil toolchain-manager env --as-script
    7. Then to tie it all together, I exported the contents to the file that gets picked up by zephyr-env.sh with nrfutil toolchain-manager env --as-script > ~/.zephyrrc
    8. Now "all" I need to do is open a terminal and run one command to get a build environment: source /opt/nordic/ncs/v2.3.0/zephyr/zephyr-env.sh

    Phew! I don't know why these basics are so hard...

Reply
  • OMG, what a mission. Here's what worked for me on macOS, based on your excellent suggestion:

    1. I couldn't find nrfutil anywhere on my system despite much searching, so I downloaded it fresh from https://www.nordicsemi.com/Products/Development-tools/nrf-util
    2. It just comes as a binary, so then I put it on my path with:  sudo mv ~/Downloads/nrfutil /usr/local/bin/
    3. And made it executable: sudo chmod 755 /usr/local/bin/nrfutil
    4. And then worked around the developer signing issue by opening the folder in Finder with open /usr/local/bin , right-clicking the file, selecting "Open", and approving the unverified executable.
    5. I still couldn't run the command until I installed toolchain manager with nrfutil install toolchain-manager
    6. Finally, the command worked and the output looked good: nrfutil toolchain-manager env --as-script
    7. Then to tie it all together, I exported the contents to the file that gets picked up by zephyr-env.sh with nrfutil toolchain-manager env --as-script > ~/.zephyrrc
    8. Now "all" I need to do is open a terminal and run one command to get a build environment: source /opt/nordic/ncs/v2.3.0/zephyr/zephyr-env.sh

    Phew! I don't know why these basics are so hard...

Children
No Data
Related