nRF52840DK Matter samples assume 8MB external flash. How to configure for 2MB external flash instead?

Hello,

We are developing a product using the nRF52840 and have most of our h/w turned on except we haven’t activated the external flash yet. We have been successful at interacting with the internal flash. We have that working. We are using the library calls flash_erase(), flash_write() and flash_read() for that (#include <zephyr/drivers/flash.h>).

Initially we would like (if possible) to use that same library interface for interacting with the external flash? One issue is that the external flash component we are using is not the same size as the one on the nRF52840DK board, and we’re having trouble learning what changes will be needed for our prj.conf and/or *.overlay files. The part we are using is the  MX25R1635FZUIH0 (2Mx8). I glanced around the Nordic doc sites but so far no luck (e.g. infocenter.nordicsemi.com/…).

It seems the various Nordic matter samples assume an external flash part of mx25r64 which I believe is the 8MB version of the 2MB version we have loaded. Any ideas on how we can get configured for the MX25R16? And if we can use the zephyr/drivers/flash.h interface for interacting with it?

Thank you in advance!
Steve K.
PuzL Labs, LLC

  • Hi Steve

    It should only really be the .overlay file that needs changing to set up your external flash correctly. In the nRF52840dk_nrf52840.dts file you can see we have set up the QSPI to use the MX25 as an external flash by default, but this can be overwritten with something similar for your flash in an .overlay file.

    The size is changed by setting the size parameter equal to 2MB in bits (16 777 216 if I'm not mistaken). I have not checked if there are any other big differences between the R16 and R64, but you might need to change the JEDEC ID and sfdp-bfp as well.

    If you are to use it as an external flash over QSPI I'd strongly recommend using the nrfx_qspi driver instead of the zephyr flash driver, but I think the zephyr flash driver should be possible to use if you set up a separate partition for the external flash with a separate start address, etc.

    &qspi {
    	status = "okay";
    	pinctrl-0 = <&qspi_default>;
    	pinctrl-1 = <&qspi_sleep>;
    	pinctrl-names = "default", "sleep";
    	mx25r64: mx25r6435f@0 {
    		compatible = "nordic,qspi-nor";
    		reg = <0>;
    		/* MX25R64 supports only pp and pp4io */
    		writeoc = "pp4io";
    		/* MX25R64 supports all readoc options */
    		readoc = "read4io";
    		sck-frequency = <8000000>;
    		jedec-id = [c2 28 17];
    		sfdp-bfp = [
    			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
    			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
    			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
    			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
    		];
    		size = <67108864>;
    		has-dpd;
    		t-enter-dpd = <10000>;
    		t-exit-dpd = <35000>;
    	};
    };

    Best regards,

    Simon

  • Hi Simon,

    Thank you for the reply. The way I interpret your response is that we might only have to change the line indicating size. If the two parts are similar then maybe all the rest can stay the same but maybe you aren’t sure if the JEDEC ID and sfdp-bfp settings are different between the two components. If so, I'm hearing those would entail adjustments to two more lines of the DeviceTree block (makes sense) that we would copy-and-paste to our local *.overlay file to override the default block located in the SDK at the path (Mac Install):

    /opt/nordic/ncs/v2.5.0/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts

    In that file is the following DeviceTree default block that you referenced. Thank you. We would cut-and-paste and adjust as we place this in our local *.overlay:

    &qspi {
        status = "okay";
        pinctrl-0 = <&qspi_default>;
        pinctrl-1 = <&qspi_sleep>;
        pinctrl-names = "default", "sleep";
        mx25r64: mx25r6435f@0 {
            compatible = "nordic,qspi-nor";
            reg = <0>;
            /* MX25R64 supports only pp and pp4io */
            writeoc = "pp4io";
            /* MX25R64 supports all readoc options */
            readoc = "read4io";
            sck-frequency = <8000000>;
            jedec-id = [c2 28 17];
            sfdp-bfp = [
                e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
                ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
                10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
                30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
            ];
            size = <67108864>;
            has-dpd;
            t-enter-dpd = <10000>;
            t-exit-dpd = <35000>;
        };
    };

    Also, can I ask. Should we also add the following lines also to our *.overlay? I notice that the Matter examples have this in their local *.overlays. Maybe we could even just leave it as “mx25r64” (assuming the pertinent DeviceTree block adjustments just mentioned). Since the “mx25r16” designator might not be natively recognized by the build system. Yes/No? Do we need this too in our *.overlay file?

    / {
        chosen {
            nordic,pm-ext-flash = &mx25r64;
        };
    };

    Thanks!
    Steve K.
    PuzL Labs, LLC

  • Hi Steve

    Correct, you need to change size, and possibly JEDEC ID and/or sfdp-bfp. Yes you can add this to an overlay on your end. What these should be is specified in the product datasheet.

    Yes, you can also add the pm-ext-flash to your overlay, but I think you should name it mx25r16 to avoid confusion (just common developer sense).

    Best regards,

    Simon

  • Simon,

    I am a colleague of Steve Kranz.  We have made the changes that you suggested.  However, we have a problem with the last line of following code:

    &qspi {
            status = "okay";
            pinctrl-0 = <&qspi_default>;
            pinctrl-1 = <&qspi_sleep>;
            pinctrl-names = "default", "sleep";
            mx25r16: mx25r6435f@0 {

    If we change the mx25r6435f@0 to mx25r1635f@0, we get a compile error.  When I searched through the SDK, I found a definition of the mx25r6435f in the file:

    /opt/nordic/ncs/v2.5.0/zephyr/dts/bindings/flash_controller/st,stm32-qspi-nor.yaml

    I suppose that the question is whether we can continue to use the mx2566435f reference.  I believe that the settings in the yaml file are correct for the mx25r1635f part, except for the size.  I would suspect that when we setup the "qspi" data structure, that size value we set in this declaration will override the default size defined in the yaml file.

    On the other hand, do we need to create a new yaml file to define the mx25r1635f part?

    Thanks,

    Gene

  • Hi Gene

    Yes, using an external flash this similar with the same yaml file should not be a problem as long as you declare the correct size. You could also create a new yaml file altogether, and this would be the recommended way to go about it so you don't have to declare the size to overwrite it in every project, but shouldn't be necessary.

    Best regards,

    Simon

Related