Issue with flash partitions in NCS 1.7.0 on nRF9160

Hi,

I've been trying to modify the flash partitions in the nvs example provided in ncs 1.7.0, namely, I want to greatly increase the size of the storage partition so I can log data there. I had been working in ncs 1.499, and I used the method that most others ask about on this forum to change partition sizes, which is to add a pm_static.yml file in the project directory that overrides any board-defined partitions.

The issue is, when I add any pm_static.yml file in the nvs 1.7 example, it is not able to build. Also, I do not have a good starting point for formatting the pm_static.yml file because this sample does not generate partitions.yml or regions.yml files in the build directory on a successful build. It looks like in this log, the partition manager script is running, but it is creating errors when I try to create a static partition definition. Has the recommended way to create static partitions changed in ncs 1.7.0?

Building example_nvs
west build --build-dir c:\Users\jwhite\Desktop\L20\FW\1.7.0\example_nvs\build c:\Users\jwhite\Desktop\L20\FW\1.7.0\example_nvs

[0/1] Re-running CMake...
Including boilerplate (Zephyr base (cached)): C:/Users/jwhite/ncs/v1.7.0/zephyr/cmake/app/boilerplate.cmake
-- Application: C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs
-- Zephyr version: 2.6.99 (C:/Users/jwhite/ncs/v1.7.0/zephyr), build: v2.6.99-ncs1
-- Found west (found suitable version "0.11.1", minimum required is "0.7.1")
-- Board: nrf9160dk_nrf9160, Revision: 0.7.0
-- Cache files will be written to: C:/Users/jwhite/ncs/v1.7.0/zephyr/.cache
-- Found dtc: C:/Users/jwhite/ncs/v1.7.0/toolchain/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
-- Found toolchain: gnuarmemb (c:/Users/jwhite/ncs/v1.7.0/toolchain/opt)
-- Found BOARD.dts: C:/Users/jwhite/ncs/v1.7.0/zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160.dts
-- Generated zephyr.dts: C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs/build/zephyr/dts.cmake
Parsing C:/Users/jwhite/ncs/v1.7.0/zephyr/Kconfig
Loaded configuration 'C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs/build/zephyr/.config'
-- Configuring incomplete, errors occurred!
See also "C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/jwhite/Desktop/L20/FW/1.7.0/example_nvs/build/CMakeFiles/CMakeError.log".
FAILED: build.ninja 
C:\Users\jwhite\ncs\v1.7.0\toolchain\opt\bin\cmake.exe --regenerate-during-build -SC:\Users\jwhite\Desktop\L20\FW\1.7.0\example_nvs -BC:\Users\jwhite\Desktop\L20\FW\1.7.0\example_nvs\build

warning: ENTROPY_CC3XX (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\drivers\entropy\Kconfig:7) has direct dependencies (CRYPTOCELL_USABLE || SPM || BUILD_WITH_TFM) && ENTROPY_GENERATOR with value n, but is currently being y-selected by the following symbols:
 - SPM (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\subsys\spm\Kconfig:9), with value y, direct dependencies !BUILD_WITH_TFM (value: y), and select condition !BUILD_WITH_TFM (value: y)

warning: ARM_FIRMWARE_USES_SECURE_ENTRY_FUNCS (defined at C:\Users\jwhite\ncs\v1.7.0\zephyr\arch\arm\core\aarch32\cortex_m\tz\Kconfig:57) has direct dependencies ARM_NONSECURE_FIRMWARE && (ARM_SECURE_FIRMWARE || ARM_NONSECURE_FIRMWARE) && ARM_TRUSTZONE_M && CPU_CORTEX_M && ARM with value n, but is currently being y-selected by the following symbols:
 - SPM_SECURE_SERVICES (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\subsys\spm\Kconfig:82), with value y, direct dependencies IS_SPM || SPM (value: y), and select condition SPM && (IS_SPM || SPM) (value: y)

error: Aborting due to Kconfig warnings

CMake Error at C:\Users\jwhite\ncs\v1.7.0\zephyr\cmake\kconfig.cmake:268 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  C:\Users\jwhite\ncs\v1.7.0\zephyr\cmake\app\boilerplate.cmake:554 (include)
  C:\Users\jwhite\ncs\v1.7.0\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:24 (include)
  C:\Users\jwhite\ncs\v1.7.0\zephyr\share\zephyr-package\cmake\ZephyrConfig.cmake:40 (include_boilerplate)
  c:\Users\jwhite\Desktop\L20\FW\1.7.0\example_nvs\build\CMakeLists.txt:11 (find_package)


ninja: error: rebuilding 'build.ninja': subcommand failed
FATAL ERROR: command exited with status 1: 'c:\Users\jwhite\ncs\v1.7.0\toolchain\opt\bin\cmake.EXE' --build 'c:\Users\jwhite\Desktop\L20\FW\1.7.0\example_nvs\build'

Thanks,

Jacob

  • Hi,

     

    The project is failing before any PM is able to run properly:

    warning: ENTROPY_CC3XX (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\drivers\entropy\Kconfig:7) has direct dependencies (CRYPTOCELL_USABLE || SPM || BUILD_WITH_TFM) && ENTROPY_GENERATOR with value n, but is currently being y-selected by the following symbols:
     - SPM (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\subsys\spm\Kconfig:9), with value y, direct dependencies !BUILD_WITH_TFM (value: y), and select condition !BUILD_WITH_TFM (value: y)
    
    warning: ARM_FIRMWARE_USES_SECURE_ENTRY_FUNCS (defined at C:\Users\jwhite\ncs\v1.7.0\zephyr\arch\arm\core\aarch32\cortex_m\tz\Kconfig:57) has direct dependencies ARM_NONSECURE_FIRMWARE && (ARM_SECURE_FIRMWARE || ARM_NONSECURE_FIRMWARE) && ARM_TRUSTZONE_M && CPU_CORTEX_M && ARM with value n, but is currently being y-selected by the following symbols:
     - SPM_SECURE_SERVICES (defined at C:\Users\jwhite\ncs\v1.7.0\nrf\subsys\spm\Kconfig:82), with value y, direct dependencies IS_SPM || SPM (value: y), and select condition SPM && (IS_SPM || SPM) (value: y)

    It seems there's a conflict between BUILD_WITH_TFM and SPM here. Do you see this issue when building other samples as well?

     

    Kind regards,

    Håkon

  • Hi,

    Thanks for the response. I have built a few other standalone projects with NCS 1.7.0, and added a pm_static.yml, and their partitions.yml do generate as expected

    What I've done next is try to integrate the code from the nvs example into others, namely the cloud_client example. I've modified the prj.conf and cmakelists.txt files accordingly, and tried adding some flash initialization to main.c:

    static struct nvs_fs fs;
    
    #define STORAGE_NODE DT_NODE_BY_FIXED_PARTITION_LABEL(storage)
    #define FLASH_NODE DT_MTD_FROM_FIXED_PARTITION(STORAGE_NODE)
    
    
    void main(void)
    {
    	int err;
    	int rc = 0;
    	struct flash_pages_info info;
    	const struct device *flash_dev;
    
    	/* define the nvs file system by settings with:
    	 *	sector_size equal to the pagesize,
    	 *	3 sectors
    	 *	starting at FLASH_AREA_OFFSET(storage)
    	 */
    	flash_dev = DEVICE_DT_GET(FLASH_NODE);
    	if (!device_is_ready(flash_dev)) {
    		printk("Flash device %s is not ready\n", flash_dev->name);
    		return;
    	}
    
    	
    	fs.offset = FLASH_AREA_OFFSET(storage);
    	rc = flash_get_page_info_by_offs(flash_dev, fs.offset, &info);
    	if (rc) {
    		printk("Unable to get page info\n");
    		return;
    	}
    	fs.sector_size = info.size;
    	fs.sector_count = 3U;
    
    	rc = nvs_init(&fs, flash_dev->name);
    	if (rc) {
    		printk("Flash Init failed\n");
    		return;
    	}
    .......

    But now, I am getting the same error that was present in this post a few weeks ago:

    https://devzone.nordicsemi.com/f/nordic-q-a/78897/non-volatile-storage-nvs-sample-compile-issue-on-nrf-sdk-v1-6

    I have tried applying the change that is suggested by Øivind, but the error persists. It seems that buried in the DEVICE_DT_GET function, something is undefined.

    In file included from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\toolchain\gcc.h:66,
                     from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\toolchain.h:43,
                     from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\kernel_includes.h:19,
                     from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\kernel.h:17,
                     from C:\Users\jwhite\ncs\v1.7.0\zephyr\include\zephyr.h:18,
                     from c:\Users\jwhite\Desktop\L20\FW\1.7.0\cloud_l20\src\main.c:11:
    ../src/main.c: In function 'main':
    C:\Users\jwhite\ncs\v1.7.0\zephyr\include\device.h:80:39: error: '__device_dts_ord_DT_COMPAT_fixed_partitions_LABEL_settings_storage_PARENT_PARENT_ORD' undeclared (first use in this function)

  • Hi,

     

    Thank you for the detailed description. I managed to reproduce this locally and will follow up internally with this issue.

     

    As a workaround for now, could you try to revert to this "old" way of defining the flash device?

    https://github.com/nrfconnect/sdk-zephyr/commit/673b4b4394f4cd0c946419ac139abc17c6ec3feb#diff-45eb4432327c37ce8848981cdcf353afa36f5c46c0e09669d1034b3b991a10beL78

    ie, like this:

    flash_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller));

     

    Kind regards,

    Håkon

  •  

    Hi Jacob,

    Did you ever get this sorted?  I'm struggling with a similar issue, trying to increase the NVS available for logging data, and am not really making much progress.

    Would be interested to hear if you got it fixed, and what you did to get your solution

    Cheers,

    Mike

  • Hi Mike,

    I unfortunately left this question open because I was not able to fix this specific error, even using Håkon's answer.

    My goal with this was to upgrade my project's firmware from NCS version 1.5.0 to 1.7.0, and I ended up staying with 1.5.0 for now. Perhaps we can check with some of the Nordic folks to see if there is another way to do this in newer versions of NCS.

    Best regards,

    Jacob

Related