<?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>File write (-22) using External flash zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/127799/file-write--22-using-external-flash-zephyr</link><description>Hello, 
 I am trying to write data into an external flash memory using a custom board (NRF52840-QFAA). The external flash is the W25Q256JVEIQ. I get a fs_write (-22) error at random times when writing to the file. I have set the partition to 28MB and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Apr 2026 12:45:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/127799/file-write--22-using-external-flash-zephyr" /><item><title>RE: File write (-22) using External flash zephyr</title><link>https://devzone.nordicsemi.com/thread/565238?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2026 12:45:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d95f7433-b9b8-4fda-8579-8c3d1c103e9e</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Happy to know you fixed it.&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: File write (-22) using External flash zephyr</title><link>https://devzone.nordicsemi.com/thread/565191?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2026 20:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c1d45c4-27e8-4e14-adcb-cf5d0579e79c</guid><dc:creator>fshaikh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was able to fix this by adjusting my device tree definition.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Specifically, the size definition in the spi2 section was set using bytes instead of bits.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Once I changed the bytes to bits, the write error went away.&lt;/p&gt;
&lt;p&gt;The size of the memory is around 32 MB and when I was setting the size inside the device tree, it was reading as 4 MB, so there was a mismatch.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The new size I set was&amp;nbsp;0x10000000 in bits, which reads as 32MB&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: File write (-22) using External flash zephyr</title><link>https://devzone.nordicsemi.com/thread/565064?ContentTypeID=1</link><pubDate>Thu, 16 Apr 2026 18:36:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfe949cd-9315-4ae3-93c5-3e4a5d98e730</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Faheem,&amp;nbsp;&lt;/p&gt;
[quote user=""][00:02:39.928,985] &amp;lt;inf&amp;gt; littlefs: sizes: rd 16 ; pr 256 ; ca 256 ; la 128 
[00:02:39.943,023] &amp;lt;wrn&amp;gt; main: Filesystem recovery complete 
[00:02:40.177,398] &amp;lt;err&amp;gt; fs: file write error (-22)[/quote]
&lt;p&gt;&lt;span&gt;It seems that these sizes are wrong.&lt;/span&gt;&lt;a href="https://docs.zephyrproject.org/latest/doxygen/html/group__system__errno.html"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;-22 means invalid argument.&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please refer to the&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.7.99-ncs1/samples/subsys/fs/littlefs"&gt;littlefs&lt;/a&gt;&amp;nbsp;sample for fs_write&amp;nbsp;and&amp;nbsp;&lt;a title="nrf52840dk_nrf52840_spi.overlay" href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.7.99-ncs1/samples/subsys/fs/littlefs/boards/nrf52840dk_nrf52840_spi.overlay"&gt;nrf52840dk_nrf52840_spi.overlay&lt;/a&gt;&amp;nbsp;for setting sizes, or &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.7.99-ncs1/include/zephyr/fs/littlefs.h#L64-L85"&gt;use configs to set sizes&lt;/a&gt;.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;br /&gt;Amanda H.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>