This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

entering command-line environment

Hi,

I've installed the nRF Connect SDK, and want to bring up a command-line build environment.

I'm able to do it as it says in the instructions here: Bring up the Toolchain Manager and use the "Open Bash" option from the drop-down menu.

However, I'd like to be able to get into the environment without bringing up the Toolchain Manager. What do I do? What script do I run from git-bash?

I tried running zephyr/zephyr-env.sh, but apparently that's not enough.

Thanks!

  • Hi,

    Running zephyr-env.sh does not set ZEPHYR_TOOLCHAIN_VARIANT and GNUARMEMB_TOOLCHAIN_PATH. You need to run env.cmd located in toolchain/cmd from the command line you are going to use.

    Alternatively, you can set ZEPHYR_TOOLCHAIN_VARIANT and GNUARMEMB_TOOLCHAIN_PATH in your system environment variables as you would do if you installed nRF Connect SDK manually instead of with the Toolchain Manager. In that case you need to set the following:

    ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    GNUARMEMB_TOOLCHAIN_PATH=c:\ncs\v1.9.1\toolchain\opt

    Make sure that the path you set GNUARMEMB_TOOLCHAIN_PATH to is the path to your nRF Connect SDK installation and where your toolchain folder is.

    Best regards,

    Marte

  • Hi,

    Thanks for the response.

    I brought up Windows PowerShell, navigated to my SDK dir (ncs\v1.9.1), then down to toolchain\cmd, and executed env.cmd.
    Then I tried running west, and it wasn't a recognized command.

    Similarly, I brought up Git Bash, navigated to my SDK dir (ncs\v1.9.1), and did the following:

    • source zephyr/zephyr-env.sh
    • export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    • export GNUARMEMB_TOOLCHAIN_PATH=`pwd`/toolchain/opt

    Then I tried running west, and it wasn't a recognized command.

    What am I missing?

    Thanks!

  • Hi,

    Try to adding the path to toolchain/opt/bin and toolchain/opt/bin/Scripts to your system path.

    Best regards,

    Marte

  • Hi,

    I think we're getting closer.

    Some good news: I tried it out on Windows command prompt (not Power Shell), and found that after just running env.cmd, I could run west and build an example with it!

    As for Git Bash:

    To the steps I described before, I added:

    export PATH=$PATH:`pwd`/toolchain/opt/bin:`pwd`/toolchain/opt/bin/Scripts

    Now if I execute "which west", I get (correctly):

    /c/Users/yaron.shragai/ncs/v1.9.1/toolchain/opt/bin/Scripts/west

    But if I try to run west, regardless of options, it just returns without doing anything and with no screen output.

    By the way: It looks like the Git Bash environment spawned by the Toolchain Manager sets the root dir (the "/" dir) to the SDK's directory. In my setup, the root dir is still Git Bash's default root dir (which is C:\Program Files\Git). I tried to search the web for how to change Git Bash's root dir, but came up empty; but that is clearly something that the Toolchain Manager does when it spawns a Bash shell - so if you can tell me how to do that, it just might resolve this.

    And as for Windows Power Shell:

    After executing env.cmd, I navigated to the toolchain\opt\bin dir and executed:

    $env:path += ";" + $pwd

    Then I navigated down to Scripts and did the same.

    I verified that $env:path now includes those dirs.

    When I executed west, I got:

    Traceback (most recent call last):
    File "C:\Users\yaron.shragai\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
    File "C:\Users\yaron.shragai\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
    File "C:\Users\yaron.shragai\ncs\v1.9.1\toolchain\opt\bin\Scripts\west.exe\__main__.py", line 4, in <module>
    ModuleNotFoundError: No module named 'west'

    So, it seems like west.exe is trying to set off some Python code which is not working.

  • Hi,

    When you open bash or command prompt using the buttons in the Toolchain Manager you are actually just running the files git-bash.exe or git-cmd.cmd located in the toolchain folder. What these do is to set up the environment correctly before running bash and command prompt. You can see that by opening git-cmd.cmd and cmd/env.cmd in a text editor. So the issue is not the root dir, but that the environment variables are not correctly set. If you do not run env.cmd you need to make sure that all environment variables set by that file is set in your path instead.

    As for Windows Power Shell it seems like it is using the incorrect Python path. I should have mentioned in my last reply that you will also need to add the correct Python path to your environment variables. You can also find this in env.cmd.

    Best regards,

    Marte

Related