<?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>Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106074/little-fs-io-operation-gets-extremely-slow</link><description>Hi, 
 
 I am using sample project (with the name of LittleFS) and am using nRF52840 dev kit. I modified the project to run a loop of 100 iteration. In the loop I am writing 1KB array in separate file on external flash (mx25r64). Most of the the time the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 01 Dec 2023 08:08:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106074/little-fs-io-operation-gets-extremely-slow" /><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/458452?ContentTypeID=1</link><pubDate>Fri, 01 Dec 2023 08:08:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5158dfd0-2113-4130-825f-bfd7811b3158</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Thank you for elaborating&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What I believe is happening is that you&amp;#39;ve reached the garbage collection part of the&amp;nbsp;littlefs design.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;This case,&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/85243/when-ist-littlefs-garbage-collection-flash-erase-block-called"&gt;When ist littlefs garbage collection / flash erase block called?&lt;/a&gt;&amp;nbsp;mentions this briefly and links to the design-readme of littlefs:&amp;nbsp;&lt;a href="https://github.com/littlefs-project/littlefs/blob/master/DESIGN.md"&gt;https://github.com/littlefs-project/littlefs/blob/master/DESIGN.md&amp;nbsp;&lt;/a&gt;which should elaborate on it&lt;/p&gt;
&lt;p&gt;The garbage collection procedure takes quite a while, so I would recommend you to investigate if this is what you&amp;#39;re observing&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/458204?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2023 02:56:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd0a63e9-c066-46c7-8127-9bcfde890310</guid><dc:creator>imtiz_ahmed</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
[quote userid="107683" url="~/f/nordic-q-a/106074/little-fs-io-operation-gets-extremely-slow/457897"]This is a bit unclear to us, could you elaborate what you mean when you do this?&amp;nbsp;[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am using&amp;nbsp;&lt;span&gt;nRF52840 dev kit and used one of the sample projects called LittleFS. I am not doing anything other than writing 1KB&amp;nbsp;array in new file. I call the function that does the file IO in a loop, the function opens a new file in create mode, writes the 1KB array to it and then closes it. The code is as basic as it can get.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="107683" url="~/f/nordic-q-a/106074/little-fs-io-operation-gets-extremely-slow/457897"]The amount of time this takes could also indicate that either something not beeing properly connected or that the application does something important for a&amp;nbsp;&lt;strong&gt;&lt;/strong&gt;long time before it allows for FS to do its thing. Could you check and verify if this is not the case?[/quote]
&lt;p&gt;Again, since I am using&amp;nbsp;&lt;span&gt;nRF52840 dev kit and the external flash (mx25r64) that comes mounted on the dev board, I am not sure there is any chance of improper connection. It is not a custom board.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BTW, I have attached the full sample project that can be run on&amp;nbsp;nRF52840 dev kit&amp;nbsp;to see the results, if you happen to have the time for it of course.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for taking time to reply!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457897?ContentTypeID=1</link><pubDate>Tue, 28 Nov 2023 14:21:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0aba232-7fe1-4232-b956-5cff9b3ee6cd</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you state which pins you&amp;#39;re using that results in this speed?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="imtiz_ahmed"]One strange thing I have notice is that if you add fs_unlink(fname); after&amp;nbsp;&lt;span&gt;fs_close&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;file&lt;/span&gt;&lt;span&gt;); inside&amp;nbsp;&lt;/span&gt;fs_write_bytes_to_file(...), which of course will delete the file after it is written, everything works fine, I tried with the loop of 1000 and I could get 9 files per sec, by if I do not delete the file, I get avg or 2 or 3 files a sec.&amp;nbsp;[/quote]
&lt;p&gt;This is a bit unclear to us, could you elaborate what you mean when you do this?&amp;nbsp;&lt;/p&gt;
[quote user=""]But sometimes one of the step (out of opening, writing or closing file) gets stuck for upto 13 seconds. [/quote]
&lt;p&gt;The amount of time this takes could also indicate that either something not beeing properly connected or that the application does something important for a&amp;nbsp;&lt;strong&gt;&lt;/strong&gt;long time before it allows for FS to do its thing. Could you check and verify if this is not the case?&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457742?ContentTypeID=1</link><pubDate>Tue, 28 Nov 2023 07:15:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87c97569-e21b-44e0-8f53-17f8449612be</guid><dc:creator>imtiz_ahmed</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Please do let me know if you find something.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457450?ContentTypeID=1</link><pubDate>Fri, 24 Nov 2023 15:09:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b530213-184a-429d-833e-4d2945708e4a</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve unfortunately been out of office due to illness this week. I will check back with you and this case early next week&lt;/p&gt;
&lt;p&gt;Apologies for the inconvinience&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457449?ContentTypeID=1</link><pubDate>Fri, 24 Nov 2023 04:32:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0f80a90-90e1-42c5-bfab-33ae8f6a8363</guid><dc:creator>imtiz_ahmed</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/andreas"&gt;Andreas&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any feedback?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457448?ContentTypeID=1</link><pubDate>Tue, 21 Nov 2023 16:18:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b1ecf57-2537-4bd1-a681-d773002b3129</guid><dc:creator>imtiz_ahmed</dc:creator><description>&lt;p&gt;One strange thing I have notice is that if you add fs_unlink(fname); after&amp;nbsp;&lt;span&gt;fs_close&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;file&lt;/span&gt;&lt;span&gt;); inside&amp;nbsp;&lt;/span&gt;fs_write_bytes_to_file(...), which of course will delete the file after it is written, everything works fine, I tried with the loop of 1000 and I could get 9 files per sec, by if I do not delete the file, I get avg or 2 or 3 files a sec.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457447?ContentTypeID=1</link><pubDate>Tue, 21 Nov 2023 16:15:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ba83259-b531-4662-934f-25af1028f24b</guid><dc:creator>imtiz_ahmed</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2620.littlefs.zip"&gt;devzone.nordicsemi.com/.../2620.littlefs.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There you go, it is very basic code, just calling a test method in the loop in main and in that test method, i give values to 1024 bytes array and then call another method &amp;quot;fs_write_bytes_to_file&amp;quot; to create file with that data. Nothing special.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457446?ContentTypeID=1</link><pubDate>Tue, 21 Nov 2023 16:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cec2ef51-ab7e-4b63-8773-2592f8d82ad8</guid><dc:creator>imtiz_ahmed</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2251.output.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sure, I will give you zip of project in a short while. It is not even my firmware, just the sample project called LittleFS with some minor changes to write files in a loop. The output looks something like this, where some files just randomly take LOT more time than most of others.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Little FS IO operation gets extremely slow</title><link>https://devzone.nordicsemi.com/thread/457445?ContentTypeID=1</link><pubDate>Tue, 21 Nov 2023 15:15:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b40f331c-2415-49da-8856-c23d18e4f312</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I will look into this&lt;/p&gt;
&lt;p&gt;Does your firmware do anything other than write to the littlefs partition? Could you upload a minimal version of your project so I can attempt to recreate the behaviour?&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>