<?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>nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119214/nrf5340dk-external-flash-fatfs-with-sysbuild</link><description>Hi, we have recently started developing with the nRF5340DK. We encountered several issues while configuring a FATFS on the external flash (mx25r64). 
 
 
 1. The sample code located here [ zephyrproject-fs_sample ]( github.com/.../fs_sample ) fails to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 Apr 2026 16:20:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119214/nrf5340dk-external-flash-fatfs-with-sysbuild" /><item><title>RE: nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/thread/565412?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2026 16:20:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9459acbc-13d4-4210-bd70-ec5daba10e73</guid><dc:creator>Michael Wagner</dc:creator><description>&lt;p&gt;Really appreciate the update and heads up! I don&amp;#39;t have time to look into making this change right now, but I will definitely follow up if I run into any issues or this resolves the complaints I had.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;While this does seem to stop short of implementing system device tree it does seem hopeful that it is moving in that direction.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/thread/565411?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2026 15:02:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:266b8e91-3006-4ec7-a6a7-8f9238dae0be</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The solution we ended up with was using static DT partitions and the partition manager has&amp;nbsp;now been deprecated&amp;nbsp;(in SDK v.3.3.0). For more information, please see the migration guide&amp;nbsp; &amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/releases_and_maturity/migration/migration_partitions.html#migration-partitions"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/releases_and_maturity/migration/migration_partitions.html#migration-partitions&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/thread/525564?ContentTypeID=1</link><pubDate>Mon, 03 Mar 2025 15:27:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8565c0e-6a6c-443d-bf05-abe1f47abb5f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I will try to update the ticket here when I know more.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/thread/525356?ContentTypeID=1</link><pubDate>Fri, 28 Feb 2025 19:48:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31c5f518-56a0-4eec-970f-0a28d2112488</guid><dc:creator>Michael Wagner</dc:creator><description>&lt;p&gt;Thanks for your reply again. Please keep me updated if there is any progress for the issues with multi-image support between nRF and zephyr.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/thread/524807?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2025 12:31:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75d0d8b3-a707-4d45-a6bb-4f9f59600649</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately, there is no public issue to track this yet, and I&amp;#39;m not aware of any concrete plans I can share. I just know that we are currently exploring alternative solutions. I previously thought we were waiting for system device tree support (&lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/51830"&gt;github issue&lt;/a&gt;), but&amp;nbsp;after&amp;nbsp;asking about it internally&amp;nbsp;I found out that we are&amp;nbsp;actually not dependent on it.&lt;/p&gt;
[quote user="Michael Wagner"]Also do you have any input about what the correct way to configure the device tree overlay is, as per question 2 above?[/quote]
&lt;p&gt;I&amp;nbsp;had to do&amp;nbsp;the same in the example I posted in order to get&amp;nbsp;&lt;span&gt;DT_HAS_ZEPHYR_FLASH_DISK_ENABLED selected in Kconfig:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* 
 * NOTE: Actual partition placement and size is controlled
 * by the partition manager. DT entries below is to enable
 * flash disk support.
 * 
 * https://docs.nordicsemi.com/bundle/ncs-2.9.0/page/nrf/app_dev/bootloaders_dfu/mcuboot_nsib/bootloader_partitioning.html 
 */

&amp;amp;mx25r64 {
	partitions {
		compatible = &amp;quot;fixed-partitions&amp;quot;;
		#address-cells = &amp;lt;1&amp;gt;;
		#size-cells = &amp;lt;1&amp;gt;;

		external_partition: partition@0 {
			reg = &amp;lt;0x00000000 0x00020000&amp;gt;;
		};
	};
};

/ {
	msc_disk0 {
		status=&amp;quot;okay&amp;quot;;
		compatible = &amp;quot;zephyr,flash-disk&amp;quot;;
		partition = &amp;lt;&amp;amp;external_partition&amp;gt;;
		disk-name = &amp;quot;SD&amp;quot;;
		/* cache-size == page erase size */
		cache-size = &amp;lt;4096&amp;gt;;
	};
};&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
[quote user="Michael Wagner"]I&amp;#39;m aware the default sector size for FatFS is 512 Bytes but the samples and the data sheet for the MX25R6435F made it seem like the default was 4096 bytes. I would be fine using 512 Byte sector size. However, it&amp;#39;s not clear what config value controls this. The sample does set the FatFS sector size to 512 Bytes but then attempts to read a 4096 Byte sector into it.[/quote]
&lt;p&gt;Got some comments to this ticket from one of the developers who has been working on this code:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Depends on what they want. If they want to be able to mount this partition, via USB for example, to Windows/Linux it is advised to use 512 byte, mostly by urban legend that FS drivers are not that well written and usually work best with 512 byte sectors... leftover from floppy disk times. But, if they do not want to mount this thing externally, then 4kiB sector would be preferred, because sector writes would be then aligned with size of erase-page (or secotr) of a device.&amp;nbsp;Note though, that FAT requires 128 sectors to function, so if you choose 512 byte sector, that means you have 128kiB minimal partition, if you choose 4096, then 512KiB.&amp;nbsp;The cache, as mentioned in the user post, is used to avoid multiple erases into one sector.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;Normally to write to any NOR device, the place to write has to be erased; the erase can only happen at specific size, here 4096bytes.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;It does not mean that you have to erase the 4096 bytes every time you want to write within it, because write alignment is something like 4 bytes, which means that you can write any 4 bytes at any time - as long as it has not been already written after last erase.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;FAT writes data in sector size chunks, 512 by default; so you can probably see that it can do 8 of such writes to 4096, independently, keeping alignment to 512 sector size.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;But FAT is done for floppies and it is used to just write anywhere it wants and how many times it wants, for example it will write FAT table any time it needs to update it, that is it will write some one sector every time you update file.&lt;/em&gt;&lt;br /&gt;&lt;em&gt;If it does updates in 512 byte sectors then, device that is hampered by 4096 erase sectors size, needs to erase that 4096, put back all the data and write it back with that new 512 byte sector replacing the one that has been on 4096 prior to erase. Without cache, consecutive writes to one page, like you are trying to write 8 * 512 byte sectors, would means 8 erases, because disk access does not really know when the sector was last erased.&amp;nbsp;With chache, it does writes to cache first and does not erase next page untill all write operations leave cache&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/thread/524398?ContentTypeID=1</link><pubDate>Mon, 24 Feb 2025 15:00:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e700ebbf-c757-446c-a91c-075d0ae0fff4</guid><dc:creator>Michael Wagner</dc:creator><description>&lt;p&gt;Hi, thank you for your quick response.&amp;nbsp;&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/119214/nrf5340dk-external-flash-fatfs-with-sysbuild/524362"]It is unfortunate that the sample does not work out of the box in our SDK. Until we have a common solution with upstream for managing the memory layout for multi-image, I&amp;#39;m afraid it is difficult to completely avoid situations like these.&amp;nbsp;[/quote]
&lt;p&gt;This makes a lot of sense, are there currently plans for a common solution between nRF and zephyr? If so, is there an issue tracker or something where progress towards this is being tracked?&lt;/p&gt;
&lt;p&gt;Also do you have any input about what the correct way to configure the device tree overlay is, as per question 2 above?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m aware the default sector size for FatFS is 512 Bytes but the samples and the data sheet for the MX25R6435F made it seem like the default was 4096 bytes. I would be fine using 512 Byte sector size. However, it&amp;#39;s not clear what config value controls this. The sample does set the FatFS sector size to 512 Bytes but then attempts to read a 4096 Byte sector into it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.macronix.com/Lists/Datasheet/Attachments/8868/MX25R6435F,%20Wide%20Range,%2064Mb,%20v1.6.pdf"&gt;MX25R6435F, Wide Range, 64Mb, v1.6.pdf&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK External Flash FatFs with Sysbuild</title><link>https://devzone.nordicsemi.com/thread/524362?ContentTypeID=1</link><pubDate>Mon, 24 Feb 2025 13:59:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ad1838a-2266-4178-846f-cd59774e770c</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It is unfortunate that the sample does not work out of the box in our SDK. Until we have a common solution with upstream for managing the memory layout for multi-image, I&amp;#39;m afraid it is difficult to completely avoid situations like these.&amp;nbsp;&lt;/p&gt;
[quote user=""]&lt;span&gt;&amp;nbsp; &amp;nbsp; I would have assumed that setting &lt;/span&gt;&lt;span&gt;`cache-size = &amp;lt;4096&amp;gt;;`&lt;/span&gt;&lt;span&gt; in the device tree or &lt;/span&gt;&lt;span&gt;`disk_sector_size: 4096`&lt;/span&gt;&lt;span&gt; in the partition manager would correctly update this value in the FatFs config. However, this does not seem to be the case, and it seems necessary to set &lt;/span&gt;&lt;span&gt;`CONFIG_FS_FATFS_MAX_SS=4096`&lt;/span&gt;&lt;span&gt; in the prj.conf.&lt;/span&gt;[/quote]
&lt;p&gt;I think it is reasonable to expect the disk sector size from the partitioning file to be applied. I will report this internally. I recently did something similar for the nRF52840 DK and its external flash in the demo I posted here:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/118708/using-the-mass-example-on-my-custom-board-but-first-getting-it-running-on-the-nrf52840dk-qspi-flash/522041"&gt;RE: Using the Mass example on my custom board, but first getting it running on the nRF52840dk QSPI flash&lt;/a&gt;&amp;nbsp;. But I didn&amp;#39;t encounter any buffer overruns as I was using the default 512 sector size.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>