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?

Reply
  • 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?

Children
Related