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

how to define 2 boards for the same application

hello Nordic 

i have a project than works with nrf52840 and ncs (zephyr) 

i want to have the same application running on nrf52832 as well, as part of a single code base strategy.

now i work with the nrf tool in for the vs code IDE,  

i added a board and i a build configuration for the second board, but i don't understand how can both boards work with the same CMakeLists.txt, pm_static.yaml and prj.conf, since they are the same for both boards in the same application 

obviously they require different partitioning since they don't have same memory size, that is just an example

any ideas on best practice for how to do that ?

 

hope to read from you soon

best regards

Ziv

  • Hi,

    I see this was answered in the Zephyr discord server.

  • i wrote this question in discord, the answer does not really describe the application should be structure which is what i am trying to understand 

    can you be more descriptive .. 

    1. does my application dir should contain 2 pm_statics - pm_static.bord1.yml and pm_static.board2.yml ?

    if so, where do i define to which pm_static to go to ?, or they should, along with a CMakeLists.txt be inside the board1, or board2 directories ?

    same goes for prj.conf, do i need to have board1.conf and board2.conf in each board directory ? 

    also, do i need to somehow re config the (green) files here:

    ?

  • 1. does my application dir should contain 2 pm_statics - pm_static.bord1.yml and pm_static.board2.yml ?

    Yes.

    same goes for prj.conf, do i need to have board1.conf and board2.conf in each board directory ? 

    You can have that if needed.

    See how it's done for the nrf_desktop application where APPLICATION_CONFIG_DIR is used.

    https://github.com/nrfconnect/sdk-nrf/blob/v1.9.1/applications/nrf_desktop/CMakeLists.txt#L19

    Also see this link: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html#configuring-static-partitions

  • does my application dir should contain 2 pm_statics - pm_static.bord1.yml and pm_static.board2.yml ?

    Yes.

    if i do that and i remove the pm_static.yml and replace it with pm_static_board1.yml and pm_static_board2.yml, then i get an error during build 

    here is part of the build log 

    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:34:22: error: 'PM_internal_flash_storage_ID' undeclared (first use in this function); did you mean 'PM_external_flash_ID'?
       34 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:39:30: note: in expansion of macro 'PM_ID'
       39 | #define FLASH_AREA_ID(label) PM_ID(label)
          |                              ^~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/augu_uut_stage_testing.c:21:23: note: in expansion of macro 'FLASH_AREA_ID'
       21 |     unsigned int id = FLASH_AREA_ID(internal_flash_storage);
          |                       ^~~~~~~~~~~~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:34:22: note: each undeclared identifier is reported only once for each function it appears in
       34 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:39:30: note: in expansion of macro 'PM_ID'
       39 | #define FLASH_AREA_ID(label) PM_ID(label)
          |                              ^~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/augu_uut_stage_testing.c:21:23: note: in expansion of macro 'FLASH_AREA_ID'
       21 |     unsigned int id = FLASH_AREA_ID(internal_flash_storage);
          |                       ^~~~~~~~~~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/augu_uut_stage_testing.c: In function 'augu_uut_stage_testing_increment_stage':
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:34:22: error: 'PM_internal_flash_storage_ID' undeclared (first use in this function); did you mean 'PM_external_flash_ID'?
       34 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:39:30: note: in expansion of macro 'PM_ID'
       39 | #define FLASH_AREA_ID(label) PM_ID(label)
          |                              ^~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/augu_uut_stage_testing.c:56:23: note: in expansion of macro 'FLASH_AREA_ID'
       56 |     unsigned int id = FLASH_AREA_ID(internal_flash_storage);
          |                       ^~~~~~~~~~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/augu_uut_stage_testing.c: In function 'augu_uut_stage_testing_clear':
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:34:22: error: 'PM_internal_flash_storage_ID' undeclared (first use in this function); did you mean 'PM_external_flash_ID'?
       34 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:39:30: note: in expansion of macro 'PM_ID'
       39 | #define FLASH_AREA_ID(label) PM_ID(label)
          |                              ^~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/augu_uut_stage_testing.c:80:23: note: in expansion of macro 'FLASH_AREA_ID'
       80 |     unsigned int id = FLASH_AREA_ID(internal_flash_storage);
          |                       ^~~~~~~~~~~~~
    [123/606] Building C object CMakeFiles/app.dir/src/samplingManager/flash_stream.c.obj
    FAILED: CMakeFiles/app.dir/src/samplingManager/flash_stream.c.obj 
    ccache /opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gcc -DARM_ALL_FAST_TABLES -DARM_ALL_FFT_TABLES -DARM_DSP_CONFIG_TABLES -DARM_FAST_ALLOW_TABLES -DARM_FFT_ALLOW_TABLES -DARM_TABLE_BITREVIDX_FLT64_1024 -DARM_TABLE_BITREVIDX_FLT64_128 -DARM_TABLE_BITREVIDX_FLT64_16 -DARM_TABLE_BITREVIDX_FLT64_2048 -DARM_TABLE_BITREVIDX_FLT64_256 -DARM_TABLE_BITREVIDX_FLT64_32 -DARM_TABLE_BITREVIDX_FLT64_4096 -DARM_TABLE_BITREVIDX_FLT64_512 -DARM_TABLE_BITREVIDX_FLT64_64 -DARM_TABLE_BITREVIDX_FLT_1024 -DARM_TABLE_BITREVIDX_FLT_128 -DARM_TABLE_BITREVIDX_FLT_16 -DARM_TABLE_BITREVIDX_FLT_2048 -DARM_TABLE_BITREVIDX_FLT_256 -DARM_TABLE_BITREVIDX_FLT_32 -DARM_TABLE_BITREVIDX_FLT_4096 -DARM_TABLE_BITREVIDX_FLT_512 -DARM_TABLE_BITREVIDX_FLT_64 -DARM_TABLE_BITREVIDX_FXT_1024 -DARM_TABLE_BITREVIDX_FXT_128 -DARM_TABLE_BITREVIDX_FXT_16 -DARM_TABLE_BITREVIDX_FXT_2048 -DARM_TABLE_BITREVIDX_FXT_256 -DARM_TABLE_BITREVIDX_FXT_32 -DARM_TABLE_BITREVIDX_FXT_4096 -DARM_TABLE_BITREVIDX_FXT_512 -DARM_TABLE_BITREVIDX_FXT_64 -DARM_TABLE_BITREV_1024 -DARM_TABLE_DCT4_F32_128 -DARM_TABLE_DCT4_F32_2048 -DARM_TABLE_DCT4_F32_512 -DARM_TABLE_DCT4_F32_8192 -DARM_TABLE_DCT4_Q15_128 -DARM_TABLE_DCT4_Q15_2048 -DARM_TABLE_DCT4_Q15_512 -DARM_TABLE_DCT4_Q15_8192 -DARM_TABLE_DCT4_Q31_128 -DARM_TABLE_DCT4_Q31_2048 -DARM_TABLE_DCT4_Q31_512 -DARM_TABLE_DCT4_Q31_8192 -DARM_TABLE_REALCOEF_F32 -DARM_TABLE_REALCOEF_Q15 -DARM_TABLE_REALCOEF_Q31 -DARM_TABLE_RECIP_Q15 -DARM_TABLE_RECIP_Q31 -DARM_TABLE_SIN_F32 -DARM_TABLE_SIN_Q15 -DARM_TABLE_SIN_Q31 -DARM_TABLE_TWIDDLECOEF_F32_1024 -DARM_TABLE_TWIDDLECOEF_F32_128 -DARM_TABLE_TWIDDLECOEF_F32_16 -DARM_TABLE_TWIDDLECOEF_F32_2048 -DARM_TABLE_TWIDDLECOEF_F32_256 -DARM_TABLE_TWIDDLECOEF_F32_32 -DARM_TABLE_TWIDDLECOEF_F32_4096 -DARM_TABLE_TWIDDLECOEF_F32_512 -DARM_TABLE_TWIDDLECOEF_F32_64 -DARM_TABLE_TWIDDLECOEF_F64_1024 -DARM_TABLE_TWIDDLECOEF_F64_128 -DARM_TABLE_TWIDDLECOEF_F64_16 -DARM_TABLE_TWIDDLECOEF_F64_2048 -DARM_TABLE_TWIDDLECOEF_F64_256 -DARM_TABLE_TWIDDLECOEF_F64_32 -DARM_TABLE_TWIDDLECOEF_F64_4096 -DARM_TABLE_TWIDDLECOEF_F64_512 -DARM_TABLE_TWIDDLECOEF_F64_64 -DARM_TABLE_TWIDDLECOEF_Q15_1024 -DARM_TABLE_TWIDDLECOEF_Q15_128 -DARM_TABLE_TWIDDLECOEF_Q15_16 -DARM_TABLE_TWIDDLECOEF_Q15_2048 -DARM_TABLE_TWIDDLECOEF_Q15_256 -DARM_TABLE_TWIDDLECOEF_Q15_32 -DARM_TABLE_TWIDDLECOEF_Q15_4096 -DARM_TABLE_TWIDDLECOEF_Q15_512 -DARM_TABLE_TWIDDLECOEF_Q15_64 -DARM_TABLE_TWIDDLECOEF_Q31_1024 -DARM_TABLE_TWIDDLECOEF_Q31_128 -DARM_TABLE_TWIDDLECOEF_Q31_16 -DARM_TABLE_TWIDDLECOEF_Q31_2048 -DARM_TABLE_TWIDDLECOEF_Q31_256 -DARM_TABLE_TWIDDLECOEF_Q31_32 -DARM_TABLE_TWIDDLECOEF_Q31_4096 -DARM_TABLE_TWIDDLECOEF_Q31_512 -DARM_TABLE_TWIDDLECOEF_Q31_64 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_1024 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_128 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_2048 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_256 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_32 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_4096 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_512 -DARM_TABLE_TWIDDLECOEF_RFFT_F32_64 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_1024 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_128 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_2048 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_256 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_32 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_4096 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_512 -DARM_TABLE_TWIDDLECOEF_RFFT_F64_64 -DBUILD_VERSION=v2.6.99-ncs1-1 -DKERNEL -DNRF52840_XXAA -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=2 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/zhershkovitch/workspace/ncs/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/augury_app/build_release/zephyr/include/generated -I/home/zhershkovitch/workspace/ncs/zephyr/soc/arm/nordic_nrf/nrf52 -I/home/zhershkovitch/workspace/ncs/zephyr/lib/libc/newlib/include -I/home/zhershkovitch/workspace/ncs/zephyr/subsys/settings/include -I/home/zhershkovitch/workspace/ncs/zephyr/subsys/bluetooth -I/home/zhershkovitch/workspace/ncs/zephyr/subsys/bluetooth/controller/ll_sw/nordic -I/home/zhershkovitch/workspace/ncs/nrf/include -I/home/zhershkovitch/workspace/ncs/modules/hal/cmsis/CMSIS/Core/Include -I/home/zhershkovitch/workspace/ncs/modules/hal/cmsis/CMSIS/DSP/Include -I/home/zhershkovitch/workspace/ncs/modules/hal/nordic/nrfx -I/home/zhershkovitch/workspace/ncs/modules/hal/nordic/nrfx/drivers/include -I/home/zhershkovitch/workspace/ncs/modules/hal/nordic/nrfx/mdk -I/home/zhershkovitch/workspace/ncs/zephyr/modules/hal_nordic/nrfx/. -I/home/zhershkovitch/workspace/ncs/modules/hal/st/sensor/stmemsc/iis3dwb_STdC/driver -I/home/zhershkovitch/workspace/ncs/modules/hal/st/sensor/stmemsc/lis3mdl_STdC/driver -I/home/zhershkovitch/workspace/ncs/modules/debug/segger/SEGGER -I/home/zhershkovitch/workspace/ncs/modules/debug/segger/Config -I/home/zhershkovitch/workspace/ncs/zephyr/modules/segger/. -I/home/zhershkovitch/workspace/ncs/modules/lib/tinycbor/zephyr/../include -I/home/zhershkovitch/workspace/ncs/modules/crypto/tinycrypt/lib/include -I/home/zhershkovitch/workspace/canary-ep/drivers/sensor/iis3dwb/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/sensor/ltc3335/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/sensor/augusi7210/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/sensor/augu_lis3mdl/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/flash/augu_flash_w25n/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/power/augu_gpio_power/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/utils/augu_gpio/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/utils/augu_spi/zephyr/include -I/home/zhershkovitch/workspace/canary-ep/drivers/utils/augu_queue/zephyr/include -I/home/zhershkovitch/workspace/ncs/nrfxlib/nfc/include -I/home/zhershkovitch/workspace/canary-ep/augury_app/src/utils -I/home/zhershkovitch/workspace/ncs/modules/fs/littlefs -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/cborattr/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/cmd/fs_mgmt/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/cmd/img_mgmt/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/cmd/os_mgmt/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/cmd/stat_mgmt/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/mgmt/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/mgmt/port/zephyr/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/smp/include -I/home/zhershkovitch/workspace/ncs/modules/lib/mcumgr/util/include -isystem /home/zhershkovitch/workspace/ncs/nrfxlib/crypto/nrf_cc310_platform/include -mfp16-format=alternative -Os -imacros /home/zhershkovitch/workspace/canary-ep/augury_app/build_release/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -imacros /home/zhershkovitch/workspace/ncs/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/home/zhershkovitch/workspace/canary-ep/augury_app=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/zhershkovitch/workspace/ncs/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/zhershkovitch/workspace/ncs=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT CMakeFiles/app.dir/src/samplingManager/flash_stream.c.obj -MF CMakeFiles/app.dir/src/samplingManager/flash_stream.c.obj.d -o CMakeFiles/app.dir/src/samplingManager/flash_stream.c.obj -c /home/zhershkovitch/workspace/canary-ep/augury_app/src/samplingManager/flash_stream.c
    In file included from /home/zhershkovitch/workspace/ncs/zephyr/include/storage/flash_map.h:260,
                     from /home/zhershkovitch/workspace/ncs/zephyr/include/fs/littlefs.h:12,
                     from /home/zhershkovitch/workspace/canary-ep/augury_app/src/samplingManager/flash_stream.c:9:
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/samplingManager/flash_stream.c: In function 'init_flash_stream':
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:34:22: error: 'PM_scratch_pad_ID' undeclared (first use in this function)
       34 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:39:30: note: in expansion of macro 'PM_ID'
       39 | #define FLASH_AREA_ID(label) PM_ID(label)
          |                              ^~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/samplingManager/flash_stream.c:139:23: note: in expansion of macro 'FLASH_AREA_ID'
      139 |     unsigned int id = FLASH_AREA_ID(scratch_pad);
          |                       ^~~~~~~~~~~~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:34:22: note: each undeclared identifier is reported only once for each function it appears in
       34 | #define PM_ID(label) PM_##label##_ID
          |                      ^~~
    /home/zhershkovitch/workspace/ncs/nrf/include/flash_map_pm.h:39:30: note: in expansion of macro 'PM_ID'
       39 | #define FLASH_AREA_ID(label) PM_ID(label)
          |                              ^~~~~
    /home/zhershkovitch/workspace/canary-ep/augury_app/src/samplingManager/flash_stream.c:139:23: note: in expansion of macro 'FLASH_AREA_ID'
      139 |     unsigned int id = FLASH_AREA_ID(scratch_pad);
          |                       ^~~~~~~~~~~~~
    [130/606] Linking C static library zephyr/libzephyr.a
    ninja: build stopped: subcommand failed.

    my pm_static_baord1.yml looks like this:

    mcuboot:
      address: 0x0
      size: 0xc000
    
    mcuboot_primary:
      address: 0xc000
      orig_span: &id001
      - mcuboot_pad
      - app
      sharers: 0x1
      size: 0x76000
      span: *id001
    
    mcuboot_secondary:
      address: 0x82000
      size: 0x76000
    
    internal_flash_storage:
      address: 0xF8000
      size: 0x8000  
    
    littlefs_storage:
      address: 0x0
      region: external_flash
      size: 0x75c0000
    
    scratch_pad:
      address: 0x75c0000
      region: external_flash
      size: 0x3c0000
    
    reserved:
      address: 0x7980000
      region: external_flash
      size: 0x100000
    
    replace_blocks:
      address: 0x7A80000
      region: external_flash
      size: 0x560000
    
    params:
      address: 0x7FE0000
      region: external_flash
      size: 0x20000

    any ideas what i am doing wrong ?

    one more thing, when i create another board_x.conf, then it is only reachable under application directory, if i put the .conf in each board directory the build does not find it why ?

    my CMakeLists.txt, looks like this with regards to boards and .conf files:

    set(BOARD_ROOT ${CMAKE_CURRENT_LIST_DIR}/../)
    if(DEFINED BOARD=halo_ep2)
        set(BOARD halo_ep2)
        if(NOT DEFINED OVERLAY_CONFIG)
            set(OVERLAY_CONFIG halo_ep2.conf)
        endif()    
    else()
        set(BOARD canary_proto_rev_4)
        if(NOT DEFINED OVERLAY_CONFIG)
            set(OVERLAY_CONFIG canary_proto_rev_4.conf)
        endif() 
    endif()

    hope to read from you soon

    best regards

    Ziv

  • ziv123 said:
    if i do that and i remove the pm_static.yml and replace it with pm_static_board1.yml and pm_static_board2.yml, then i get an error during build 

    You only renamed the file? The content is the same? If you don't set a pm_static file, how does the BUILD_DIR/partitions.yml file look like? Try taking that, and rename it to pm_static_baord1.yml and use that instead.

    ziv123 said:
    one more thing, when i create another board_x.conf, then it is only reachable under application directory, if i put the .conf in each board directory the build does not find it why ?

    Try doing a pristine build. How does the folder structure look like? You have a boards folder in the application directory with all the overlays and .configs? Or do you have a configuration/"board_name_x" directory ?

Related