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

Parents
  • 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

Reply
  • 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

Children
No Data
Related