<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF5340 DK: QSPI falsh erase and write</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110267/nrf5340-dk-qspi-falsh-erase-and-write</link><description>Hi Support Team, 
 I want to store sensor-monitored data per minute into the QSPI flash(mx25r6435f) on the nRF5340 DK, and send these data over LTE/mqtt per day. Could you help me with the below questions? 
 1 At first I used low-level APIs like flash_erase</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Apr 2024 06:55:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110267/nrf5340-dk-qspi-falsh-erase-and-write" /><item><title>RE: nRF5340 DK: QSPI falsh erase and write</title><link>https://devzone.nordicsemi.com/thread/480102?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 06:55:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f84bb900-275f-4d97-b247-5e4b479d71a8</guid><dc:creator>Yanpengwu</dc:creator><description>&lt;p&gt;Hi Simonr,&lt;/p&gt;
&lt;p&gt;Thank you for the update. I can set up the partitions with the static partitions.&lt;br /&gt;These static partitions can be defined in a pm_static.yml file, instead of in DTS.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Yanpeng&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 DK: QSPI falsh erase and write</title><link>https://devzone.nordicsemi.com/thread/479636?ContentTypeID=1</link><pubDate>Fri, 19 Apr 2024 08:49:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5de8accc-148c-4327-88ef-a14c73e1ff61</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi Yanpeng&lt;/p&gt;
&lt;p&gt;An external flash would be set up in a .yml file like the following for example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;external_flash:
  address: 0x120000
  size: 0x6e0000
  device: MX25R64
  region: external_flash&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Where the address and size is something you configure not to overlap with the flash of the nRF5340. It seems to me like the base_address in your external_flash is incorrect and that&amp;#39;s likely what you&amp;#39;re having trouble with. What errors/issues are you currently having on your side?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 DK: QSPI falsh erase and write</title><link>https://devzone.nordicsemi.com/thread/479392?ContentTypeID=1</link><pubDate>Thu, 18 Apr 2024 11:04:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da58f0b1-b1ae-47da-8b7b-11c6a64dba16</guid><dc:creator>Yanpengwu</dc:creator><description>&lt;p&gt;Hello again,&lt;br /&gt;In&amp;nbsp;&lt;a title="Partition Manager" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.2/nrf/scripts/partition_manager/partition_manager.html"&gt;Partition Manager&lt;/a&gt; mentioned &amp;quot;&lt;strong&gt;&lt;em&gt;When you build a multi-image application using the Partition Manager, the devicetree source flash partitions are ignored.&lt;/em&gt;&lt;/strong&gt;&amp;quot;.&lt;/p&gt;
&lt;p&gt;In my application, the mult-image was used and had the below cmake arguments:&lt;br /&gt;&lt;em&gt;&lt;strong&gt;-Dhci_rpmsg_OVERLAY_CONFIG=&amp;quot;../child_image/hci_rpmsg.conf; /ncs/v2.5.2/nrf/subsys/partition_manager/partition_manager_enabled.conf&amp;quot;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Maybe the reason of the partitions defined in overlay failed is this?&lt;/p&gt;
&lt;p&gt;If the partition_manager was enabled, how to create partitions on the external QSPI flash? Seems need define it in pm.yml, but I can&amp;#39;t find this file in my prject and don&amp;#39;t know how to define it. Could you help give some guidance? Thank you very much.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 DK: QSPI falsh erase and write</title><link>https://devzone.nordicsemi.com/thread/479360?ContentTypeID=1</link><pubDate>Thu, 18 Apr 2024 08:35:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db5f1251-9376-4ffa-96b0-104f697ab0e2</guid><dc:creator>Yanpengwu</dc:creator><description>&lt;p&gt;Update:&lt;br /&gt;I followed&amp;nbsp;&lt;a title="External flash memory partitions" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.2/nrf/scripts/partition_manager/partition_manager.html#external-flash-memory-partitions"&gt;External flash memory partitions&lt;/a&gt;&amp;nbsp;and added the below to my overlay:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
	chosen {
		nordic,pm-ext-flash = &amp;amp;mx25r64;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;After that, I can see the&amp;nbsp;external_flash region was created in&amp;nbsp;&lt;strong&gt;\build\regions.yml&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;external_flash:
  base_address: 0x0
  default_driver_kconfig: CONFIG_PM_EXTERNAL_FLASH_HAS_DRIVER
  device: DT_CHOSEN(nordic_pm_ext_flash)
  dynamic_partition: null
  name: external_flash
  placement_strategy: start_to_end
  size: 0x800000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But in&amp;nbsp;\&lt;strong&gt;build\partitions.yml&lt;/strong&gt;, these two partitions were not created:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;external_flash:
  address: 0x0
  end_address: 0x800000
  region: external_flash
  size: 0x800000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And In the&amp;nbsp;\build\zephyr\.config, I can see &amp;#39;CONFIG_PM_EXTERNAL_FLASH_HAS_DRIVER=y&amp;#39;.&lt;/p&gt;
&lt;p&gt;Maybe something missed in the prj.conf? I attached my prj.conf and overlay here.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/50625.prj.conf"&gt;devzone.nordicsemi.com/.../50625.prj.conf&lt;/a&gt;,&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8037.nrf5340dk_5F00_nrf5340_5F00_cpuapp.overlay"&gt;devzone.nordicsemi.com/.../8037.nrf5340dk_5F00_nrf5340_5F00_cpuapp.overlay&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 DK: QSPI falsh erase and write</title><link>https://devzone.nordicsemi.com/thread/479249?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2024 13:41:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ae6d2e4-262c-4dc7-980f-209c2e17ac80</guid><dc:creator>Yanpengwu</dc:creator><description>&lt;p&gt;Hi Simonr,&lt;/p&gt;
&lt;p&gt;Thank you for the reply. I checked the thread you suggested, which is different from my case. (I used the external flash with QSPI, that thread used SPI driver and needed to disable CONFIG_NORDIC_QSPI_NOR, if my understanding is correct).&lt;/p&gt;
&lt;p&gt;To use the FCB, I need to create partitions first.&amp;nbsp;&amp;nbsp;I tried on nRF5340 DK and tried to create two partitions on my external flash and the overlay is：&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;qspi {
    mx25r6435f@0 {
        partitions {
            compatible = &amp;quot;fixed-partitions&amp;quot;;
            #address-cells = &amp;lt;1&amp;gt;;
            #size-cells = &amp;lt;1&amp;gt;;

            stats_partition: partition@0 {
                label = &amp;quot;log_stats_parti&amp;quot;;
                reg = &amp;lt;0x00000000 0x00001000&amp;gt;; /* Start at 0, size 4KB */
            };
            log_partition: partition@1000 {
                label = &amp;quot;log_data_parti&amp;quot;;
                reg = &amp;lt;0x00001000 0x001FF000&amp;gt;; /* Start at 4KB, size just under 2MB */
            };
        };
    };
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But when I try to open the flash_area with the below way, compiling always failed:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define STATS_PARTITION   					log_stats_parti
#define LOG_PARTITION     					log_data_parti

int init_flash_area()
{
	int rc;
	const struct flash_area *stats_fa;
	const struct flash_area *log_fa;

    rc = flash_area_open(FLASH_AREA_ID(log_stats_parti), &amp;amp;stats_fa);
    if (rc) {
        printk(&amp;quot;Failed to open stats partition: %d\n&amp;quot;, rc);
        return -EINVAL;
    }
/*
    rc = flash_area_open(FLASH_AREA_ID(log_data_parti), &amp;amp;log_fa);
    if (rc) {
        printk(&amp;quot;Failed to open log partition: %d\n&amp;quot;, rc);
        return -EINVAL;
    }
*/
	return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Error info:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;In file included from C:/ncs/v2.5.2/zephyr/include/zephyr/storage/flash_map.h:275,
                 from ../include/IoTDL_flash.h:11,
                 from ../src/IoTDL_flash.c:6:
../src/IoTDL_flash.c: In function &amp;#39;init_flash_area&amp;#39;:
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:43:22: error: &amp;#39;PM_log_stats_parti_ID&amp;#39; undeclared (first use in this function)
   43 | #define PM_ID(label) PM_##label##_ID
      |                      ^~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:48:35: note: in expansion of macro &amp;#39;PM_ID&amp;#39;
   48 | #define FIXED_PARTITION_ID(label) PM_ID(label)
      |                                   ^~~~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:49:30: note: in expansion of macro &amp;#39;FIXED_PARTITION_ID&amp;#39;
   49 | #define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)
      |                              ^~~~~~~~~~~~~~~~~~
../src/IoTDL_flash.c:28:26: note: in expansion of macro &amp;#39;FLASH_AREA_ID&amp;#39;
   28 |     rc = flash_area_open(FLASH_AREA_ID(log_stats_parti), &amp;amp;stats_fa);
      |                          ^~~~~~~~~~~~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:43:22: note: each undeclared identifier is reported only once for each function it appears in
   43 | #define PM_ID(label) PM_##label##_ID
      |                      ^~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:48:35: note: in expansion of macro &amp;#39;PM_ID&amp;#39;
   48 | #define FIXED_PARTITION_ID(label) PM_ID(label)
      |                                   ^~~~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:49:30: note: in expansion of macro &amp;#39;FIXED_PARTITION_ID&amp;#39;
   49 | #define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)
      |                              ^~~~~~~~~~~~~~~~~~
../src/IoTDL_flash.c:28:26: note: in expansion of macro &amp;#39;FLASH_AREA_ID&amp;#39;
   28 |     rc = flash_area_open(FLASH_AREA_ID(log_stats_parti), &amp;amp;stats_fa);
      |                          ^~~~~~~~~~~~~
../src/IoTDL_flash.c:26:34: warning: unused variable &amp;#39;log_fa&amp;#39; [-Wunused-variable]
   26 |         const struct flash_area *log_fa;
      |                                  ^~~~~~
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: &amp;#39;C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE&amp;#39; --build &amp;#39;c:\02_dataLogger\IOTDL\build&amp;#39;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I double-checked and can&amp;#39;t find the&amp;nbsp;cause. Could you help give some guidance? The flash setting in prj.conf is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_SPI=y
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_PARTITION_MANAGER_ENABLED=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you very much.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Yanpeng Wu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 DK: QSPI falsh erase and write</title><link>https://devzone.nordicsemi.com/thread/479200?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2024 11:59:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b7f459b-746d-41da-bbec-2f81387f67b7</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;1. If the QSPI flash sector you&amp;#39;re about to write to is already used, you should indeed erase the sector before writing to it.&lt;/p&gt;
&lt;p&gt;2. The &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfx/drivers/qspi/driver.html"&gt;QSPI driver&lt;/a&gt;&amp;nbsp;in NCS supports erasing one memory block, so 4kB, 64kB or the whole chip, so no. You can&amp;#39;t erase just 1024 bytes.&lt;/p&gt;
&lt;p&gt;3. Please check out &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/109004/spi-flash---parition-manager---qspi-config-causing-build-errors"&gt;this thread&lt;/a&gt; where using a circular buffer with external QSPI flash is already discussed in detail. Let me know if you have any other questions or follow ups to these questions.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>