This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiple targets with NCS

When building a product which has multiple models but the firmware is essentially the same, perhaps with a few different parameters, I want to use the same code base and have multiple build targets. Previously I’ve used CMake with nRF5 SDK and created multiple targets with the same source files except a few files which are model specific.

In NCS, it seems Zephyr creates the ‘app’ target which is a library, and that gets linked into the 'zephyr_final' target. I’m not sure the user is able to create multiple targets.

How would you suggest I should structure the project to accommodate for multiple ‘models’?

Parents
  • Hello, 

    Sorry, can you please elaborate more on what you are trying to achieve? Do you have an example? Unfortunately, I will not be able to start on this today, but will get back to you on Monday.

    Kind regards,
    Øyvind

  • For example, if you had two models of a product - one with 2 buttons and one with 4. All the other code is the same (which could be substantial), but one is configured with 2 buttons and the other with 4. So you might have a c file for each model with a few functions specific to each. In CMake usually you would create two targets and add the respective c file to each target. But I don’t think you can do this with NCS. It seems like you would need to create a separate project with its own CMakeLists.txt for each model, and include the shared source code from elsewhere.

    E.g.

    multi-model-project
    ├── main.c
    ├── model1
    │   ├── CMakeLists.txt
    │   └── customise.c
    └── model2
        ├── CMakeLists.txt
        └── customise.c

    Where CMakeLists.txt would add ../main.c and customise.c to the app target sources. Or is there a better way? Can you tell zephyr to use different target names for zephyr_final etc, and add another app target?

  • Hi, 

    Sorry for the late reply. First, I recommend looking at the Application Development chapter of the Zephyr documentation. This goes through many of the important features of the Zephyr build system, that is based on CMake

    Next, you could have a look at the Asset Tracker folder in NCS. Here we have the prj_thingy91_nrf9160ns.conf which will configure the project according to Thingy:91 when building with board thingy91_nrf9160ns. Then to configure different GPIO you should use an .overlay file similar to this one, nrf9160dk_nrf9160ns.overlay in the Serial LTE Modem application.

    You can also add your own board files, have a look at the Custom Board, Devicetree and SOC Definitions chapter. This will allow you to build your own board, e.g. multi_model, with default values for your board. Then use different .conf and .overlay to build different revisions of your board. See The Initial Configuration chapter under KConfig.

    Then have a look at the files found in nrf\boards\arm\thingy91_nrf9160 or zephyr\boards\arm\nrf9160dk_nrf9160, which are board files for the Thingy:91 and the nRF9160DK respectively. 

    If you do have more questions, specific for the Zephyr RTOS, you can also get more answer through the community support.

    Hope this helps you on your path. 

    Kind regards,
    Øyvind

Reply Children
No Data
Related