Issue with devicetree configuration, while using MCUBoot on v2.4.1 and external flash module

Dear All,

At the moment we have created a custom board device tree, based on the nRF9160 SOC.

At the moment we are using the v2.1.0 of the nRF SDK and everything works fine.  We need to upgrade to v2.4.1 that includes the nRF7002 chip.

During this transition we have encountered the following issue:

In the custom_board_nrf9160_common.dts we had the following node for the external flash:

&spi3 {
    compatible = "nordic,nrf-spim";
    status = "okay";
    cs-gpios = <&gpio0 21 GPIO_ACTIVE_LOW>, <&gpio0 31 GPIO_ACTIVE_LOW>;
    pinctrl-0 = <&spi3_default>;
    pinctrl-1 = <&spi3_sleep>;
    pinctrl-names = "default", "sleep";

    w25q16jv: w25q16jv@0 {
        compatible = "jedec,spi-nor";
        reg = <0>;
        spi-max-frequency = <1000000>;
        reset-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
        size = <0x1000000>;
        has-dpd;
        t-enter-dpd = <4000>;
        t-exit-dpd = <25000>;
        jedec-id = [ ef 40 15  ];
    };
    
    ...
};


When transitioning to the new version of the SDK, this node this issue:

[275/285] Linking C executable zephyr\zephyr_pre0.elf
FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map .../build/mcuboot/zephyr/zephyr_pre0.map

...

undefined reference to '__device_dts_ord_110'


Looking into the generated file build/zephyr/mcuboot/include/devicetree_generated.h I see this:




Based on this I decided to remove the external flash node from the custom_board_nrf9160_common.dts and add it to an overlay file for the non-secure part of my application

custom_board_nrf9160ns.overlay:

&spi3 {
    w25q16jv: w25q16jv@0 {
        compatible = "jedec,spi-nor";
        reg = <0>;
        spi-max-frequency = <1000000>;
        reset-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
        size = <0x1000000>;
        has-dpd;
        t-enter-dpd = <4000>;
        t-exit-dpd = <25000>;
        jedec-id = [ ef 40 15  ];
    };
};


After doing this, the code built fine.

So the question is why does the external flash is causing an issue to the device tree when it is added in the common dts, but works when it is put on the overlay file?

Parents Reply Children
  •   

    Based on your response and the error described in my ticket the solution for us was to remove the external flash definition from the nrf9160.dts (so the secure part) and also disable the SPI and SPI_NOR in the defconfig of our board.

  • Hi,

     

    If you remove SPI/External flash from the secure part, mcuboot will not see the SPI flash, and you're not able to access it for dual banking your image slot.

    Is this intended?

     

    You can verify this by looking at the build-folder/partitions.yml file to see if the mcuboot_secondary is located in internal or external flash.

     

    Kind regards,

    Håkon

  • The external flash is used for storing data related to the application and not for dual boot. Having said that it is strange that we need to add these configurations in v2.4.1 but they were not needed in v2.1.0. What exactly has changed between the 2 versions (I think that the change is there already in v2.2.0)?

  • Hi,

     

    Thank you for clarifying. I needed to ask in case it wasn't the desired behavior.

    Giannis Anastasopoulos said:
    Having said that it is strange that we need to add these configurations in v2.4.1 but they were not needed in v2.1.0. What exactly has changed between the 2 versions (I think that the change is there already in v2.2.0)?

    The change is highly likely due to the devicetree/kconfig integration work that has been in-progress between these versions. Enabling a peripheral in devicetree is mitigated through kconfig, selecting the peripheral/driver in kconfig.

    Here's an example by adding your overlay to the mcuboot child image overlay in NCS v2.5.0:

    $ grep -r CONFIG_SPI
    ...
    mcuboot/zephyr/.config:CONFIG_SPI=y
    mcuboot/zephyr/.config:CONFIG_SPI_NOR=y
    mcuboot/zephyr/.config:CONFIG_SPI_NOR_SFDP_MINIMAL=y
    ..

    versus the same added overlay in ncs v2.1.0:

    $ grep -r CONFIG_SPI
    ...
    mcuboot/zephyr/.config:# CONFIG_SPI is not set
    

     

    Kind regards,

    Håkon

  • The overlay solution became needed to transition from 2.1.0 to to 2.4.1. Before that, there was no need for the overlay. So, from what I understand something changed regarding enabling SPI in the non secure part of the application in the board files. Also note that my overlay is not meant for the child_image, but the main application. And this is because I had to remove the flash definition from the common.dts and then only apply it for the non secure part.

    In order to fix my project without adding the overlay I had to simply disable SPI for the secure device.

Related