west build freezes with specific config in prj.conf (CONFIG_NVS / CONFIG_SETTINGS_FCB)

Hello,

we are upgrading our application firmware to the v1.3.0 of nrf-sdk. We have now encountered a problem in which the build process just freezes/stops without exiting. NO ERROR IS REPORTED.

The build output:

 west build -p always -b nrf9160_pca10090ns                                                    (irnas) 
-- west build: generating a build system
Including boilerplate (Zephyr base): /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2
-- Zephyr version: 2.3.0-rc1 (/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr)
-- Found Python3: /home/comemaster/anaconda3/envs/irnas/bin/python3.7 (found suitable exact version "3.7.4") found components: Interpreter 
-- Board: nrf9160_pca10090ns
CMake Warning at /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/cmake/app/boilerplate.cmake:210 (message):
  Deprecated BOARD=nrf9160_pca10090ns name specified, board automatically
  changed to: nrf9160dk_nrf9160ns.
Call Stack (most recent call first):
  /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
  /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
  CMakeLists.txt:16 (find_package)


-- Found west: /home/comemaster/.local/bin/west (found suitable version "0.7.2", minimum required is "0.7.1")
-- Found dtc: /usr/bin/dtc (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/home/comemaster/gnuarmemb)
-- Found BOARD.dts: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160ns.dts
-- Generated zephyr.dts: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/zephyr/include/generated/devicetree_unfixed.h
Parsing /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/Kconfig
Loaded configuration '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160ns_defconfig'
Merged configuration '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/prj.conf'
Configuration saved to '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/zephyr/.config'
Kconfig header saved to '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /home/comemaster/gnuarmemb/bin/arm-none-eabi-gcc
-- Cache files will be written to: /home/comemaster/.cache/zephyr
Changed board to secure nrf9160dk_nrf9160 (NOT NS)

=== child image spm - nrf9160dk_nrf9160 begin ===
Including boilerplate (Zephyr base): /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/samples/nrf9160/spm
-- Zephyr version: 2.3.0-rc1 (/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr)
-- Found Python3: /home/comemaster/anaconda3/envs/irnas/bin/python3.7 (found suitable exact version "3.7.4") found components: Interpreter 
-- Board: nrf9160dk_nrf9160
-- Found west: /home/comemaster/.local/bin/west (found suitable version "0.7.2", minimum required is "0.7.1")
-- Found dtc: /usr/bin/dtc (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/home/comemaster/gnuarmemb)
-- Found BOARD.dts: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts
-- Found devicetree overlay: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/samples/nrf9160/spm/nrf9160dk_nrf9160.overlay
-- Generated zephyr.dts: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/spm/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/spm/zephyr/include/generated/devicetree_unfixed.h
Parsing /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/Kconfig
Loaded configuration '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_defconfig'
Merged configuration '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/spm.conf'
Configuration saved to '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/spm/zephyr/.config'
Kconfig header saved to '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/spm/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /home/comemaster/gnuarmemb/bin/arm-none-eabi-gcc
-- Cache files will be written to: /home/comemaster/.cache/zephyr
-- Configuring done
-- Generating done
-- Build files have been written to: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/spm
=== child image spm - nrf9160dk_nrf9160 end ===

Changed board to secure nrf9160dk_nrf9160 (NOT NS)

=== child image mcuboot - nrf9160dk_nrf9160 begin ===
Including boilerplate (Zephyr base): /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/cmake/app/boilerplate.cmake
-- Application: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/bootloader/mcuboot/boot/zephyr
-- Zephyr version: 2.3.0-rc1 (/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr)
-- Found Python3: /home/comemaster/anaconda3/envs/irnas/bin/python3.7 (found suitable exact version "3.7.4") found components: Interpreter 
-- Board: nrf9160dk_nrf9160
-- Found west: /home/comemaster/.local/bin/west (found suitable version "0.7.2", minimum required is "0.7.1")
-- Found dtc: /usr/bin/dtc (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (/home/comemaster/gnuarmemb)
-- Found BOARD.dts: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts
-- Found devicetree overlay: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/bootloader/mcuboot/boot/zephyr/dts.overlay
-- Generated zephyr.dts: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/mcuboot/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/mcuboot/zephyr/include/generated/devicetree_unfixed.h
Parsing /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/bootloader/mcuboot/boot/zephyr/Kconfig
Loaded configuration '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_defconfig'
Merged configuration '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/bootloader/mcuboot/boot/zephyr/prj.conf'
Configuration saved to '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/mcuboot/zephyr/.config'
Kconfig header saved to '/home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/mcuboot/zephyr/include/generated/autoconf.h'
-- The C compiler identification is GNU 7.3.1
-- The CXX compiler identification is GNU 7.3.1
-- The ASM compiler identification is GNU
-- Found assembler: /home/comemaster/gnuarmemb/bin/arm-none-eabi-gcc
-- Cache files will be written to: /home/comemaster/.cache/zephyr
-- Configuring done
-- Generating done
-- Build files have been written to: /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/nrf/applications/asset_tracker2/build/mcuboot
=== child image mcuboot - nrf9160dk_nrf9160 end ===

CMake Warning at /home/comemaster/Synology-Drive/IRNAS-Users/tjaz/Nordic/sdk-1.3.0-env/zephyr/CMakeLists.txt:1384 (message):
  __ASSERT() statements are globally ENABLED


Changed board to secure nrf9160dk_nrf9160 (NOT NS)

at this point the build freezes and i have to ctrl-c to cancel it.

I spent a long time investigating the cause and found it in prf.conf. The following lines are the cause:

# Flash
CONFIG_FLASH=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_FCB=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_FCB=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

CONFIG_NVS=y

This can be easily reproduced by taking, for example, the asset_tracker application that is shipped with nrf-sdk v1.3.0 and adding those lines to prj.conf.
Commenting out either CONFIG_NVS=y or CONFIG_SETTINGS_FCB=y the build process continues and finishes.

These settings were originally taken from bifravst ( https://github.com/bifravst/firmware ) and we added CONFIG_NVS to be able to store specific application configurations.

Using nrf-sdk v1.1.0, which we used previously, this config was ok, and now it is not anymore (with sdk v1.3.0) - it is unfortunate that the build freezes instead of printing some error message.

To me it seems that FCB and NVS setting are in conflict with each other, but the documentation
http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/CONFIG_FCB.html?highlight=config_fcb#cmdoption-arg-config-fcb
http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/CONFIG_SETTINGS.html?highlight=config_settings#cmdoption-arg-config-settings
http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/CONFIG_SETTINGS_NVS.html?highlight=config_settings#cmdoption-arg-config-settings-nvs
http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/CONFIG_NVS.html?highlight=config_nvs#cmdoption-arg-config-nvs

does not really explain what these setting/libraries are for.
We probably don't even need to enable some of these config options, but I am unable to determine which by just reading the docs, I would have to try changing each one and seeing if the app still works.

Do you have any suggestions on how to improve our process? For now I will continue porting to the new version and at the end verify which settings are even needed in our app. It would be nice if maybe the build process would verify that a selected setting/library is even in use.

Regards,
Tjaž Vračko

Related