How do I add another board and .conf file to an existing project?

I have been working with some code for a nrf5340 DK and now want to add a custom board to the project as an additional build configuration, but I need to now pull out configurations which are set in the prj.conf as they conflict. For example the dk uses a st7789 display and the custom board uses a gc9a01. In my prj.conf I have CONFIG_ST7789V=y which now should not be in the prj.conf but a specific conf for the configured DK.

I had the dk overlay in the root directory. Do I create another directory under boards for my specific configuration of the DK and create a .conf file for it? Will that make it get automatically picked up? Since it's a nrf5340 dk, should I name the directory something else as not to conflict with the existing structure? By naming the conf file the same as the overlay (just different extension, conf vs overlay) does that mean it will get picked up? 
By putting the overlay in a different directory and referencing it in the build, does zephry know to look for a corresponding conf file automatically? 

This might be simple, but I haven't found a good explanation of this specific process which a novice like me could consume.

I'm using vs code and nrf connect (2.6) and zephyr.

  • Hello,

    I am not sure if I understand you correctly, but you can create a project structure that includes different build configurations for each board. Something like below will be a project structure for two different boards:

    project_folder
        - board_1
            - inc
                - *.h files
            - src
                -*.c files (including main.c)
            - CMakeLists.txt
            - board_1.overlay
            - prj.conf
        - board_2
            - inc
                - *.h files
            - src
                -*.c files (including main.c)
            - CMakeLists.txt
            - board_2.overlay
            - prj.conf
        - CMakeLists.txt
        - KConfig
        - prj.conf

    In this structure, each board has its own directory with its own source files, header files, CMakeLists.txt, overlay file, and configuration file. The overlay file allows you to specify different settings for each build. You can specify which overlay file to use during the build configuration process using the -DDTS_OVERLAY_FILE argument. See the section on configuration files, which discusses selecting different configuration and overlay files. See the below devzone threads.

    https://devzone.nordicsemi.com/support-private/support/301462

    https://devzone.nordicsemi.com/support-private/support/305501

    Kind Regards,

    Abhijith

  • In the directory you only have one prj.conf. What if one board uses QSPI and the other uses SPI and I want to enable them. Don't I need two prj.conf files, one for each board?

    The SPI board needs this in the prj.conf file:

    CONFIG_SPI=y
    CONFIG_SPI_NOR=y

    and the QSPI board needs this:

    CONFIG_NORDIC_QSPI_NOR=y

    Both of these I would set in a prj.conf file if I had seperate projects for each board, but if I had the same project for both boards wouldn't I need 3 configuration files:

    • one for both boards (prj.conf) where the configurations are the same
    • one for the SPI flash board
    • one for the QSPI flash board

    Is this the way it works? How would I name them and where would I put them?

  • Hello,

    prj.conf can be used to enable the configurations necessary for both boards, and you can place board-specific configs inside the boards folder. For example, see the project structure below.

    my_project/
    │── boards/
    │   ├── spi_board.conf        
    │   ├── qspi_board.conf      
    │   ├── spi_board.overlay     
    │   ├── qspi_board.overlay    
    │── build/
    │   ├── spi_board/    
    │   ├── qspi_board/   
    │── src/
    │   ├── main.c
    │── CMakeLists.txt
    │── prj.conf  #(common config for both boards)
    
    

    Take a look at the Zigbee light bulb sample to see how different configurations are used for different DKs. Also, check the boards folder here.

    Kind Regards,

    Abhijith

Related