Adapted SPI NOR driver not accepted by configuration

Hello,

for my project I need a secondary image for McuBoot on an external flash drive, so I integrated the examples in the partitions.yml, the device tree and SPI NOR configuration. With the generic spi_nor driver it compiled fine. The SPI flash we need to use in our project because of the low power requirements is not entirely compatible with this, as the commands and write-protect handling is fairly different. So I adapted the spi_nor driver for my specific use and gave it a new id: 'renesas,at25pe80'. I added this in the device tree as well.

But now it does not build anymore, it does not get to the compiling stage even:

warning: SPI_NOR (defined at drivers/flash/Kconfig.nor:4) was assigned the value 'y' but got the
value 'n'. Check these unsatisfied dependencies: DT_HAS_JEDEC_SPI_NOR_ENABLED (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_SPI_NOR and/or look up SPI_NOR in the
menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
and Kconfig - Tips and Best Practices sections of the manual might be helpful too.


warning: SPI_NOR_FLASH_LAYOUT_PAGE_SIZE (defined at drivers/flash/Kconfig.nor:56) was assigned the
value '4096' but got the value ''. Check these unsatisfied dependencies: SPI_NOR (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE and/or look
up SPI_NOR_FLASH_LAYOUT_PAGE_SIZE in the menuconfig/guiconfig interface. The Application Development
Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual
might be helpful too.

The first error, that DT_HAS_JEDEC_SPI_NOR_ENABLED is set to no is the culprit, the error with SPI_NOR_FLASH_LAYOUT_PAGE_SIZE is just the result of the first error.

I have attached my driver and the DeviceTree and Config generated for the build. Maybe someone can find the error.

DT_HAS_JEDEC_SPI_NOR_ENABLED is not documented anywhere, so I cannot find help in official sources.

Thanks,

Rico

  • Hi Rico,

    You can see the dependencies for the SPI_NOR Kconfig option in CONFIG_SPI_NOR.
    SPI_NOR requires that your SPI NOR flash device is compatible with jedec,spi-nor, and you need to match the jedec,spi-nor binding to the node in devicetree using the compatible property:

    compatible = "jedec,spi-nor";

    Best regards,
    Marte

  • But then how can I ensure that the bootloader uses the correct driver? As I understand, when I use "jedec, spi-nor", the driver "spi_nor.c" is used, not my own one.

  • Hi,

    If you want to use a different driver that does not use jedec,spi-nor, then you cannot enable the Kconfig option CONFIG_SPI_NOR. You can create your own Kconfig option instead if you want to be able to enable and disable the driver, and enable certain things if the driver is enabled.

    Best regards,
    Marte

  • Thanks for the answer, it seems to remove the errors if I remove the SPI_NOR options.

    The next problem seems to be the following error:

    -- Found partition manager static configuration: C:/carl-ble-sensor-firmware/partition.yml
    CMake Error at C:/Users/sw2.KRAFFT/ncs/nrf/cmake/partition_manager.cmake:220 (math):
      math cannot parse the expression: " / 8": syntax error, unexpected
      exp_DIVIDE (2).
    Call Stack (most recent call first):
      C:/Users/sw2.KRAFFT/ncs/zephyr/cmake/modules/kernel.cmake:247 (include)
      C:/Users/sw2.KRAFFT/ncs/zephyr/cmake/modules/zephyr_default.cmake:124 (include)
      C:/Users/sw2.KRAFFT/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/Users/sw2.KRAFFT/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:20 (find_package)
    
    
    usage: partition_manager.py [-h] --sram_primary-size SRAM_PRIMARY_SIZE
                                [--sram_primary-base-address SRAM_PRIMARY_BASE_ADDRESS]
                                [--sram_primary-placement-strategy {start_to_end,end_to_start,complex}]
                                [--sram_primary-device SRAM_PRIMARY_DEVICE]
                                [--sram_primary-default-driver-kconfig SRAM_PRIMARY_DEFAULT_DRIVER_KCONFIG]
                                [--sram_primary-dynamic-partition SRAM_PRIMARY_DYNAMIC_PARTITION]
                                --flash_primary-size FLASH_PRIMARY_SIZE
                                [--flash_primary-base-address FLASH_PRIMARY_BASE_ADDRESS]
                                [--flash_primary-placement-strategy {start_to_end,end_to_start,complex}]
                                [--flash_primary-device FLASH_PRIMARY_DEVICE]
                                [--flash_primary-default-driver-kconfig FLASH_PRIMARY_DEFAULT_DRIVER_KCONFIG]
                                [--flash_primary-dynamic-partition FLASH_PRIMARY_DYNAMIC_PARTITION]
                                --external_flash-size EXTERNAL_FLASH_SIZE
                                [--external_flash-base-address EXTERNAL_FLASH_BASE_ADDRESS]
                                [--external_flash-placement-strategy {start_to_end,end_to_start,complex}]
                                [--external_flash-device EXTERNAL_FLASH_DEVICE]
                                [--external_flash-default-driver-kconfig EXTERNAL_FLASH_DEFAULT_DRIVER_KCONFIG]
                                [--external_flash-dynamic-partition EXTERNAL_FLASH_DYNAMIC_PARTITION]
    partition_manager.py: error: argument --external_flash-size: invalid <lambda> value: 'ERROR'
    CMake Error at C:/Users/sw2.KRAFFT/ncs/nrf/cmake/partition_manager.cmake:304 (message):
      Partition Manager failed, aborting.  Command:
      C:/Users/sw2.KRAFFT/ncs/toolchains/31f4403e35/opt/bin/python.exe;C:/Users/sw2.KRAFFT/ncs/nrf/scripts/partition_manager.py;--input-files;C:/carl-ble-sensor-firmware/build/mcuboot/zephyr/include/generated/pm.yml;C:/carl-ble-sensor-firmware/build/zephyr/include/generated/pm.yml;C:/carl-ble-sensor-firmware/build/modules/nrf/subsys/partition_manager/pm.yml.nvs;--regions;sram_primary;flash_primary;external_flash;--output-partitions;C:/carl-ble-sensor-firmware/build/partitions.yml;--output-regions;C:/carl-ble-sensor-firmware/build/regions.yml;--static-config;C:/carl-ble-sensor-firmware/partition.yml;--sram_primary-size;0x20000;--sram_primary-base-address;0x20000000;--sram_primary-placement-strategy;complex;--sram_primary-dynamic-partition;sram_primary;--flash_primary-size;0x80000;--flash_primary-base-address;0x0;--flash_primary-placement-strategy;complex;--flash_primary-device;flash_controller;--flash_primary-default-driver-kconfig;CONFIG_SOC_FLASH_NRF;--external_flash-size;ERROR;--external_flash-base-address;0;--external_flash-placement-strategy;start_to_end;--external_flash-device;DT_CHOSEN(nordic_pm_ext_flash);--external_flash-default-driver-kconfig;CONFIG_PM_EXTERNAL_FLASH_HAS_DRIVER

    It seems the partition manager script is getting passed 'error' as the value for external_flash-size. I've checked the size values in the device tree and in the partitions file and it seems okay.

    Why would the partition manager script be getting no size? I can't seem to pin down from where this size is gotten or which option might be missing.

  • Hi,

    Can you share your static partition file, carl-ble-sensor-firmware/partition.yml?

    Best regards,
    Marte

Related