Setting Extra CMake Arguments only applies to initial build

When I apply an Extra CMake build argument when creating a build configuration, it only takes effect on the first build, but none after that.

For example, I have added this code to my CMakeLists.txt file:

# Set JLINK_FLASH_BUILD to TRUE in order to build an image that will boot
# from the initial flash (this will automatically confirm the applications in
# the merged.hex file)
#
# When building images for DFU updates, this should be set to FALSE
set(JLINK_FLASH_BUILD FALSE CACHE INTERNAL "Automatically confirm application for initial flash images")
if(JLINK_FLASH_BUILD)
  list(APPEND IMGTOOL_ARGS "--confirm")
endif(JLINK_FLASH_BUILD)

If I define JLINK_FLASH_BUILD in the Extra CMake Arguments part of the "Create Build Configuration", I can see that the image is built with the --confirm flag as expected. However, in an MCUboot based image with two partitions, the secondary image is NOT confirmed. The build log shows that the --confirm option is not set for the secondary image.

In addition, if I run a build from the command line, the same issue shows up. The secondary image is NOT confirmed, when it is expected to be so.

The overall issue is that in VS code, if I re-run a build where I expect the primary boot image to be confirmed with the --confirm flag, even the primary image is not confirmed.

This is easily reproduced by simply adding the above code to your CMakeLists.txt file, creating a build configuration and adding the extra CMake argument of "-DJLINK_FLASH_BUI
LD=TRUE". The initial image generated will be confirmed and boot properly. Subsequent builds of the same configuration will not be bootable.

This is using NCS v2.5.1.

Parents
  • Hi jrhaws,

    The nRF Connect Extension for VS Code issue with using build configuration, extra CMake arguments, and multi-image build is unfortunately a known issue that our team hasn't been able to resolve due to some complications in the build system.

    Our apologies for the inconvenience.

    In addition, if I run a build from the command line, the same issue shows up. The secondary image is NOT confirmed, when it is expected to be so.

    Regarding this point, however. Is this from the first time building with the command line? Or from the second time? Could you please give me some detailed steps to reproduce this observation?

    Hieu

  • Hello  ,
    but, is another way to give compiler flag for a specific build exists?

    For example, we need to have two build configurations for single application, 
    with second configuration CMake compiler flag added 

    -DCMAKE_C_FLAGS="-DUSE_PIPE2"

    The flag works well for the initial build, but lost when I open "edit build configuration" or  run pristine build.

    Is it true impossible to use conditional compilation specific to selected build, with nRF Connect extension?

  • Hi Sergii_K,

    The issue where additional flags are lost after editing build configuration is a known limitation of nRF Connect for VS Code. It is being worked on.

    I don't remember issue with pristine build though, but it is likely related.

    My apologies for the inconvenience.

    Hieu

Reply Children
No Data
Related