west build is invalid choice

Hi,

I have installed the nRF Connect SDK v2.0.0 with Visual Studio and can now successfully, build, flash and run the nrf9160 at_client sample application. But when I try to build it from the command line west says that 'build' is an invalid choice. When building from the command line, I select "Open Terminal" from the nRF Connect SDK line in the toolchain manager. Then when I try to build, I get this:

at_client [master●] % west build -b nrf9160dk_nrf9160_ns
usage: west [-h] [-z ZEPHYR_BASE] [-v] [-V] <command> ...
west: error: argument <command>: invalid choice: 'build' (choose from 'init', 'update', 'list', 'manifest', 'diff', 'status', 'forall', 'help', 'config', 'topdir', 'selfupdate')
Any ideas why this is happening?
Thanks
Greg
Parents
  • Thanks Ted. What I have done is copy one of Nordic's sample apps (at_client) to a new directory and I ran west from that directory when it failed. Your post made me try one more thing. I went back to the original sample app and ran 'west build' from that directory and it works. So now I just have to figure out what west is missing when I copied the sample app to a new location.

    To sum up, if I build the sample app from it's original location, which on my computer is:

    /opt/nordic/ncs/v2.0.0/nrf/samples/nrf9160/at_client

    Then west is happy and it builds. If I try to build my copy of at_client at:

    ~/git/nordic/at_client

    Then west says build is an invalid choice. I can however build it from VS Code.

    I guess I need to go learn more about west and Zephyr...

  • Hi Greg,

    That's more clear to me now when you describe "I copied one of Nordic's sample apps to a new directory and I ran west from [there]...".  I think what is missing is that Nordic Semi's Zephyr based sample apps are part of a larger 'west workspace'.  To copy a single app to another location without performing a `west init` on that new location will leave the `west` utility with only its core commands, not the extra ones which are provided by either Zephyr or Nordic.

    You can do what you want to do, but from what I gather you are trying to make a stand alone application out of an existing sample app from one of Nordic's ncs releases.  Is your goal to work with a given sample app, and be able to copy or clone that to new locations on demand?

    A few months ago I found myself needing to do this.  There are a couple steps involved, but the work is not too harrowing.  When I wanted to extend and experiment with Nordic Semi's aws_iot sample app, and be able to check that into a git repo of my choosing, I needed to complete four key steps:

    (1)  copy the sample app to a new dedicated location

    (2)  create a west manifest file along side the sample app's src directory

    (3)  invoke `west init -l custom_app` in the parent directory of my project dir named custom_app

    (4)  cd into 'custom_app' and invoke `west update`

    To create the west manifest file, a file which is by convention named 'west.yml' took me the longest time to figure out of any of these steps.  It is possible I have forgotten some details, but these steps are in the ballpark of what's needed to move from building within Nordic Semi's super big west based project, to building our own apps based on Nordic and Zephyr source trees.

    The critical benefit I needed from this effort is the ability to version control my coding work.  In the sample apps which came with my initial `git clone` of Nordic ncs, I can update all I want, but I cannot git control any of my changes.  Git is already pointed to Nordic's repositories on github.  That is the way I want it, but I need to be able to leverage their open source code in my own work, and track my changes in git repositories where I have read and write access.

    As an aside, here is what my west.yml west manifest file looks like:

    manifest:
      remotes:
        - name: nrfconnect
          url-base: https://github.com/nrfconnect
      projects:
        - name: nrf 
          repo-path: sdk-nrf
          remote: nrfconnect
          revision: v1.6.1
          import: true 
    ## 2021-10-28 - contributor Ted removing Kionix out-of-Zephyr-tree driver dependency:
    ##    # Drivers repository
    ##    - name: zephyr-driver-work-v2
    ##      path: kionix-drivers
    ##      revision: sensor-configuration-routines-work-001
    ##      url: [email protected]:tedhavelka/zephyr-driver-work-v2
      self:
        # This repository should be cloned to 
        path: aws-iot-stand-alone
    

    Lines which begin with # are commented out.

    Basically this is the simplest of west manifest files.  All it says to `west` when I invoke `west update` is for this utility to go and either download or update Nordic's nrf repository, at its 1.6.1 release.  You can find other more complex examples of west manifest files in ncs 1.6.1 itself -- it has a lot of third party code projects comprising it -- and also in Zephyr RTOS source tree.

    I think you're pretty close to copying and building your desired sample app in a path of your choosing.  But you will need to `west` initialize that path location, and then `west update` to download the needed third party repos.

    Hope this helps, Greg.  Stay safe,

    - Ted

Reply
  • Hi Greg,

    That's more clear to me now when you describe "I copied one of Nordic's sample apps to a new directory and I ran west from [there]...".  I think what is missing is that Nordic Semi's Zephyr based sample apps are part of a larger 'west workspace'.  To copy a single app to another location without performing a `west init` on that new location will leave the `west` utility with only its core commands, not the extra ones which are provided by either Zephyr or Nordic.

    You can do what you want to do, but from what I gather you are trying to make a stand alone application out of an existing sample app from one of Nordic's ncs releases.  Is your goal to work with a given sample app, and be able to copy or clone that to new locations on demand?

    A few months ago I found myself needing to do this.  There are a couple steps involved, but the work is not too harrowing.  When I wanted to extend and experiment with Nordic Semi's aws_iot sample app, and be able to check that into a git repo of my choosing, I needed to complete four key steps:

    (1)  copy the sample app to a new dedicated location

    (2)  create a west manifest file along side the sample app's src directory

    (3)  invoke `west init -l custom_app` in the parent directory of my project dir named custom_app

    (4)  cd into 'custom_app' and invoke `west update`

    To create the west manifest file, a file which is by convention named 'west.yml' took me the longest time to figure out of any of these steps.  It is possible I have forgotten some details, but these steps are in the ballpark of what's needed to move from building within Nordic Semi's super big west based project, to building our own apps based on Nordic and Zephyr source trees.

    The critical benefit I needed from this effort is the ability to version control my coding work.  In the sample apps which came with my initial `git clone` of Nordic ncs, I can update all I want, but I cannot git control any of my changes.  Git is already pointed to Nordic's repositories on github.  That is the way I want it, but I need to be able to leverage their open source code in my own work, and track my changes in git repositories where I have read and write access.

    As an aside, here is what my west.yml west manifest file looks like:

    manifest:
      remotes:
        - name: nrfconnect
          url-base: https://github.com/nrfconnect
      projects:
        - name: nrf 
          repo-path: sdk-nrf
          remote: nrfconnect
          revision: v1.6.1
          import: true 
    ## 2021-10-28 - contributor Ted removing Kionix out-of-Zephyr-tree driver dependency:
    ##    # Drivers repository
    ##    - name: zephyr-driver-work-v2
    ##      path: kionix-drivers
    ##      revision: sensor-configuration-routines-work-001
    ##      url: [email protected]:tedhavelka/zephyr-driver-work-v2
      self:
        # This repository should be cloned to 
        path: aws-iot-stand-alone
    

    Lines which begin with # are commented out.

    Basically this is the simplest of west manifest files.  All it says to `west` when I invoke `west update` is for this utility to go and either download or update Nordic's nrf repository, at its 1.6.1 release.  You can find other more complex examples of west manifest files in ncs 1.6.1 itself -- it has a lot of third party code projects comprising it -- and also in Zephyr RTOS source tree.

    I think you're pretty close to copying and building your desired sample app in a path of your choosing.  But you will need to `west` initialize that path location, and then `west update` to download the needed third party repos.

    Hope this helps, Greg.  Stay safe,

    - Ted

Children
No Data
Related